/* Navbatchi dashboard. Tokens follow flarestamina.com's paper design system. */
@font-face { font-family: Inter; src: url(/fonts/Inter-Regular.ttf) format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: Inter; src: url(/fonts/Inter-Medium.ttf) format("truetype"); font-weight: 500 700; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url(/fonts/PlexMono-Regular.ttf) format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url(/fonts/PlexMono-Medium.ttf) format("truetype"); font-weight: 500 700; font-display: swap; }

:root {
  --bg: #fff; --elev: #fff; --surface: #f7f7f6;
  --fg: #0a0a0a; --muted: #5c5c5c; --subtle: #6b6b6b; --dim: #8a8a8a;
  --border: color-mix(in oklab, #0a0a0a 10%, transparent);
  --border-strong: color-mix(in oklab, #0a0a0a 18%, transparent);
  --card: 0 0 0 1px rgb(10 10 10 / .08), 0 1px 2px rgb(10 10 10 / .04);
  --card-hover: 0 0 0 1px rgb(10 10 10 / .14), 0 8px 24px -16px rgb(10 10 10 / .18);
  --rail: linear-gradient(90deg, #2dd4bf, #38bdf8 32%, #818cf8 64%, #e879f9 100%);
  --ok: #15803d; --warn: #b45309; --bad: #b91c1c; --attn: #ea580c; --run: #2563eb;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --wrap: 78rem;
  color-scheme: light;
}
html.dark {
  --bg: #000; --elev: #0a0a0a; --surface: #0f0f0f;
  --fg: #f5f5f5; --muted: #9a9a9a; --subtle: #808080; --dim: #5c5c5c;
  --border: color-mix(in oklab, #f5f5f5 12%, transparent);
  --border-strong: color-mix(in oklab, #f5f5f5 22%, transparent);
  --card: 0 0 0 1px rgb(255 255 255 / .1);
  --card-hover: 0 0 0 1px rgb(255 255 255 / .2);
  --ok: #4ade80; --warn: #fbbf24; --bad: #f87171; --attn: #fb923c; --run: #60a5fa;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 400 15px/1.5 var(--sans); font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased; min-height: 100vh; display: flex; flex-direction: column;
}
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; border-radius: 6px; }
.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px); }
main.wrap { flex: 1; }
.grow { flex: 1; }
.px { image-rendering: pixelated; image-rendering: crisp-edges; }
.mono { font-family: var(--mono); }

/* ---- header ---- */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in oklab, var(--bg) 86%, transparent); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--border); }
.top-in { display: flex; align-items: center; gap: 14px; height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand canvas { width: 26px; height: 24px; }
.conn { display: inline-flex; align-items: center; gap: 7px; font: 500 12px/1 var(--mono); color: var(--muted); }
.conn { min-width: 0; }
.conn > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn i { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); flex: none; }
.conn[data-on="1"] i { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ok) 20%, transparent); }
.conn[data-on="-1"] i { background: var(--bad); }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 9px; background: transparent; cursor: pointer; }
.icon-btn:hover { background: var(--surface); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.i-sun { display: none; }
html.dark .i-sun { display: block; }
html.dark .i-moon { display: none; }

/* ---- banner ---- */
.banner { margin-top: 18px; padding: 12px 14px; border-radius: 12px; box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--warn) 45%, transparent); background: color-mix(in oklab, var(--warn) 7%, transparent); font-size: 14px; }
.banner code { font: 500 13px var(--mono); }

/* ---- hero ---- */
.hero { padding: 36px 0 30px; border-bottom: 1px solid var(--border); }
.hero-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 28px; align-items: center; }
.buddy { width: 130px; height: 120px; }
.kicker { margin: 0; font: 500 11.5px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 10px; }
.kicker::before { content: ""; width: 28px; height: 3px; border-radius: 2px; background: var(--rail); }
h1 { margin: 12px 0 8px; font: 600 clamp(30px, 4.4vw, 52px)/1.04 var(--sans); letter-spacing: -.04em; text-wrap: balance; }
h1[data-tone="attn"] { color: var(--attn); }
h1[data-tone="bad"] { color: var(--bad); }
.lede { margin: 0; color: var(--muted); font-size: 16px; }

.limits { width: 250px; display: grid; gap: 14px; }
.limit-row { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.limit-row b { font: 500 13px var(--mono); }
.bar { height: 6px; border-radius: 4px; background: var(--border); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: 4px; background: var(--fg); transition: width .4s; }
.bar[data-tone="warn"] i { background: var(--warn); }
.bar[data-tone="bad"] i { background: var(--bad); }
.limit-note { margin: 0; font: 11.5px var(--mono); color: var(--subtle); }

.live { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-top: 28px; }
.live:empty { display: none; }
.card { position: relative; display: flex; flex-direction: column; gap: 8px; padding: 15px 16px 14px; border-radius: 14px; background: var(--elev); box-shadow: var(--card); transition: box-shadow .15s; cursor: default; }
.card[data-open] { cursor: pointer; }
.card:hover { box-shadow: var(--card-hover); }
.card[data-s="needs_you"] { box-shadow: 0 0 0 1.5px var(--attn), 0 10px 28px -18px var(--attn); }
.card[data-s="failed"] { box-shadow: 0 0 0 1.5px var(--bad); }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card h3 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -.015em; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-detail { margin: 0; font: 12.5px/1.45 var(--mono); color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 2px; font: 12px var(--mono); color: var(--subtle); }

/* ---- chips ---- */
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 5px 9px; border-radius: 999px; font: 500 11.5px/1 var(--mono); letter-spacing: .01em; white-space: nowrap; color: var(--dim); box-shadow: inset 0 0 0 1px currentColor; }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.chip[data-s="needs_you"] { color: var(--attn); background: color-mix(in oklab, var(--attn) 9%, transparent); }
.chip[data-s="working"] { color: var(--run); }
.chip[data-s="working"]::before { animation: pulse 1.4s ease-in-out infinite; }
.chip[data-s="done"] { color: var(--ok); }
.chip[data-s="failed"] { color: var(--bad); background: color-mix(in oklab, var(--bad) 8%, transparent); }
.chip[data-s="stale"] { color: var(--warn); }
.chip[data-s="idle"], .chip[data-s="ended"] { color: var(--dim); }
@keyframes pulse { 50% { opacity: .25; transform: scale(.75); } }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 13px; border: 0; border-radius: 9px; background: var(--elev); box-shadow: inset 0 0 0 1px var(--border-strong); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { box-shadow: inset 0 0 0 1px var(--fg); text-decoration: none; }
.btn.solid { background: var(--fg); color: var(--bg); box-shadow: none; }
.btn.solid:hover { opacity: .88; }
.btn.small { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn[aria-busy="true"] { opacity: .55; pointer-events: none; }

/* ---- kpis ---- */
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px; padding: 30px 0; border-bottom: 1px solid var(--border); }
.kpi { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px; align-items: center; padding-top: 14px; border-top: 2px solid var(--fg); }
.kpi[data-click] { cursor: pointer; }
.kpi b { font: 600 46px/1 var(--sans); letter-spacing: -.05em; min-width: 1ch; }
.kpi[data-tone="bad"] b { color: var(--bad); }
.kpi[data-tone="warn"] b { color: var(--warn); }
.kpi[data-tone="ok"] b { color: var(--dim); }
.kpi .t { font-weight: 600; letter-spacing: -.01em; line-height: 1.3; }
.kpi .s { color: var(--muted); font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }

/* ---- blocks ---- */
.block { padding: 34px 0 8px; }
.block-head { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 14px; margin-bottom: 14px; }
.block-head h2 { margin: 0; font-size: 28px; font-weight: 600; letter-spacing: -.035em; }
.count { font: 500 12.5px var(--mono); color: var(--muted); }
.group { margin: 18px 0 6px; font: 500 11px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.empty { padding: 26px 18px; border-radius: 14px; background: var(--surface); color: var(--muted); font-size: 14px; line-height: 1.55; }
.empty b { color: var(--fg); font-weight: 600; }

/* sessions */
.rows { border-top: 1px solid var(--border); }
.srow { display: grid; grid-template-columns: 136px minmax(0, 1fr) 112px 84px; gap: 16px; align-items: center; padding: 11px 4px; border-bottom: 1px solid var(--border); }
.srow > .chip { justify-self: start; }
.srow[data-open] { cursor: pointer; }
.srow[data-open]:hover { background: var(--surface); }
.srow .t { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: -.005em; }
.srow .d { font: 12.5px/1.5 var(--mono); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srow .d em { font-style: normal; color: var(--fg); }
.when { font: 12px var(--mono); color: var(--subtle); white-space: nowrap; }
.srow .act { justify-self: end; }

/* projects */
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); }
.seg button { height: 28px; padding: 0 11px; border: 0; border-radius: 7px; background: transparent; font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer; white-space: nowrap; }
.seg button span { font: 11.5px var(--mono); color: var(--subtle); }
.seg button[aria-selected="true"] { background: var(--elev); color: var(--fg); box-shadow: var(--card); }
.search { display: flex; align-items: center; gap: 7px; height: 34px; padding: 0 11px; border-radius: 10px; box-shadow: inset 0 0 0 1px var(--border-strong); background: var(--elev); }
.search:focus-within { box-shadow: inset 0 0 0 1.5px var(--fg); }
.search svg { width: 15px; height: 15px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; flex: none; }
.search input { width: 170px; border: 0; outline: 0; background: transparent; font: 13.5px var(--sans); color: var(--fg); }

.ptable { width: 100%; border-collapse: collapse; table-layout: fixed; }
.ptable th { text-align: left; padding: 10px 8px; font: 500 10.5px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--border-strong); white-space: nowrap; }
.ptable td { padding: 13px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.ptable tr:hover td { background: color-mix(in oklab, var(--surface) 70%, transparent); }
.c-name { width: 22%; } .c-what { width: auto; } .c-act { width: 120px; } .c-state { width: 186px; } .c-when { width: 104px; } .c-go { width: 164px; }
.pname { display: flex; align-items: center; gap: 11px; min-width: 0; }
.pname > div { min-width: 0; }
.pn { font-weight: 600; letter-spacing: -.01em; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub { font: 12px/1.45 var(--mono); color: var(--subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.desc.none { color: var(--dim); }
.fails { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 4px; font: 12px var(--mono); }
.fails a { color: var(--bad); }
.avatar { flex: none; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font: 600 11.5px/1 var(--mono); letter-spacing: .02em; }
.av0 { background: #fde8d8; color: #9a3412; } .av1 { background: #dbeafe; color: #1e40af; } .av2 { background: #dcfce7; color: #166534; }
.av3 { background: #f3e8ff; color: #6b21a8; } .av4 { background: #fef9c3; color: #854d0e; } .av5 { background: #ccfbf1; color: #115e59; }
.av6 { background: #fce7f3; color: #9d174d; } .av7 { background: #e5e7eb; color: #374151; }
html.dark .avatar { filter: saturate(.9) brightness(.82); }
.spark { display: flex; align-items: flex-end; gap: 2px; height: 24px; }
.spark i { width: 6px; min-height: 2px; border-radius: 1.5px; background: var(--fg); }
.spark i.z { opacity: .14; }
.pchips { display: flex; flex-wrap: wrap; gap: 5px; }
.pchip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 999px; font: 500 11.5px/1 var(--mono); white-space: nowrap; box-shadow: inset 0 0 0 1px currentColor; }
.pchip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pchip.bad { color: var(--bad); } .pchip.warn { color: var(--warn); } .pchip.run { color: var(--run); } .pchip.attn { color: var(--attn); }
.pchip.ok { color: var(--ok); } .pchip.dim { color: var(--dim); }
.go { display: flex; gap: 6px; justify-content: flex-end; }
.more { display: flex; justify-content: center; padding: 16px 0 4px; }

/* ---- footer + toast ---- */
.foot { margin-top: 40px; border-top: 1px solid var(--border); }
.foot-in { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 18px clamp(16px, 4vw, 40px) 26px; font: 12px/1.5 var(--mono); color: var(--subtle); }
.foot-in b { color: var(--muted); font-weight: 500; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 10px 16px; border-radius: 12px; background: var(--fg); color: var(--bg); font-size: 13.5px; font-weight: 500; transition: .2s; z-index: 30; max-width: calc(100vw - 32px); }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---- phone view (cmd.zitou.uz) and login ---- */
html.remote .local-only { display: none !important; }
.login { min-height: 62vh; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 4px; max-width: 34rem; padding: 48px 0; }
.login canvas { width: 104px; height: 96px; margin-bottom: 18px; }
.login h1 { margin: 0 0 10px; }
.login .lede b { color: var(--fg); font-weight: 600; }
.note { margin: 10px 0 0; font: 12.5px/1.5 var(--mono); color: var(--subtle); }
.linkish { border: 0; padding: 0; background: none; color: inherit; font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* ---- ask Navbatchi ---- */
.ask { padding: 30px 0 4px; }
.ask-form { display: flex; gap: 8px; }
.ask-form input { flex: 1; min-width: 0; height: 44px; padding: 0 14px; border: 0; border-radius: 12px; background: var(--elev); color: var(--fg); font: 15px var(--sans); box-shadow: inset 0 0 0 1px var(--border-strong); outline: 0; }
.ask-form input:focus { box-shadow: inset 0 0 0 1.5px var(--fg); }
.ask-form .btn { height: 44px; padding: 0 18px; border-radius: 12px; }
.ask-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ask-chips button { height: 30px; padding: 0 12px; border: 0; border-radius: 999px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); color: var(--muted); font-size: 13px; cursor: pointer; }
.ask-chips button:hover { color: var(--fg); box-shadow: inset 0 0 0 1px var(--border-strong); }
.ask-answer { margin-top: 14px; padding: 16px 18px; border-radius: 14px; background: var(--surface); line-height: 1.6; font-size: 15px; }
.ask-answer .ask-q { margin-bottom: 8px; font: 500 12px var(--mono); letter-spacing: .02em; color: var(--subtle); }
.ask-answer p { margin: 0 0 8px; }
.ask-answer p:last-child, .ask-answer ul:last-child { margin-bottom: 0; }
.ask-answer ul { margin: 0 0 8px; padding-left: 20px; }
.ask-answer li { margin: 2px 0; }
.ask-answer code { font: 13px var(--mono); }
.ask-answer .thinking { color: var(--muted); display: flex; align-items: center; gap: 10px; }
.ask-answer .thinking::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--attn); animation: pulse 1s ease-in-out infinite; }

/* ---- pairing dialog ---- */
.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgb(0 0 0 / .42); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.modal-card { position: relative; width: min(420px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 26px 24px 22px; border-radius: 18px; background: var(--elev); box-shadow: var(--card), 0 30px 80px -20px rgb(0 0 0 / .45); }
.modal-card h2 { margin: 0 0 6px; font-size: 22px; font-weight: 600; letter-spacing: -.03em; }
.modal-card .muted { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.modal-card .muted b { color: var(--fg); font-weight: 600; }
.close { position: absolute; top: 12px; right: 12px; }
.close svg { stroke-width: 2; }
.qr { margin: 18px auto 0; width: 248px; height: 248px; display: grid; place-items: center; border-radius: 14px; background: #fff; box-shadow: var(--card); overflow: hidden; }
.qr img { width: 236px; height: 236px; image-rendering: pixelated; }
.modal-row { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.devices { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); line-height: 1.6; }
.devices b { color: var(--fg); font-weight: 600; }

/* ---- narrow screens ---- */
@media (max-width: 960px) {
  .hero-head { grid-template-columns: auto minmax(0, 1fr); }
  .limits { grid-column: 1 / -1; width: 100%; grid-template-columns: 1fr 1fr; }
  .limit-note { grid-column: 1 / -1; }
  .c-act { display: none; }
}
@media (max-width: 760px) {
  .hero { padding-top: 24px; }
  .hero-head { gap: 16px; }
  .buddy { width: 78px; height: 72px; }
  .kpis { grid-template-columns: 1fr; gap: 18px; padding: 22px 0; }
  .kpi b { font-size: 38px; }
  .srow { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "chip when" "main main" "main main"; gap: 6px 10px; padding: 12px 2px; }
  .srow .chip { grid-area: chip; justify-self: start; }
  .srow .main { grid-area: main; }
  .srow .when { grid-area: when; justify-self: end; }
  .srow .act { display: none; }
  .block-head h2 { font-size: 24px; }
  .seg { order: 3; }
  .search { order: 4; flex: 1; }
  .search input { width: 100%; }
  #refresh { order: 2; }
  .ptable, .ptable tbody, .ptable tr, .ptable td { display: block; width: 100%; }
  .ptable thead { display: none; }
  .ptable tr { padding: 14px 0; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; }
  .ptable td { padding: 0; border: 0; }
  .ptable tr:hover td { background: none; }
  .ptable td.c-name { grid-column: 1; }
  .ptable td.c-when { grid-column: 2; grid-row: 1; text-align: right; }
  .ptable td.c-what, .ptable td.c-state, .ptable td.c-go { grid-column: 1 / -1; }
  .ptable td.c-act { display: none; }
  .go { justify-content: flex-start; }
  .foot { margin-top: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
