/* ==========================================================================
   Anderson Drive Club — Console shell (admin · employee · franchise)
   ========================================================================== */

body.app { background: var(--plane); overflow: hidden; }

.shell {
  display: grid;
  grid-template-columns: var(--nav-w) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}
body.nav-collapsed .shell { grid-template-columns: var(--nav-w-collapsed) minmax(0, 1fr); }

/* ------------------------------------------------------------- side nav */
.side {
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
  min-height: 0;
  transition: width var(--dur-3) var(--ease-out);
}

.side-brand {
  display: flex; align-items: center; gap: 10px;
  height: var(--topbar-h);
  padding-inline: var(--sp-4);
  border-bottom: 1px solid var(--line-soft);
  flex-shrink: 0;
}
.side-brand .bt {
  font-family: var(--font-display); font-weight: 660; font-size: var(--t-md);
  letter-spacing: -.024em; white-space: nowrap;
}
.side-brand .bt small {
  display: block; font-family: var(--font-ui); font-size: 8.5px; font-weight: 620;
  letter-spacing: .15em; text-transform: uppercase; color: var(--ink-muted); margin-top: -2px;
}

/* location switcher */
.loc-switch {
  margin: var(--sp-3) var(--sp-3) var(--sp-2);
  padding: 9px 11px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  display: flex; align-items: center; gap: var(--sp-2);
  cursor: pointer; width: calc(100% - var(--sp-3) * 2);
  text-align: left;
  transition: all var(--dur-1) var(--ease);
  position: relative;
}
.loc-switch:hover { border-color: var(--line-strong); background: var(--surface-3); }
.loc-switch .ls-name { font-size: var(--t-sm); font-weight: 580; color: var(--ink); line-height: 1.25; }
.loc-switch .ls-sub { font-size: 10.5px; color: var(--ink-muted); }

.side-scroll { flex: 1; overflow-y: auto; padding: var(--sp-2) var(--sp-3) var(--sp-4); min-height: 0; }

.nav-group { margin-top: var(--sp-4); }
.nav-group:first-child { margin-top: var(--sp-1); }
.nav-group > .ng-label {
  padding: 0 10px 6px;
  font-size: 10px; font-weight: 660; letter-spacing: .11em; text-transform: uppercase;
  color: var(--ink-muted);
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  width: 100%; padding: 8px 10px; margin-bottom: 1px;
  border-radius: var(--r-sm);
  font-size: var(--t-sm); font-weight: 520; color: var(--ink-2);
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
  position: relative;
  white-space: nowrap;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item .ni-icon { flex-shrink: 0; color: var(--ink-muted); transition: color var(--dur-1) var(--ease); }
.nav-item:hover .ni-icon { color: var(--ink-2); }
.nav-item.active {
  background: var(--brand-soft); color: var(--brand-strong); font-weight: 600;
}
.nav-item.active .ni-icon { color: var(--brand-strong); }
.nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--brand);
}
.nav-item .ni-count {
  margin-left: auto; padding: 1px 6px; border-radius: var(--r-pill);
  background: var(--surface-3); font-size: 10.5px; font-weight: 640; color: var(--ink-3);
}
.nav-item.active .ni-count { background: var(--brand); color: var(--brand-ink); }
.nav-item .ni-count.alert { background: var(--critical); color: #fff; }

.side-foot {
  padding: var(--sp-3);
  border-top: 1px solid var(--line-soft);
  flex-shrink: 0;
}
.user-chip {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%; padding: 8px; border-radius: var(--r-sm);
  transition: background var(--dur-1) var(--ease);
  text-align: left; position: relative;
}
.user-chip:hover { background: var(--surface-2); }
.user-chip .uc-name { font-size: var(--t-sm); font-weight: 580; color: var(--ink); }
.user-chip .uc-role { font-size: 10.5px; color: var(--ink-muted); }

/* collapsed state */
body.nav-collapsed .side-brand .bt,
body.nav-collapsed .loc-switch .ls-text,
body.nav-collapsed .loc-switch .ls-chev,
body.nav-collapsed .ng-label,
body.nav-collapsed .nav-item span:not(.ni-count),
body.nav-collapsed .user-chip .uc-text,
body.nav-collapsed .user-chip .uc-chev { display: none; }
body.nav-collapsed .nav-item { justify-content: center; padding-inline: 0; }
body.nav-collapsed .nav-item .ni-count { position: absolute; top: 2px; right: 6px; margin: 0; padding: 0 4px; font-size: 9px; }
body.nav-collapsed .side-brand { justify-content: center; padding-inline: 0; }
body.nav-collapsed .loc-switch { justify-content: center; }
body.nav-collapsed .user-chip { justify-content: center; }
body.nav-collapsed .nav-group > .ng-label { height: 10px; padding: 0; }

/* ---------------------------------------------------------------- main */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.topbar {
  display: flex; align-items: center; gap: var(--sp-3);
  height: var(--topbar-h);
  padding-inline: var(--sp-5);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.topbar .page-title {
  font-family: var(--font-display); font-size: var(--t-lg); font-weight: 620; letter-spacing: -.018em;
  white-space: nowrap;
}
.topbar .page-sub { font-size: var(--t-xs); color: var(--ink-3); }
.topbar .search-box { width: min(340px, 32vw); }

.view {
  flex: 1; overflow-y: auto; min-height: 0;
  padding: var(--sp-5) var(--sp-5) var(--sp-9);
  scroll-behavior: smooth;
}
.view-inner { max-width: var(--shell-max); margin-inline: auto; }

.view-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-4); flex-wrap: wrap;
  margin-bottom: var(--sp-5);
}
.view-head h1 { font-size: var(--t-2xl); letter-spacing: -.026em; }
.view-head .vh-sub { font-size: var(--t-sm); color: var(--ink-3); margin-top: 3px; }

.toolbar {
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
  margin-bottom: var(--sp-4);
}
.toolbar .grow-search { flex: 1 1 220px; max-width: 340px; }

/* mobile shell */
.side-scrim { display: none; }
@media (max-width: 1000px) {
  .shell, body.nav-collapsed .shell { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: fixed; z-index: 150; top: 0; bottom: 0; left: 0;
    width: var(--nav-w);
    transform: translateX(-102%);
    transition: transform var(--dur-3) var(--ease-out);
    box-shadow: var(--sh-4);
  }
  body.nav-open .side { transform: none; }
  body.nav-collapsed .side-brand .bt,
  body.nav-collapsed .nav-item span:not(.ni-count),
  body.nav-collapsed .ng-label,
  body.nav-collapsed .loc-switch .ls-text,
  body.nav-collapsed .user-chip .uc-text { display: revert; }
  body.nav-collapsed .nav-item { justify-content: flex-start; padding-inline: 10px; }
  body.nav-collapsed .side-brand { justify-content: flex-start; padding-inline: var(--sp-4); }
  body.nav-open .side-scrim {
    display: block; position: fixed; inset: 0; z-index: 140;
    background: var(--overlay);
  }
  .topbar .search-box { display: none; }
  .view { padding: var(--sp-4) var(--sp-4) var(--sp-8); }
}

/* ---------------------------------------------------------- KPI strip */
.kpi-grid {
  display: grid; gap: var(--sp-4);
  grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr));
}

/* --------------------------------------------------------- entity head */
.entity-head {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-5);
  border-bottom: 1px solid var(--line-soft);
}

/* ------------------------------------------------------- kanban board */
.kanban { display: flex; gap: var(--sp-4); overflow-x: auto; padding-bottom: var(--sp-3); }
.kan-col {
  flex: 0 0 268px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  display: flex; flex-direction: column;
  max-height: 620px;
}
.kan-head {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line);
}
.kan-head .k-name { font-size: var(--t-sm); font-weight: 620; }
.kan-head .k-count {
  margin-left: auto; padding: 1px 7px; border-radius: var(--r-pill);
  background: var(--surface-3); font-size: 10.5px; font-weight: 640; color: var(--ink-3);
}
.kan-body { padding: var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-2); overflow-y: auto; }
.kan-card {
  padding: var(--sp-3);
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  cursor: grab;
  transition: box-shadow var(--dur-1) var(--ease), transform var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
.kan-card:hover { box-shadow: var(--sh-2); border-color: var(--line-strong); transform: translateY(-1px); }
.kan-card.dragging { opacity: .4; }
.kan-col.drop-target { border-color: var(--brand); background: var(--brand-soft); }

/* ------------------------------------------------------------ GPS map */
.map-wrap {
  position: relative;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
  min-height: 420px;
}
.map-svg { display: block; width: 100%; height: 100%; }
.map-pin { cursor: pointer; transition: transform var(--dur-1) var(--ease); transform-origin: center; }
.map-pin:hover { transform: scale(1.18); }
.map-overlay {
  position: absolute; top: var(--sp-4); left: var(--sp-4);
  display: flex; flex-direction: column; gap: var(--sp-2);
}
.map-legend {
  position: absolute; bottom: var(--sp-4); left: var(--sp-4);
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  box-shadow: var(--sh-2);
}

/* --------------------------------------------------------- vehicle row */
.veh-thumb {
  display: grid; place-items: center;
  width: 46px; height: 34px; border-radius: 6px;
  background: var(--photo-tile); color: var(--ink-muted);
  flex-shrink: 0; overflow: hidden;
}
.veh-thumb img { width: 100%; height: 100%; object-fit: contain; padding: 2px; }

/* larger hero photo inside a detail drawer */
.veh-hero-photo { width: 100%; margin-bottom: var(--sp-5); }

/* ------------------------------------------------------- health pill */
.health-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--t-xs); font-weight: 620; font-variant-numeric: tabular-nums;
}
.health-bar { width: 46px; height: 5px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.health-bar i { display: block; height: 100%; border-radius: var(--r-pill); }

/* ------------------------------------------------------ inbox / ticket */
.inbox { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); min-height: 560px; }
@media (max-width: 1080px) { .inbox { grid-template-columns: minmax(0, 1fr); } .inbox .thread { display: none; } }
.inbox-list { border-right: 1px solid var(--line); overflow-y: auto; max-height: 640px; }
.inbox-item {
  display: block; width: 100%; text-align: left;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line-soft);
  transition: background var(--dur-1) var(--ease);
  position: relative;
}
.inbox-item:hover { background: var(--surface-2); }
.inbox-item.active { background: var(--brand-soft); }
.inbox-item.active::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--brand);
}
.thread { display: flex; flex-direction: column; max-height: 640px; }
.thread-body { flex: 1; overflow-y: auto; padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-4); }
.msg { display: flex; gap: var(--sp-3); max-width: 82%; }
.msg .bubble {
  padding: 10px 13px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--line-soft);
  font-size: var(--t-sm); line-height: 1.55;
}
.msg.out { align-self: flex-end; flex-direction: row-reverse; }
.msg.out .bubble { background: var(--brand-soft); border-color: var(--brand-line); }
.msg .meta { font-size: 10.5px; color: var(--ink-muted); margin-top: 4px; }
.thread-compose { border-top: 1px solid var(--line); padding: var(--sp-3) var(--sp-4); }

/* ------------------------------------------------- settings / perms grid */
.perm-grid { width: 100%; font-size: var(--t-sm); }
.perm-grid th, .perm-grid td { padding: 9px var(--sp-3); border-bottom: 1px solid var(--line-soft); }
.perm-grid th { text-align: left; font-size: var(--t-2xs); text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); font-weight: 620; }
.perm-grid td.tc, .perm-grid th.tc { text-align: center; }

/* -------------------------------------------------------------- utility */
.sticky-sub {
  position: sticky; top: 0; z-index: 5;
  background: var(--plane);
  padding-block: var(--sp-2);
  margin-block: calc(var(--sp-2) * -1);
}
.scroll-shadow { box-shadow: inset 0 -12px 12px -12px rgba(0,0,0,.08); }

.pill-row { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

.mini-stat {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
}
.mini-stat .ms-val { font-family: var(--font-display); font-size: var(--t-xl); font-weight: 640; letter-spacing: -.025em; }
.mini-stat .ms-lab { font-size: var(--t-xs); color: var(--ink-3); }
