/* UniDash owner console. Careem/Uber-style like the apps: white ground, bold
   headings, filled inputs with no border until focus, and green (kPrimary) only on
   things you can press. Tokens mirror core/lib/core/theme.dart. */
:root {
  --primary: #0E8A5F;
  --primary-press: #0b734f;
  --primary-soft: #E7F4EE;
  --text: #111111;
  --text2: #3a3a3a;
  --muted: #6B6B6B;
  --faint: #A3A3A3;
  --border: #EAEAEA;
  --surface: #FFFFFF;
  --surface2: #F5F5F5;
  --red: #C63B3B;
  --red-soft: #FBECEC;
  --amber: #B7791F;
  --amber-soft: #FDF3E1;
  --radius: 12px;
  --radius-lg: 16px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--surface); color: var(--text); }
body { font: 400 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; }
p { margin: 0; }
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ── Login ─────────────────────────────────────────────────────────── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { margin-bottom: 6px; }
.login-card .muted { margin-bottom: 28px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 36px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }

/* ── Fields ────────────────────────────────────────────────────────── */
.field { display: block; }
.field + .field { margin-top: 14px; }
.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--text2); margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; border: 1.5px solid transparent; background: var(--surface2);
  border-radius: var(--radius); padding: 12px 14px; outline: none; transition: border-color .15s;
}
textarea.input { resize: vertical; min-height: 96px; }
.input:focus { border-color: var(--primary); background: var(--surface); }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.hint.warn { color: var(--amber); }
.error { color: var(--red); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ── Buttons: opacity feedback, never scale (CLAUDE.md §5) ─────────── */
.btn {
  border: 0; border-radius: 14px; padding: 12px 18px; font-weight: 700; cursor: pointer;
  background: var(--primary); color: #fff; transition: opacity .12s;
}
.btn:hover { background: var(--primary-press); }
.btn:active { opacity: .7; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--primary); padding: 8px 10px; }
.btn.ghost:hover { background: var(--primary-soft); }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #a93131; }
.btn.quiet { background: var(--surface2); color: var(--text); }
.btn.quiet:hover { background: #ececec; }

/* ── Shell ─────────────────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
/* A grid item defaults to min-width:auto, which lets a wide table push the whole page
   sideways on a phone. Tables scroll inside .table-wrap instead. */
.shell > * { min-width: 0; }
.side { border-right: 1px solid var(--border); padding: 22px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.side .brand { padding: 0 10px; margin-bottom: 26px; }
.nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-radius: 10px; color: var(--text2); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--surface2); }
.nav a.active { background: var(--surface2); color: var(--text); font-weight: 700; }
.nav a:active { opacity: .7; }
.side-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--border); }
.side-foot .who { font-weight: 700; }
.main { padding: 32px 40px 64px; max-width: 1180px; width: 100%; }
.page-head { margin-bottom: 26px; }
.page-head p { margin-top: 6px; }
.badge {
  display: inline-block; min-width: 20px; padding: 1px 7px; border-radius: 999px;
  font-size: 11px; font-weight: 700; text-align: center; background: var(--red); color: #fff;
}

/* ── Cards, KPIs, tables ───────────────────────────────────────────── */
.card { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; }
.card + .card, .card + .section, .section + .section, .kpis + .section, .kpis + .card { margin-top: 20px; }
.section h2 { margin-bottom: 12px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--surface2); border-radius: var(--radius-lg); padding: 16px 18px; }
.kpi .label { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi .value { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; margin-top: 4px; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.alert { background: var(--red-soft); }
.kpi.alert .value { color: var(--red); }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: left; white-space: nowrap; }
th { font-size: 12px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; }
td { border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: 0; }
tr.dim td { color: var(--faint); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface2); }
tr.selected td { background: var(--primary-soft); }
td.wrap { white-space: normal; min-width: 220px; }

.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface2); color: var(--text2); }
.pill.green { background: var(--primary-soft); color: var(--primary); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }

.empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.note { background: var(--surface2); border-radius: var(--radius); padding: 12px 14px; color: var(--text2); font-size: 13px; }
.note.warn { background: var(--amber-soft); color: #6b4a12; }
.note.danger { background: var(--red-soft); color: #7a2323; }

.tabs { display: flex; gap: 4px; margin-bottom: 14px; }
.tabs button { border: 0; background: transparent; padding: 8px 12px; border-radius: 10px; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button.active { background: var(--surface2); color: var(--text); }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid2 > .field + .field { margin-top: 0; }
.setting { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 20px; padding: 18px 0; border-bottom: 1px solid var(--border); }
.setting:last-child { border-bottom: 0; }
.setting .control .row { flex-wrap: nowrap; }
.setting .control .input { min-width: 0; }

.preview { background: #1c1c1e; color: #fff; border-radius: 18px; padding: 14px 16px; max-width: 360px; }
.preview .t { font-weight: 700; }
.preview .b { color: #d6d6d6; margin-top: 2px; white-space: pre-wrap; word-break: break-word; }

/* ── Dialog + toast ────────────────────────────────────────────────── */
dialog { border: 0; border-radius: 20px; padding: 24px; width: min(460px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.18); }
dialog::backdrop { background: rgba(17,17,17,.4); }
dialog h2 { margin-bottom: 8px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: 11px 16px; border-radius: 12px; font-weight: 600; z-index: 20; max-width: calc(100vw - 32px); }
#toast.err { background: var(--red); }

/* ── Narrow screens ────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 14px 16px; }
  .side .brand { margin-bottom: 12px; padding: 0; }
  .nav { display: flex; gap: 4px; overflow-x: auto; }
  .nav a { white-space: nowrap; }
  .side-foot { display: flex; align-items: center; gap: 10px; border-top: 0; padding: 10px 0 0; }
  .main { padding: 22px 16px 48px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2, .setting { grid-template-columns: 1fr; }
}

/* ── Overseer ──────────────────────────────────────────────────────────── */
.page-head.row { align-items: flex-end; }
.kpis-8 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi.warn { background: var(--amber-soft); }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 0 rgba(14,138,95,.45); animation: pulse 2s infinite; }
.live-dot.paused { background: var(--faint); animation: none; }
.live-dot.stale { background: var(--amber); animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(14,138,95,.45); } 70% { box-shadow: 0 0 0 7px rgba(14,138,95,0); } 100% { box-shadow: 0 0 0 0 rgba(14,138,95,0); } }

/* Status colours are reserved for alerts and always ship with an icon AND a label. */
.alerts { display: grid; gap: 8px; }
/* Scoped to .alerts: a bare .alert rule collided with the kpi tile's own `alert` modifier
   and laid the tile out as a flex row. */
.alerts > .alert { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; border-radius: 12px; background: var(--surface2); }
.alerts > .alert.critical { background: #fbecec; }
.alerts > .alert.serious { background: #fdf0ea; }
.alerts > .alert.warning { background: #fef7e6; }
.alert-level { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text2); min-width: 64px; }
.alert-text { flex: 1; min-width: 200px; }
.status-icon { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; font-size: 11px; font-weight: 800; color: #fff; flex: none; }
.status-icon.critical { background: #d03b3b; }
.status-icon.serious { background: #ec835a; }
.status-icon.warning { background: #fab219; color: #111; }
.status-icon.good { background: #0ca30c; }
.empty-inline { display: flex; align-items: center; gap: 10px; color: var(--text2); }

.deadline { font-weight: 600; color: var(--text2); font-variant-numeric: tabular-nums; }
.deadline.urgent { color: #b42f2f; }

.lanes { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; align-items: start; }
.lane { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px; background: var(--surface); }
.lane-head { padding: 2px 2px 10px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.lane-head .small { margin-top: 3px; }
.lane-empty { color: var(--faint); padding: 14px 4px; text-align: center; }
.lane-group + .lane-group { margin-top: 10px; }
.lane-group-title { display: flex; justify-content: space-between; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 2px 4px 6px; }
.lane-group-title .count { background: var(--surface2); border-radius: 999px; padding: 0 8px; color: var(--text2); }
.ocard { background: var(--surface2); border-radius: 12px; padding: 10px 12px; }
.ocard + .ocard { margin-top: 6px; }
/* A new arrival fades from green to the normal surface: colour only, never scale. */
.ocard.fresh { animation: arrive 2.4s ease-out; }
@keyframes arrive { from { background: var(--primary-soft); } to { background: var(--surface2); } }
.ocard-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.ocard-num { font-weight: 800; font-size: 15px; letter-spacing: -.01em; }
.ocard-total { font-weight: 700; }
.ocard-items { color: var(--text2); margin: 3px 0 6px; font-size: 13px; }
.ocard-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: 12px; }

/* ── Performance ───────────────────────────────────────────────────────── */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 22px; }
.filters .input { width: auto; padding: 9px 12px; }
.filters .btn { padding: 9px 14px; }
.filter-sep { width: 1px; height: 26px; background: var(--border); margin: 0 4px; }
.section-sub { margin: -6px 0 12px; }
.hero { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; background: var(--surface2); border-radius: var(--radius-lg); padding: 20px 22px; }
.hero .label { font-size: 12px; color: var(--muted); font-weight: 600; }
.hero-value { font-size: 48px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; margin: 4px 0; }
.hero-side { border-left: 1px solid var(--border); padding-left: 16px; }
.hero-lost { font-size: 26px; font-weight: 800; margin: 4px 0; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.grid3 > .field + .field { margin-top: 0; }

.viz-wrap { position: relative; }
.viz-scroll { overflow-x: auto; }
.viz { display: block; width: 100%; min-width: 520px; height: auto; }
.viz-grid { stroke: #ececea; stroke-width: 1; }
.viz-axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.viz-hit { fill: transparent; cursor: default; }
.viz-hit:hover { fill: rgba(17,17,17,.04); }
.viz-tip { position: absolute; z-index: 3; min-width: 150px; max-width: 220px; background: #111; color: #fff; border-radius: 10px; padding: 8px 10px; font-size: 12px; pointer-events: none; }
.viz-tip-title { font-weight: 700; margin-bottom: 3px; }
.viz-tip-row { display: flex; align-items: center; gap: 6px; }
.viz-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 8px; font-size: 12px; color: var(--text2); }
.viz-key { display: inline-flex; align-items: center; gap: 6px; }
.viz-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.viz-scale { display: flex; align-items: center; gap: 4px; margin-top: 8px; }
.viz-scale .viz-swatch { width: 18px; }
.viz-table { margin-top: 10px; }
.viz-table summary { cursor: pointer; color: var(--primary); font-weight: 600; font-size: 13px; }
.viz-table .table-wrap { margin-top: 8px; }

.barlist { display: grid; gap: 8px; }
.barlist-row { display: grid; grid-template-columns: minmax(120px, 1.2fr) 2fr auto; gap: 10px; align-items: center; font-size: 13px; }
.barlist-label { color: var(--text2); }
.barlist-track { height: 10px; background: var(--surface2); border-radius: 999px; overflow: hidden; }
.barlist-fill { display: block; height: 100%; border-radius: 999px; }
.barlist-value { color: var(--text); font-weight: 600; white-space: nowrap; }

/* ── Billing details ───────────────────────────────────────────────────── */
.venue-billing { padding: 14px 18px; }
.venue-billing + .venue-billing { margin-top: 10px; }
.venue-billing summary { cursor: pointer; }

@media (max-width: 860px) {
  .kpis-8 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { grid-template-columns: 1fr; }
  .hero-side { border-left: 0; padding-left: 0; border-top: 1px solid var(--border); padding-top: 12px; }
  .hero-value { font-size: 38px; }
  .grid3 { grid-template-columns: 1fr; }
  .barlist-row { grid-template-columns: 1fr; }
  .lanes { grid-template-columns: 1fr; }
}
