/* === Reset & Base === */
[x-cloak] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface2: #242836;
    --border: #2e3345;
    --text: #e4e6ef;
    --text-muted: #8b8fa3;
    --primary: #14b8a6;
    --primary-hover: #2dd4bf;
    --danger: #ff6b6b;
    --danger-bg: #3a1f1f;
    --warning: #ffb347;
    --warning-bg: #3a3020;
    --success: #63e6be;
    --success-bg: #1a3a2e;
    --radius: 8px;
}
html { font-size: 16px; color-scheme: dark; }
input[type="date"] { cursor: pointer; position: relative; }
input[type="date"]::-webkit-calendar-picker-indicator {
    position: absolute; inset: 0; width: 100%; height: 100%;
    opacity: 0; cursor: pointer;
}
html[data-theme="light"] { color-scheme: light; }

/* Light theme overrides */
html[data-theme="light"] {
    --bg: #f0f2f5;
    --surface: #ffffff;
    --surface2: #e8ebf0;
    --border: #d4d8e1;
    --text: #1a1d27;
    --text-muted: #6b7080;
    --primary: #0d9488;
    --primary-hover: #0f766e;
    --danger: #dc3545;
    --danger-bg: #fef2f2;
    --warning: #b87600;
    --warning-bg: #fefce8;
    --success: #0a8a5e;
    --success-bg: #ecfdf5;
    --routine: #2563eb;
    --routine-bg: #eff6ff;
    --upgrade: #7c3aed;
    --upgrade-bg: #f5f3ff;
}

/* Smooth theme transition */
html.theme-shift, html.theme-shift *, html.theme-shift *::before, html.theme-shift *::after {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease !important;
    transition-delay: 0s !important;
}
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; min-height: 100vh; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* === App shell + sidebar === */
.app-shell { min-height: 100vh; }
.sidebar { position: fixed; top: 0; left: 0; height: 100vh; width: 244px; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border); z-index: 100; overflow-y: auto; }
.app-main { margin-left: 244px; min-height: 100vh; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 1.15rem 1.25rem 0.85rem; }
.sidebar-brand { display: flex; align-items: center; gap: 0.55rem; font-weight: 700; font-size: 1.2rem; color: var(--text); white-space: nowrap; }
.sidebar-brand svg { width: 22px; height: 22px; color: var(--primary); flex-shrink: 0; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 0.4rem 0.6rem; flex: 1 1 auto; }
.sidebar-nav .navlink { display: flex; align-items: center; gap: 0.7rem; padding: 0.62rem 0.7rem; border-radius: var(--radius); color: var(--text-muted); font-size: 0.92rem; font-weight: 500; white-space: nowrap; transition: background 0.15s, color 0.15s; }
.sidebar-nav .navlink svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.9; }
.sidebar-nav .navlink:hover { background: var(--surface2); color: var(--text); }
.sidebar-nav .navlink.active { background: var(--surface2); color: var(--text); }
.sidebar-nav .navlink.active svg { color: var(--primary); opacity: 1; }
.sidebar-foot { display: flex; align-items: center; gap: 0.4rem; padding: 0.7rem 0.9rem; border-top: 1px solid var(--border); }
.topbar { display: none; align-items: center; gap: 0.6rem; height: 56px; padding: 0 1rem; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 90; }
.topbar-brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.nav-icon-btn {
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: var(--radius);
    border: none; background: none; color: var(--text-muted);
    cursor: pointer; transition: background 0.15s, color 0.15s;
    text-decoration: none;
}
.nav-icon-btn:hover { background: var(--surface2); color: var(--text); }
.nav-icon-btn svg { width: 18px; height: 18px; }
.nav-avatar {
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--surface2); color: var(--text-muted);
    border: 2px solid var(--border); text-decoration: none;
    transition: border-color 0.15s, color 0.15s;
}
.nav-avatar:hover { border-color: var(--primary); color: var(--text); }
.nav-avatar svg { width: 16px; height: 16px; }
#theme-toggle svg { display: block; }
#theme-toggle .icon-moon { display: none; }
html[data-theme="light"] #theme-toggle .icon-sun { display: none; }
html[data-theme="light"] #theme-toggle .icon-moon { display: flex; }
.nav-toggle { display: none; background: none; border: none; color: var(--text); font-size: 1.5rem; cursor: pointer; padding: 0.4rem; }
.nav-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 150; }
.nav-backdrop.open { display: block; }
.nav-drawer-close { display: none; }
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.25s ease; width: 80%; max-width: 300px; }
    .sidebar.open { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .topbar { display: flex; }
    .nav-toggle { display: flex; align-items: center; }
    .nav-drawer-close { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; background: none; border: none; color: var(--text); font-size: 1.8rem; cursor: pointer; line-height: 1; padding: 0; }
}

/* === Back button === */
.back-btn {
    display: inline-flex; align-items: center; gap: 0.3rem;
    color: var(--text-muted); font-size: 0.85rem; padding: 0.3rem 0.5rem;
    border-radius: var(--radius); transition: background 0.15s, color 0.15s;
    text-decoration: none; margin-bottom: 0.5rem;
}
.back-btn:hover { background: var(--surface2); color: var(--text); }
.back-btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* === Container === */
/* One canonical content width for EVERY page (schedules width + a bit). */
.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 1.6rem 2rem; animation: pageIn 0.35s ease both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .container { animation: none; } a.stat-card:hover, .btn-primary:not(:disabled):hover, button[type="submit"]:not(:disabled):hover { transform: none; } }

/* === Flash messages === */
.flash { padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: 0.9rem; }
.flash.error { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger); }
.flash.success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success); }
.flash.info { background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); }

/* === Notes Callout === */
.notes-callout {
    padding: 0.75rem 1rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* === Login === */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--surface); padding: 2rem; border-radius: var(--radius); width: 100%; max-width: 360px; border: 1px solid var(--border); }
.login-card h1 { text-align: center; margin-bottom: 1.5rem; font-size: 1.4rem; }
.login-card form { display: flex; flex-direction: column; gap: 1rem; }

/* === Forms === */
input, select, textarea { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.6rem 0.75rem; font-size: 0.95rem; width: 100%; font-family: inherit; transition: border-color 0.15s, box-shadow 0.15s; }
input[type="checkbox"], input[type="radio"] { width: auto; padding: 0; margin: 0 0.4rem 0 0; vertical-align: middle; background: transparent; border: none; box-shadow: none; cursor: pointer; }
input[type="checkbox"]:focus, input[type="radio"]:focus { box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.25); }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238b8fa3' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; padding-right: 2rem; cursor: pointer; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.15); }
label:has(> input[type="checkbox"]), label:has(> input[type="radio"]) { display: inline-flex; align-items: center; gap: 0.4rem; margin-bottom: 0; cursor: pointer; }
textarea { resize: vertical; min-height: 80px; }
label { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.25rem; display: block; }
.form-group { margin-bottom: 1rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .analytics-grid { grid-template-columns: 1fr !important; } }
@media (max-width: 640px) {
    .stat-row[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
}
.form-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; }

/* === Buttons === */
button, .btn { display: inline-flex; align-items: center; justify-content: center; padding: 0.6rem 1.25rem; border-radius: 10px; border: none; font-size: 0.9rem; font-weight: 500; cursor: pointer; font-family: inherit; transition: background 0.15s, opacity 0.15s, transform 0.15s, box-shadow 0.15s; }
.btn-primary, button[type="submit"] { background: var(--primary); color: #fff; }
.btn-primary:not(:disabled):hover, button[type="submit"]:not(:disabled):hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(20, 184, 166, 0.25); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:not(:disabled):hover { background: var(--border); }
.btn.btn-danger, button.btn-danger { background: var(--danger); color: #fff; }
.btn.btn-danger:not(:disabled):hover, button.btn-danger:not(:disabled):hover { opacity: 0.85; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

/* === Cards & Tables === */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1.5rem; margin-bottom: 1.25rem; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.card-header h2 { font-size: 1.1rem; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.75rem; flex-wrap: wrap; gap: 0.75rem; }
.page-header h1 { font-size: 1.65rem; font-weight: 600; letter-spacing: -0.02em; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.6rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
th { color: var(--text-muted); font-weight: 500; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; -webkit-user-select: none; user-select: none; }
tr:hover { background: var(--surface2); }
.table-responsive { overflow-x: auto; }

/* === Status badges === */
.badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 99px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.badge-active { background: var(--success-bg); color: var(--success); }
.badge-stored { background: var(--warning-bg); color: var(--warning); }
.badge-retired { background: var(--surface2); color: var(--text-muted); }

/* Inline status select (detail page) */
.status-select { appearance: none; width: auto; border: none; border-radius: 99px; padding: 0.25rem 1.8rem 0.25rem 0.7rem; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; cursor: pointer; background-repeat: no-repeat; background-position: right 0.5rem center; background-size: 10px; transition: opacity 0.15s; }
.status-select:hover { opacity: 0.85; }
.status-select:focus { box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.25); outline: none; }
.status-select[data-status="active"] { background-color: var(--success-bg); color: var(--success); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%2363e6be' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E"); }
.status-select[data-status="stored"] { background-color: var(--warning-bg); color: var(--warning); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%23ffb347' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E"); }
.status-select[data-status="retired"] { background-color: var(--surface2); color: var(--text-muted); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%238b8fa3' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E"); }
.status-select option { background: var(--surface); color: var(--text); }
.badge-overdue { background: var(--danger-bg); color: var(--danger); }
.badge-upcoming { background: var(--warning-bg); color: var(--warning); }
.badge-ok { background: var(--success-bg); color: var(--success); }
.badge-routine { background: var(--routine-bg, #1a2a3a); color: var(--routine, #6cb4ee); }
.badge-repair { background: var(--danger-bg); color: var(--danger); }
.badge-upgrade { background: var(--upgrade-bg, #2a1a3a); color: var(--upgrade, #b68cff); }
.badge-inspection { background: var(--warning-bg); color: var(--warning); }
.badge-custom { background: var(--custom-bg, #1a2e2a); color: var(--custom, #5ed4b8); }
.badge-other { background: var(--surface2); color: var(--text-muted); }

/* === Dashboard === */
.dashboard-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.75rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1.25rem; text-align: center; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease; }
a.stat-card:hover { transform: translateY(-3px); border-color: var(--primary); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28); }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; }
.stat-card .stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }
.section-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.75rem; display: flex; align-items: center; gap: 0.5rem; }

/* === Detail page === */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 1.5rem; margin-bottom: 1rem; }
.detail-grid dt { color: var(--text-muted); font-size: 0.85rem; }
.detail-grid dd { margin-bottom: 0.5rem; }
@media (max-width: 640px) { .detail-grid { grid-template-columns: 1fr; } }

/* === Empty state === */
.empty { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty p { margin-bottom: 1rem; }

/* === Utility === */
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-success { color: var(--success); }
.text-right { text-align: right; }
.text-sm { font-size: 0.85rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.pre-line { white-space: pre-line; }
.expand-detail { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.5rem 0.75rem; margin: 0.25rem 0; }

/* === Search === */
.search-bar { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }
.search-bar input { flex: 1; }
.search-bar select { width: auto; min-width: 120px; }

/* === Tom Select dark theme === */
.ts-wrapper { width: 100%; }
.ts-control { background: var(--bg) !important; color: var(--text) !important; border: 1px solid var(--border) !important; border-radius: var(--radius) !important; padding: 0.45rem 0.75rem !important; font-size: 0.95rem !important; min-height: 44px !important; display: flex !important; align-items: center !important; }
.ts-control input { color: var(--text) !important; }
.ts-control input::placeholder { color: var(--text-muted) !important; }
.ts-wrapper.focus .ts-control { border-color: var(--primary) !important; box-shadow: none !important; }
.ts-dropdown { background: var(--surface) !important; border: 1px solid var(--border) !important; border-radius: var(--radius) !important; color: var(--text) !important; z-index: 200; }
.ts-dropdown .optgroup-header { color: var(--text-muted) !important; background: var(--surface2) !important; font-size: 0.75rem !important; text-transform: uppercase !important; letter-spacing: 0.5px; padding: 0.5rem 0.75rem !important; }
.ts-dropdown .option { color: var(--text) !important; padding: 0.5rem 0.75rem !important; }
.ts-dropdown .option:hover, .ts-dropdown .active { background: var(--surface2) !important; color: var(--text) !important; }
.ts-dropdown .option.selected { background: var(--primary) !important; color: #fff !important; }
.ts-control .item { color: var(--text) !important; }
.ts-wrapper.single .ts-control::after { border-color: var(--text-muted) transparent transparent !important; }

/* === VIN decode === */
.vin-section { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 1.5rem; }
.vin-section .vin-row { display: flex; gap: 0.5rem; align-items: flex-start; }
.vin-section input { flex: 1; text-transform: uppercase; font-family: monospace; letter-spacing: 1px; }
.vin-status { font-size: 0.85rem; margin-top: 0.5rem; }
.vin-status.success { color: var(--success); }
.vin-status.error { color: var(--danger); }
.vin-status.loading { color: var(--text-muted); }

/* === Specs grid === */
.specs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
@media (max-width: 640px) { .specs-grid { grid-template-columns: 1fr; } }

/* === Engine section === */
.engine-section { border: 1px dashed var(--border); border-radius: var(--radius); padding: 1rem; margin-top: 1rem; }
.engine-header { display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.engine-header h3 { font-size: 0.95rem; color: var(--text-muted); }

/* === Custom Select Dropdown === */
select.cs-native {
    position: absolute !important; width: 1px !important; height: 1px !important;
    padding: 0 !important; margin: -1px !important; overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important;
    border: 0 !important; opacity: 0 !important;
}
.cs-wrap { position: relative; width: 100%; }
.cs-trigger {
    display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
    background: var(--bg); color: var(--text); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 0.6rem 0.75rem; font-size: 0.95rem;
    cursor: pointer; width: 100%; text-align: left;
    font-family: inherit; line-height: 1.5;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.cs-trigger:hover { border-color: var(--text-muted); }
.cs-trigger:focus, .cs-wrap.open .cs-trigger {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.15);
    outline: none;
}
.cs-arrow {
    flex-shrink: 0; color: var(--text-muted);
    display: flex; align-items: center;
    transition: transform 0.2s;
}
.cs-wrap.open .cs-arrow { transform: rotate(180deg); }
.cs-panel {
    position: absolute; top: calc(100% + 4px); left: 0; min-width: 100%;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 4px;
    z-index: 200; max-height: 256px; display: flex; flex-direction: column;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    opacity: 0; pointer-events: none; transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
}
.cs-options { overflow: hidden auto; flex: 1; min-height: 0; padding-right: 2px; }
.cs-wrap.open .cs-panel { opacity: 1; pointer-events: auto; transform: translateY(0); }
.cs-panel.cs-flip { top: auto; bottom: calc(100% + 4px); transform: translateY(4px); }
.cs-wrap.open .cs-panel.cs-flip { transform: translateY(0); }
.cs-option {
    padding: 0.5rem 0.75rem; border-radius: calc(var(--radius) - 2px);
    cursor: pointer; font-size: 0.95rem; color: var(--text);
    transition: background 0.1s;
}
.cs-option:hover { background: var(--surface2); }
.cs-option.selected { background: var(--primary); color: #fff; }
.cs-option.disabled { color: var(--text-muted); cursor: default; opacity: 0.5; }
.cs-option.disabled:hover { background: transparent; }

/* G-content (2026-06-13 s2, SCRN-06): disabled buttons had NO visual state, so a
   :disabled submit (e.g. schedules setup at 0 selected) looked fully clickable.
   Hover rules carry :not(:disabled) so a disabled button shows no hover feedback
   (the .btn-danger:hover opacity:0.85 at (0,3,0) used to out-dim this rule). */
button:disabled, .btn:disabled, input[type="submit"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.cs-placeholder { color: var(--text-muted); }
.cs-search { width: calc(100% - 8px) !important; margin: 4px; margin-bottom: 6px; padding: 0.4rem 0.6rem !important; font-size: 0.85rem !important; border: 1px solid var(--border) !important; border-radius: calc(var(--radius) - 2px) !important; background: var(--bg) !important; color: var(--text) !important; flex-shrink: 0; }
.cs-options::-webkit-scrollbar { width: 6px; }
.cs-options::-webkit-scrollbar-track { background: transparent; }
.cs-options::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.search-bar .cs-wrap { width: auto; min-width: 120px; }

/* Status pill variant */
.cs-status { width: auto; display: inline-block; }
.cs-status .cs-trigger {
    border: none; border-radius: 99px;
    padding: 0.25rem 0.7rem; font-size: 0.75rem;
    font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.5px; width: auto; gap: 0.35rem;
    background: var(--surface2); line-height: 1.4;
}
.cs-status .cs-trigger:focus, .cs-status.open .cs-trigger {
    box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.25);
}
.cs-status .cs-arrow { color: inherit; }
.cs-status .cs-arrow svg { width: 10px; height: 10px; }
.cs-status .cs-panel { min-width: 130px; }
.cs-status[data-status="active"] .cs-trigger { background: var(--success-bg); color: var(--success); }
.cs-status[data-status="stored"] .cs-trigger { background: var(--warning-bg); color: var(--warning); }
.cs-status[data-status="retired"] .cs-trigger { background: var(--surface2); color: var(--text-muted); }

/* === Confirm Modal === */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; opacity: 0; pointer-events: none;
    transition: opacity 0.15s ease;
    backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
.modal-overlay.visible { opacity: 1; pointer-events: auto; }
.modal-dialog {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.5rem;
    max-width: 380px; width: 90%;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    transform: scale(0.95) translateY(-8px);
    transition: transform 0.15s ease;
}
.modal-overlay.visible .modal-dialog { transform: scale(1) translateY(0); }
.modal-message { font-size: 1rem; margin-bottom: 1.25rem; line-height: 1.5; }
.modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; }

/* Character limit warning */
input[maxlength]:focus { transition: border-color 0.15s; }
input.at-max { border-color: var(--danger) !important; box-shadow: 0 0 0 2px rgba(255, 107, 107, 0.15) !important; }

/* Mobile-only elements - hidden on desktop */
.sm { display: none !important; }

/* ========================================
   MOBILE LAYOUT
   ======================================== */
@media (max-width: 640px) {
    /* === Base === */
    html { font-size: 14px; }
    body { -webkit-text-size-adjust: 100%; }
    .container { padding: 0.75rem 0.5rem; overflow-x: hidden; }

    /* === Navbar === */
    .nav-brand { font-size: 0.95rem; margin-right: 0.5rem; }
    .nav-actions { gap: 0.1rem; margin-left: auto; }
    .nav-icon-btn { width: 30px; height: 30px; }
    .nav-icon-btn svg { width: 16px; height: 16px; }
    .nav-avatar { width: 26px; height: 26px; }
    .nav-avatar svg { width: 14px; height: 14px; }

    /* === Page headers === */
    .page-header { margin-bottom: 1rem; gap: 0.5rem; }
    .page-header h1 { font-size: 1.2rem; }
    .page-header .btn, .page-header a.btn { font-size: 0.75rem; padding: 0.35rem 0.6rem; }

    /* === Cards === */
    .card { padding: 0.65rem; margin-bottom: 0.65rem; }
    .card-header { flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.6rem; }
    .section-title { font-size: 0.9rem; margin-bottom: 0.5rem; }

    /* === Tables - tight and compact === */
    th, td { padding: 0.3rem 0.4rem; font-size: 0.75rem; }
    th { font-size: 0.65rem; letter-spacing: 0.3px; }
    .table-responsive { margin: 0 -0.65rem; padding: 0 0.65rem; overflow-x: auto; }

    /* === Dashboard === */
    .stat-row { gap: 0.5rem; margin-bottom: 1rem; }
    .stat-row[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
    .stat-card { padding: 0.6rem; }
    .stat-card .stat-value { font-size: 1.3rem; }
    .stat-card .stat-label { font-size: 0.7rem; }
    .analytics-grid { grid-template-columns: 1fr !important; }

    /* === Search / Filter bars === */
    .search-bar { flex-direction: column; gap: 0.4rem; }
    .search-bar select, .search-bar input { width: 100%; min-width: unset; }
    .search-bar .btn { width: 100%; }

    /* === Buttons === */
    button, .btn { padding: 0.4rem 0.75rem; font-size: 0.8rem; min-height: 36px; }
    .btn-sm { padding: 0.25rem 0.5rem; font-size: 0.7rem; min-height: 28px; }
    .form-actions { flex-wrap: wrap; gap: 0.5rem; }
    .form-actions .btn, .form-actions button { flex: 1; min-width: 0; }

    /* === Forms === */
    .form-group { margin-bottom: 0.65rem; }
    .form-row { grid-template-columns: 1fr !important; gap: 0; }
    label { font-size: 0.75rem; margin-bottom: 0.15rem; }
    input, select, textarea { font-size: 16px !important; padding: 0.5rem 0.6rem; max-width: 100%; } /* 16px prevents iOS zoom */
    input[type="date"] { width: 100% !important; min-width: 0; overflow: hidden; -webkit-appearance: none; appearance: none; min-height: 44px; line-height: 1.2; }
    input[type="date"]::-webkit-date-and-time-value { text-align: left; }
    textarea { min-height: 60px; }

    /* === Detail pages === */
    .detail-grid { grid-template-columns: 1fr; gap: 0.15rem; }
    .detail-grid dt { font-size: 0.7rem; margin-top: 0.4rem; }
    .detail-grid dd { font-size: 0.85rem; margin-bottom: 0.15rem; }
    .specs-grid { grid-template-columns: 1fr !important; }

    /* === Badges === */
    .badge { font-size: 0.65rem; padding: 0.15rem 0.45rem; }

    /* === Expandable parts rows === */
    td[colspan] { padding: 0.3rem 0.4rem 0.3rem 0.75rem !important; }

    /* === Asset list - tighter === */
    .truncate { max-width: 100px; }

    /* === Modals === */
    .modal-dialog { padding: 1rem; width: 95%; }
    .modal-message { font-size: 0.9rem; }

    /* === Login === */
    .login-card { padding: 1.25rem; margin: 0 0.5rem; }
    .login-card h1 { font-size: 1.2rem; }

    /* === Custom select === */
    .cs-trigger { padding: 0.5rem 0.6rem; font-size: 0.85rem; }
    .cs-panel { max-height: 200px; max-width: calc(100vw - 2rem); }
    .cs-options { overflow-x: hidden; padding-right: 10px; }
    .cs-option { padding: 0.45rem 0.6rem; font-size: 0.85rem; }
    .cs-wrap { max-width: 100%; }

    /* === Engine cards === */
    .engine-section { padding: 0.5rem; }
    .engine-section select { max-width: 100%; }
    .engine-section .form-group { overflow: hidden; }
    /* Engine cards on detail page - stack on mobile */
    .card .detail-grid + div[x-show] { flex-direction: column; }
    .card div[style*="justify-content: space-between"] { flex-wrap: wrap; }
    .card div[style*="justify-content: space-between"] > div[style*="flex-shrink: 0"] { flex-shrink: 1 !important; flex-wrap: wrap; }
    .card form[style*="display: flex"][style*="gap: 0.5rem"] { flex-wrap: wrap; }

    /* === VIN section === */
    .vin-section { padding: 0.65rem; }
    .vin-row { flex-direction: column; gap: 0.4rem; }

    /* === Hide/Show on mobile === */
    .hm { display: none !important; }
    .show-mobile { display: inline !important; }
    .mobile-only { display: block !important; }
    span.sm, td.sm { display: inline !important; }
    div.sm { display: block !important; }
    button.sm { display: inline-flex !important; }

    /* === Schedule cards (mobile) === */
    .schedule-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.65rem; margin-bottom: 0.5rem; }
    .schedule-card--overdue { border-color: var(--danger); }
    .schedule-card-top { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin-bottom: 0.35rem; }
    .schedule-card-title { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; min-width: 0; }
    .schedule-card-title a { font-weight: 500; font-size: 0.85rem; }
    .schedule-card-details { display: flex; gap: 0.5rem; align-items: center; font-size: 0.75rem; margin-bottom: 0.25rem; flex-wrap: wrap; }
    .schedule-card-details > span:not(:last-child)::after { content: '·'; margin-left: 0.5rem; color: var(--text-muted); }
    .schedule-card-dates { display: flex; gap: 1rem; font-size: 0.75rem; }

    /* === Utility overrides === */
    .text-sm { font-size: 0.75rem; }
    .mt-1 { margin-top: 0.35rem; }
    .mb-1 { margin-bottom: 0.35rem; }
    .empty { padding: 2rem 0.75rem; }
}

/* ===== Attachments ===== */
.attachments-section { margin-top: 1rem; }
.attachment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}
.attachment-item {
    position: relative;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
}
.attachment-thumb {
    width: 100%;
    height: 100px;
    object-fit: cover;
    cursor: pointer;
    display: block;
}
.attachment-file-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100px;
    color: var(--text-muted);
    text-decoration: none;
}
.attachment-file-icon:hover { color: var(--primary); }
.attachment-meta {
    padding: 0.35rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}
.attachment-name {
    font-size: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.att-type-badge {
    font-size: 0.65rem;
    text-transform: capitalize;
    color: var(--primary);
    opacity: 0.8;
}
.att-type-badge.att-type-other {
    color: var(--text-muted);
    opacity: 0.6;
}
.mobile-only { display: none; }

/* Part highlight (used when clicking a partial-part name in Used Parts to flash its On Hand row + sibling ghosts).
   Flat / square-edged to match table-row styling - tr elements can't take border-radius cleanly
   so keep both styles consistent across divs and trs. */
@keyframes part-highlight-pulse {
    0%, 100% { background-color: rgba(255, 152, 0, 0.08); }
    50%      { background-color: rgba(255, 152, 0, 0.35); }
}
.part-highlight-flash {
    animation: part-highlight-pulse 1s ease-in-out infinite;
    transition: background-color 0.3s;
}
.part-highlight-settled {
    background-color: rgba(255, 152, 0, 0.12);
    transition: background-color 0.5s;
}
/* Persistent partial-use row tint in On Hand table (always on, independent of click) */
tr.on-hand-row.partial-used-row {
    background-color: rgba(255, 152, 0, 0.04);
}
.attachment-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    border: none;
    color: #fff;
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
    padding: 0;
    box-sizing: border-box;
}
.attachment-delete::before {
    content: '';
    display: block;
    width: 10px;
    height: 10px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round'%3E%3Cline x1='18' y1='6' x2='6' y2='18'/%3E%3Cline x1='6' y1='6' x2='18' y2='18'/%3E%3C/svg%3E") center/contain no-repeat;
}
.attachment-delete:hover { background: rgba(220,50,50,0.85); }
.attachment-item:hover .attachment-delete { opacity: 1; }
@media (hover: none) { .attachment-delete { opacity: 1; } }

.attachment-pending { margin-bottom: 0.75rem; }
.attachment-pending-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.35rem;
}
.attachment-upload-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
}
.att-badge {
    vertical-align: -1px;
    margin-left: 0.3rem;
    color: var(--text-muted);
    opacity: 0.7;
}

@media (max-width: 600px) {
    .attachment-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 0.5rem; }
    .attachment-thumb { height: 80px; }
    .attachment-file-icon { height: 80px; }
    .attachment-delete { opacity: 1; width: 28px; height: 28px; min-width: 28px; min-height: 28px; }
}

/* ===== Document sections (collapsible) ===== */
.doc-section { margin-top: 0.75rem; }
.doc-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    transition: background 0.15s;
}
.doc-section-header:hover { background: var(--bg); }
.doc-section-header .doc-chevron {
    width: 16px; height: 16px;
    transition: transform 0.2s;
    flex-shrink: 0;
    color: var(--text-muted);
}
.doc-section-header[aria-expanded="true"] .doc-chevron { transform: rotate(180deg); }
.doc-section-body { padding: 0.5rem 0 0 0; }

.doc-group { margin-top: 0.5rem; }
.doc-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.4rem 0.6rem;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    transition: background 0.15s;
}
.doc-group-header:hover { background: var(--surface); }
.doc-group-header .doc-chevron { width: 14px; height: 14px; }
.doc-group-body { padding: 0.4rem 0 0 0; }

.doc-child-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.75rem;
    margin-top: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.15s, border-color 0.15s;
}
.doc-child-link:hover { background: var(--bg); border-color: var(--primary); }
.doc-child-link .doc-arrow {
    width: 16px; height: 16px;
    flex-shrink: 0;
    color: var(--text-muted);
    transition: transform 0.15s;
}
.doc-child-link:hover .doc-arrow { transform: translateX(2px); color: var(--primary); }

.doc-asset-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 0.75rem;
    margin-bottom: 0.5rem;
}

/* ===== Lightbox ===== */
.att-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 9999;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    flex-direction: column;
    touch-action: none;
}
.att-lightbox[style*="display: none"] { display: none !important; }
.att-lightbox-close {
    position: absolute;
    top: 0.75rem;
    right: 1rem;
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    cursor: pointer;
    z-index: 10000;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background 0.15s;
}
.att-lightbox-close svg { width: 20px; height: 20px; display: block; }
.att-lightbox-close:hover { background: rgba(255,255,255,0.3); }
/* Prev/next arrows (images only; PDFs/files aren't in the thumbnail list so they're skipped) */
.att-lightbox-nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    width: 44px; height: 44px; border-radius: 50%;
    background: rgba(255,255,255,0.15); border: none; color: #fff;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; z-index: 10000; transition: background 0.15s;
}
.att-lightbox-nav:hover { background: rgba(255,255,255,0.3); }
.att-lightbox-nav svg { width: 22px; height: 22px; display: block; }
.att-lb-prev { left: 1rem; }
.att-lb-next { right: 1rem; }
@media (max-width: 640px) { .att-lightbox-nav { width: 38px; height: 38px; } .att-lb-prev { left: 0.4rem; } .att-lb-next { right: 0.4rem; } }
.att-lightbox-download {
    position: absolute;
    top: 0.75rem;
    right: 4rem;
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    cursor: pointer;
    z-index: 10000;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    text-decoration: none;
}
.att-lightbox-download:hover { background: rgba(255,255,255,0.3); color: #fff; }

/* Inputs that uppercase user typing (license plate, vehicle reg, etc.) without
   propagating the transform to the placeholder text. seg 2.2 N2 fix. */
.input-upper { text-transform: uppercase; }
.input-upper::placeholder { text-transform: none; }
.att-lightbox-zoom {
    touch-action: none;
    display: flex;
    align-items: center;
    justify-content: center;
}
.att-lightbox-img {
    max-width: 90vw;
    max-height: 82vh;
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.5);
    object-fit: contain;
    transform-origin: center center;
}
.att-lightbox-caption {
    margin-top: 0.75rem;
    color: #aaa;
    font-size: 0.85rem;
    text-align: center;
}

/* ===== Asset link badge (parts list) ===== */

/* ===== Partial-use indicators (parts with amount_used > 0) ===== */
.partial-badge {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.1rem 0.5rem;
    background: var(--warning);
    color: var(--bg);
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    vertical-align: middle;
    white-space: nowrap;
}
.partial-used-row td {
    background: color-mix(in srgb, var(--warning) 8%, transparent);
}

/* ===== Info tooltip component (Stage 5.5 Part A, 2026-05-13 session 3) =====
   Reusable (i) icon + tooltip pair. WCAG 1.4.13 dismissible/hoverable/persistent.
   Desktop: hover or keyboard focus shows tooltip.
   Mobile: tap toggles is-active class; tap-outside or Escape dismisses (JS in asset-form.js).
   Usage: <button class="info-tooltip"><svg>(i)</svg><span class="info-tooltip-text">...</span></button>
*/
.info-tooltip {
    display: inline-flex;
    align-items: center;
    margin-left: 0.35rem;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: help;
    color: var(--text-muted);
    vertical-align: middle;
    position: relative;
    line-height: 0;
}
.info-tooltip:hover,
.info-tooltip:focus-visible {
    color: var(--accent, #4a9eff);
    outline: none;
}
.info-tooltip:focus-visible {
    outline: 2px solid var(--accent, #4a9eff);
    outline-offset: 2px;
    border-radius: 50%;
}
.info-tooltip svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    display: block;
}
.info-tooltip-text {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    min-width: 220px;
    max-width: 320px;
    background: var(--bg-elevated, #2a2a2a);
    color: var(--text, #e0e0e0);
    border: 1px solid var(--border, #444);
    border-radius: 4px;
    padding: 0.55rem 0.7rem;
    font-size: 0.78rem;
    font-weight: 400;
    line-height: 1.45;
    text-align: left;
    z-index: 1000;
    pointer-events: none;
    transition: opacity 0.15s ease, visibility 0s linear 0.15s;
    white-space: normal;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.info-tooltip:hover .info-tooltip-text,
.info-tooltip:focus-visible .info-tooltip-text,
.info-tooltip.is-active .info-tooltip-text {
    visibility: visible;
    opacity: 1;
    transition: opacity 0.15s ease, visibility 0s linear 0s;
}
.info-tooltip-text::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -6px;
    border-width: 6px 6px 0 6px;
    border-style: solid;
    border-color: var(--border, #444) transparent transparent transparent;
}
/* Mobile: tighter tooltip to fit narrow viewport */
@media (max-width: 480px) {
    .info-tooltip-text {
        min-width: 180px;
        max-width: 260px;
        font-size: 0.75rem;
        padding: 0.5rem 0.6rem;
    }
}

/* ---- Stage 5.5-A: inline expiry/anchor reminder component ----
   Appears under a date field once a date is entered, letting the user spin
   up a schedule reminder without leaving the asset form. One reusable block:
   rendered by the reminder_date_field() macro, driven by reminderField() in
   asset-form.js. Must look and behave identically everywhere it is used. */
.reminder-prompt {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-top: 0.45rem;
    padding: 0.5rem 0.65rem;
    background: var(--surface2);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}
.reminder-prompt-q {
    font-size: 0.82rem;
    color: var(--text-muted);
}
.reminder-creator {
    margin-top: 0.45rem;
    padding: 0.7rem 0.75rem;
    background: var(--surface2);
    border: 1px solid var(--primary);
    border-radius: var(--radius);
}
.reminder-creator-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}
.reminder-creator-row:last-of-type {
    margin-bottom: 0;
}
.reminder-sub-label {
    flex: 0 0 6.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}
.reminder-creator input[type="text"],
.reminder-creator input[type="number"],
.reminder-creator select {
    margin: 0;
    min-height: 38px;
}
.reminder-name-input,
.reminder-lead-select {
    flex: 1 1 auto;
    min-width: 0;
}
.reminder-interval {
    flex: 1 1 auto;
    display: flex;
    gap: 0.4rem;
    min-width: 0;
}
.reminder-interval-num {
    flex: 0 0 5rem;
}
.reminder-interval-unit {
    flex: 1 1 auto;
    min-width: 0;
}
.reminder-note {
    margin: 0.15rem 0 0.55rem;
}
.reminder-remove {
    background: transparent;
    border: 0;
    padding: 0;
    color: var(--text-muted);
    font-size: 0.78rem;
    text-decoration: underline;
    cursor: pointer;
}
.reminder-remove:hover {
    color: var(--danger);
}
@media (max-width: 480px) {
    .reminder-creator-row {
        flex-wrap: wrap;
    }
    .reminder-sub-label {
        flex-basis: 100%;
        margin-bottom: 0.2rem;
    }
}

/* Stage 3 color chips (multi-color "+" pattern, 2026-05-15).
   Used by the colorChips() Alpine factory for any list-of-short-strings field. */
.color-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}
.color-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    background: var(--bg-elev, rgba(255,255,255,0.04));
    border: 1px solid var(--border, rgba(255,255,255,0.1));
    border-radius: 999px;
    padding: 0.15rem 0.15rem 0.15rem 0.55rem;
}
.color-chip-input {
    background: transparent !important;
    border: none !important;
    color: inherit;
    font-size: 0.9rem;
    width: 8rem;
    padding: 0.25rem 0 !important;
    outline: none;
    min-height: 0 !important;
}
.color-chip-input::placeholder { opacity: 0.5; }
.color-chip-remove {
    background: transparent;
    border: none;
    color: var(--text-muted, rgba(255,255,255,0.55));
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0 0.35rem;
    border-radius: 999px;
}
.color-chip-remove:hover { color: var(--text, inherit); background: rgba(255,255,255,0.08); }
.color-chip-add {
    background: transparent;
    border: 1px dashed var(--border, rgba(255,255,255,0.18));
    border-radius: 999px;
    color: var(--text-muted, rgba(255,255,255,0.6));
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0.3rem 0.7rem;
}
.color-chip-add:hover { color: var(--text, inherit); border-color: var(--accent, #4a8cff); }

/* ===== Asset list cards (2026-06-17) ===== */
.asset-cards { display: flex; flex-direction: column; gap: 0.85rem; }
.asset-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.ac-head { display: flex; align-items: center; gap: 0.8rem; padding: 0.85rem 1rem 0.7rem; }
.ac-ico { width: 42px; height: 42px; flex: 0 0 auto; border-radius: 11px; display: flex; align-items: center; justify-content: center; background: var(--surface2); color: var(--text-muted); }
.ac-ico svg { width: 22px; height: 22px; }
.ac-ico-vehicle, .ac-ico-marine { background: rgba(20,184,166,0.13); color: var(--primary-hover); }
.ac-ico-equipment { background: rgba(255,179,71,0.14); color: var(--warning); }
.ac-ico-sched { background: rgba(20,184,166,0.13); color: var(--primary-hover); }
.asset-card.is-overdue { border-color: var(--danger); }
.ac-sched-actions { margin-left: auto; display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.ac-title { flex: 1; min-width: 0; }
.ac-name { font-size: 1rem; font-weight: 600; color: var(--text); text-decoration: none; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-name:hover { color: var(--primary-hover); }
.ac-sub { font-size: 0.78rem; color: var(--text-muted); margin-top: 1px; }
.ac-stats { display: flex; align-items: center; flex-wrap: wrap; gap: 0.75rem 1.1rem; padding: 0 1rem 0.9rem; }
.ac-left { display: flex; flex-wrap: wrap; gap: 0.75rem 1.1rem; flex: 1; min-width: 0; }
.ac-right { display: flex; gap: 1.1rem; padding-left: 1rem; border-left: 1px solid var(--border); }
.ac-stat { display: flex; flex-direction: column; gap: 1px; min-width: 0; text-decoration: none; }
.ac-stat b { font-size: 0.86rem; font-weight: 500; color: var(--text); white-space: nowrap; display: flex; align-items: center; gap: 3px; }
.ac-stat span { font-size: 0.62rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); }
.ac-clk { cursor: pointer; }
.ac-clk b { color: var(--primary-hover); }
a.ac-clk:hover b { text-decoration: underline; }
.ac-arr { width: 11px; height: 11px; }
.ac-clip { width: 12px; height: 12px; vertical-align: -1px; }
.ac-fuel { color: var(--warning) !important; }
.ac-total { color: var(--primary-hover) !important; }
.ac-foot { display: flex; gap: 0.5rem; align-items: center; border-top: 1px solid var(--border); padding: 0.55rem 1rem; }
.ac-eb { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.76rem; color: var(--text-muted); background: var(--surface2); border: 1px solid var(--border); border-radius: 20px; padding: 0.3rem 0.7rem; cursor: pointer; font-family: inherit; }
.ac-eb svg { width: 14px; height: 14px; }
.ac-eb:hover, .ac-eb.active { border-color: var(--primary); color: var(--primary-hover); }
.ac-chev { transition: transform 0.28s ease; }
.ac-chev.flip { transform: rotate(180deg); }
.ac-exp { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.3s ease; }
.ac-exp.open { grid-template-rows: 1fr; }
.ac-exp-in { overflow: hidden; min-height: 0; }
.ac-child { display: flex; align-items: center; gap: 0.7rem; margin: 0 1rem 0.7rem; padding: 0.6rem 0.75rem; background: var(--surface2); border: 1px solid var(--border); border-radius: 9px; }
.ac-child:first-child { margin-top: 0.2rem; }
.ac-child-ico { width: 30px; height: 30px; flex: 0 0 auto; border-radius: 8px; display: flex; align-items: center; justify-content: center; background: rgba(20,184,166,0.13); color: var(--primary-hover); }
.ac-child-ico svg { width: 17px; height: 17px; }
.ac-child-main { flex: 1; min-width: 0; }
.ac-child-name { font-size: 0.85rem; font-weight: 500; color: var(--text); text-decoration: none; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-child-name:hover { color: var(--primary-hover); }
.ac-child-sub { font-size: 0.7rem; color: var(--text-muted); }
.ac-child-stats { display: flex; gap: 0.9rem; flex-wrap: wrap; }
.ac-notes { margin: 0 1rem 0.9rem; padding-top: 0.2rem; font-size: 0.85rem; line-height: 1.55; color: var(--text); white-space: pre-wrap; }
@media (max-width: 640px) {
  .ac-right { border-left: none; padding-left: 0; }
  .ac-child-stats { display: none; }
}

/* ===== Log clusters (2026-06-17) ===== */
.log-search-bar { position: relative; margin-bottom: 1rem; }
.log-search-bar svg { position: absolute; left: 0.8rem; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-muted); pointer-events: none; }
.log-search-bar input { width: 100%; padding-left: 2.3rem; }
.log-clusters { display: flex; flex-direction: column; gap: 0.85rem; }
.lc-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.lc-head { display: flex; align-items: center; gap: 0.7rem; padding: 0.65rem 1rem; background: var(--surface2); border-bottom: 1px solid var(--border); }
.lc-head .ac-ico { width: 30px; height: 30px; border-radius: 8px; }
.lc-head .ac-ico svg { width: 17px; height: 17px; }
.lc-name { font-size: 0.95rem; font-weight: 600; color: var(--text); text-decoration: none; }
.lc-name:hover { color: var(--primary-hover); }
.lc-meta { margin-left: auto; font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; }
.lc-body { padding: 0 0.5rem; }
.lc-row { border-bottom: 1px solid var(--border); }
.lc-row:last-child { border-bottom: none; }
.lc-row-h { display: flex; align-items: center; gap: 0.7rem; padding: 0.6rem 0.5rem; }
.lc-clickable { cursor: pointer; border-radius: 7px; }
.lc-clickable:hover { background: var(--surface2); }
.lc-date { flex: 0 0 auto; width: 66px; font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; }
.lc-title { flex: 0 0 auto; max-width: 200px; font-size: 0.85rem; color: var(--primary-hover); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc-title:hover { text-decoration: underline; }
.lc-clip { color: var(--text-muted); flex: 0 0 auto; }
.lc-cat { flex: 0 0 auto; }
.lc-note { flex: 1 1 auto; min-width: 0; font-size: 0.8rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc-note-dim { color: var(--text-muted); opacity: 0.7; font-style: italic; }
.lc-parts { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 3px; font-size: 0.74rem; color: var(--text-muted); }
.lc-parts svg { width: 13px; height: 13px; }
.lc-cost { flex: 0 0 auto; width: 70px; text-align: right; font-size: 0.85rem; font-weight: 500; color: var(--text); }
.lc-chev { flex: 0 0 auto; width: 15px; height: 15px; color: var(--text-muted); }
.lc-detail { padding: 0.2rem 0.6rem 0.7rem 4.7rem; }
.lc-fullnote { margin: 0 0 0.5rem; font-size: 0.82rem; line-height: 1.55; color: var(--text); white-space: pre-wrap; }
.lc-part { display: flex; justify-content: space-between; gap: 0.6rem; padding: 0.25rem 0; border-bottom: 1px solid var(--border); }
.lc-part:last-child { border-bottom: none; }
@media (max-width: 640px) {
  .lc-title { max-width: 120px; }
  .lc-note { display: none; }
  .lc-detail { padding-left: 1rem; }
}

/* ===== Asset detail info card (2026-06-17) ===== */
.dcard-metrics { display: flex; flex-wrap: wrap; gap: 1.4rem 2.2rem; align-items: flex-start; padding-bottom: 1.1rem; margin-bottom: 1.3rem; border-bottom: 1px solid var(--border); }
.dcard-metric { display: flex; flex-direction: column; gap: 0.3rem; }
.dcard-m-label { font-size: 0.7rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); }
.dcard-m-val { font-size: 1.45rem; font-weight: 600; color: var(--text); line-height: 1; }
.dcard-total { color: var(--primary-hover); }
.dcard-fuel { color: var(--warning); }
.dcard-status-metric { margin-left: auto; }
.dcard-section { margin-bottom: 1.5rem; }
.dcard-section:last-child { margin-bottom: 0; }
.dcard-sec-label { font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--primary-hover); font-weight: 600; margin: 0 0 0.8rem; }
.dcard-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0.9rem 1.6rem; margin-bottom: 0; }
.dcard-field { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.dcard-f-label { font-size: 0.68rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); }
.dcard-f-val { margin: 0; font-size: 0.95rem; color: var(--text); word-break: break-word; line-height: 1.35; }
@media (max-width: 640px) {
  .dcard-metrics { gap: 1rem 1.5rem; }
  .dcard-status-metric { margin-left: 0; }
  .dcard-fields { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.75rem 1rem; }
}

/* ===== Log-row icon (Slim 1, 2026-06-17) — shared by the logs list + asset-detail history (macros/log_ui.html) ===== */
.lc-ico { width: 28px; height: 28px; flex: 0 0 auto; border-radius: 7px; background: rgba(20,184,166,0.13); color: var(--primary-hover); display: flex; align-items: center; justify-content: center; text-decoration: none; }
.lc-ico:hover { background: rgba(20,184,166,0.22); }
.lc-ico .li-svg { width: 16px; height: 16px; }
/* asset-detail history reuses the logs-page .lc-card/.lc-body wrapper; a thin top rule separates it from the header */
.mh-wrap { border-top: 1px solid var(--border); }
.mh-icon-preview { width: 40px; height: 40px; flex: 0 0 auto; border-radius: 10px; background: rgba(20,184,166,0.13); color: var(--primary-hover); display: flex; align-items: center; justify-content: center; }
.mh-icon-preview .li-svg { width: 22px; height: 22px; }
@media (max-width: 640px) { .lc-ico { width: 26px; height: 26px; } }
