/* Sabibot dashboard. The one memorable idea is embroidery: quotas are running stitches,
   dividers are stitched lines, and the connection is a thread that is solid when linked. */

:root {
  --chalk: #f3f4f1;
  --surface: #ffffff;
  --surface-2: #eceee9;
  --ink: #22306b;
  --ink-soft: #3d4d8f;
  --on-ink: #ffffff;
  --text: #1b1f2a;
  --muted: #5c6475;
  --line: #d3d8df;
  --thread: #d6334b;
  --moss: #2f7d5b;
  --saffron: #b87a0c;
  --moss-bg: #e3f1ea;
  --saffron-bg: #f7ecd5;
  --thread-bg: #fbe3e7;
  --ink-bg: #e4e8f7;
  --shadow: 0 1px 0 rgba(27, 31, 42, 0.04);
  --radius: 10px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  --nav-h: 62px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --chalk: #12151f;
    --surface: #1a1f2e;
    --surface-2: #222839;
    --ink: #9aabff;
    --ink-soft: #b4c0ff;
    --on-ink: #10142a;
    --text: #e8eaf1;
    --muted: #9aa2b6;
    --line: #313852;
    --thread: #ff6b81;
    --moss: #5fc59a;
    --saffron: #e6b04c;
    --moss-bg: #1b2f28;
    --saffron-bg: #332a16;
    --thread-bg: #3a1c24;
    --ink-bg: #232a4a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--chalk);
  color: var(--text);
  font: 15px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--ink); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- shell ---------- */
.shell { min-height: 100vh; }
.nav {
  position: fixed; z-index: 10; left: 0; right: 0; bottom: 0; height: var(--nav-h);
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--muted); font-size: 11.5px; font-weight: 600;
}
.nav a svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav a[aria-current="page"] { color: var(--ink); }
.brand { display: none; }
.main { padding: 20px 16px calc(var(--nav-h) + 28px); max-width: 960px; margin: 0 auto; }

@media (min-width: 860px) {
  .nav {
    top: 0; bottom: auto; right: auto; width: 208px; height: 100vh; flex-direction: column;
    border-top: 0; border-right: 1px solid var(--line); padding: 18px 12px; gap: 2px;
  }
  .nav a { flex: 0; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 10px 12px; font-size: 14.5px; border-radius: 8px; }
  .nav a[aria-current="page"] { background: var(--ink-bg); }
  .brand { display: block; font-size: 19px; font-weight: 800; letter-spacing: -0.02em; color: var(--ink); padding: 4px 12px 18px; }
  .main { margin-left: 208px; padding: 32px 36px 48px; max-width: none; }
  .main > .wrap { max-width: 900px; }
}

/* ---------- type ---------- */
h1 { font-size: 26px; line-height: 1.15; letter-spacing: -0.025em; font-weight: 780; margin: 0 0 4px; }
h2 { font-size: 16px; letter-spacing: -0.01em; font-weight: 720; margin: 0 0 10px; }
.sub { color: var(--muted); margin: 0 0 22px; max-width: 60ch; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.head .sub { margin: 0; }

/* ---------- stitched structure ---------- */
.stitch-rule { height: 0; border: 0; border-top: 2px dashed var(--line); margin: 22px 0; }
.thread {
  height: 4px; border-radius: 2px; margin-top: 18px;
  background: repeating-linear-gradient(90deg, var(--line) 0 7px, transparent 7px 11px);
}
.thread[data-state="open"] { background: var(--ink); }
.thread[data-state="busy"] {
  background: repeating-linear-gradient(90deg, var(--ink) 0 7px, transparent 7px 11px);
  background-size: 22px 4px; animation: march 1.1s linear infinite;
}
.thread[data-state="down"] { background: repeating-linear-gradient(90deg, var(--thread) 0 7px, transparent 7px 18px); }
@keyframes march { to { background-position-x: 22px; } }
@media (prefers-reduced-motion: reduce) { .thread[data-state="busy"] { animation: none; } }

.meter { margin: 14px 0; }
.meter-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.meter-top b { font-weight: 650; }
.meter-track, .meter-fill { height: 6px; border-radius: 3px; }
.meter-track { position: relative; background: repeating-linear-gradient(90deg, var(--line) 0 7px, transparent 7px 11px); }
.meter-fill { position: absolute; inset: 0 auto 0 0; background: repeating-linear-gradient(90deg, var(--ink) 0 7px, transparent 7px 11px); }
.meter[data-level="high"] .meter-fill { background: repeating-linear-gradient(90deg, var(--thread) 0 7px, transparent 7px 11px); }

/* ---------- surfaces ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.panel + .panel, .stack > * + * { margin-top: 14px; }
.grid2 { display: grid; gap: 14px; }
@media (min-width: 720px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

.hero { padding: 22px 20px 20px; }
.hero-state { font-size: clamp(34px, 8vw, 48px); line-height: 1; letter-spacing: -0.035em; font-weight: 800; margin: 2px 0 6px; }
.hero-state[data-state="down"] { color: var(--thread); }
.hero-line { color: var(--muted); margin: 0; }

.qr-wrap { display: flex; gap: 22px; align-items: flex-start; flex-wrap: wrap; margin-top: 16px; }
.qr { width: 232px; height: 232px; background: #fff; border-radius: 8px; padding: 6px; border: 1px solid var(--line); }
.qr svg { width: 100%; height: 100%; display: block; }
.steps-list { margin: 0; padding-left: 20px; flex: 1; min-width: 220px; }
.steps-list li { margin: 0 0 8px; }
.code {
  font-size: 30px; font-weight: 800; letter-spacing: 0.2em; font-variant-numeric: tabular-nums;
  background: var(--ink-bg); color: var(--ink); padding: 10px 16px; border-radius: 8px; display: inline-block;
}

.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 720px) { .facts { grid-template-columns: repeat(4, 1fr); } }
.fact { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; text-decoration: none; color: inherit; display: block; }
a.fact:hover { border-color: var(--ink); }
.fact b { display: block; font-size: 24px; letter-spacing: -0.02em; font-weight: 760; line-height: 1.2; }
.fact span { color: var(--muted); font-size: 13px; }

/* a one-line nudge that links to where the problem is fixed; a dashed edge like a stitched hem */
.callout {
  display: block; padding: 11px 14px; border-radius: var(--radius); text-decoration: none; color: var(--text);
  background: var(--saffron-bg); border: 2px dashed var(--saffron);
}
.callout:hover { border-style: solid; }
.code-box {
  display: block; margin-top: 4px; padding: 7px 10px; border-radius: 6px; background: var(--surface-2);
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; overflow-wrap: anywhere; user-select: all;
}

/* ---------- controls ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: 9px 14px; border-radius: 8px; font-weight: 640; cursor: pointer; min-height: 40px;
}
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--thread); border-color: var(--thread); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--ink); padding-inline: 8px; }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn[disabled] { opacity: 0.55; cursor: default; }

.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-weight: 640; margin-bottom: 4px; }
.field small { display: block; color: var(--muted); margin-top: 4px; font-size: 13px; }
input[type="text"], input[type="password"], input[type="number"], input[type="search"], input[type="tel"], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); min-height: 40px;
}
textarea { min-height: 84px; resize: vertical; line-height: 1.45; }
textarea.code-area { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; min-height: 320px; }
input:focus, select:focus, textarea:focus { border-color: var(--ink); outline: 2px solid var(--ink-bg); }
.fields { display: grid; gap: 0 14px; }
@media (min-width: 640px) { .fields.two { grid-template-columns: 1fr 1fr; } .fields.three { grid-template-columns: repeat(3, 1fr); } }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; }
.switch input { appearance: none; width: 46px; height: 26px; border-radius: 13px; background: var(--line); position: relative; cursor: pointer; flex: none; transition: background 0.15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked { background: var(--ink); }
.switch input:checked::after { transform: translateX(20px); }
@media (prefers-reduced-motion: reduce) { .switch input, .switch input::after { transition: none; } }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 12px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }

.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 650; background: var(--surface-2); color: var(--muted); }
.pill.ok { background: var(--moss-bg); color: var(--moss); }
.pill.warn { background: var(--saffron-bg); color: var(--saffron); }
.pill.bad { background: var(--thread-bg); color: var(--thread); }
.pill.info { background: var(--ink-bg); color: var(--ink); }

/* ---------- lists ---------- */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.item { padding: 12px 16px; display: flex; gap: 12px; align-items: center; }
.item + .item { border-top: 2px dashed var(--line); }
.item .grow b { font-weight: 650; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--ink-bg); color: var(--ink); display: grid; place-items: center; font-weight: 750; flex: none; }
.expand { padding: 4px 16px 14px 64px; }
.empty { padding: 28px 18px; text-align: left; color: var(--muted); }
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }

/* ---------- sequences ---------- */
.step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.step + .step { margin-top: 10px; }
.step-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.step-head .num { width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: var(--on-ink); display: grid; place-items: center; font-size: 12.5px; font-weight: 750; flex: none; }
.case { display: grid; grid-template-columns: 1fr; gap: 8px; padding: 10px; border: 1px dashed var(--line); border-radius: 8px; margin-bottom: 8px; }
@media (min-width: 640px) { .case { grid-template-columns: 150px 1fr 150px auto; align-items: center; } }
.problems { background: var(--thread-bg); color: var(--thread); border-radius: 8px; padding: 10px 14px; margin: 0 0 14px; }
.problems ul { margin: 6px 0 0; padding-left: 18px; }

.chat { background: var(--surface-2); border-radius: var(--radius); padding: 12px; min-height: 160px; max-height: 360px; overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.bubble { max-width: 82%; padding: 7px 11px; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.me { align-self: flex-end; background: var(--ink); color: var(--on-ink); border-bottom-right-radius: 3px; }
.bubble.bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.note { align-self: center; color: var(--muted); font-size: 12.5px; padding: 2px 10px; border: 1px dashed var(--line); border-radius: 999px; }

.toast { position: fixed; z-index: 30; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 14px); background: var(--text); color: var(--chalk); padding: 10px 16px; border-radius: 8px; font-weight: 600; max-width: calc(100vw - 32px); }
.toast.bad { background: var(--thread); color: #fff; }
@media (min-width: 860px) { .toast { bottom: 24px; left: calc(50% + 104px); } }

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .panel { width: 100%; max-width: 380px; }
.login h1 { font-size: 30px; }
