/* Dobaara Studio owner panel: black and white, calm, dense enough for a desk, comfortable on a phone. */
:root {
  --bg: #ffffff; --surface: #ffffff; --fg: #0a0a0a; --muted: #5c5c5c; --faint: #8a8a8a; --line: #e2e2e2; --line-strong: #c9c9c9;
  --soft: #f5f5f5; --inv-bg: #0a0a0a; --inv-fg: #ffffff; --bar: #0a0a0a; --bar-dim: #c9c9c9;
  --radius: 10px; --side: 232px;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a0a; --surface: #111111; --fg: #f5f5f5; --muted: #a3a3a3; --faint: #737373; --line: #262626; --line-strong: #3a3a3a;
    --soft: #171717; --inv-bg: #f5f5f5; --inv-fg: #0a0a0a; --bar: #f5f5f5; --bar-dim: #404040;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { min-height: 100dvh; font-size: 15px; line-height: 1.5; -webkit-text-size-adjust: 100%; font-variant-numeric: tabular-nums; }
.boot { color: var(--muted); text-align: center; margin-top: 30vh; }
h1 { font-size: 26px; letter-spacing: -0.02em; margin: 0; line-height: 1.2; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0; font-weight: 600; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 20px 0 8px; font-weight: 600; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
a { color: inherit; }

/* Brand */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -0.01em; }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; letter-spacing: 0; }
.brand .mark { width: 30px; height: 30px; border-radius: 8px; background: var(--inv-bg); color: var(--inv-fg); display: grid; place-items: center; font-size: 15px; flex: none; }

/* Sign-in */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 420px; border: 1px solid var(--line); border-radius: 14px; padding: 28px; background: var(--surface); }
.auth-card h1 { margin: 24px 0 4px; }
.auth-card button[type=submit], .auth-card > button { width: 100%; }
.foot { margin-top: 24px; font-size: 13px; color: var(--muted); text-align: center; }

/* Shell */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100dvh; }
.side { border-right: 1px solid var(--line); padding: 20px 16px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100dvh; background: var(--bg); }
.side .biz { font-weight: 600; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { text-decoration: none; padding: 9px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.side nav a:hover { background: var(--soft); color: var(--fg); }
.side nav a[aria-current="page"] { background: var(--inv-bg); color: var(--inv-fg); }
.side .me { margin-top: auto; font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.content { padding: 28px 32px 48px; max-width: 1200px; width: 100%; outline: none; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }

/* Controls */
input, select {
  font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 9px 12px; min-height: 42px; width: 100%; outline: none;
}
input:focus, select:focus { border-color: var(--fg); box-shadow: 0 0 0 3px color-mix(in srgb, var(--fg) 14%, transparent); }
button {
  font: inherit; font-weight: 600; border-radius: 8px; min-height: 42px; padding: 9px 16px; cursor: pointer;
  background: var(--inv-bg); color: var(--inv-fg); border: 1px solid var(--inv-bg); margin-top: 14px;
}
button.ghost { background: transparent; color: var(--fg); border-color: var(--line-strong); }
button.danger { background: transparent; color: var(--fg); border: 2px solid var(--fg); }
button.link { background: none; border: none; color: var(--fg); text-decoration: underline; min-height: 0; padding: 4px 0; margin: 0; font-weight: 500; }
button.narrow { width: auto; }
button:disabled { opacity: 0.45; cursor: default; }
button:focus-visible, a:focus-visible, select:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
.field label { display: block; font-weight: 600; font-size: 13px; margin: 12px 0 5px; }
.hint { font-weight: 400; color: var(--muted); margin-left: 6px; }
.err { border: 2px solid var(--fg); border-radius: 8px; padding: 10px 12px; margin-top: 12px; font-weight: 500; }
.err::before { content: "! "; font-weight: 800; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; padding: 3px; gap: 2px; }
.seg button { margin: 0; min-height: 32px; padding: 4px 12px; background: transparent; color: var(--muted); border: 0; font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--inv-bg); color: var(--inv-fg); }
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input { flex: 1 1 240px; width: auto; }
.toolbar select { flex: 0 1 200px; width: auto; }
.toolbar button { margin: 0; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 16px; }
.grid-form .span { grid-column: 1 / -1; }
[hidden] { display: none !important; }

/* Cards and tiles */
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; background: var(--surface); margin-bottom: 16px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.note { background: var(--soft); border-style: dashed; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; background: var(--surface); min-width: 0; }
.t-label { font-size: 13px; color: var(--muted); }
.t-value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin: 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-change { font-size: 12px; font-weight: 600; }
.t-change.down, .t-change.flat { color: var(--muted); }
.t-note { font-size: 12px; color: var(--muted); }
.cols { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; }
.kv { display: grid; gap: 6px; }
.kv div { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 6px 0; }
.meter { margin: 10px 0; }
.m-row { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.m-track { height: 8px; background: var(--soft); border-radius: 4px; overflow: hidden; border: 1px solid var(--line); }
.m-fill { height: 100%; background: var(--fg); border-radius: 4px; }
.m-fill.full { background: repeating-linear-gradient(135deg, var(--fg) 0 4px, transparent 4px 7px); }

/* Tables */
.scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.card:not(.flush) .table th:first-child, .card:not(.flush) .table td:first-child { padding-left: 0; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; }
.table .act { text-align: right; white-space: nowrap; }
.table tr.off td { color: var(--faint); }
.table .share { width: 32%; }
.share-in { display: flex; align-items: center; gap: 8px; }
.share-in .small { min-width: 34px; text-align: right; }
.bar { flex: 1; height: 6px; background: var(--soft); border-radius: 3px; overflow: hidden; }
.bar div { height: 100%; background: var(--fg); border-radius: 0 3px 3px 0; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; border: 1px solid currentColor; border-radius: 4px; padding: 0 5px; margin-left: 6px; vertical-align: 1px; }
ul.rows { list-style: none; margin: 0; padding: 0; }
ul.rows li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
ul.rows li:last-child { border-bottom: 0; }
ul.log li { padding: 11px 18px; }
ul.log time { white-space: nowrap; }
.list-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 4px 0 16px; }
.list-foot button { margin: 0; }

/* Chart: one series, thin bars, rounded tops on the baseline, recessive grid */
.chart-wrap { position: relative; }
.chart { width: 100%; height: auto; max-height: 260px; display: block; overflow: visible; touch-action: pan-y; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { stroke: var(--line-strong); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart .bar { fill: var(--bar); transition: fill 0.12s; }
.chart .bar.zero { stroke: var(--line-strong); stroke-width: 2; fill: none; }
.chart .bar.dim { fill: var(--bar-dim); }
.tip { position: absolute; top: 0; transform: translateX(-50%); background: var(--inv-bg); color: var(--inv-fg); border-radius: 8px; padding: 8px 10px; font-size: 12px; pointer-events: none; white-space: nowrap; box-shadow: 0 4px 16px rgba(0,0,0,.18); }
.tip .muted { color: color-mix(in srgb, var(--inv-fg) 70%, transparent); }
.as-table { margin-top: 10px; font-size: 13px; }
.as-table summary { cursor: pointer; color: var(--muted); }
.as-table table { margin-top: 8px; }

/* Program */
.preview { border-left: 3px solid var(--fg); padding: 6px 12px; margin: 16px 0 0; background: var(--soft); border-radius: 0 6px 6px 0; }
ul.changes { list-style: none; padding: 0; margin: 8px 0; }
ul.changes li { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--line); }

/* Dialog and toast */
dialog.modal { border: 1px solid var(--line-strong); border-radius: 14px; padding: 24px; width: min(460px, calc(100vw - 32px)); background: var(--surface); color: var(--fg); }
dialog.modal::backdrop { background: rgba(0, 0, 0, 0.45); }
dialog.modal h2 { font-size: 18px; text-transform: none; letter-spacing: -0.01em; color: var(--fg); margin-bottom: 8px; }
dialog.modal .actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
dialog.modal .actions button { margin: 0; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--inv-bg); color: var(--inv-fg); padding: 12px 18px; border-radius: 10px; font-weight: 500; max-width: calc(100vw - 32px); box-shadow: 0 8px 28px rgba(0,0,0,.25); z-index: 10; }

/* Narrow screens: the side bar becomes a top bar with scrolling tabs */
@media (max-width: 1080px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 14px 16px 0; gap: 12px; display: grid; grid-template-columns: 1fr auto; align-items: center; }
  .side .biz, .side select { grid-column: 1 / -1; }
  .side nav { grid-column: 1 / -1; flex-direction: row; overflow-x: auto; gap: 4px; margin: 0 -16px; padding: 0 16px 12px; scrollbar-width: none; }
  .side nav a { white-space: nowrap; padding: 7px 12px; }
  .side .me { grid-row: 1; grid-column: 2; margin: 0; align-items: flex-end; }
  .side .me span { display: none; }
  .content { padding: 20px 16px 40px; }
  h1 { font-size: 22px; }
  .t-value { font-size: 21px; }
  .card { padding: 14px 16px; }
}
@media (max-width: 420px) { .tiles { gap: 8px; } .tile { padding: 12px; } .seg button { padding: 4px 9px; } }
@media (forced-colors: active) { .chart .bar { fill: CanvasText; } .chart .bar.dim { fill: GrayText; } }

/* Studio growth screens: insights, hours, codes, levels */
.insights { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-bottom: 16px; }
.insight { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; background: var(--surface); min-width: 0; }
.insight h3 { font-size: 16px; text-transform: none; letter-spacing: -0.01em; color: var(--fg); margin: 8px 0 4px; line-height: 1.35; }
.insight .tag { margin-left: 0; }
.insight.warn { border-left: 4px solid var(--fg); }
.insight.good { border-left: 4px double var(--fg); }
.insight.idea { border-left: 4px dashed var(--fg); }
.chart .col { fill: var(--bar); }
.chart .col.quiet { fill: url(#hatch); stroke: var(--fg); stroke-width: 1; }
.chart .hatch-bg { fill: var(--surface); }
.chart .hatch-line { stroke: var(--fg); stroke-width: 2; }
.legend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 8px 0 0; }
.legend .key { display: inline-block; width: 12px; height: 12px; border-radius: 2px; border: 1px solid var(--fg); margin-left: 8px; }
.legend .key:first-child { margin-left: 0; }
.legend .key.solid { background: var(--fg); }
.legend .key.hatched { background: repeating-linear-gradient(135deg, var(--fg) 0 2px, transparent 2px 5px); }
.days { display: flex; flex-wrap: wrap; gap: 6px 14px; }
label.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; font-size: 14px; margin: 12px 0 0; }
label.check input { width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--fg); }
.days label.check { margin: 4px 0 0; }
.levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.level { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 4px; }
.lv-num { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.table.edit td { padding: 6px 6px; vertical-align: middle; }
.table.edit input, .table.edit select { min-height: 36px; padding: 6px 8px; min-width: 80px; }
.table.edit .lv-name { min-width: 140px; }
.grid-form.in-modal { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
dialog.modal:has(.in-modal) { width: min(720px, calc(100vw - 32px)); }
dialog.modal { max-height: calc(100dvh - 32px); overflow-y: auto; }

/* customer value (RFM) */
.two { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; }
@media (max-width: 860px) { .two { grid-template-columns: minmax(0, 1fr); } }
table.heatmap { border-collapse: separate; border-spacing: 3px; margin: 6px 0; }
table.heatmap th { font-size: 12px; color: var(--muted); font-weight: 600; padding: 4px 6px; text-align: center; }
table.heatmap td.heat { width: 56px; height: 40px; text-align: center; font-weight: 600; font-size: 13px; border-radius: 6px; border: 1px solid var(--line); }
.calc-scores { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 8px; }
.calc-box { border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 12px; min-width: 76px; display: grid; }
.calc-box b { font-size: 18px; }
.calc-box span { font-size: 12px; color: var(--muted); }
.seg-list { display: grid; gap: 6px; margin: 8px 0; }
#rfm-calc details { margin-top: 10px; }
#rfm-calc summary { cursor: pointer; font-weight: 600; }
ul.kv { list-style: none; padding: 0; margin: 6px 0 0; }
ul.kv li { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
ul.kv li:last-child { border-bottom: 0; }
ul.kv li > b { white-space: nowrap; }
label.small input[type="checkbox"], .seg-list input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; margin: 0 6px 0 0; vertical-align: -3px; accent-color: var(--fg); }
label.small { display: block; margin: 10px 0; }

/* Connected cafés (our team) */
.pairs { display: grid; gap: 12px; margin-top: 12px; }
.pair .m-track { height: 7px; }
.pair .m-track + .m-track { margin-top: 2px; }
.summary { width: 100%; font: 13px/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace; color: var(--fg); background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-top: 12px; resize: vertical; }
.err-text { color: var(--fg); font-weight: 600; }
.err-text::before { content: "! "; }
.cafe-link { font-weight: 600; }
