/* Estel CRM design system.
   Calm neutral canvas, one warm "ember" accent, soft depth, big confident numbers. Light and dark. */
:root {
  --font: 'Geist', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --bg: #f4f4f1; --bg-grad: radial-gradient(1200px 600px at 100% -10%, #ffe9d6 0%, transparent 55%), radial-gradient(900px 500px at -10% 110%, #e5ecff 0%, transparent 55%);
  --surface: #ffffff; --surface-2: #f7f7f4; --surface-3: #efefeb; --glass: rgba(255,255,255,.72);
  --ink: #16181d; --ink-2: #3d424c; --muted: #6c7280; --faint: #9aa0aa;
  --line: #e6e6e1; --line-2: #d9d9d3;
  --accent: #f0611a; --accent-2: #ff8a3d; --accent-ink: #fff; --accent-soft: #fff0e6; --accent-line: #ffd2b8;
  --blue: #3866f2; --blue-soft: #e9efff; --green: #12915b; --green-soft: #e2f6ec; --amber: #b7791f; --amber-soft: #fdf3df;
  --red: #d63b3b; --red-soft: #fde8e8; --violet: #7b5cf0; --violet-soft: #efeaff; --gray-soft: #efefec;
  --side: #121418; --side-ink: #e9eaee; --side-muted: #8b909b; --side-hover: rgba(255,255,255,.06); --side-active: rgba(255,255,255,.1);
  --r-sm: 8px; --r: 12px; --r-lg: 18px; --r-xl: 24px;
  --sh-1: 0 1px 2px rgba(16,18,24,.05), 0 1px 1px rgba(16,18,24,.03);
  --sh-2: 0 8px 24px -8px rgba(16,18,24,.12), 0 2px 6px rgba(16,18,24,.04);
  --sh-3: 0 24px 64px -16px rgba(16,18,24,.28), 0 4px 12px rgba(16,18,24,.06);
  --ring: 0 0 0 3px rgba(240,97,26,.22);
  --side-w: 252px; --top-h: 64px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0d0f12; --bg-grad: radial-gradient(1200px 600px at 100% -10%, rgba(240,97,26,.13) 0%, transparent 55%), radial-gradient(900px 500px at -10% 110%, rgba(56,102,242,.12) 0%, transparent 55%);
  --surface: #15181d; --surface-2: #1a1d23; --surface-3: #22262d; --glass: rgba(21,24,29,.72);
  --ink: #eef0f3; --ink-2: #c8ccd3; --muted: #9097a3; --faint: #6b717c;
  --line: #262a31; --line-2: #313640;
  --accent: #ff7a33; --accent-2: #ff9b5c; --accent-ink: #1a0d05; --accent-soft: rgba(255,122,51,.13); --accent-line: rgba(255,122,51,.35);
  --blue: #7b9bff; --blue-soft: rgba(123,155,255,.13); --green: #3fcf8e; --green-soft: rgba(63,207,142,.13); --amber: #f0b354; --amber-soft: rgba(240,179,84,.13);
  --red: #ff6b6b; --red-soft: rgba(255,107,107,.13); --violet: #a58bff; --violet-soft: rgba(165,139,255,.14); --gray-soft: rgba(255,255,255,.06);
  --side: #0a0b0e; --side-hover: rgba(255,255,255,.05); --side-active: rgba(255,255,255,.09);
  --sh-1: 0 1px 2px rgba(0,0,0,.4); --sh-2: 0 8px 24px -8px rgba(0,0,0,.6); --sh-3: 0 24px 64px -16px rgba(0,0,0,.8);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); background-image: var(--bg-grad); background-attachment: fixed;
  -webkit-font-smoothing: antialiased; font-feature-settings: 'ss01', 'cv11'; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
::selection { background: var(--accent-soft); }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.muted { color: var(--muted); } .faint { color: var(--faint); }
.row-gap { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; } .row-gap.center { justify-content: center; }
.spacer { flex: 1; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; padding: 18px 12px; gap: 4px; overflow-y: auto; z-index: 20; }
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 10px 18px; }
.logo { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--accent) 0%, #ffb067 100%); display: grid; place-items: center; color: #1a0d05;
  box-shadow: 0 6px 18px -6px rgba(240,97,26,.7), inset 0 1px 0 rgba(255,255,255,.4); flex: none; }
.brand b { font-size: 15px; font-weight: 650; letter-spacing: -.01em; display: block; line-height: 1.15; }
.brand small { color: var(--side-muted); font-size: 11.5px; }
.nav-group { margin-top: 10px; }
.nav-label { color: var(--side-muted); font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; padding: 8px 12px 6px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 8px 12px; border-radius: 10px; color: #c5c8d0; text-decoration: none; font-weight: 500; position: relative; transition: background .15s, color .15s; }
.nav a:hover { background: var(--side-hover); color: #fff; }
.nav a[aria-current="page"] { background: var(--side-active); color: #fff; }
.nav a[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav a svg { opacity: .85; flex: none; }
.nav .badge { margin-left: auto; background: rgba(255,107,107,.18); color: #ff9b9b; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; font-family: var(--mono); }
.side-foot { margin-top: auto; padding-top: 14px; }
.me { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.06); cursor: pointer; width: 100%; text-align: left; color: inherit; }
.me:hover { background: rgba(255,255,255,.07); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 650; flex: none;
  background: linear-gradient(135deg, #3a3f4b, #23262d); color: #fff; border: 1px solid rgba(255,255,255,.1); }
.avatar.lg { width: 40px; height: 40px; font-size: 14px; }
.me b { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me small { color: var(--side-muted); font-size: 11.5px; }
.me > div:not(.avatar) { min-width: 0; flex: 1; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 15; height: var(--top-h); display: flex; align-items: center; gap: 12px; padding: 0 28px;
  background: var(--glass); backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px); border-bottom: 1px solid var(--line); }
.top h1 { font-size: 17px; font-weight: 650; margin: 0; letter-spacing: -.015em; white-space: nowrap; }
.top .crumb { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.searchbtn { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); cursor: pointer; min-width: 240px; box-shadow: var(--sh-1); }
.searchbtn:hover { border-color: var(--line-2); }
.searchbtn span { flex: 1; text-align: left; }
kbd { font-family: var(--mono); font-size: 11px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); }
.top-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.btn.mobile-menu { display: none; }
.page { padding: 26px 28px 64px; max-width: 1560px; width: 100%; margin: 0 auto; animation: pagein .28s ease-out; }
@keyframes pagein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-weight: 550; cursor: pointer; white-space: nowrap; box-shadow: var(--sh-1); transition: transform .08s, background .15s, border-color .15s, box-shadow .15s; text-decoration: none; }
.btn:hover { border-color: var(--line-2); background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, .seg button:focus-visible, tr[tabindex]:focus-visible { outline: none; box-shadow: var(--ring); }
.btn.primary { background: linear-gradient(180deg, var(--accent-2), var(--accent)); border-color: transparent; color: #fff; box-shadow: 0 6px 16px -6px rgba(240,97,26,.6), inset 0 1px 0 rgba(255,255,255,.25); }
:root[data-theme="dark"] .btn.primary { color: #1a0d05; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.dark { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, transparent); }
.btn.danger:hover { background: var(--red-soft); }
.btn.solid-danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn.sm { height: 30px; padding: 0 10px; border-radius: 8px; font-size: 13px; }
.btn.icon-only { width: 36px; padding: 0; } .btn.sm.icon-only { width: 30px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; cursor: pointer; font-size: 13px; }
.linkbtn:hover { text-decoration: underline; }

/* ---------- forms ---------- */
input, select, textarea { height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); min-width: 0; transition: border-color .15s, box-shadow .15s; }
textarea { height: auto; padding: 9px 12px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: var(--line-2); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[type="date"] { font-family: var(--mono); font-size: 13px; }
input[type="checkbox"] { height: auto; width: 16px; height: 16px; accent-color: var(--accent); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .lbl { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.lbl.up { text-transform: uppercase; letter-spacing: .08em; font-size: 10.5px; color: var(--muted); }
.req::after { content: " *"; color: var(--accent); }
.hint { font-size: 12px; color: var(--muted); }
.err { color: var(--red); font-size: 13px; font-weight: 500; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.full { grid-column: 1 / -1; }
.section-title { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .09em; margin-top: 6px; }
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.searchbox { position: relative; display: flex; align-items: center; }
.searchbox svg { position: absolute; left: 11px; color: var(--faint); pointer-events: none; }
.searchbox input { padding-left: 34px; width: 280px; }

/* segmented control */
.seg { display: inline-flex; padding: 3px; background: var(--surface-3); border-radius: 11px; gap: 2px; border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; padding: 0 12px; height: 30px; border-radius: 8px; font-weight: 550; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--sh-1); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 99px; border: 1px dashed var(--line-2); background: transparent; color: var(--muted); font-size: 12.5px; cursor: pointer; font-weight: 500; }
.chip:hover { border-color: var(--accent); color: var(--ink); }
.chip.on { border-style: solid; border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-1); min-width: 0; }
.card.pad { padding: 20px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px 0; flex-wrap: wrap; }
.card-head h3 { margin: 0; font-size: 14px; font-weight: 650; letter-spacing: -.005em; }
.card-head .sub { color: var(--muted); font-size: 12.5px; }
.card-body { padding: 16px 20px 20px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h2 { font-size: 26px; line-height: 1.15; margin: 0; letter-spacing: -.025em; font-weight: 650; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpis.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { position: relative; padding: 16px 18px; overflow: hidden; }
.kpi .k-top { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; font-weight: 550; }
.kpi .k-ic { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.kpi .v { font-family: var(--mono); font-size: clamp(18px, 1.5vw, 25px); font-weight: 550; letter-spacing: -.035em; margin-top: 10px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.kpi .spark { position: absolute; right: 12px; bottom: 12px; opacity: .9; }
.delta { font-family: var(--mono); font-size: 11.5px; font-weight: 600; padding: 1px 6px; border-radius: 6px; }
.delta.up { color: var(--green); background: var(--green-soft); } .delta.down { color: var(--red); background: var(--red-soft); } .delta.flat { color: var(--muted); background: var(--gray-soft); }
.tone-accent { background: var(--accent-soft); color: var(--accent); } .tone-blue { background: var(--blue-soft); color: var(--blue); }
.tone-green { background: var(--green-soft); color: var(--green); } .tone-amber { background: var(--amber-soft); color: var(--amber); }
.tone-red { background: var(--red-soft); color: var(--red); } .tone-violet { background: var(--violet-soft); color: var(--violet); }

/* dashboard bento */
.bento { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; }
.span-8 { grid-column: span 8; } .span-4 { grid-column: span 4; } .span-6 { grid-column: span 6; } .span-12 { grid-column: span 12; } .span-5 { grid-column: span 5; } .span-7 { grid-column: span 7; }
.hero { padding: 22px 24px; display: flex; gap: 24px; align-items: center; flex-wrap: wrap; overflow: hidden; position: relative;
  background: linear-gradient(120deg, #17191e 0%, #23262e 60%, #2b2622 100%); color: #f3f4f6; border-color: transparent; }
.hero::after { content: ""; position: absolute; right: -80px; top: -120px; width: 380px; height: 380px; border-radius: 50%; background: radial-gradient(closest-side, rgba(255,122,51,.45), transparent); pointer-events: none; }
.hero h2 { margin: 0; font-size: 24px; letter-spacing: -.02em; font-weight: 650; }
.hero p { margin: 4px 0 0; color: #aeb3bd; }
.hero .seg { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.1); }
.hero .seg button { color: #b9bec8; } .hero .seg button[aria-pressed="true"] { background: rgba(255,255,255,.16); color: #fff; box-shadow: none; }
.barlist { display: flex; flex-direction: column; gap: 10px; }
.bl-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; cursor: default; }
.bl-row .bl-name { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bl-row .bl-val { font-family: var(--mono); font-size: 13px; }
.bl-bar { grid-column: 1 / -1; height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bl-bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transform-origin: left; animation: grow .7s cubic-bezier(.2,.7,.2,1) both; }
@keyframes grow { from { transform: scaleX(0); } }
.chart { width: 100%; display: block; }
.chart .gridline { stroke: var(--line); stroke-dasharray: 3 4; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--mono); }
.chart .area { fill: url(#areaGrad); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.chart .line2 { fill: none; stroke: var(--blue); stroke-width: 1.75; stroke-dasharray: 4 4; }
.chart .dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.chart .bar { fill: var(--accent); } .chart .bar.dim { fill: var(--accent-line); }
.chart-tip { position: fixed; pointer-events: none; z-index: 80; background: var(--ink); color: var(--surface); padding: 8px 10px; border-radius: 10px; font-size: 12px; box-shadow: var(--sh-3); white-space: nowrap; }
.chart-tip b { font-family: var(--mono); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.donut-wrap { display: flex; align-items: center; gap: 18px; }
.alert-list { display: flex; flex-direction: column; gap: 8px; }
.alert-row { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; text-decoration: none; }
.alert-row:hover { border-color: var(--line-2); }
.alert-row .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.red { background: var(--red); box-shadow: 0 0 0 4px var(--red-soft); } .dot.amber { background: var(--amber); box-shadow: 0 0 0 4px var(--amber-soft); } .dot.green { background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.banner { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 12px; font-weight: 500; margin-bottom: 14px; border: 1px solid; }
.banner.amber { background: var(--amber-soft); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 25%, transparent); }
.banner.red { background: var(--red-soft); color: var(--red); border-color: color-mix(in srgb, var(--red) 25%, transparent); }
.banner.blue { background: var(--blue-soft); color: var(--blue); border-color: color-mix(in srgb, var(--blue) 25%, transparent); }

/* ---------- pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; white-space: nowrap; line-height: 1.6; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.pill.green { background: var(--green-soft); color: var(--green); } .pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.red { background: var(--red-soft); color: var(--red); } .pill.gray { background: var(--gray-soft); color: var(--muted); }
.pill.blue { background: var(--blue-soft); color: var(--blue); } .pill.violet { background: var(--violet-soft); color: var(--violet); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill.plain::before { display: none; }
.tag { display: inline-block; font-size: 10.5px; font-weight: 650; letter-spacing: .03em; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line); color: var(--faint); margin-right: 3px; font-family: var(--mono); }
.tag.on { background: var(--green-soft); color: var(--green); border-color: transparent; cursor: pointer; }
.tag.on:hover { filter: brightness(.95); }

/* ---------- tables ---------- */
.tablewrap { overflow: auto; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--sh-1); max-height: calc(100vh - 230px); }
table.t { border-collapse: separate; border-spacing: 0; width: 100%; }
.t th, .t td { padding: 11px 14px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); font-size: 11.5px; font-weight: 600; color: var(--muted); letter-spacing: .02em; user-select: none; }
.t th.sortable { cursor: pointer; } .t th.sortable:hover { color: var(--ink); }
.t th.num, .t td.num { text-align: right; }
.t td.num, .t td.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 13px; }
.t tbody tr { transition: background .1s; }
.t tbody tr.row { cursor: pointer; }
.t tbody tr.row:hover td { background: var(--accent-soft); }
.t tbody tr.cancelled td:not(.st) { color: var(--faint); text-decoration: line-through; text-decoration-color: var(--line-2); }
.t tr.group td { background: var(--surface-2); font-weight: 600; font-size: 12.5px; position: sticky; top: 40px; z-index: 1; }
.t tr.foot td { font-weight: 650; background: var(--surface-2); border-bottom: 0; position: sticky; bottom: 0; }
.t tr:last-child td { border-bottom: 0; }
.t tr.quiet td { color: var(--faint); }
.t td.wrap { white-space: normal; }
.lane { display: flex; flex-direction: column; line-height: 1.3; }
.lane small { color: var(--muted); font-size: 12px; }
.lane small::before { content: "→ "; color: var(--faint); }
.strong { font-weight: 600; }
.more-row { display: flex; justify-content: center; padding: 14px; }
.meter { display: inline-flex; gap: 3px; vertical-align: middle; }
.meter i { width: 7px; height: 14px; border-radius: 2px; background: var(--surface-3); }
.meter i.on { background: var(--green); }

/* ---------- sheet (side drawer) ---------- */
.scrim { position: fixed; inset: 0; background: rgba(10,12,16,.38); backdrop-filter: blur(2px); z-index: 40; opacity: 0; transition: opacity .2s; }
.scrim.in { opacity: 1; }
.sheet { position: fixed; top: 10px; right: 10px; bottom: 10px; width: min(600px, calc(100% - 20px)); background: var(--bg); z-index: 41; border-radius: var(--r-xl);
  box-shadow: var(--sh-3); display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line); transform: translateX(30px); opacity: 0; transition: transform .22s cubic-bezier(.2,.8,.2,1), opacity .2s; }
.sheet.in { transform: none; opacity: 1; }
.sheet.wide { width: min(1040px, calc(100% - 20px)); }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); background: var(--surface); }
.sheet-titles { min-width: 0; margin-right: auto; }
.sheet-head h2 { margin: 0; font-size: 18px; letter-spacing: -.015em; font-weight: 650; }
.sheet-sub { color: var(--muted); font-size: 12.5px; }
.sheet-sub:empty { display: none; }
.sheet-extra { display: flex; gap: 6px; align-items: center; }
.sheet-body { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 18px; }
.sheet-foot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface); }
.sheet-foot:empty { display: none; }
.calc { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
.calc > div { background: var(--surface); padding: 12px 14px; }
.calc .v { font-family: var(--mono); font-size: 18px; font-weight: 550; letter-spacing: -.02em; }
.confirm-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; width: 100%; padding: 10px 12px; border-radius: 12px; background: var(--red-soft); color: var(--red); font-weight: 500; }

/* documents */
.docs { display: flex; flex-direction: column; gap: 10px; }
.doc { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 9px; }
.doc.missing { border-style: dashed; background: transparent; }
.doc-top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.doc-top b { font-weight: 600; margin-right: auto; }
.doc-file { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 13px; min-width: 0; }
.doc-file a { font-weight: 550; word-break: break-all; text-decoration: none; }
.doc-file a:hover { color: var(--accent); }
.thumb { width: 52px; height: 52px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); flex: none; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--muted); }
.gallery { display: flex; flex-wrap: wrap; gap: 8px; }
.gallery .thumb { width: 80px; height: 80px; cursor: pointer; }
.hist { border-top: 1px dashed var(--line); padding-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.hist-row { display: flex; gap: 10px; align-items: center; font-size: 12.5px; flex-wrap: wrap; color: var(--muted); }
.hist-row a { color: var(--ink-2); }
.exp { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.exp input { height: 30px; font-size: 12px; padding: 0 8px; }
.upl { position: relative; overflow: hidden; }
.upl input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; height: 100%; }
.dropzone { border: 1.5px dashed var(--line-2); border-radius: 14px; padding: 16px; text-align: center; color: var(--muted); background: var(--surface-2); position: relative; font-size: 13px; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; height: 100%; }
.pending { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; justify-content: center; }
.pending span { font-size: 12px; background: var(--surface); border: 1px solid var(--line); padding: 2px 8px; border-radius: 6px; color: var(--ink-2); }

/* preview */
.pv { position: fixed; inset: 0; z-index: 70; background: rgba(8,9,12,.72); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 24px; }
.pvbox { background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--sh-3); width: min(1000px, 100%); height: min(90vh, 1100px); display: flex; flex-direction: column; overflow: hidden; }
.pvhead, .pvfoot { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.pvfoot { border-bottom: 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pvhead h3 { margin: 0; font-size: 15px; }
.pvbody { flex: 1; min-height: 0; background: var(--surface-3); display: flex; align-items: center; justify-content: center; overflow: auto; }
.pvbody img { max-width: 100%; max-height: 100%; object-fit: contain; }
.pvbody iframe { width: 100%; height: 100%; border: 0; background: #fff; }

/* modal */
.modal-wrap { position: fixed; inset: 0; z-index: 60; background: rgba(10,12,16,.45); backdrop-filter: blur(3px); display: flex; align-items: flex-start; justify-content: center; padding: 10vh 16px 16px; opacity: 0; transition: opacity .18s; overflow-y: auto; }
.modal-wrap.in { opacity: 1; }
.modal { width: min(480px, 100%); background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--sh-3); border: 1px solid var(--line); transform: translateY(10px) scale(.98); transition: transform .2s cubic-bezier(.2,.8,.2,1); }
.modal.wide { width: min(720px, 100%); }
.modal-wrap.in .modal { transform: none; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px 0; }
.modal-head h2 { margin: 0 auto 0 0; font-size: 17px; font-weight: 650; }
.modal-body { padding: 14px 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-body p { margin: 0; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 0 20px 18px; flex-wrap: wrap; }

/* command palette */
.cmdk { width: min(640px, 100%); background: var(--surface); border-radius: 20px; box-shadow: var(--sh-3); border: 1px solid var(--line); overflow: hidden; }
.cmdk-in { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.cmdk-in input { border: 0; height: 56px; flex: 1; font-size: 16px; background: transparent; box-shadow: none !important; padding: 0; }
.cmdk-list { max-height: 420px; overflow-y: auto; padding: 8px; }
.cmdk-group { font-size: 11px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .08em; padding: 10px 10px 4px; }
.cmdk-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 10px; cursor: pointer; }
.cmdk-item[aria-selected="true"] { background: var(--accent-soft); }
.cmdk-item .ci-ic { width: 30px; height: 30px; border-radius: 8px; background: var(--surface-3); display: grid; place-items: center; color: var(--muted); flex: none; }
.cmdk-item[aria-selected="true"] .ci-ic { background: var(--accent); color: #fff; }
.cmdk-item b { font-weight: 550; display: block; }
.cmdk-item small { color: var(--muted); font-size: 12px; }
.cmdk-item > div { min-width: 0; flex: 1; }
.cmdk-foot { display: flex; gap: 14px; padding: 10px 16px; border-top: 1px solid var(--line); color: var(--faint); font-size: 12px; }

/* menu popover */
.menu { position: fixed; z-index: 75; min-width: 220px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--sh-3); padding: 6px; animation: pop .14s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(4px) scale(.98); } }
.menu button, .menu a { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 9px; border: 0; background: none; cursor: pointer; text-align: left; text-decoration: none; font-weight: 500; }
.menu button:hover, .menu a:hover { background: var(--surface-3); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.menu .mh { padding: 8px 10px; }
.menu .mh b { display: block; } .menu .mh small { color: var(--muted); }

/* toasts */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { display: flex; gap: 9px; align-items: center; background: var(--ink); color: var(--surface); padding: 11px 16px; border-radius: 12px; box-shadow: var(--sh-3); font-weight: 500;
  opacity: 0; transform: translateY(10px); transition: all .25s cubic-bezier(.2,.8,.2,1); max-width: min(560px, 90vw); }
.toast.in { opacity: 1; transform: none; }
.toast svg { color: var(--green); flex: none; } :root[data-theme="dark"] .toast svg { color: #12915b; }
.toast.err svg { color: #ff6b6b; }

/* empty + skeleton */
.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty-art { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; margin: 0 auto 14px; background: var(--accent-soft); color: var(--accent); }
.empty h3 { color: var(--ink); margin: 0 0 4px; font-size: 16px; }
.empty p { margin: 0 0 16px; }
.skel { height: 14px; border-radius: 6px; margin: 12px 0; background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* driver cards / grid */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.pcard { padding: 16px; display: flex; flex-direction: column; gap: 12px; cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s; }
.pcard:hover { transform: translateY(-2px); box-shadow: var(--sh-2); border-color: var(--line-2); }
.pcard h4 { margin: 0; font-size: 15px; font-weight: 650; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 13px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-family: var(--mono); text-align: right; }
.kv.big dd { font-size: 14px; } .kv .tot { font-weight: 700; color: var(--ink); }

/* company docs */
.co-sec { margin-bottom: 22px; }
.co-sec h3 { font-size: 15px; margin: 0 0 2px; font-weight: 650; }
.co-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 10px; margin-top: 10px; }
.missing-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; }
.progress { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--green), #4ade80); border-radius: 99px; }

/* P&L */
.pl-list { display: flex; flex-direction: column; gap: 6px; }
.pl-item { display: grid; grid-template-columns: auto 1fr auto auto; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.pl-item > * { min-width: 0; }
.addrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.addrow input.grow { flex: 1; min-width: 150px; }
.addrow input[type=number] { width: 120px; }
.plsec h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
details.box { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; }
details.box summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; gap: 8px; align-items: center; }
details.box summary::-webkit-details-marker { display: none; }
details.box[open] summary { margin-bottom: 14px; }

/* login */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { position: relative; overflow: hidden; background: #0f1115; color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.login-art::before { content: ""; position: absolute; inset: -20%; background: radial-gradient(600px 400px at 80% 20%, rgba(255,122,51,.45), transparent 60%), radial-gradient(500px 400px at 10% 90%, rgba(56,102,242,.35), transparent 60%); filter: blur(10px); }
.login-art > * { position: relative; }
.login-art h1 { font-size: clamp(32px, 4vw, 52px); line-height: 1.05; letter-spacing: -.035em; margin: 0 0 14px; font-weight: 650; max-width: 560px; }
.login-art p { color: #aeb3bd; max-width: 460px; font-size: 15px; margin: 0; }
.road { position: absolute; left: 0; right: 0; bottom: 120px; height: 2px; background: repeating-linear-gradient(90deg, rgba(255,255,255,.18) 0 40px, transparent 40px 80px); animation: road 1.6s linear infinite; }
@keyframes road { to { background-position: -80px 0; } }
.stats-row { display: flex; gap: 28px; flex-wrap: wrap; }
.stats-row b { display: block; font-family: var(--mono); font-size: 22px; font-weight: 550; }
.stats-row small { color: #8b909b; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 32px; }
.login-box { width: min(380px, 100%); display: flex; flex-direction: column; gap: 16px; }
.login-box h2 { margin: 0; font-size: 26px; letter-spacing: -.025em; }
.login-box .btn { height: 44px; font-size: 15px; }
.login-box input { height: 44px; }

/* responsive */
@media (max-width: 1280px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } .span-8, .span-4, .span-5, .span-7 { grid-column: span 12; } .span-6 { grid-column: span 12; } }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 272px; transform: translateX(-100%); transition: transform .25s; box-shadow: var(--sh-3); }
  .side.open { transform: none; }
  .btn.mobile-menu { display: inline-flex; }
  .top { padding: 0 14px; } .page { padding: 18px 14px 80px; }
  .searchbtn { min-width: 0; } .searchbtn span, .searchbtn kbd { display: none; }
  .top .crumb { display: none; }
  .kpis, .kpis.k4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .login { grid-template-columns: 1fr; } .login-art { display: none; }
  .searchbox input { width: 100%; } .searchbox { flex: 1; min-width: 200px; }
  .sheet { top: 0; right: 0; bottom: 0; width: 100%; border-radius: 0; }
  .calc { grid-template-columns: 1fr 1fr; }
  .tablewrap { max-height: none; }
  .t tr.group td { top: 40px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media print { .side, .top, .toolbar { display: none !important; } .app { display: block; } .tablewrap { max-height: none; overflow: visible; box-shadow: none; } body { background: #fff; } }
@media print {
  body:has(.sheet) .app, body:has(.sheet) .scrim, .sheet-foot, .sheet-head .btn, details.box, .addrow { display: none !important; }
  .sheet { position: static; width: 100% !important; box-shadow: none; border: 0; transform: none; opacity: 1; }
  .sheet-body { overflow: visible; }
}
.plsec textarea { width: 100%; }
@media (max-width: 900px) {
  .kpi .spark { display: none; }
  .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .seg button { white-space: nowrap; }
  .top-actions .btn span { display: none; } .top { gap: 6px; } .top h1 { font-size: 16px; overflow: hidden; text-overflow: ellipsis; }
  .top-actions .btn { width: 36px; padding: 0; } .top-actions { gap: 4px; }
  .hero { padding: 18px; }
  .bento { grid-template-columns: 1fr; }
  .bento > * { grid-column: 1 / -1 !important; }
}
/* compact loads table: fits on one screen */
.t.compact th, .t.compact td { padding: 8px 10px; }
.t.compact th:first-child, .t.compact td:first-child { padding-left: 14px; }
.t.compact .two { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.t.compact .two small { color: var(--muted); font-size: 11.5px; font-family: var(--font); font-weight: 400; }
.t.compact .two.mono > span { font-family: var(--mono); font-size: 13px; }
.t.compact .two.strong-top > span { font-weight: 650; }
.t.compact .two.right { align-items: flex-end; }
.t.compact .clip { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t.compact .lane-cell .clip { max-width: 150px; }
.t.compact .broker-cell .clip { max-width: 120px; }
.t.compact td:nth-child(5) .clip { max-width: 110px; }
.t.compact .docs-cell .tag { margin-right: 2px; }
@media (max-width: 1350px) { .t.compact .lane-cell .clip { max-width: 130px; } .t.compact .broker-cell .clip { max-width: 100px; } }
@media (max-width: 1350px) { .t.compact th, .t.compact td { padding: 8px 7px; } .t.compact .lane-cell .clip { max-width: 120px; } .t.compact .broker-cell .clip { max-width: 90px; } .t.compact td:nth-child(5) .clip { max-width: 90px; } .t.compact td.num, .t.compact .two.mono > span { font-size: 12.5px; } }
.brand-switch { width: 100%; border: 1px solid rgba(255,255,255,.08); background: rgba(255,255,255,.04); border-radius: 12px; color: inherit; cursor: pointer; padding: 8px 10px; margin-bottom: 8px; }
.brand-switch:hover { background: rgba(255,255,255,.08); }
.brand-switch small { color: var(--accent-2); }
