/* mycar UI v2 — mobile-first fleet operations shell
 * This file intentionally loads after the legacy inline styles.  The first
 * migration keeps existing report data contracts intact while establishing a
 * single visual language and a real mobile application shell.
 */

:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --panel: #ffffff;
  --panel-alt: #f7f9fc;
  --panel-raised: #ffffff;
  --text: #152238;
  --text-2: #526077;
  --text-3: #748198;
  --border: #e2e8f1;
  --border-2: #cdd6e4;
  --accent: #2764d8;
  --accent-strong: #174cae;
  --accent-bg: #edf4ff;
  --pos: #087f5b;
  --pos-bg: #eaf8f2;
  --neg: #c9364e;
  --neg-bg: #fff0f2;
  --warn: #a85d00;
  --warn-bg: #fff7e8;
  --info-bg: #edf1f7;
  --hover: #f0f4fa;

  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 18px;
  --fs-2xl: 24px;
  --fs-3xl: 32px;

  --r-sm: 8px;
  --r: 10px;
  --r-lg: 16px;
  --r-xl: 20px;
  --shadow-sm: 0 1px 2px rgba(20, 36, 61, .05);
  --shadow: 0 8px 28px rgba(31, 50, 81, .07), 0 1px 3px rgba(31, 50, 81, .06);
  --shadow-lg: 0 22px 56px rgba(12, 28, 52, .16);
  --sidebar-w: 244px;
  --mobile-bar-h: 58px;
  --mobile-tabs-h: 64px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0c1422;
    --panel: #121e30;
    --panel-alt: #17253a;
    --panel-raised: #19283d;
    --text: #edf3fb;
    --text-2: #b2bfd0;
    --text-3: #8c9aaf;
    --border: #26364e;
    --border-2: #374b68;
    --accent: #6fa3ff;
    --accent-strong: #91b8ff;
    --accent-bg: #192f52;
    --pos: #55d7a5;
    --pos-bg: #13382f;
    --neg: #ff7b8c;
    --neg-bg: #40212b;
    --warn: #ffc068;
    --warn-bg: #3b2d18;
    --info-bg: #1d2b40;
    --hover: #1a2a40;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .25);
    --shadow: 0 12px 32px rgba(0, 0, 0, .2), 0 1px 2px rgba(0, 0, 0, .35);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, .42);
  }
}

html {
  min-height: 100%;
  background: var(--bg);
  scroll-behavior: smooth;
  text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(circle at 82% -10%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 31rem),
    var(--bg);
  color: var(--text);
  font-size: var(--fs-md);
  line-height: 1.55;
  letter-spacing: -.004em;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.skip-link {
  position: fixed;
  left: 14px;
  top: 10px;
  z-index: 2000;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  box-shadow: var(--shadow);
  transform: translateY(-180%);
  transition: transform var(--t);
}

.skip-link:focus { transform: translateY(0); }

.sr-only {
  width: 1px;
  height: 1px;
  position: absolute;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.mobile-topbar,
.nav-scrim {
  display: none;
}

/* Application shell ------------------------------------------------------ */
.layout {
  min-height: 100dvh;
  align-items: stretch;
}

aside.app-sidebar {
  width: var(--sidebar-w);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 18px 12px 12px;
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  border-right: 1px solid var(--border);
  box-shadow: 8px 0 30px rgba(31, 50, 81, .025);
  backdrop-filter: blur(18px);
}

aside.app-sidebar .brand {
  min-height: 58px;
  margin: 0 4px 16px;
  padding: 8px 10px;
  border: 0;
  border-radius: 14px;
  gap: 11px;
}

aside.app-sidebar .brand:hover {
  background: var(--accent-bg);
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #fff;
  background: linear-gradient(145deg, #3d7aec, #174cae);
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(39, 100, 216, .22);
}

aside.app-sidebar .brand svg.brand-icon {
  width: 22px;
  height: 22px;
  color: currentColor;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.15;
}

.brand-copy strong {
  color: var(--text);
  font-size: 16px;
  letter-spacing: -.02em;
}

.brand-copy small {
  margin-top: 3px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 500;
}

.nav-scroll {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
}

aside.app-sidebar .group {
  padding: 18px 12px 7px;
  color: var(--text-3);
  font-size: 11px;
  letter-spacing: .1em;
}

aside.app-sidebar .nav-link,
aside.app-sidebar .account-link {
  min-height: 42px;
  margin: 2px 0;
  padding: 9px 12px;
  border: 0;
  border-radius: 11px;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 550;
}

aside.app-sidebar .nav-link .icon,
aside.app-sidebar .account-link .icon {
  width: 20px;
  height: 20px;
  color: var(--text-3);
}

aside.app-sidebar .nav-link .icon svg,
aside.app-sidebar .account-link .icon svg {
  width: 19px;
  height: 19px;
}

aside.app-sidebar .nav-link:hover,
aside.app-sidebar .account-link:hover {
  background: var(--hover);
  color: var(--text);
}

aside.app-sidebar .nav-link.active {
  background: var(--accent-bg);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 9%, transparent);
}

aside.app-sidebar .nav-link.active .icon {
  color: var(--accent);
}

.nav-account {
  flex: 0 0 auto;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px 9px;
  color: var(--text-2);
  font-size: 12px;
}

.nav-avatar {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--info-bg);
  color: var(--text);
  font-weight: 700;
  text-transform: uppercase;
}

main.app-main {
  width: calc(100% - var(--sidebar-w));
  min-width: 0;
  padding: 30px clamp(22px, 3vw, 48px) 48px;
}

.page-head {
  max-width: 1400px;
  margin: 0 auto 22px;
  padding: 0 0 18px;
  align-items: center;
  border-bottom-color: var(--border);
}

.page-head h1 {
  font-size: 26px;
  line-height: 1.2;
  letter-spacing: -.035em;
}

.page-head .sub {
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--info-bg);
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
}

.page-head .actions {
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

.page-head select,
.page-head input[type="date"] {
  min-height: 36px;
  padding: 7px 10px;
  border-color: transparent;
  border-radius: 8px;
  background: var(--panel-alt);
}

/* Shared surfaces -------------------------------------------------------- */
.panel,
.card,
.stat,
body .w,
body .kpi {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.panel {
  border-radius: var(--r-lg);
  background: var(--panel);
}

.panel-head,
.section-title {
  min-height: 54px;
  padding: 14px 18px;
  background: transparent;
  border-bottom-color: var(--border);
  font-size: 15px;
}

.stats,
.summary-cards {
  gap: 12px;
  margin-bottom: 18px;
}

.stat,
.card {
  min-width: 0;
  padding: 15px 17px;
  border-radius: 15px;
  background: var(--panel);
}

.stat:hover {
  border-color: color-mix(in srgb, var(--accent) 22%, var(--border));
  box-shadow: var(--shadow);
}

.stat .k,
.card .k {
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
}

.stat .v,
.card .v {
  margin-top: 3px;
  font-size: 24px;
  line-height: 1.16;
  letter-spacing: -.025em;
}

.stat .sub,
.card .sub {
  color: var(--text-3);
  font-size: 12px;
}

.pill,
.tg {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.25;
}

.pill.pos,
.tg-g { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--pos) 13%, transparent); }
.pill.neg,
.tg-r { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--neg) 14%, transparent); }
.pill.warn,
.tg-o { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 15%, transparent); }

.data-table thead th,
table thead th {
  padding: 10px 12px;
  background: var(--panel-alt);
  color: var(--text-2);
  font-size: 11px;
  letter-spacing: .055em;
}

.data-table tbody td,
table tbody td {
  padding: 11px 12px;
}

table tbody tr:last-child td {
  border-bottom: 0;
}

.empty {
  padding: 42px 20px;
  color: var(--text-3);
  font-size: 14px;
}

.btn,
.btn-inline,
.docs-btn,
.parts-btn,
.copy-btn,
.gps-toolbar button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 10px;
  font-weight: 650;
}

.modal-overlay,
.modal-ov {
  backdrop-filter: blur(8px);
}

.modal,
.modal-box {
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
}

.modal-head,
.modal-hd {
  min-height: 58px;
  padding: 14px 18px;
}

/* Dashboard -------------------------------------------------------------- */
body .dash-wrap {
  max-width: 1400px;
}

body .hero {
  gap: 14px;
  margin-bottom: 14px;
}

body .kpi {
  min-height: 168px;
  padding: 18px;
  overflow: hidden;
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

body .kpi::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--border-2);
}

body .kpi-profit::before { background: linear-gradient(var(--accent), #69a2ff); }
body .kpi-performance::before { background: linear-gradient(var(--pos), #66d9ad); }
body .kpi-assets::before { background: linear-gradient(#7b6ce6, #a698ff); }
body .kpi-balance::before { background: linear-gradient(var(--warn), #ffbd66); }

body .kpi:hover {
  border-color: color-mix(in srgb, var(--accent) 22%, var(--border));
  transform: translateY(-1px);
}

body .kpi .k {
  margin-bottom: 8px;
  color: var(--text-2);
  font-size: 12px;
  letter-spacing: .035em;
}

body .kpi .v,
body .kpi.kpi-profit .v {
  font-size: 30px;
}

body .dual-v {
  gap: 18px;
  margin: 9px 0;
}

body .dv-num {
  font-size: 27px;
}

body .w {
  padding: 18px;
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

body .w-head {
  margin-bottom: 16px;
}

body .w-title {
  font-size: 15px;
  letter-spacing: -.012em;
}

body .w-sub {
  margin-top: 3px;
  color: var(--text-3);
  font-size: 12px;
}

body .w-link {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 9px;
  background: var(--accent-bg);
  font-size: 12px;
  font-weight: 650;
}

body .row {
  gap: 14px;
  margin-bottom: 14px;
}

body .todo-w {
  margin-bottom: 14px;
}

body .todo-list {
  gap: 7px;
}

body .todo-row {
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-left-width: 3px;
  border-radius: 11px;
  background: var(--panel-alt);
}

body .todo-row.prio-0 { border-color: color-mix(in srgb, var(--neg) 25%, var(--border)); border-left-color: var(--neg); }
body .todo-row.prio-1 { border-color: color-mix(in srgb, var(--warn) 25%, var(--border)); border-left-color: var(--warn); }
body .todo-row.prio-2 { border-color: var(--border); border-left-color: var(--text-3); }

body .alert-bar {
  padding: 13px 16px;
  border-radius: 15px;
  box-shadow: var(--shadow-sm);
}

body .gps-row,
body .exp-row,
body .stl-row {
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--panel-alt);
}

/* Vehicles --------------------------------------------------------------- */
.vehicle-mobile-tools {
  display: none;
}

body .vt thead th {
  padding: 11px 10px;
}

body .vt tbody td {
  padding: 11px 10px;
}

body .vt tbody tr.mr:hover {
  background: var(--hover);
}

body .payback-bar {
  background: var(--info-bg);
}

.vehicle-empty-filter {
  display: none;
  padding: 36px 18px;
  border: 1px dashed var(--border-2);
  border-radius: var(--r-lg);
  color: var(--text-3);
  text-align: center;
}

.vcard-detail-btn {
  width: 100%;
  min-height: 42px;
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--panel);
  color: var(--accent);
  font-size: 13px;
  font-weight: 650;
}

.vgps {
  display: none;
}

/* AR/AP ------------------------------------------------------------------ */
.cp-mobile {
  display: none;
}

body .cp-card {
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
}

body .cp-head {
  width: 100%;
  min-height: 64px;
  padding: 15px 18px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

body .cp-head:hover {
  background: var(--hover);
}

body .cp-name {
  font-size: 18px;
}

body .cp-table tr.settle-row td {
  background: var(--panel-alt);
}

/* GPS -------------------------------------------------------------------- */
body .gps-toolbar {
  gap: 7px;
}

body .gps-toolbar button {
  padding: 8px 12px;
  border-radius: 10px;
}

body .gps-layout {
  gap: 14px;
}

body .gps-map-wrap,
body .gps-list {
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
}

body .gps-summary .card {
  min-width: 104px;
  border-radius: 14px;
}

/* Secondary reports ------------------------------------------------------ */
body .mt-section,
body .pm-table-wrap {
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
}

body .mt-head {
  min-height: 60px;
  padding: 14px 18px;
  background: transparent;
}

body .pm-table-wrap {
  border-color: var(--border);
}

body .inv-meta {
  flex-wrap: wrap;
  gap: 6px 12px;
  color: var(--text-3);
}

body .bp-filter input,
body .bp-filter select {
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel);
  color: var(--text);
}

/* Compact desktop / tablet landscape. Keep the desktop information model,
 * but avoid squeezing four KPI cards and multi-field toolbars beside the
 * persistent sidebar. */
@media (min-width: 769px) and (max-width: 1100px) {
  :root { --sidebar-w: 210px; }

  main.app-main { padding: 24px 20px 40px; }

  body .hero { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body .row.r-2-1,
  body .row.r-1-1,
  body .row.r-1-1-1 { grid-template-columns: 1fr; }

  body .as-summary,
  body .inv-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  body .bp-filter {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

  body .bp-filter .search,
  body .bp-filter .bp-filter-actions { grid-column: 1 / -1; }
}

/* Mobile application ----------------------------------------------------- */
@media (max-width: 768px) {
  :root {
    --fs-xs: 12px;
    --fs-sm: 13px;
    --fs-md: 15px;
    --fs-lg: 17px;
    --fs-xl: 20px;
    --fs-2xl: 25px;
    --fs-3xl: 31px;
  }

  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  body {
    font-size: 15px;
    background: var(--bg);
  }

  body.nav-lock {
    overflow: hidden;
  }

  .mobile-topbar {
    min-height: var(--mobile-bar-h);
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1100;
    padding: 4px 10px;
    background: color-mix(in srgb, var(--panel) 92%, transparent);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(20px) saturate(150%);
  }

  .mobile-menu-btn,
  .mobile-home-btn {
    width: 42px;
    height: 42px;
    min-height: 42px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--text-2);
  }

  .mobile-home-spacer {
    width: 42px;
    height: 42px;
  }

  .mobile-menu-btn:active,
  .mobile-home-btn:active {
    background: var(--hover);
  }

  .mobile-menu-btn svg,
  .mobile-home-btn svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
  }

  .mobile-title {
    min-width: 0;
    padding: 0 8px;
    text-align: center;
  }

  .mobile-title strong {
    display: block;
    overflow: hidden;
    color: var(--text);
    font-size: 17px;
    line-height: 1.2;
    letter-spacing: -.02em;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-title small {
    display: block;
    margin-top: 1px;
    color: var(--text-3);
    font-size: 10px;
    line-height: 1.1;
  }

  .nav-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1240;
    border: 0;
    background: rgba(5, 12, 24, .48);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
    backdrop-filter: blur(2px);
  }

  body.nav-open .nav-scrim {
    opacity: 1;
    pointer-events: auto;
  }

  .layout {
    min-height: calc(100dvh - var(--mobile-bar-h));
    display: block;
  }

  aside.app-sidebar {
    width: min(86vw, 340px);
    max-width: none;
    height: 100dvh;
    max-height: none;
    display: flex;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1250;
    padding: calc(14px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
    overflow: hidden;
    border: 0;
    border-right: 1px solid var(--border);
    border-radius: 0 22px 22px 0;
    box-shadow: var(--shadow-lg);
    transform: translateX(-105%);
    transition: transform 220ms cubic-bezier(.22, .9, .32, 1);
  }

  body.nav-open aside.app-sidebar {
    transform: translateX(0);
  }

  aside.app-sidebar .brand {
    min-height: 62px;
    margin-bottom: 8px;
    padding: 9px 10px;
  }

  aside.app-sidebar .brand::after {
    display: none;
  }

  aside.app-sidebar .group {
    padding: 15px 12px 6px;
  }

  aside.app-sidebar .nav-link,
  aside.app-sidebar .account-link {
    min-height: 48px;
    padding: 11px 12px;
    font-size: 15px;
  }

  aside.app-sidebar .nav-link.active {
    border: 0;
  }

  main.app-main {
    width: 100%;
    padding: 14px 12px calc(var(--mobile-tabs-h) + 22px + env(safe-area-inset-bottom));
  }

  .page-head {
    margin-bottom: 13px;
    padding-bottom: 0;
    border: 0;
  }

  .page-head:not(.has-actions) {
    display: none;
  }

  .page-head.has-actions h1,
  .page-head.has-actions .sub {
    display: none;
  }

  .page-head .actions {
    width: 100%;
    margin: 0;
    padding: 6px;
    border-radius: 14px;
  }

  .page-head .actions form {
    width: 100%;
  }

  .page-head select,
  .page-head input[type="date"] {
    min-height: 42px;
    font-size: 16px !important;
  }

  .bottom-tabs {
    min-height: var(--mobile-tabs-h);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: stretch;
    padding: 5px 6px max(4px, env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--panel) 94%, transparent);
    border-top-color: var(--border);
    box-shadow: 0 -10px 32px rgba(22, 38, 64, .08);
    backdrop-filter: blur(20px) saturate(150%);
  }

  .bottom-tabs .bt-item {
    min-width: 0;
    min-height: 52px;
    padding: 4px 2px 2px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--text-3);
    font-size: 11px !important;
    font-weight: 600;
  }

  .bottom-tabs .bt-item svg {
    width: 22px;
    height: 22px;
  }

  .bottom-tabs .bt-item.is-active {
    background: var(--accent-bg);
    color: var(--accent);
  }

  .bottom-tabs .bt-item:active {
    transform: scale(.96);
  }

  .stats,
  .summary-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 9px;
    margin-bottom: 13px;
  }

  .stat,
  .card {
    min-height: 104px;
    padding: 13px 14px;
    border-radius: 15px;
  }

  .stat .v,
  .card .v {
    font-size: 23px;
  }

  .stat .sub,
  .card .sub {
    margin-top: 5px;
    font-size: 12px;
    line-height: 1.4;
  }

  .panel {
    margin-bottom: 12px;
    overflow: hidden;
    border-radius: 16px;
  }

  .panel-head,
  .section-title {
    min-height: 52px;
    padding: 13px 15px;
  }

  .pill,
  .tg {
    min-height: 25px;
    padding: 3px 9px;
    font-size: 12px;
  }

  /* Professional tables may scroll inside their surface; never the page. */
  .panel:has(> table),
  .pm-table-wrap,
  .as-wrap,
  .mt-body,
  .modal-bd {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
  }

  /* Dashboard mobile hierarchy */
  body .dash-wrap {
    display: flex;
    flex-direction: column;
  }

  body .alert-bar { order: 1; }
  body .todo-w { order: 2; }
  body .hero { order: 3; }
  body .dashboard-operations { order: 4; }
  body .dashboard-gps { order: 5; }
  body .dashboard-core-analysis { order: 6; }
  body .dashboard-analysis { order: 7; }
  body .dashboard-footnote { order: 8; }

  body .hero {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    margin-bottom: 10px;
  }

  body .hero .kpi-profit { order: 1; }
  body .hero .kpi-performance { order: 2; }
  body .hero .kpi-balance { order: 3; }
  body .hero .kpi-assets { order: 4; }

  body .kpi {
    min-height: 140px;
    padding: 15px;
    border-radius: 17px;
  }

  body .kpi-profit,
  body .kpi-assets {
    grid-column: 1 / -1;
  }

  body .kpi-profit {
    min-height: 188px;
  }

  body .kpi .k {
    margin-bottom: 7px;
    font-size: 12px;
  }

  body .kpi .v,
  body .kpi.kpi-profit .v {
    font-size: 29px;
  }

  body .kpi-performance .dv-num {
    font-size: 23px;
  }

  body .kpi-performance .dual-v {
    align-items: flex-start;
    gap: 10px;
  }

  body .kpi-performance .dv-sep {
    height: 38px;
  }

  body .kpi .delta {
    font-size: 12px;
    line-height: 1.45;
  }

  body .w {
    padding: 15px;
    border-radius: 17px;
  }

  body .w-head {
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 13px;
  }

  body .w-title {
    font-size: 16px;
  }

  body .w-link {
    min-height: 36px;
    flex: 0 0 auto;
  }

  body .todo-row {
    grid-template-columns: 25px 1fr;
    min-height: 58px;
    padding: 10px 11px;
  }

  body .todo-tag {
    font-size: 14px;
  }

  body .todo-text {
    font-size: 13px;
    line-height: 1.4;
  }

  body .dashboard-analysis,
  body .dashboard-operations > .mobile-defer,
  body .dashboard-core-analysis > .mobile-defer {
    display: none !important;
  }

  body .dashboard-operations,
  body .dashboard-core-analysis {
    grid-template-columns: 1fr !important;
  }

  body .dashboard-operations .exp-row {
    grid-template-columns: 76px 1fr auto;
    min-height: 50px;
    padding: 10px 11px;
  }

  body .gps-grid {
    grid-template-columns: 1fr;
  }

  body .gps-row {
    min-height: 48px;
    grid-template-columns: 16px 86px 1fr auto;
  }

  /* Vehicle mobile tools and cards */
  .vehicle-mobile-tools {
    display: block;
    position: sticky;
    top: calc(var(--mobile-bar-h) + 4px);
    z-index: 150;
    margin: 0 0 11px;
    padding: 9px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: color-mix(in srgb, var(--panel) 94%, transparent);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
  }

  .vehicle-search-wrap {
    position: relative;
  }

  .vehicle-search-wrap svg {
    width: 18px;
    height: 18px;
    position: absolute;
    left: 12px;
    top: 50%;
    color: var(--text-3);
    fill: currentColor;
    transform: translateY(-50%);
    pointer-events: none;
  }

  #vehicle-search {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px 10px 39px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel-alt);
    color: var(--text);
    font-size: 16px !important;
  }

  .vehicle-filters {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .vehicle-filters::-webkit-scrollbar { display: none; }

  .vehicle-filter {
    min-height: 36px;
    flex: 0 0 auto;
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--panel);
    color: var(--text-2);
    font-size: 13px !important;
    font-weight: 650;
  }

  .vehicle-filter.is-active {
    border-color: var(--accent);
    background: var(--accent-bg);
    color: var(--accent);
  }

  body .vcard-grid {
    display: flex;
    gap: 11px;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  body .vcard {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 17px;
    background: var(--panel);
    box-shadow: var(--shadow-sm);
  }

  body .vcard.untrans {
    box-shadow: inset 3px 0 var(--neg), var(--shadow-sm);
  }

  body .vcard-head {
    width: 100%;
    min-height: 126px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto auto;
    gap: 8px 12px;
    padding: 15px 42px 14px 15px;
    border: 0;
    border-radius: 0;
    background: var(--panel);
    color: var(--text);
    text-align: left;
  }

  body .vcard-head .vname {
    grid-column: 1;
    grid-row: 1;
    font-size: 16px;
  }

  body .vcard-head .vplate {
    display: block;
    margin: 3px 0 0;
    color: var(--text-3);
    font-size: 12px;
  }

  body .vcard-head .vstatus {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }

  body .vcard-head .vstatus .tg {
    min-height: 25px;
    padding: 3px 9px;
    font-size: 12px;
  }

  body .vcard-head .vexpires {
    grid-column: 1;
    grid-row: 2;
    justify-self: start;
    color: var(--text-2);
    font-size: 13px;
  }

  body .vcard-head .vgps {
    grid-column: 2;
    grid-row: 2;
    display: inline-flex;
    align-items: center;
    justify-self: end;
    gap: 6px;
    color: var(--text-3);
    font-size: 12px;
    white-space: nowrap;
  }

  body .vcard-head .vgps .gps-dot {
    width: 8px;
    height: 8px;
  }

  body .vcard-head .vline2 {
    grid-column: 1;
    grid-row: 3;
    font-size: 13px;
  }

  body .vcard-head .vinvest {
    grid-column: 2;
    grid-row: 3;
    align-self: center;
    justify-self: end;
    margin: 0;
    color: var(--text-3);
    font-size: 12px;
  }

  body .vcard-head .varrow {
    right: 14px;
    grid-column: auto;
    grid-row: auto;
  }

  body .vcard-body {
    padding: 14px 15px 15px;
    background: var(--panel-alt);
  }

  body .vcard-kpis {
    gap: 10px;
  }

  body .vcard-kpi {
    min-height: 66px;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--panel);
  }

  body .vcard-kpi .k { font-size: 12px; }
  body .vcard-kpi .v,
  body .vcard-kpi .v.small { margin-top: 3px; font-size: 14px; }

  body .vcard-detail {
    padding: 14px 15px 18px;
    background: var(--panel-alt);
  }

  /* AR/AP gets a readable mobile list instead of a compressed table. */
  .stats.apar-stats .stat-primary {
    grid-column: 1 / -1;
    min-height: 118px;
    background: linear-gradient(145deg, var(--accent-bg), var(--panel));
    border-color: color-mix(in srgb, var(--accent) 25%, var(--border));
  }

  body .cp-card {
    margin-bottom: 12px;
  }

  body .cp-head {
    min-height: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 11px;
    padding: 15px;
  }

  body .cp-head-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  body .cp-name {
    font-size: 18px;
  }

  body .cp-tags {
    gap: 6px;
  }

  body .cp-table {
    display: none;
  }

  .cp-mobile {
    display: block;
  }

  .cp-mobile-section + .cp-mobile-section {
    border-top: 8px solid var(--bg);
  }

  .cp-mobile-title {
    padding: 11px 15px 7px;
    color: var(--text-3);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
  }

  .cp-mobile-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 5px 12px;
    min-height: 74px;
    padding: 11px 15px;
    border-top: 1px solid var(--border);
  }

  .cp-mobile-vehicle {
    color: var(--text-2);
    font-size: 12px;
    font-weight: 650;
  }

  .cp-mobile-amount {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
    font-size: 15px;
    font-weight: 750;
    white-space: nowrap;
  }

  .cp-mobile-narr {
    grid-column: 1;
    color: var(--text);
    font-size: 14px;
    line-height: 1.42;
  }

  .cp-mobile-oid {
    display: block;
    margin-top: 3px;
    color: var(--text-3);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 10px;
    overflow-wrap: anywhere;
  }

  .cp-mobile-subtotal,
  .cp-mobile-settle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 50px;
    padding: 10px 15px;
    border-top: 1px solid var(--border);
    background: var(--panel-alt);
    font-size: 14px;
    font-weight: 700;
  }

  .cp-mobile-settle {
    min-height: 60px;
    border-top: 2px solid var(--border-2);
    font-size: 16px;
  }

  /* GPS: map first, useful vertical cards, no invisible list. */
  body .gps-summary {
    gap: 6px;
    margin: 0 -12px 10px;
    padding: 0 12px 2px;
    scrollbar-width: none;
  }

  body .gps-summary::-webkit-scrollbar { display: none; }

  body .gps-summary .card {
    min-width: max-content;
    min-height: 36px;
    padding: 7px 11px;
    border-radius: 999px;
    box-shadow: none;
  }

  body .gps-layout {
    gap: 10px;
  }

  body .gps-map-wrap {
    height: min(54dvh, 510px);
    min-height: 350px;
    position: relative;
    flex: 0 0 auto;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: 16px;
  }

  body .gps-map-wrap > #gps-map {
    width: auto;
    height: auto;
    position: absolute;
    inset: 0;
  }

  body .gps-list {
    width: auto;
    margin: 0;
    padding: 0;
    overflow-x: visible;
    background: transparent;
  }

  body .gps-list .m-cards {
    display: flex;
    flex-direction: column;
    gap: 9px;
    padding: 0;
  }

  body .gps-list .m-card {
    min-height: 108px;
    flex: 0 0 auto;
    padding: 13px 14px;
    border-radius: 15px;
    box-shadow: var(--shadow-sm);
    scroll-snap-align: none;
  }

  body .gps-list .m-card.no-coord {
    display: flex;
    opacity: .72;
  }

  body .gps-list .m-card .row3 a {
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 13px;
  }

  body .ack-btn {
    min-height: 36px;
    margin-left: auto;
    padding: 7px 11px;
    border-radius: 9px;
    font-size: 12px !important;
  }

  /* Maintenance / permits / inventory readability. */
  body .mt-head {
    flex-direction: row;
    align-items: center;
    min-height: 72px;
    padding: 13px 15px;
  }

  body .mt-head-left {
    min-width: 0;
    flex-wrap: wrap;
  }

  body .mt-name { font-size: 16px; }
  body .mt-plate { font-size: 13px; }
  body .mt-mileage { font-size: 13px; white-space: nowrap; }

  body .s-table {
    min-width: 560px;
  }

  body .pm-legend {
    display: none;
  }

  body .pm-table th,
  body .pm-table td {
    min-width: 112px;
    padding: 9px;
    font-size: 12px;
  }

  body .pm-table th:first-child,
  body .pm-table td:first-child {
    min-width: 104px;
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--panel);
    box-shadow: 1px 0 var(--border);
  }

  body .pm-table th:first-child {
    z-index: 3;
    background: var(--panel-alt);
  }

  body .pm-table th.hide-m,
  body .pm-table td.hide-m {
    display: table-cell;
    min-width: 70px;
  }

  body .pm-cell .d,
  body .pm-cell .r {
    font-size: 12px;
  }

  body .inv-meta {
    padding: 0 2px 10px;
    font-size: 12px;
  }

  body .inv-table,
  body .sub-table {
    min-width: 620px;
  }

  body .bp-filter {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px !important;
    padding: 10px !important;
  }

  body .bp-filter label,
  body .bp-filter input {
    min-width: 0 !important;
  }

  body .bp-filter input {
    grid-column: 1 / -1;
    min-height: 42px;
    font-size: 16px !important;
  }

  .modal-overlay,
  .modal-ov {
    align-items: flex-end;
    padding: 0;
  }

  .modal,
  .modal-box {
    width: 100%;
    max-width: none;
    max-height: min(88dvh, 760px);
    border-radius: 22px 22px 0 0;
  }

  .modal-head,
  .modal-hd {
    min-height: 62px;
    padding: 14px 16px;
  }

  .modal-body {
    padding: 15px;
  }
}

@media (max-width: 380px) {
  main.app-main {
    padding-inline: 9px;
  }

  .mobile-topbar {
    padding-inline: 6px;
  }

  .stats,
  .summary-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .stat,
  .card {
    padding: 12px;
  }

  .stat .v,
  .card .v {
    font-size: 21px;
  }

  body .hero {
    grid-template-columns: 1fr;
  }

  body .kpi,
  body .kpi-profit,
  body .kpi-assets {
    grid-column: 1;
  }

  body .vcard-head {
    padding-left: 13px;
  }
}

/* Telegram 对账截图使用 760px 视口；该宽度保留紧凑表格，手机才切换流水卡。 */
@media (min-width: 680px) and (max-width: 768px) {
  body .cp-head {
    flex-direction: row;
    align-items: center;
  }

  body .cp-table { display: table; }
  body .cp-mobile { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media print {
  .mobile-topbar,
  .nav-scrim,
  .vehicle-mobile-tools {
    display: none !important;
  }
}
