/* RFI TRANSPORTS CRM - feuille de styles (aucune dépendance externe) */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e6e9f0;
  --text: #0f172a;
  --muted: #64748b;
  --faint: #94a3b8;
  --primary: #4f46e5;
  --primary-600: #4338ca;
  --primary-50: #eef2ff;
  --primary-100: #e0e7ff;
  --dark: #0b1020;
  --green: #059669; --green-50: #ecfdf5;
  --amber: #d97706; --amber-50: #fffbeb;
  --red: #dc2626; --red-50: #fef2f2;
  --blue: #2563eb; --blue-50: #eff6ff;
  --violet: #7c3aed; --violet-50: #f5f3ff;
  --cyan: #0891b2; --cyan-50: #ecfeff;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 6px 24px rgba(15,23,42,.05);
  --shadow-lg: 0 20px 60px rgba(15,23,42,.18);
  --font: Inter, ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0b1020; --surface: #121a2f; --surface-2: #0f1628; --border: #222c45; --text: #e5e9f5;
  --muted: #94a3b8; --faint: #64748b; --primary-50: #1e1b4b; --primary-100: #2e2a6b;
  --green-50: #052e24; --amber-50: #2d1d05; --red-50: #3b0d0d; --blue-50: #0c1d3d; --violet-50: #221042; --cyan-50: #08252c;
  --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
svg.i.sm { width: 14px; height: 14px; }
svg.i.lg { width: 24px; height: 24px; }
svg.i.xl { width: 32px; height: 32px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.top { align-items: flex-start; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.gap-sm { gap: 6px; } .gap-lg { gap: 18px; }
.mt { margin-top: 16px; } .mt-sm { margin-top: 8px; } .mb { margin-bottom: 16px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.label-xs { font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.big-num { font-size: 28px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.title-xl { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin: 0; }
.title-lg { font-size: 18px; font-weight: 800; margin: 0; letter-spacing: -.01em; }
.title-md { font-size: 15px; font-weight: 700; margin: 0; }
.sub { color: var(--muted); margin: 2px 0 0; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 248px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 14px; }
.brand-logo { width: 40px; height: 40px; border-radius: 12px; background: var(--primary); color: #fff; display: grid; place-items: center; box-shadow: 0 6px 18px rgba(79,70,229,.35); overflow: hidden; }
.brand-logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.brand-name { font-weight: 800; font-size: 15px; line-height: 1.1; }
.brand-name small { display: block; font-size: 10px; font-weight: 700; color: var(--faint); letter-spacing: .1em; text-transform: uppercase; margin-top: 2px; }
.nav { padding: 6px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-section { font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); padding: 14px 12px 6px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 11px; color: var(--muted); font-weight: 500; text-decoration: none; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--primary-50); color: var(--primary); font-weight: 700; }
.nav a .badge { margin-left: auto; }
.sidebar-foot { padding: 14px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; background: var(--surface-2); margin-bottom: 8px; }
.avatar { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); font-weight: 800; flex-shrink: 0; overflow: hidden; }
.avatar.lg { width: 52px; height: 52px; border-radius: 14px; font-size: 18px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.content { padding: 28px 32px 80px; max-width: 1500px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card.pad-lg { padding: 24px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head h3 { margin: 0; font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; display: flex; align-items: center; gap: 8px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0,1fr)); }
.cards-auto { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: 18px; align-items: start; }
.stat { display: flex; align-items: center; gap: 14px; }
.stat-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; flex-shrink: 0; }
.tone-primary { background: var(--primary-50); color: var(--primary); }
.tone-green { background: var(--green-50); color: var(--green); }
.tone-amber { background: var(--amber-50); color: var(--amber); }
.tone-red { background: var(--red-50); color: var(--red); }
.tone-blue { background: var(--blue-50); color: var(--blue); }
.tone-violet { background: var(--violet-50); color: var(--violet); }
.tone-cyan { background: var(--cyan-50); color: var(--cyan); }
.tone-gray { background: var(--surface-2); color: var(--muted); }
.kpi { position: relative; overflow: hidden; }
.kpi.solid { background: var(--primary); color: #fff; border: none; }
.kpi.solid .label-xs, .kpi.solid .muted { color: rgba(255,255,255,.75); }
.kpi.dark { background: var(--dark); color: #fff; border: none; }
.kpi.dark .label-xs, .kpi.dark .muted { color: rgba(255,255,255,.6); }

/* ---------- Hero (Command center) ---------- */
.hero { background: radial-gradient(120% 140% at 0% 0%, #1e1b4b 0%, #0b1020 55%); color: #fff; border-radius: 28px; padding: 26px 30px; display: flex;
  align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; box-shadow: var(--shadow-lg); }
.hero h1 { font-size: 34px; font-weight: 900; font-style: italic; letter-spacing: -.03em; margin: 0; line-height: 1; text-transform: uppercase; }
.hero .live { display: inline-flex; align-items: center; gap: 6px; font-size: 10px; font-weight: 800; letter-spacing: .12em; color: #34d399;
  background: rgba(16,185,129,.12); border: 1px solid rgba(16,185,129,.35); padding: 5px 10px; border-radius: 99px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }
.pulse { animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.hero .clock { font-family: var(--mono); font-weight: 700; color: #a5b4fc; font-size: 16px; }
.seg { display: inline-flex; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); border-radius: 16px; padding: 5px; gap: 4px; }
.seg a, .seg button { border: none; background: transparent; color: #cbd5e1; padding: 9px 16px; border-radius: 11px; font-weight: 800; font-size: 11px; letter-spacing: .1em;
  text-transform: uppercase; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; text-decoration: none; }
.seg .on, .seg a:hover { background: #fff; color: var(--dark); text-decoration: none; }
.seg.light { background: var(--surface-2); border-color: var(--border); }
.seg.light button, .seg.light a { color: var(--muted); }
.seg.light .on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.quick { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 14px; margin: 18px 0; }
.quick a { background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 22px 10px 18px; display: flex; flex-direction: column; align-items: center; gap: 12px;
  color: var(--text); text-decoration: none; font-size: 10.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; box-shadow: var(--shadow); transition: transform .15s; }
.quick a:hover { transform: translateY(-2px); }
.quick a.primary { background: var(--primary); color: #fff; border: none; box-shadow: 0 12px 30px rgba(79,70,229,.35); }
.quick a .stat-icon { width: 50px; height: 50px; }
.quick a.primary .stat-icon { background: rgba(255,255,255,.18); color: #fff; }
.priority { background: linear-gradient(120deg, #4f46e5, #6d28d9); color: #fff; border-radius: 28px; padding: 26px 30px; display: flex; align-items: center; gap: 24px;
  box-shadow: 0 18px 50px rgba(79,70,229,.35); cursor: pointer; position: relative; overflow: hidden; }
.priority h2 { font-size: 30px; font-weight: 900; text-transform: uppercase; letter-spacing: -.02em; margin: 8px 0 12px; }
.priority .pill-white { background: #fff; color: var(--primary); font-size: 10px; font-weight: 900; letter-spacing: .1em; padding: 5px 12px; border-radius: 99px; text-transform: uppercase; }
.priority .route { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.priority .route span.box { background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2); padding: 10px 14px; border-radius: 14px; font-weight: 700; display: inline-flex; gap: 8px; align-items: center; }
.priority .time { font-family: var(--mono); font-size: 46px; font-weight: 800; color: #c7d2fe; line-height: 1; }
.alert-bar { border-radius: 18px; padding: 14px 18px; display: flex; align-items: center; gap: 14px; }
.alert-bar.red { background: var(--red); color: #fff; }
.alert-bar.amber { background: #f59e0b; color: #fff; }
.alert-bar.soft { background: var(--amber-50); color: var(--amber); border: 1px solid #fde68a; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 9px 15px; border-radius: 12px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, transform .05s; line-height: 1.2; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(79,70,229,.25); }
.btn.primary:hover { background: var(--primary-600); }
.btn.dark { background: var(--dark); border-color: var(--dark); color: #fff; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.success { background: var(--green); border-color: var(--green); color: #fff; }
.btn.warning { background: #f59e0b; border-color: #f59e0b; color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 6px 10px; font-size: 12.5px; border-radius: 10px; }
.btn.xs { padding: 4px 8px; font-size: 11px; border-radius: 8px; font-weight: 700; }
.btn.icon { padding: 8px; }
.btn.block { width: 100%; }
.btn.lg { padding: 14px 20px; font-size: 15px; border-radius: 14px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--surface); padding: 6px 12px; border-radius: 99px; font-size: 12px; font-weight: 600; cursor: pointer; color: var(--muted); }
.chip.on { background: var(--dark); border-color: var(--dark); color: #fff; }
.chip.on.primary { background: var(--primary); border-color: var(--primary); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 99px; font-size: 10.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
.b-gray { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.b-primary { background: var(--primary-50); color: var(--primary); }
.b-green { background: var(--green-50); color: var(--green); }
.b-amber { background: var(--amber-50); color: var(--amber); }
.b-red { background: var(--red-50); color: var(--red); }
.b-blue { background: var(--blue-50); color: var(--blue); }
.b-violet { background: var(--violet-50); color: var(--violet); }
.b-cyan { background: var(--cyan-50); color: var(--cyan); }
.count { background: var(--red); color: #fff; border-radius: 99px; font-size: 10px; font-weight: 800; padding: 1px 6px; min-width: 18px; text-align: center; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .flabel { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--border); background: var(--surface-2); border-radius: 12px; padding: 10px 12px; outline: none; transition: border .15s, box-shadow .15s; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(79,70,229,.12); background: var(--surface); }
textarea.input { min-height: 84px; resize: vertical; }
.input.err { border-color: var(--red); }
.ferr { color: var(--red); font-size: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-section { border: 1px solid var(--border); border-radius: 16px; padding: 16px; background: var(--surface); }
.form-section h4 { margin: 0 0 12px; font-size: 13px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search .input { padding-left: 38px; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.toggle { position: relative; width: 44px; height: 26px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle span { position: absolute; inset: 0; background: #cbd5e1; border-radius: 99px; transition: .2s; cursor: pointer; }
.toggle span::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle input:checked + span { background: var(--primary); }
.toggle input:checked + span::before { transform: translateX(18px); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters .search { flex: 1; min-width: 220px; }
.filters select.input { width: auto; min-width: 160px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 10.5px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); padding: 12px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--surface-2); }

/* ---------- Missions ---------- */
.day-head { display: flex; align-items: center; justify-content: space-between; margin: 22px 0 10px; }
.day-badge { width: 44px; height: 44px; border-radius: 13px; background: var(--primary); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.day-badge small { font-size: 9px; font-weight: 800; text-transform: uppercase; }
.day-badge b { font-size: 18px; }
.mission { display: grid; grid-template-columns: 120px minmax(0,1fr) 240px; gap: 18px; align-items: center; }
.mission + .mission { margin-top: 12px; }
.mission .when { font-size: 22px; font-weight: 800; font-family: var(--mono); }
.route { display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); gap: 10px; align-items: center; }
.route .pt { display: flex; gap: 8px; align-items: flex-start; }
.route .pt b { display: block; }
.note { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 9px 12px; font-size: 12.5px; color: var(--muted); font-style: italic; }
.stepper { display: flex; align-items: center; margin-top: 12px; }
.stepper .s { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 9px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); min-width: 50px; }
.stepper .s i { width: 10px; height: 10px; border-radius: 50%; background: var(--border); display: block; }
.stepper .s.done i { background: var(--primary); opacity: .6; }
.stepper .s.cur i { background: var(--primary); box-shadow: 0 0 0 5px var(--primary-100); }
.stepper .s.cur { color: var(--primary); }
.stepper .ln { flex: 1; height: 2px; background: var(--border); margin-bottom: 14px; }
.stepper .ln.done { background: var(--primary); opacity: .6; }
.assign-row { display: grid; grid-template-columns: minmax(0,1.2fr) minmax(0,1.5fr) 90px 36px; gap: 8px; align-items: end; padding: 10px; border: 1px dashed var(--border); border-radius: 12px; }
.capacity { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-radius: 14px; }
.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline .ev { position: relative; padding: 0 0 14px; }
.timeline .ev::before { content: ""; position: absolute; left: -18px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }

/* ---------- Planning ---------- */
.plan { overflow-x: auto; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
.plan table { border-collapse: collapse; width: 100%; min-width: 900px; }
.plan th, .plan td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); vertical-align: top; }
.plan th { background: var(--surface-2); font-size: 11px; font-weight: 800; padding: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.plan th.today { color: var(--primary); background: var(--primary-50); }
.plan td.res { width: 190px; padding: 10px 12px; font-weight: 700; background: var(--surface-2); position: sticky; left: 0; z-index: 2; }
.plan td.cell { padding: 6px; min-height: 64px; height: 64px; min-width: 120px; }
.plan td.cell.drop { background: var(--primary-50); outline: 2px dashed var(--primary); outline-offset: -3px; }
.plan td.cell.off { background: repeating-linear-gradient(45deg, transparent 0 6px, var(--surface-2) 6px 12px); }
.pchip { display: block; background: var(--primary-50); border-left: 3px solid var(--primary); border-radius: 8px; padding: 5px 7px; font-size: 11.5px; margin-bottom: 4px; cursor: grab; color: var(--text); }
.pchip b { font-family: var(--mono); }
.pchip.conflict { background: var(--red-50); border-left-color: var(--red); }
.pchip.st-completed { opacity: .55; border-left-color: var(--green); background: var(--green-50); }
.pchip.st-cancelled { opacity: .45; text-decoration: line-through; border-left-color: var(--faint); background: var(--surface-2); }
.pchip.st-en_route, .pchip.st-arrived, .pchip.st-on_board { border-left-color: var(--amber); background: var(--amber-50); }
.pchip.attr { border-left-color: var(--cyan); background: var(--cyan-50); cursor: default; }
.month { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; background: var(--surface); }
.month .mh { background: var(--surface-2); padding: 8px; font-size: 11px; font-weight: 800; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--border); }
.month .md { min-height: 110px; padding: 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.month .md.out { background: var(--surface-2); opacity: .6; }
.month .md .n { font-weight: 800; font-size: 12px; margin-bottom: 4px; }
.month .md.today .n { color: #fff; background: var(--primary); border-radius: 6px; display: inline-block; padding: 0 6px; }
.daystrip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.daystrip button { border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 6px 10px; cursor: pointer; display: flex; flex-direction: column; align-items: center; min-width: 52px; }
.daystrip button small { font-size: 10px; color: var(--muted); }
.daystrip button b { font-size: 15px; }
.daystrip button.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.daystrip button.on small { color: #e0e7ff; }

/* ---------- Modal / Drawer / Toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.45); backdrop-filter: blur(3px); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--surface); border-radius: 24px; width: 100%; max-width: 640px; box-shadow: var(--shadow-lg); animation: rise .2s; }
.modal.wide { max-width: 980px; }
.modal.narrow { max-width: 440px; }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 18px; font-weight: 800; }
.modal-body { padding: 20px 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 24px 24px; }
.drawer-overlay { align-items: stretch; justify-content: flex-end; padding: 0; }
.drawer { background: var(--surface); width: 100%; max-width: 720px; height: 100vh; overflow-y: auto; box-shadow: var(--shadow-lg); animation: slide .2s; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer .modal-head { position: sticky; top: 0; background: var(--surface); z-index: 2; }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--dark); color: #fff; padding: 12px 16px; border-radius: 14px; box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: center; max-width: 380px; animation: rise .2s; }
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: none; background: none; padding: 10px 14px; font-weight: 700; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--primary); border-bottom-color: var(--primary); }
.dropdown { position: absolute; right: 0; top: calc(100% + 8px); width: 360px; max-height: 480px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg); z-index: 50; }
.notif { padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.notif.unread { background: var(--primary-50); }
.notif:hover { background: var(--surface-2); }
.empty { text-align: center; padding: 44px 16px; color: var(--muted); }
.empty .stat-icon { margin: 0 auto 12px; width: 56px; height: 56px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--primary-100); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.fab { position: fixed; right: 26px; bottom: 26px; width: 58px; height: 58px; border-radius: 50%; background: var(--primary); color: #fff; border: none; display: grid; place-items: center;
  box-shadow: 0 12px 30px rgba(79,70,229,.45); cursor: pointer; z-index: 40; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: none; }
.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.map-frame { width: 100%; height: 360px; border: 0; border-radius: 16px; background: var(--surface-2); }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 10px; font-family: var(--font); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.kbd { font-family: var(--mono); font-size: 10px; border: 1px solid var(--border); border-radius: 6px; padding: 1px 5px; color: var(--faint); }
.search-results { position: absolute; left: 0; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); z-index: 60; max-height: 360px; overflow-y: auto; }
.search-results a { display: flex; gap: 10px; align-items: center; padding: 10px 14px; color: var(--text); border-bottom: 1px solid var(--border); text-decoration: none; }
.search-results a:hover { background: var(--surface-2); }
.perm-grid { display: grid; grid-template-columns: minmax(220px, 1fr) repeat(var(--cols), 110px); align-items: center; }
.perm-grid > div { padding: 8px 10px; border-bottom: 1px solid var(--border); }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.auth-card { width: 100%; max-width: 440px; background: var(--surface); border-radius: 28px; padding: 34px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.auth-logo { width: 78px; height: 78px; border-radius: 22px; background: var(--primary); color: #fff; display: grid; place-items: center; margin: 0 auto 18px; box-shadow: 0 16px 36px rgba(79,70,229,.35); overflow: hidden; }
.auth-logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.auth-card h1 { text-align: center; font-size: 26px; font-weight: 900; margin: 0; letter-spacing: -.02em; }
.auth-card p.lead { text-align: center; color: var(--muted); margin: 6px 0 24px; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) { .g5 { grid-template-columns: repeat(3, minmax(0,1fr)); } .quick { grid-template-columns: repeat(3, minmax(0,1fr)); } .split { grid-template-columns: 1fr; } }
@media (max-width: 1000px) {
  .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .mission { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
  .content { padding: 18px 14px 90px; }
  .hero h1 { font-size: 26px; } .priority { flex-direction: column; align-items: flex-start; } .priority .time { font-size: 34px; }
  .g2, .g3, .form-grid { grid-template-columns: 1fr; }
  .quick { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .route { grid-template-columns: 1fr; }
  .assign-row { grid-template-columns: 1fr 1fr; }
  .dropdown { position: fixed; left: 10px; right: 10px; width: auto; top: 60px; }
}
@media (max-width: 520px) { .g4, .g5 { grid-template-columns: 1fr 1fr; } .big-num { font-size: 22px; } }
@media print { .sidebar, .topbar, .fab, .page-head .actions { display: none !important; } .content { padding: 0; } .card { box-shadow: none; } }
