/* SICO TRACK — application styles v2 (modern refresh) */

:root {
  --bg: #F5F6FB;
  --surface: #FFFFFF;
  --surface-2: #F0F1F9;
  --ink: #1E2233;
  --ink-soft: #666B85;
  --line: #E3E5F0;
  --brand: #4F46E5;
  --brand-strong: #4338CA;
  --brand-soft: #ECEBFC;
  --accent: #7C3AED;
  --warn: #B45309;
  --warn-soft: #FCF3E3;
  --critical: #DC2626;
  --critical-soft: #FDECEC;
  --ok: #0284C7;
  --shadow-sm: 0 1px 2px rgba(30, 34, 51, 0.06);
  --shadow-md: 0 1px 3px rgba(30, 34, 51, 0.07), 0 12px 32px -16px rgba(30, 34, 51, 0.22);
  --radius: 14px;
  --radius-sm: 9px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10121F;
    --surface: #171928;
    --surface-2: #1E2136;
    --ink: #E7E8F5;
    --ink-soft: #9195B3;
    --line: #2B2E45;
    --brand: #818CF8;
    --brand-strong: #A5B0FC;
    --brand-soft: #23264A;
    --accent: #A78BFA;
    --warn: #F0B429;
    --warn-soft: #2E2410;
    --critical: #F87171;
    --critical-soft: #2E1518;
    --ok: #38BDF8;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 1px 3px rgba(0, 0, 0, 0.5), 0 14px 36px -18px rgba(0, 0, 0, 0.7);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
}

a { color: var(--brand); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--brand-strong); }

h1 {
  font-family: 'Inter', sans-serif;
  font-weight: 800; font-size: 1.75rem; letter-spacing: -0.02em;
  margin: 0 0 0.2rem;
}
h2 {
  font-family: 'Inter', sans-serif;
  font-weight: 600; letter-spacing: -0.005em;
  font-size: 1.02rem; color: var(--ink);
  margin: 0 0 0.9rem;
}
.muted { color: var(--ink-soft); }
.center { text-align: center; }
.error { color: var(--critical); font-size: 0.85rem; margin: 0.25rem 0 0; }

:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 2px; }

/* ================= App shell (authenticated) ================= */
.app-body { flex-direction: row; }

.sidebar {
  width: 250px; flex-shrink: 0;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: #14162A;
  color: #A6ABC7;
  overflow-y: auto;
  z-index: 60;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 1.05rem 1.15rem 0.95rem;
  font-family: 'Inter', sans-serif;
  font-weight: 800; text-transform: uppercase; letter-spacing: 0.07em;
  font-size: 1.12rem; color: #F2F3FA; text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.sidebar-brand:hover { color: #fff; }
.sidebar-brand span { color: #818CF8; }

.sidebar-nav { padding: 0.7rem 0.7rem 1rem; flex: 1; }
.nav-section {
  display: block; margin: 1.1rem 0.5rem 0.35rem;
  font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.02em; color: rgba(255, 255, 255, 0.34);
}
.nav-section:first-child { margin-top: 0.2rem; }
.nav-item {
  display: flex; align-items: center; gap: 0.65rem;
  width: 100%; text-align: left;
  padding: 0.52rem 0.75rem; margin: 0.1rem 0;
  border: 0; border-radius: 9px;
  background: transparent; color: #9CA1C4;
  font: inherit; font-size: 0.9rem; font-weight: 500;
  text-decoration: none; cursor: pointer;
  transition: background 0.13s ease, color 0.13s ease;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }
.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #EEF0FA; }
.nav-item.active {
  background: rgba(129, 140, 248, 0.14);
  color: #A5B4FC; font-weight: 600;
  box-shadow: inset 2.5px 0 0 #818CF8;
}
.nav-item.soon { cursor: default; opacity: 0.5; }
.nav-item.soon:hover { background: transparent; color: #9CA1C4; }
.badge-soon {
  margin-left: auto; font-style: normal;
  font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  padding: 0.05rem 0.4rem; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18); color: rgba(255, 255, 255, 0.45);
}

.sidebar-footer {
  padding: 0.8rem 0.9rem;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}
.sidebar-user {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.45rem 0.5rem; margin-bottom: 0.35rem;
  border-radius: 9px; text-decoration: none;
  transition: background 0.13s ease;
}
.sidebar-user:hover { background: rgba(255, 255, 255, 0.06); }
.sidebar-user-active { background: rgba(129, 140, 248, 0.14); }
.avatar {
  width: 32px; height: 32px; flex-shrink: 0;
  display: grid; place-items: center;
  background: #4F46E5;
  color: #fff; font-weight: 700; font-size: 0.9rem;
  border-radius: 999px;
}
.sidebar-user-meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.sidebar-user-meta strong { color: #EDEEFA; font-size: 0.86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-meta small { color: rgba(255, 255, 255, 0.4); font-size: 0.72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-logout { font-size: 0.82rem; padding: 0.4rem 0.75rem; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }

.app-topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 0.9rem;
  padding: 0.6rem 1.4rem;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.hamburger {
  display: none; border: 0; background: transparent; color: var(--ink);
  padding: 0.3rem; cursor: pointer; border-radius: 8px;
}
.hamburger:hover { background: var(--surface-2); }
.context-chip {
  display: inline-flex; align-items: center;
  font-size: 0.8rem; font-weight: 600;
  padding: 0.22rem 0.7rem; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand-strong);
  border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent);
}
.context-chip-admin { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }

.topbar-actions { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }

.icon-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 999px;
  border: 1px solid transparent; background: transparent;
  color: var(--ink-soft); text-decoration: none; cursor: pointer;
  transition: background 0.13s ease, color 0.13s ease, border-color 0.13s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn-active { color: var(--brand-strong); background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 30%, transparent); }
.icon-btn-badge {
  position: absolute; top: 2px; right: 2px;
  min-width: 16px; height: 16px; padding: 0 3px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--critical); color: #fff;
  font-size: 0.62rem; font-weight: 700; line-height: 1;
  border-radius: 999px; border: 2px solid var(--surface);
}

.dropdown-menu { position: relative; }
.dropdown-menu summary { list-style: none; cursor: pointer; }
.dropdown-menu summary::-webkit-details-marker,
.dropdown-menu summary::marker { display: none; content: ''; }
.user-menu-trigger {
  display: flex; align-items: center; border-radius: 999px;
  transition: box-shadow 0.13s ease;
}
.user-menu[open] .user-menu-trigger,
.user-menu-trigger:hover { box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 35%, transparent); }
.avatar-sm { width: 32px; height: 32px; font-size: 0.82rem; }
.user-menu-panel {
  position: absolute; top: calc(100% + 0.6rem); right: 0; z-index: 45;
  width: 220px; padding: 0.4rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 4px 10px rgba(30, 34, 51, 0.06), 0 16px 40px -16px rgba(30, 34, 51, 0.28);
}
.user-menu-info {
  padding: 0.55rem 0.7rem 0.6rem; margin-bottom: 0.3rem;
  border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; line-height: 1.3;
}
.user-menu-info strong { font-size: 0.88rem; color: var(--ink); }
.user-menu-info small { font-size: 0.76rem; color: var(--ink-soft); }
.user-menu-item {
  display: block; width: 100%; text-align: left;
  padding: 0.5rem 0.7rem; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink);
  font: inherit; font-size: 0.86rem; font-weight: 500;
  text-decoration: none; cursor: pointer;
}
.user-menu-item:hover { background: var(--surface-2); }
.user-menu-item-danger { color: var(--critical); }

.content { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 1.7rem 1.4rem; }

.backdrop {
  display: none; position: fixed; inset: 0; z-index: 55;
  background: rgba(10, 11, 22, 0.5); backdrop-filter: blur(2px);
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.4);
  }
  .nav-open .sidebar { transform: translateX(0); }
  .nav-open .backdrop { display: block; }
  .hamburger { display: inline-flex; }
  .content { padding: 1.2rem 1rem; }
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1120px; margin: 0 auto; padding: 0.65rem 1.2rem;
  display: flex; align-items: center; gap: 1.6rem; flex-wrap: wrap;
}
.brand {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-family: 'Inter', sans-serif;
  font-weight: 800; text-transform: uppercase; letter-spacing: 0.07em;
  font-size: 1.15rem; text-decoration: none; color: var(--ink);
  white-space: nowrap;
}
.brand:hover { color: var(--ink); }
.brand svg { display: block; }
.brand span { color: var(--brand); }

.mainnav {
  display: flex; gap: 0.25rem; flex: 1;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.mainnav::-webkit-scrollbar { display: none; }
.mainnav a { flex-shrink: 0; }
.mainnav a {
  font-family: 'Inter', sans-serif;
  font-weight: 600; font-size: 0.88rem;
  text-decoration: none; color: var(--ink-soft);
  padding: 0.38rem 0.85rem; border-radius: 999px;
  transition: background 0.15s ease, color 0.15s ease;
}
.mainnav a:hover { color: var(--ink); background: var(--surface-2); }
.mainnav a.active { color: var(--brand-strong); background: var(--brand-soft); }

.userbox { display: flex; align-items: center; gap: 0.8rem; margin-left: auto; }
.username { font-size: 0.88rem; font-weight: 500; color: var(--ink-soft); }

/* ---------- Layout ---------- */
.container { max-width: 1120px; width: 100%; margin: 0 auto; padding: 1.8rem 1.2rem; flex: 1; }
.footer {
  border-top: 1px solid var(--line);
  padding: 1.1rem 1.2rem; text-align: center;
  font-size: 0.78rem; color: var(--ink-soft);
}
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap;
}
.page-head p { margin: 0; }

/* ---------- Stats ---------- */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 145px), 1fr));
  gap: 0.9rem; margin-bottom: 1.5rem;
}
.stat {
  position: relative;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem 1.05rem; display: flex; flex-direction: column;
  transition: border-color 0.15s ease;
}
.stat:hover { border-color: color-mix(in srgb, var(--brand) 30%, var(--line)); }
.stat-value {
  font-family: 'Inter', sans-serif;
  font-weight: 800; font-size: 2.1rem; line-height: 1.15; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  font-size: 0.86rem; font-weight: 500;
  color: var(--ink-soft); margin-top: 0.15rem;
}
.stat-warn { border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }
.stat-warn .stat-value { color: var(--warn); }

/* ---------- Usage strip (compact, subtle alternative to .stat-grid) ---------- */
.usage-strip {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem;
  margin-bottom: 1rem; font-size: 0.82rem; color: var(--ink-soft);
}
.usage-item strong { color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 700; }
.usage-item.usage-warn strong { color: var(--warn); }
.usage-item.usage-warn { color: var(--warn); }
.usage-sep { color: var(--line); }

/* ---------- Upload card (dropzone + type + submit in one compact row) ---------- */
.upload-row { display: flex; gap: 1.4rem; flex-wrap: wrap; align-items: stretch; }
.upload-dropzone-col { flex: 1 1 320px; min-width: 0; }
.upload-side-col {
  flex: 1 1 260px; min-width: 240px; max-width: 340px;
  display: flex; flex-direction: column; justify-content: flex-start;
}
.upload-side-col .btn { margin-top: auto; align-self: stretch; }
.upload-side-col label { margin-top: 0; }
.upload-progress { margin-top: 0.9rem; display: flex; flex-direction: column; gap: 0.4rem; }
.upload-progress-row {
  display: flex; align-items: center; justify-content: space-between; gap: 0.8rem;
  padding: 0.5rem 0.75rem; border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface-2); font-size: 0.86rem;
}
.upload-progress-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-progress-status { flex-shrink: 0; }
.dropzone-hint { margin: 0.15rem 0 0; font-size: 0.78rem; }
.dropzone-filename {
  margin: 0.15rem 0 0; font-size: 0.82rem; min-height: 1.1em;
  color: var(--brand-strong); font-weight: 600;
}

/* ---------- Cards ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 0.9rem; }

/* ---------- Financial KPI strip ---------- */
.kpi-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
  gap: 0.9rem; margin-bottom: 1.2rem;
}
.kpi {
  display: flex; flex-direction: column; gap: 0.2rem;
  padding: 0.85rem 1rem; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line);
}
.kpi-label { font-size: 0.84rem; font-weight: 500; color: var(--ink-soft); }
.kpi-value { font-family: 'Inter', sans-serif; font-weight: 800; font-size: 1.7rem; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi-value.kpi-good { color: var(--ok); }
.kpi-value.kpi-bad { color: var(--critical); }
.kpi-delta { font-size: 0.78rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi-delta.kpi-good { color: var(--ok); }
.kpi-delta.kpi-bad { color: var(--critical); }
.kpi-delta.kpi-neutral { color: var(--ink-soft); font-weight: 500; }
.kpi-net { background: color-mix(in srgb, var(--brand) 7%, var(--surface-2)); border-color: color-mix(in srgb, var(--brand) 28%, var(--line)); }

/* ---------- Report tabs ---------- */
.report-tabs {
  display: flex; gap: 0.2rem; flex-wrap: nowrap;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  border-bottom: 1px solid var(--line); margin-bottom: 1.1rem;
}
.report-tabs::-webkit-scrollbar { display: none; }
.report-tab {
  border: 0; background: transparent; cursor: pointer; flex-shrink: 0;
  font-family: 'Inter', sans-serif; font-weight: 700; font-size: 0.92rem; letter-spacing: 0.02em;
  color: var(--ink-soft); padding: 0.55rem 0.9rem; margin-bottom: -1px;
  border-bottom: 2px solid transparent; transition: color 0.13s ease, border-color 0.13s ease;
}
.report-tab:hover { color: var(--ink); }
.report-tab.active { color: var(--brand-strong); border-bottom-color: var(--brand); }
.report-panel[hidden] { display: none; }
.report-subhead {
  font-family: 'Inter', sans-serif; font-size: 1rem; font-weight: 700;
  margin: 1.3rem 0 0.6rem; color: var(--ink);
}
.table.mini-table { font-size: 0.85rem; width: 100%; min-width: 0; }
.mini-table th, .mini-table td { padding: 0.5rem 0.75rem; }

/* ---------- Report empty states ---------- */
.report-empty {
  display: flex; flex-direction: column; align-items: center; gap: 0.6rem;
  text-align: center; padding: 2.8rem 1.5rem;
}
.report-empty-icon { width: 38px; height: 38px; color: var(--ink-soft); opacity: 0.5; }
.report-empty h3 { margin: 0.1rem 0 0; font-size: 1.05rem; font-weight: 700; color: var(--ink); }
.report-empty p { margin: 0; max-width: 30rem; color: var(--ink-soft); font-size: 0.9rem; }
.report-empty .btn { margin-top: 0.3rem; }
.report-empty-inline { padding: 1.3rem 1rem; }

/* ---------- Insight cards (Suggestions/Simulations/Patterns/Opportunities/Strategies) ---------- */
.insight-card {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); padding: 0.9rem 1.05rem; margin-bottom: 0.7rem;
}
.insight-card:last-child { margin-bottom: 0; }
.insight-card h4 { margin: 0 0 0.3rem; font-family: 'Inter', sans-serif; font-size: 1rem; letter-spacing: 0.01em; }
.insight-card p { margin: 0; font-size: 0.9rem; color: var(--ink-soft); }
.insight-card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.insight-card-head h4 { margin: 0; }

/* ---------- Trend chart (hand-drawn SVG, no charting library) ---------- */
.trend-chart-wrap { margin: 0.9rem 0 0.4rem; }
.trend-chart { width: 100%; height: 130px; display: block; overflow: visible; }
.trend-chart .bar-expense { fill: var(--warn); }
.trend-chart .bar-revenue { fill: var(--brand); }
.trend-chart .bar-label { font-size: 7px; fill: var(--ink-soft); font-family: 'Inter', sans-serif; }
.trend-legend { display: flex; gap: 1.2rem; margin-top: 0.3rem; font-size: 0.78rem; color: var(--ink-soft); }
.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 0.35rem; vertical-align: middle; }
.legend-expense { background: var(--warn); }
.legend-revenue { background: var(--brand); }

/* ---------- Dashboard 2/3 + 1/3 layout ---------- */
/* Dashboard only — wider content column so it doesn't float in a sea of
   empty background on large screens like the other, more form/table-centric
   pages do; scoped via body.is-dashboard so nothing else is affected. */
.is-dashboard .content { max-width: 1600px; }
.dash-columns { display: flex; align-items: flex-start; gap: 1.1rem; }
.dash-col-main { flex: 2 1 0; min-width: 0; }
.dash-col-side { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 1.1rem; }
@media (max-width: 900px) {
  .dash-columns { flex-direction: column; }
  .dash-col-main, .dash-col-side { flex: 1 1 auto; width: 100%; }
}
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 1.25rem 1.35rem;
}
.card-fleety {
  background: var(--surface);
  border-color: color-mix(in srgb, var(--brand) 35%, var(--line));
}

.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-list li {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  flex-wrap: wrap;
  padding: 0.55rem 0.4rem; border-bottom: 1px solid var(--line);
  font-size: 0.93rem; border-radius: 6px;
  transition: background 0.12s ease;
}
.doc-list li > span { overflow-wrap: anywhere; }
.doc-list li:hover { background: var(--surface-2); }
.doc-list li:last-child { border-bottom: none; }
.doc-list .due { color: var(--warn); white-space: nowrap; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Notifications (list page + topbar dropdown, shared) ---------- */
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif-row { border-bottom: 1px solid var(--line); }
.notif-row:last-child { border-bottom: none; }
.notif-link {
  display: flex; align-items: flex-start; gap: 0.7rem;
  padding: 0.7rem 0.4rem; text-decoration: none; color: inherit;
  border-radius: 8px; transition: background 0.12s ease;
}
.notif-link:hover { background: var(--surface-2); }
.notif-row-icon { width: 19px; height: 19px; flex-shrink: 0; margin-top: 0.15rem; color: var(--ink-soft); }
.notif-unread .notif-row-icon { color: var(--brand); }
.notif-row-body { display: flex; flex-direction: column; gap: 0.15rem; flex: 1; min-width: 0; }
.notif-row-body strong { font-size: 0.9rem; color: var(--ink); font-weight: 600; }
.notif-unread .notif-row-body strong::before {
  content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 999px;
  background: var(--brand); margin-right: 0.4rem; vertical-align: middle;
}
.notif-row-body .muted { font-size: 0.82rem; overflow-wrap: anywhere; }
.notif-row-time { flex-shrink: 0; font-size: 0.76rem; white-space: nowrap; color: var(--ink-soft); }

.notif-panel {
  position: absolute; top: calc(100% + 0.6rem); right: 0; z-index: 45;
  width: min(360px, 88vw); max-height: 70vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 4px 10px rgba(30, 34, 51, 0.06), 0 16px 40px -16px rgba(30, 34, 51, 0.28);
}
.notif-panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  padding: 0.7rem 0.8rem 0.5rem; border-bottom: 1px solid var(--line);
}
.notif-panel-head strong { font-size: 0.92rem; }
.notif-panel-head button {
  border: 0; background: transparent; color: var(--brand-strong);
  font: inherit; font-size: 0.78rem; font-weight: 600; cursor: pointer; padding: 0;
}
.notif-panel .notif-list { padding: 0.3rem; }
.notif-panel-empty { padding: 1.5rem 1rem; text-align: center; font-size: 0.86rem; color: var(--ink-soft); }
.notif-panel-foot { padding: 0.5rem 0.8rem; border-top: 1px solid var(--line); text-align: center; }
.notif-panel-foot a { font-size: 0.82rem; font-weight: 600; }

/* ---------- Forms ---------- */
.auth-card {
  max-width: 430px; margin: 3rem auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  padding: 2rem 2.1rem 1.7rem;
  position: relative; overflow: hidden;
}
.auth-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: var(--brand);
}
.auth-card h1 { font-size: 1.6rem; }

label { display: block; margin: 1rem 0 0.3rem; font-size: 0.85rem; font-weight: 600; color: var(--ink); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], textarea {
  width: 100%; padding: 0.65rem 0.8rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--ink);
  font: inherit; font-size: 0.95rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
textarea { resize: vertical; }
input:hover, textarea:hover, select:hover { border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--brand); background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
}
.checkline { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; font-size: 0.88rem; margin-top: 1rem; }
.checkline input { width: auto; accent-color: var(--brand); }

select {
  padding: 0.55rem 2rem 0.55rem 0.7rem; font: inherit; font-size: 0.9rem;
  background-color: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-sm); max-width: 100%;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23888' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.7rem center;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 0 1.2rem;
}
.form-grid select { width: 100%; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  cursor: pointer; text-decoration: none;
  font-family: 'Inter', sans-serif; font-weight: 700;
  font-size: 0.86rem; letter-spacing: 0.02em;
  padding: 0.6rem 1.25rem;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 1px 2px rgba(67, 56, 202, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
@media (prefers-color-scheme: dark) {
  .btn-primary { color: #0B1510; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.18); }
}
.btn-primary:hover { color: #fff; filter: brightness(1.08); box-shadow: 0 3px 10px -2px color-mix(in srgb, var(--brand) 55%, transparent); }
@media (prefers-color-scheme: dark) {
  .btn-primary:hover { color: #0B1510; }
}
.btn-block { width: 100%; margin-top: 1.4rem; }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: var(--line); }
.btn-ghost:hover { color: var(--ink); border-color: var(--ink-soft); background: var(--surface-2); }
.btn-sm { font-size: 0.76rem; padding: 0.38rem 0.8rem; }

/* ---------- Tables ---------- */
.tablewrap {
  overflow-x: auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.table { border-collapse: collapse; width: 100%; min-width: 880px; font-size: 0.9rem; }
.table th, .table td { text-align: left; padding: 0.65rem 0.9rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table thead th {
  position: sticky; top: 0;
  background: var(--surface-2);
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem; letter-spacing: 0.02em;
  color: var(--ink-soft); font-weight: 600;
}
.table tbody tr { transition: background 0.12s ease; }
.table tbody tr:hover { background: color-mix(in srgb, var(--brand-soft) 45%, transparent); }
.table tbody tr:last-child td { border-bottom: none; }
.table .num, .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Filter tabs ---------- */
.filter-tabs { display: flex; gap: 0.35rem; margin-bottom: 0.9rem; flex-wrap: wrap; }
.filter-tab {
  font-size: 0.84rem; font-weight: 600; text-decoration: none;
  padding: 0.32rem 0.85rem; border-radius: 999px;
  color: var(--ink-soft); border: 1px solid var(--line); background: var(--surface);
  transition: background 0.13s ease, color 0.13s ease;
}
.filter-tab:hover { color: var(--ink); background: var(--surface-2); }
.filter-tab.active { color: var(--brand-strong); background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 35%, transparent); }

/* ---------- List toolbar (search) ---------- */
.list-toolbar { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.9rem; flex-wrap: wrap; }
.search-input {
  flex: 1 1 260px; max-width: 360px;
  padding: 0.55rem 0.8rem; font: inherit; font-size: 0.9rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--ink);
}
.search-input:focus {
  outline: none; border-color: var(--brand); background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
}

/* ---------- Sortable table headers ---------- */
.th-sort {
  display: inline-flex; align-items: center; gap: 0.3rem;
  color: inherit; text-decoration: none;
}
.th-sort:hover { color: var(--brand-strong); }
.th-sort-active { color: var(--brand-strong); }
.th-sort-arrow { font-size: 0.65em; }
.crt { width: 2.5rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
td.crt { text-align: right; }

/* ---------- Pagination ---------- */
.pagination {
  display: flex; align-items: center; justify-content: center; gap: 1rem;
  margin-top: 1.1rem; flex-wrap: wrap;
}
.page-btn {
  font-size: 0.84rem; font-weight: 600; text-decoration: none;
  padding: 0.4rem 0.9rem; border-radius: 999px;
  color: var(--ink); border: 1px solid var(--line); background: var(--surface);
  transition: background 0.13s ease, color 0.13s ease;
}
.page-btn:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--brand) 35%, transparent); }
.page-btn-disabled { color: var(--ink-soft); opacity: 0.5; pointer-events: none; }
.page-info { font-size: 0.82rem; color: var(--ink-soft); }

/* ---------- Vehicle photo ---------- */
.vehicle-photo {
  display: block; width: 100%; max-width: 320px; max-height: 220px;
  object-fit: cover; border-radius: var(--radius-sm);
  border: 1px solid var(--line); margin-bottom: 1rem;
}

input[type="file"] {
  width: 100%; font-size: 0.88rem; color: var(--ink-soft);
  padding: 0.45rem; border: 1px dashed var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2);
}
input[type="file"]::file-selector-button {
  font: inherit; font-weight: 600; font-size: 0.8rem;
  padding: 0.35rem 0.8rem; margin-right: 0.7rem;
  border: 1px solid var(--line); border-radius: 7px;
  background: var(--surface); color: var(--ink); cursor: pointer;
}

/* ---------- Drag & drop upload zone ---------- */
.dropzone {
  position: relative; display: flex; flex-direction: column; align-items: center;
  gap: 0.4rem; text-align: center; cursor: pointer;
  padding: 1.6rem 1rem; margin-top: 0.3rem;
  border: 1.5px dashed var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone:hover, .dropzone:focus-visible {
  border-color: color-mix(in srgb, var(--brand) 45%, var(--line));
  outline: none;
}
.dropzone.dropzone-active {
  border-color: var(--brand); background: var(--brand-soft);
}
.dropzone-input {
  position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%;
  cursor: pointer; pointer-events: none;
}
.dropzone-icon { width: 28px; height: 28px; color: var(--ink-soft); }
.dropzone-text { margin: 0; font-size: 0.9rem; color: var(--ink); }
.dropzone-text strong { color: var(--brand-strong); }
.dropzone-filename { margin: 0; font-size: 0.82rem; min-height: 1.1em; }

/* ---------- Badges & flash ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.14rem 0.55rem;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em;
  border: 1px solid var(--line); border-radius: 999px;
  color: var(--ink-soft); background: var(--surface-2);
  white-space: nowrap;
}
.badge-ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.badge-bad { color: var(--critical); border-color: color-mix(in srgb, var(--critical) 45%, transparent); background: color-mix(in srgb, var(--critical) 9%, transparent); }

.flash {
  display: flex; align-items: baseline; gap: 0.5rem;
  background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 40%, transparent);
  color: var(--ink); padding: 0.7rem 1rem; margin-bottom: 1.1rem;
  font-size: 0.92rem; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}
.flash::before { content: "✓"; color: var(--brand); font-weight: 700; }
.flash-key { font-family: ui-monospace, Menlo, monospace; font-size: 0.85rem; }
.flash-key::before { content: ""; }

/* ---------- User account editing (admin) ---------- */
.user-block {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 1rem 1.1rem; margin-top: 0.9rem;
}
.user-block-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 0.2rem; font-size: 0.95rem;
}
.user-block-actions { display: flex; gap: 0.6rem; margin: 0.9rem 0 0.5rem; flex-wrap: wrap; }
.user-block input, .user-block select { background: var(--surface); }

/* ---------- Ticket thread ---------- */
.thread { display: flex; flex-direction: column; gap: 0.7rem; }
.msg {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
  padding: 0.9rem 1.1rem; max-width: 46rem;
}
.msg-staff {
  border-color: color-mix(in srgb, var(--brand) 35%, var(--line));
  background: color-mix(in srgb, var(--brand-soft) 35%, var(--surface));
}
.msg-head { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.84rem; margin-bottom: 0.3rem; }
.msg p { margin: 0; white-space: pre-line; font-size: 0.95rem; }

/* ---------- Responsive: tables become stacked cards on phones ---------- */
@media (max-width: 760px) {
  .table { min-width: 0; }
  .table thead { display: none; }
  .table tbody tr {
    display: block; padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--line);
  }
  .table tbody tr:last-child { border-bottom: none; }
  .table tbody td {
    display: flex; justify-content: space-between; align-items: center;
    gap: 1rem; border: none; padding: 0.22rem 0;
    text-align: right; overflow-wrap: anywhere;
  }
  .table tbody td::before {
    content: attr(data-label);
    font-weight: 600; font-size: 0.78rem; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--ink-soft);
    text-align: left; flex-shrink: 0;
  }
  .table tbody td:not([data-label])::before { content: none; }
  .table tbody td:not([data-label]) { justify-content: flex-end; }
  .table .num { text-align: right; }
}

@media (max-width: 700px) {
  .username { display: none; }
}

@media (max-width: 560px) {
  .topbar-inner { gap: 0.7rem; padding: 0.55rem 0.9rem; }
  .container { padding: 1.2rem 0.9rem; }
  .auth-card { margin: 1rem auto; padding: 1.5rem 1.3rem; }
  h1 { font-size: 1.45rem; }
  .stat-value { font-size: 1.8rem; }
  .page-head { margin-bottom: 1.1rem; }
  .card { padding: 1rem 1.05rem; }
  .btn { padding: 0.55rem 1rem; }
  .msg { max-width: none; }
}

/* ================= Fleety floating widget ================= */
.fleety-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 150;
  width: 60px; height: 60px; border-radius: 999px; border: 0;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.fleety-fab:hover { transform: scale(1.06); }

.fleety-icon {
  width: 96px; height: auto; display: block;
  filter: drop-shadow(0 9px 16px rgba(30, 34, 51, 0.4));
}

.fleety-label {
  position: absolute; bottom: calc(100% + 4px); left: 50%;
  background: var(--brand); color: #fff;
  font-family: 'Inter', sans-serif; font-weight: 700; font-size: 0.78rem;
  padding: 0.3rem 0.75rem; border-radius: 999px; white-space: nowrap;
  box-shadow: 0 4px 10px rgba(30, 34, 51, 0.28);
  opacity: 0; pointer-events: none;
  animation: fleety-label-in 0.45s ease 1s forwards;
}
@keyframes fleety-label-in {
  from { opacity: 0; transform: translate(-50%, 6px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.fleety-dot {
  position: absolute; top: 18px; right: -6px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--critical); border: 2px solid var(--surface);
  box-shadow: 0 1px 4px rgba(30, 34, 51, 0.35);
  opacity: 0; transform: scale(0.5);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.fleety-fab.fleety-alert .fleety-dot { opacity: 1; transform: scale(1); }

.fleety-bubble {
  position: fixed; right: 90px; bottom: 24px; z-index: 151;
  max-width: 230px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 0.7rem 0.9rem; font-size: 0.86rem; line-height: 1.4;
  box-shadow: var(--shadow-md); cursor: pointer;
  opacity: 0; transform: translateX(12px) scale(0.97); pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.fleety-bubble::after {
  content: ""; position: absolute; right: -7px; bottom: 16px;
  width: 14px; height: 14px; background: var(--surface);
  border-top: 1px solid var(--line); border-right: 1px solid var(--line);
  transform: rotate(45deg);
}
.fleety-bubble.show { opacity: 1; transform: translateX(0) scale(1); pointer-events: auto; }

.fleety-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(10, 11, 22, 0.4); backdrop-filter: blur(1px);
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
}
.fleety-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 201;
  width: clamp(340px, 33vw, 480px);
  background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: -12px 0 32px rgba(0, 0, 0, 0.18);
  display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform 0.28s cubic-bezier(.2,.8,.2,1);
}
#fleety-widget.fleety-open .fleety-backdrop { opacity: 1; pointer-events: auto; }
#fleety-widget.fleety-open .fleety-drawer { transform: translateX(0); }

.fleety-drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.1rem; border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.fleety-drawer-head strong { font-family: 'Inter', sans-serif; font-size: 1.05rem; letter-spacing: 0.02em; }
.fleety-close {
  border: 0; background: transparent; color: var(--ink-soft); cursor: pointer;
  font-size: 1.5rem; line-height: 1; padding: 0.2rem 0.5rem; border-radius: 6px;
}
.fleety-close:hover { color: var(--ink); background: var(--surface-2); }

.fleety-thread {
  flex: 1; overflow-y: auto; padding: 1rem;
  display: flex; flex-direction: column; gap: 0.6rem;
}
.fleety-thread .msg { max-width: none; }

.fleety-form {
  display: flex; gap: 0.6rem; align-items: flex-end;
  padding: 0.8rem; border-top: 1px solid var(--line); flex-shrink: 0;
}
.fleety-form textarea { flex: 1; resize: none; font-size: 0.9rem; }
.fleety-form button { flex-shrink: 0; }

@media (max-width: 700px) {
  .fleety-drawer { width: 100vw; }
  .fleety-fab-arc { display: none; }
  .fleety-bubble { right: 82px; bottom: 16px; max-width: calc(100vw - 110px); }
  .fleety-fab { right: 16px; bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
