/* Mitus Labs CRM: graphite + steel, signal red for actions. Light and dark. */
:root {
  color-scheme: light;
  --bg: #e9eaec; --surface: #fbfbfb; --surface-2: #f2f3f4; --line: rgba(23,25,28,.12); --line-2: rgba(23,25,28,.22);
  --text: #17191c; --text-2: #4a5059; --muted: #6b727b;
  --side: #17191c; --side-text: #a9afb7; --side-active: #f2f3f5;
  --accent: #c8162d; --accent-ink: #fff;
  --s-visitors: #2a78d6; --s-signups: #eb6834; --s-revenue: #1baf7a; --grid: #e3e4e6;
  --good: #0f7a3d; --warn: #9a6400; --bad: #b3261e; --info: #2a5fa8;
  --radius: 12px; --sans: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif; --mono: 'JetBrains Mono', ui-monospace, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111214; --surface: #1a1b1e; --surface-2: #222428; --line: rgba(255,255,255,.09); --line-2: rgba(255,255,255,.18);
    --text: #eef0f2; --text-2: #c2c6cc; --muted: #939aa3; --side: #0b0c0d;
    --s-visitors: #3987e5; --s-signups: #d95926; --s-revenue: #199e70; --grid: #2a2c30;
    --good: #4cc27e; --warn: #e0a83a; --bad: #f07b72; --info: #7fb0ef;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111214; --surface: #1a1b1e; --surface-2: #222428; --line: rgba(255,255,255,.09); --line-2: rgba(255,255,255,.18);
  --text: #eef0f2; --text-2: #c2c6cc; --muted: #939aa3; --side: #0b0c0d;
  --s-visitors: #3987e5; --s-signups: #d95926; --s-revenue: #199e70; --grid: #2a2c30;
  --good: #4cc27e; --warn: #e0a83a; --bad: #f07b72; --info: #7fb0ef;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 1.45rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1rem; margin: 0 0 12px; }
.boot { padding: 40px; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: .85rem; } .mono { font-family: var(--mono); font-size: .85em; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { color: #f2f3f5; font-weight: 700; letter-spacing: .12em; font-size: .85rem; padding: 6px 10px 18px; }
.brand b { color: var(--accent); }
.side a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; text-decoration: none; font-weight: 500; }
.side a:hover { color: var(--side-active); background: rgba(255,255,255,.05); }
.side a[aria-current="page"] { color: var(--side-active); background: rgba(255,255,255,.09); }
.side svg { width: 18px; height: 18px; flex: none; }
.side .grow { flex: 1; }
.main { padding: 24px clamp(16px, 3vw, 36px) 80px; min-width: 0; max-width: 1280px; }
.head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.head .actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* controls */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; font-weight: 600; font-size: .9rem; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--text-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn:disabled { opacity: .55; cursor: wait; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .seg button:focus-visible, .side a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input, select, textarea { background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; width: 100%; min-width: 0; }
textarea { min-height: 80px; resize: vertical; }
label.f { display: grid; gap: 4px; font-size: .82rem; color: var(--text-2); font-weight: 500; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; cursor: pointer; font-weight: 600; font-size: .85rem; color: var(--text-2); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar input[type=search] { max-width: 320px; }

/* cards & tiles */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.cards { display: grid; gap: 16px; }
.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .k { font-size: .8rem; color: var(--muted); font-weight: 500; }
.tile .v { font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; }
.tile .d { font-size: .8rem; color: var(--muted); }
.d .up { color: var(--good); } .d .down { color: var(--bad); }
.stack { display: grid; gap: 16px; align-content: start; }
#view > .cards, #view > .card, #view > .tiles { margin-bottom: 16px; }
.pre { white-space: pre-wrap; }

/* charts */
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .bar.hover { filter: brightness(1.15); }
.tip { position: absolute; pointer-events: none; background: var(--text); color: var(--surface); padding: 6px 9px; border-radius: 7px; font-size: .8rem; white-space: nowrap; transform: translate(-50%, -100%); opacity: 0; transition: opacity .1s; z-index: 2; }
.tip.on { opacity: 1; }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.chart-head .total { font-weight: 700; font-variant-numeric: tabular-nums; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.key.visitors { background: var(--s-visitors); } .key.signups { background: var(--s-signups); } .key.revenue { background: var(--s-revenue); }

/* hbar list (sources / funnel) */
.hlist { display: grid; gap: 10px; }
.hrow { display: grid; grid-template-columns: minmax(90px, 140px) 1fr auto; align-items: center; gap: 10px; font-size: .9rem; }
.hrow .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hrow svg { width: 100%; height: 10px; display: block; }
.hrow .val { font-variant-numeric: tabular-nums; color: var(--text-2); font-size: .85rem; white-space: nowrap; }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr.link { cursor: pointer; } tbody tr.link:hover { background: var(--surface-2); }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* pills */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: .75rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--text-2); white-space: nowrap; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.good { color: var(--good); } .pill.warn { color: var(--warn); } .pill.bad { color: var(--bad); } .pill.info { color: var(--info); }

/* kanban */
.board { display: grid; grid-template-columns: repeat(5, minmax(180px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-height: 120px; }
.col h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); margin: 2px 4px 10px; display: flex; justify-content: space-between; }
.deal { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; display: grid; gap: 6px; }
.deal .t { font-weight: 600; } .deal select { padding: 4px 6px; font-size: .82rem; }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.timeline li { display: grid; grid-template-columns: 74px 1fr; gap: 10px; font-size: .9rem; }
.timeline .when { color: var(--muted); font-size: .78rem; padding-top: 2px; }
.timeline .kind { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin-right: 6px; }
.timeline .body { white-space: pre-wrap; overflow-wrap: anywhere; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--side); }
.auth .card { width: 100%; max-width: 380px; display: grid; gap: 14px; padding: 26px; }
.auth h1 { font-size: 1.2rem; }
.auth .qr { background: #fff; padding: 12px; border-radius: 10px; width: fit-content; margin: 0 auto; }
.auth .qr img, .auth .qr canvas { display: block; width: 180px; height: 180px; }
.err { color: var(--bad); font-size: .88rem; min-height: 1.2em; margin: 0; }

/* modal & toast */
dialog { border: 1px solid var(--line-2); border-radius: 14px; padding: 0; background: var(--surface); color: var(--text); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog form { padding: 20px; display: grid; gap: 12px; }
dialog .row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
dialog .row .left { margin-right: auto; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: .9rem; opacity: 0; transition: .2s; pointer-events: none; z-index: 50; max-width: calc(100vw - 32px); }
#toast.on { opacity: 1; transform: translateX(-50%); }
.copy { display: flex; gap: 6px; align-items: center; min-width: 0; }
.copy code { font-family: var(--mono); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: .9rem; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
ol.steps { padding-left: 1.2em; margin: 0; display: grid; gap: 6px; font-size: .9rem; color: var(--text-2); }

/* responsive */
@media (max-width: 1100px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } .c3 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; flex-direction: row; justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 20; gap: 0; }
  .side .brand, .side .grow, .side .wide-only { display: none; }
  .side a { flex-direction: column; gap: 2px; font-size: .68rem; padding: 6px 4px; flex: 1; text-align: center; }
  .main { padding-bottom: 110px; }
  .c2 { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2 { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .board { grid-template-columns: repeat(5, 78vw); scroll-snap-type: x mandatory; } .col { scroll-snap-align: start; }
  .kv { grid-template-columns: 110px 1fr; }
}
.auth .brand { color: var(--text); padding: 0 0 6px; }
.chart .bar { pointer-events: none; }
.hlist.geo .hrow { grid-template-columns: minmax(120px, 240px) 1fr auto; }
@media (max-width: 860px) {
  .hlist.geo .hrow, .hlist .hrow { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name val" "bar bar"; row-gap: 4px; }
  .hrow .name { grid-area: name; } .hrow .val { grid-area: val; } .hrow svg { grid-area: bar; }
  .chart-head { flex-wrap: wrap; }
}
