/* ==========================================================
   TRAFWISE CLIENT PORTAL
   Light theme by default · dark theme optional ([data-theme="dark"])
   ========================================================== */
:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --panel-2: #f7f8fa;
  --line: #e6e9ee;
  --line-2: #eef0f4;
  --text: #16181d;
  --text-2: #4b5563;
  --muted: #8a93a0;
  --brand: #ff6a00;
  --brand-soft: #fff1e7;
  --yellow: #ffc20e;
  --yellow-soft: #fff7d6;
  --asphalt: #15171b;
  --hover: #f2f4f7;
  --active: #fff3ea;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .05);
  --shadow-lg: 0 20px 50px rgba(16, 24, 40, .18);
  /* status */
  --good: #16a34a; --good-soft: #e8f7ee;
  --warn: #d97706; --warn-soft: #fff4e0;
  --bad: #dc2626; --bad-soft: #fdecec;
  --info: #2563eb; --info-soft: #e9f0ff;
  --violet: #7c3aed; --violet-soft: #f1ebff;
  /* categorical chart palette (validated, light) */
  --c1: #2563eb; --c2: #ea580c; --c3: #0d9488; --c4: #9333ea; --c5: #ca8a04;
  --radius: 16px;
  --display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0f1114;
  --panel: #171a1f;
  --panel-2: #1c2026;
  --line: #262b33;
  --line-2: #20242b;
  --text: #eef0f3;
  --text-2: #b4bac4;
  --muted: #7d8591;
  --brand-soft: rgba(255,106,0,.14);
  --yellow-soft: rgba(255,194,14,.12);
  --hover: #1f242b;
  --active: rgba(255,106,0,.12);
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  --good-soft: rgba(22,163,74,.16); --warn-soft: rgba(217,119,6,.16); --bad-soft: rgba(220,38,38,.16);
  --info-soft: rgba(37,99,235,.18); --violet-soft: rgba(124,58,237,.18);
  --good: #34c46b; --warn: #f0a02a; --bad: #f05252; --info: #5b8def; --violet: #a47cf3;
  /* categorical chart palette (validated, dark) */
  --c1: #3b82f6; --c2: #d9580f; --c3: #0d9488; --c4: #a855f7; --c5: #b07f08;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--body); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
svg.i { width: 18px; height: 18px; flex: none; }
h1, h2, h3, h4 { margin: 0; }

/* ================= Layout ================= */
.shell { display: grid; grid-template-columns: 272px 1fr; gap: 20px; padding: 20px; min-height: 100vh; }
.sidebar {
  position: sticky; top: 20px; height: calc(100vh - 40px);
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.side-top { padding: 16px; border-bottom: 1px solid var(--line-2); }
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 4px 14px; }
.brand-mark { width: 42px; height: 42px; border-radius: 12px; background: var(--asphalt); display: grid; place-items: center; flex: none; }
.brand-mark svg { width: 30px; height: 30px; }
.brand b { display: block; font-family: var(--display); font-weight: 800; font-size: 1.35rem; letter-spacing: .03em; text-transform: uppercase; line-height: 1; }
.brand b span { color: var(--brand); }
.brand small { color: var(--muted); font-size: .74rem; }
.quick { display: grid; grid-template-columns: 1.3fr 1fr; gap: 8px; }
.quick button { display: flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--panel-2); border-radius: 10px; padding: 9px; font-size: .8rem; font-weight: 600; color: var(--text-2); }
.quick button:first-child { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.quick button:hover { border-color: var(--brand); }
.quick svg { width: 15px; height: 15px; }

.nav { flex: 1; overflow-y: auto; padding: 10px 12px 16px; scrollbar-width: thin; }
.nav-group { margin-top: 14px; }
.nav-label { font-size: .66rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--brand); opacity: .8; padding: 6px 12px; }
.nav a, .nav .nav-parent {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; margin: 2px 0; border-radius: 10px;
  color: var(--text-2); font-weight: 500; font-size: .92rem; border: 0; background: transparent; text-align: left; position: relative;
}
.nav a:hover, .nav .nav-parent:hover { background: var(--hover); color: var(--text); }
.nav a.active { background: var(--active); color: var(--brand); font-weight: 700; }
.nav a.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--brand); }
.nav .count { margin-left: auto; font-size: .7rem; font-weight: 700; padding: 2px 7px; border-radius: 99px; background: var(--bad-soft); color: var(--bad); }
.nav .count.y { background: var(--yellow-soft); color: var(--warn); }
.nav .chev { margin-left: auto; width: 16px; height: 16px; transition: transform .2s; }
.nav-parent[aria-expanded="true"] .chev { transform: rotate(180deg); }
.subnav { display: none; padding-left: 30px; }
.subnav.open { display: block; }
.subnav a { font-size: .86rem; padding: 8px 12px; }
.side-bottom { padding: 12px 16px 16px; border-top: 1px solid var(--line-2); }
.btn-logout { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 11px; border-radius: 12px; border: 1px solid #fcd4d4; background: var(--bad-soft); color: var(--bad); font-weight: 600; }
[data-theme="dark"] .btn-logout { border-color: transparent; }
.btn-logout:hover { background: var(--bad); color: #fff; }
.plan-card { background: var(--asphalt); color: #fff; border-radius: 14px; padding: 14px; margin-bottom: 12px; position: relative; overflow: hidden; }
.plan-card::after { content: ""; position: absolute; right: 0; top: 0; bottom: 0; width: 8px; background: repeating-linear-gradient(-45deg, var(--yellow) 0 8px, var(--asphalt) 8px 16px); }
.plan-card small { color: #aeb4bd; font-size: .72rem; }
.plan-card b { display: block; font-size: .95rem; }
.meter { height: 6px; border-radius: 3px; background: rgba(255,255,255,.12); margin: 8px 0 4px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--yellow); border-radius: 3px; }

/* ================= Main ================= */
.main { min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.topbar {
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow);
  padding: 18px 22px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  position: sticky; top: 20px; z-index: 20;
}
.page-title h1 { font-family: var(--display); font-weight: 800; font-size: 2.1rem; text-transform: uppercase; letter-spacing: .02em; line-height: 1; }
.page-title p { color: var(--muted); margin-top: 4px; font-size: .9rem; }
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.search { display: flex; align-items: center; gap: 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; height: 42px; width: 260px; }
.search input { border: 0; background: transparent; outline: none; width: 100%; }
.search kbd { font-size: .7rem; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; background: var(--panel); }
.icon-btn { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); display: grid; place-items: center; position: relative; color: var(--text-2); }
.icon-btn:hover { border-color: var(--brand); color: var(--brand); }
.icon-btn .dot { position: absolute; top: 9px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 2px var(--panel); }
.avatar-btn { display: flex; align-items: center; gap: 10px; padding: 4px 10px 4px 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.avatar-btn img, .av { width: 34px; height: 34px; border-radius: 10px; object-fit: cover; flex: none; }
.avatar-btn b { display: block; font-size: .84rem; line-height: 1.2; }
.avatar-btn small { color: var(--muted); font-size: .72rem; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 11px; border: 1px solid var(--line); background: var(--panel); font-weight: 600; font-size: .88rem; white-space: nowrap; transition: .15s; }
.btn:hover { border-color: var(--text-2); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(255,106,0,.25); }
.btn-primary:hover { background: #ff7d1f; border-color: #ff7d1f; }
.btn-yellow { background: var(--yellow); border-color: var(--yellow); color: #15171b; }
.btn-dark { background: var(--asphalt); border-color: var(--asphalt); color: #fff; }
[data-theme="dark"] .btn-dark { background: #2a2f37; border-color: #2a2f37; }
.btn-danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--hover); }
.btn-sm { height: 32px; padding: 0 12px; font-size: .8rem; border-radius: 9px; }
.btn-good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.btn-good:hover { background: var(--good); color: #fff; }

/* ================= Content primitives ================= */
.content { display: flex; flex-direction: column; gap: 20px; animation: fadein .3s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } }
.grid { display: grid; gap: 20px; }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g-2-1 { grid-template-columns: 2fr 1fr; }
.g-1-2 { grid-template-columns: 1fr 2fr; }
.g-3-2 { grid-template-columns: 3fr 2fr; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card.flush .card-head { padding: 18px 20px 0; }
.card-title { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1rem; }
.card-title .i { color: var(--brand); }
.card-sub { color: var(--muted); font-size: .8rem; font-weight: 500; }
.link { color: var(--brand); font-weight: 600; font-size: .84rem; }
.link:hover { text-decoration: underline; }

/* KPI gradient tiles */
.kpi { border-radius: var(--radius); padding: 20px 22px; color: #fff; position: relative; overflow: hidden; box-shadow: 0 10px 24px -8px var(--kpi-shadow, rgba(0,0,0,.3)); min-height: 124px; }
.kpi::after { content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: rgba(255,255,255,.13); }
.kpi::before { content: ""; position: absolute; right: 30px; bottom: -40px; width: 80px; height: 80px; border-radius: 50%; background: rgba(255,255,255,.07); }
.kpi > * { position: relative; z-index: 1; }
.kpi .lbl { display: flex; align-items: center; gap: 8px; font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; opacity: .95; }
.kpi .lbl svg { width: 16px; height: 16px; }
.kpi .val { font-family: var(--display); font-weight: 800; font-size: 2.6rem; line-height: 1.05; margin-top: 8px; }
.kpi .val small { font-size: 1.1rem; opacity: .8; }
.kpi .sub { font-size: .8rem; opacity: .9; }
.kpi.orange { background: linear-gradient(135deg, #ff7a1a, #e84f00); --kpi-shadow: rgba(232,79,0,.45); }
.kpi.asphalt { background: linear-gradient(135deg, #2b3038, #121418); --kpi-shadow: rgba(18,20,24,.5); }
.kpi.asphalt::after { background: rgba(255,194,14,.16); }
.kpi.yellow { background: linear-gradient(135deg, #ffd23f, #f5a700); color: #15171b; --kpi-shadow: rgba(245,167,0,.45); }
.kpi.green { background: linear-gradient(135deg, #1fb866, #0c8a47); --kpi-shadow: rgba(12,138,71,.45); }
.kpi.blue { background: linear-gradient(135deg, #3b82f6, #1d4fd8); --kpi-shadow: rgba(29,79,216,.4); }
.kpi.violet { background: linear-gradient(135deg, #8b5cf6, #6025d6); --kpi-shadow: rgba(96,37,214,.4); }

/* Stat cards */
.stat .lbl { font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.stat .lbl svg { width: 16px; height: 16px; }
.stat .val { font-family: var(--display); font-size: 2.1rem; font-weight: 800; line-height: 1.1; margin-top: 6px; }
.stat .sub { color: var(--muted); font-size: .8rem; }
.delta { font-size: .74rem; font-weight: 700; padding: 2px 7px; border-radius: 6px; margin-left: 6px; vertical-align: middle; font-family: var(--body); }
.delta.up { background: var(--good-soft); color: var(--good); }
.delta.down { background: var(--bad-soft); color: var(--bad); }
.bar-track { height: 8px; border-radius: 4px; background: var(--line-2); overflow: hidden; margin: 12px 0 6px; }
.bar-track i { display: block; height: 100%; border-radius: 4px; }

/* Pills & tags */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: .72rem; font-weight: 700; padding: 4px 9px; border-radius: 99px; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.nodot::before { display: none; }
.p-good { background: var(--good-soft); color: var(--good); }
.p-warn { background: var(--warn-soft); color: var(--warn); }
.p-bad { background: var(--bad-soft); color: var(--bad); }
.p-info { background: var(--info-soft); color: var(--info); }
.p-violet { background: var(--violet-soft); color: var(--violet); }
.p-muted { background: var(--line-2); color: var(--text-2); }
.p-brand { background: var(--brand-soft); color: var(--brand); }
.tag { display: inline-block; font-size: .72rem; font-weight: 600; padding: 3px 8px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text-2); margin: 2px 4px 2px 0; }

/* Status list */
.status-list { list-style: none; margin: 0; padding: 0; }
.status-list li { display: flex; align-items: center; gap: 10px; padding: 9px 0; font-size: .88rem; color: var(--text-2); }
.status-list li b { margin-left: auto; font-weight: 800; color: var(--text); }
.status-list .sw { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.status-list li.total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 14px; color: var(--text); font-weight: 600; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .86rem; }
.tbl th { text-align: left; font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--panel-2); white-space: nowrap; cursor: default; }
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--text); }
.tbl td { padding: 12px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tbody tr { transition: background .15s; }
.tbl tbody tr:hover { background: var(--hover); }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tr:last-child td { border-bottom: 0; }
.who { display: flex; align-items: center; gap: 10px; }
.who img { width: 34px; height: 34px; border-radius: 10px; object-fit: cover; }
.who b { display: block; font-weight: 600; line-height: 1.2; }
.who small { color: var(--muted); font-size: .76rem; }
.mono { font-variant-numeric: tabular-nums; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.strong { font-weight: 700; }

/* Toolbar / filters */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.toolbar .search { width: 240px; height: 38px; }
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-size: .8rem; font-weight: 600; color: var(--text-2); }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
[data-theme="dark"] .seg button.on { background: #2a2f37; }
select.sel { height: 38px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); padding: 0 10px; }
.spacer { flex: 1; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: .82rem; }
.pager .pg { display: flex; gap: 6px; }

/* Charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-text { fill: var(--muted); font-size: 11px; font-family: var(--body); }
.chart .bar { transition: opacity .15s; }
.chart .hit:hover + .bar, .chart .bar:hover { opacity: .8; }
.tip { position: fixed; z-index: 200; pointer-events: none; background: var(--asphalt); color: #fff; padding: 8px 11px; border-radius: 9px; font-size: .78rem; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s; }
[data-theme="dark"] .tip { background: #2a2f37; }
.tip.show { opacity: 1; transform: none; }
.tip b { display: block; font-size: .86rem; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .8rem; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }
.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.donut-wrap .chart { width: 170px; flex: none; }
.donut-center { font-family: var(--display); font-weight: 800; font-size: 30px; fill: var(--text); }
.donut-sub { fill: var(--muted); font-size: 11px; }
.hbars { display: grid; gap: 12px; }
.hbar { display: grid; grid-template-columns: 140px 1fr 70px; align-items: center; gap: 12px; font-size: .84rem; }
.hbar .track { height: 10px; border-radius: 5px; background: var(--line-2); overflow: hidden; }
.hbar .track i { display: block; height: 100%; border-radius: 5px; }
.hbar b { text-align: right; font-variant-numeric: tabular-nums; }
.hbar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }

/* Activity feed */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed .ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.feed .ic svg { width: 18px; height: 18px; }
.feed b { font-weight: 600; font-size: .88rem; }
.feed p { margin: 2px 0 0; color: var(--muted); font-size: .8rem; }
.feed time { margin-left: auto; color: var(--muted); font-size: .74rem; white-space: nowrap; }

/* Alerts */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; margin-bottom: 10px; font-size: .86rem; }
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alert b { display: block; }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.info { background: var(--info-soft); color: var(--info); }
.alert p { margin: 2px 0 0; color: var(--text-2); font-size: .8rem; }
.alert .btn { margin-left: auto; }

/* Allocation board */
.board { display: grid; grid-template-columns: 250px repeat(4, minmax(200px, 1fr)); gap: 16px; overflow-x: auto; padding-bottom: 6px; }
.lane { background: var(--panel-2); border: 1px solid var(--line); border-radius: 16px; padding: 12px; min-height: 420px; display: flex; flex-direction: column; gap: 10px; }
.lane.drop { outline: 2px dashed var(--brand); outline-offset: -4px; background: var(--brand-soft); }
.lane-head { display: flex; align-items: center; justify-content: space-between; font-size: .74rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--text-2); padding: 2px 4px 6px; }
.lane-head span:last-child { background: var(--panel); border: 1px solid var(--line); border-radius: 99px; padding: 1px 8px; font-size: .72rem; }
.job-card { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--yellow); border-radius: 12px; padding: 12px; box-shadow: var(--shadow); cursor: grab; }
.job-card:active { cursor: grabbing; }
.job-card.dragging { opacity: .4; }
.job-card.short { border-left-color: var(--bad); }
.job-card.confirmed { border-left-color: var(--info); }
.job-card.onsite { border-left-color: var(--good); }
.job-card b { display: block; font-size: .88rem; }
.job-card .meta { color: var(--muted); font-size: .76rem; display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 4px 0 8px; }
.job-card .foot { display: flex; align-items: center; justify-content: space-between; }
.stack { display: flex; }
.stack img, .stack .more { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--panel); margin-left: -7px; object-fit: cover; }
.stack img:first-child { margin-left: 0; }
.stack .more { display: grid; place-items: center; font-size: .66rem; font-weight: 800; background: var(--line-2); }
.slot { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; border: 2px dashed var(--bad); margin-left: -7px; color: var(--bad); font-weight: 800; font-size: .8rem; background: var(--panel); }
.crew-chip { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; cursor: grab; }
.crew-chip img { width: 32px; height: 32px; border-radius: 9px; object-fit: cover; }
.crew-chip b { font-size: .84rem; display: block; line-height: 1.2; }
.crew-chip small { color: var(--muted); font-size: .72rem; }
.crew-chip .pill { margin-left: auto; }
.job-card.drop-target { outline: 2px solid var(--brand); }

/* Calendar */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.cal .dow { padding: 10px; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--panel-2); }
.cal .day { min-height: 118px; padding: 8px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: .78rem; }
.cal .day.out { background: var(--panel-2); color: var(--muted); }
.cal .day.today { background: var(--brand-soft); }
.cal .day .d { font-weight: 700; margin-bottom: 6px; display: flex; justify-content: space-between; }
.cal .ev { display: block; padding: 3px 7px; border-radius: 6px; margin-bottom: 4px; font-size: .72rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Map */
.map { position: relative; border-radius: 14px; overflow: hidden; background: #e8ecef; aspect-ratio: 16 / 9; }
[data-theme="dark"] .map { background: #12161b; }
.map svg { width: 100%; height: 100%; display: block; }
.map .road { stroke: #fff; fill: none; stroke-linecap: round; }
[data-theme="dark"] .map .road { stroke: #2a3039; }
.map .road.major { stroke: #ffd98a; }
[data-theme="dark"] .map .road.major { stroke: #4a3d1c; }
.map .water { fill: #bfe0f2; }
[data-theme="dark"] .map .water { fill: #16283a; }
.map .park { fill: #d4ecd2; }
[data-theme="dark"] .map .park { fill: #16261a; }
.pin { cursor: pointer; }
.pin circle.pulse { animation: pulse 2s ease-out infinite; transform-origin: center; transform-box: fill-box; }
@keyframes pulse { from { opacity: .6; transform: scale(1); } to { opacity: 0; transform: scale(3); } }
.map-legend { position: absolute; left: 12px; bottom: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }

/* Profile / drawer */
.drawer-bg { position: fixed; inset: 0; background: rgba(15,17,20,.45); z-index: 90; opacity: 0; visibility: hidden; transition: .2s; }
.drawer-bg.open { opacity: 1; visibility: visible; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: var(--panel); z-index: 100; box-shadow: var(--shadow-lg); transform: translateX(100%); transition: transform .25s ease; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer-head { padding: 20px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.drawer-head h3 { font-family: var(--display); font-size: 1.6rem; text-transform: uppercase; }
.drawer-body { padding: 22px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 10px 14px; font-size: .88rem; margin-bottom: 18px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
.section-label { font-size: .7rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 20px 0 10px; }

/* Modal & forms */
.modal-bg { position: fixed; inset: 0; background: rgba(15,17,20,.5); z-index: 110; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-bg.open { display: flex; }
.modal { background: var(--panel); border-radius: 20px; width: min(640px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; box-shadow: var(--shadow-lg); animation: fadein .2s ease; }
.modal-head { padding: 20px 24px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { font-family: var(--display); font-size: 1.6rem; text-transform: uppercase; }
.modal-body { padding: 22px 24px; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.fld label { display: block; font-size: .8rem; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.fld input, .fld select, .fld textarea { width: 100%; height: 42px; border: 1px solid var(--line); background: var(--panel); border-radius: 11px; padding: 0 12px; outline: none; transition: .15s; }
.fld textarea { height: 90px; padding: 10px 12px; resize: vertical; }
.fld input:focus, .fld select:focus, .fld textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 99px; transition: .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(18px); }
.setting-row { display: flex; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line-2); }
.setting-row:last-child { border-bottom: 0; }
.setting-row b { display: block; font-size: .9rem; }
.setting-row small { color: var(--muted); }
.setting-row > div:first-child { flex: 1; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button { border: 0; background: transparent; padding: 10px 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }

/* Messages */
.chat { display: grid; grid-template-columns: 300px 1fr; min-height: 560px; }
.threads { border-right: 1px solid var(--line); overflow-y: auto; }
.thread { display: flex; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line-2); cursor: pointer; }
.thread:hover, .thread.on { background: var(--hover); }
.thread img { width: 40px; height: 40px; border-radius: 12px; object-fit: cover; }
.thread b { display: block; font-size: .86rem; }
.thread p { margin: 0; font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.thread time { margin-left: auto; font-size: .7rem; color: var(--muted); }
.convo { display: flex; flex-direction: column; }
.msgs { flex: 1; padding: 20px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; background: var(--panel-2); }
.msg { max-width: 70%; padding: 10px 14px; border-radius: 14px; font-size: .88rem; background: var(--panel); border: 1px solid var(--line); }
.msg.me { align-self: flex-end; background: var(--brand); color: #fff; border-color: var(--brand); }
.msg small { display: block; font-size: .7rem; opacity: .7; margin-top: 4px; }
.composer { display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--line); }
.composer input { flex: 1; height: 42px; border: 1px solid var(--line); border-radius: 11px; padding: 0 12px; background: var(--panel); outline: none; }

/* Fleet cards */
.asset { display: flex; gap: 14px; align-items: center; }
.asset .ic { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; background: var(--yellow-soft); color: var(--warn); flex: none; }
.asset .ic svg { width: 24px; height: 24px; }

/* Empty/placeholder */
.empty { text-align: center; padding: 40px; color: var(--muted); }

/* Toast */
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 300; background: var(--asphalt); color: #fff; padding: 13px 18px; border-radius: 12px; border-left: 4px solid var(--yellow); box-shadow: var(--shadow-lg); font-weight: 600; font-size: .88rem; transform: translateY(20px); opacity: 0; transition: .25s; max-width: 380px; }
.toast.show { transform: none; opacity: 1; }

/* Notifications panel */
.notif { position: absolute; right: 0; top: 50px; width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); display: none; z-index: 60; overflow: hidden; }
.notif.open { display: block; }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.notif ul { list-style: none; margin: 0; padding: 0; max-height: 380px; overflow-y: auto; }
.notif li { display: flex; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line-2); font-size: .84rem; }
.notif li.unread { background: var(--brand-soft); }
.notif li small { display: block; color: var(--muted); font-size: .74rem; }
.rel { position: relative; }

/* Mobile */
.menu-btn { display: none; }
.scrim { display: none; }
@media (max-width: 1280px) {
  .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .g-2-1, .g-3-2, .g-1-2 { grid-template-columns: 1fr; }
}
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; padding: 12px; gap: 12px; }
  .sidebar { position: fixed; left: 12px; top: 12px; bottom: 12px; height: auto; width: 272px; z-index: 80; transform: translateX(-110%); transition: transform .25s; }
  .sidebar.open { transform: none; }
  .scrim.open { display: block; position: fixed; inset: 0; background: rgba(15,17,20,.45); z-index: 70; }
  .menu-btn { display: grid; }
  .topbar { top: 12px; }
  .search { display: none; }
  .g3, .g2 { grid-template-columns: 1fr; }
  .chat { grid-template-columns: 1fr; }
  .threads { display: none; }
  .avatar-btn div { display: none; }
}
@media (max-width: 560px) {
  .g4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .page-title h1 { font-size: 1.6rem; }
  .hbar { grid-template-columns: 100px 1fr 56px; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
}
