/* ===== Plastold Cockpit — futuristic dark ops console ===== */
:root {
  --bg-0: #070a12;
  --bg-1: #0b0f1c;
  --bg-2: #0f1424;
  --panel: rgba(20, 27, 46, 0.55);
  --panel-solid: #121829;
  --border: rgba(120, 150, 220, 0.14);
  --border-bright: rgba(120, 180, 255, 0.32);
  --text: #e7ecf6;
  --text-dim: #9aa6c2;
  --text-faint: #66718e;
  --cyan: #22d3ee;
  --blue: #3b82f6;
  --violet: #8b5cf6;
  --accent: #38bdf8;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 16px;
  --r-sm: 11px;
  --sidebar-w: 244px;
  --shadow: 0 18px 50px -20px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--ui);
  color: var(--text);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ambient glow backdrop */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(900px 600px at 12% -8%, rgba(56, 189, 248, 0.12), transparent 60%),
    radial-gradient(800px 600px at 100% 0%, rgba(139, 92, 246, 0.12), transparent 55%),
    radial-gradient(700px 700px at 50% 120%, rgba(34, 211, 238, 0.08), transparent 60%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0));
  pointer-events: none;
}

#app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  height: 100dvh;
}

/* ===== Topbar (mobile only) ===== */
.topbar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: rgba(8, 11, 20, 0.85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar-brand { display: flex; align-items: center; gap: 9px; font-size: 16px; letter-spacing: .2px; }
.topbar-brand b { font-weight: 700; }
.topbar-spacer { flex: 1; }
.logo-dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--cyan), var(--violet));
  box-shadow: 0 0 12px var(--cyan);
}
.icon-btn {
  background: transparent; border: 1px solid var(--border);
  color: var(--text); border-radius: 10px; padding: 7px;
  display: grid; place-items: center; cursor: pointer;
}

/* ===== Sidebar ===== */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 22px 16px 16px;
  background: linear-gradient(180deg, rgba(15, 20, 36, 0.7), rgba(9, 12, 22, 0.7));
  border-right: 1px solid var(--border);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; padding: 2px 4px 18px; }
.brand-badge {
  display: flex; align-items: center; justify-content: center;
  width: 100%; padding: 14px 16px; border-radius: 16px;
  background: linear-gradient(145deg, #e4e6eb, #cdd1d8);
  border: 1px solid rgba(0,0,0,.10);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55), 0 6px 18px -10px rgba(0,0,0,.6);
}
.brand-badge img { width: 100%; max-width: 152px; height: auto; display: block; }

.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  padding: 11px 13px;
  background: transparent; border: 1px solid transparent;
  border-radius: 12px;
  color: var(--text-dim);
  font: inherit; font-size: 14.5px; font-weight: 500;
  cursor: pointer;
  transition: background .18s, color .18s, border-color .18s, transform .12s;
  position: relative;
}
.nav-item .nav-ico { width: 20px; height: 20px; flex: none; opacity: .85; }
.nav-item:hover { color: var(--text); background: rgba(120,150,220,.06); }
.nav-item.active {
  color: var(--text);
  background: linear-gradient(100deg, rgba(56,189,248,.16), rgba(139,92,246,.10));
  border-color: var(--border-bright);
  box-shadow: inset 0 0 22px rgba(56,189,248,.10);
}
.nav-item.active::before {
  content: ""; position: absolute; left: -16px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 22px; border-radius: 3px;
  background: linear-gradient(var(--cyan), var(--violet));
  box-shadow: 0 0 12px var(--cyan);
}
.nav-badge {
  margin-left: auto;
  font-family: var(--mono); font-size: 11px;
  background: var(--accent); color: #04121e;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; display: grid; place-items: center; font-weight: 700;
}

.sidebar-foot { margin-top: auto; padding-top: 12px; }
.health-pill {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px; border-radius: 11px;
  background: rgba(10,14,24,.6); border: 1px solid var(--border);
  font-family: var(--mono); font-size: 11.5px; color: var(--text-dim);
}

/* status dots */
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--text-faint); }
.dot-good { background: var(--good); box-shadow: 0 0 10px rgba(52,211,153,.7); animation: pulse 2.4s infinite; }
.dot-bad  { background: var(--bad);  box-shadow: 0 0 10px rgba(248,113,113,.6); }
.dot-warn { background: var(--warn); box-shadow: 0 0 10px rgba(251,191,36,.6); }
.dot-idle { background: var(--text-faint); animation: blink 1.4s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.45} }
@keyframes blink { 0%,100%{opacity:.3} 50%{opacity:1} }

.scrim {
  display: none; position: fixed; inset: 0; z-index: 30;
  background: rgba(2,4,10,.6); backdrop-filter: blur(2px);
}

/* language switcher (flag dropdown) — lives in the sidebar foot, opens upward */
.lang-switch { position: relative; margin-bottom: 8px; }
.lang-current {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 11px; border-radius: 11px; cursor: pointer;
  background: rgba(10,14,24,.6); border: 1px solid var(--border);
  color: var(--text-dim); transition: border-color .15s, background .15s, color .15s;
}
.lang-current:hover { color: var(--text); border-color: var(--border-bright); background: rgba(56,189,248,.08); }
.lang-current .lang-caret { margin-left: auto; opacity: .7; transition: transform .15s; }
.lang-current[aria-expanded="true"] .lang-caret { transform: rotate(180deg); }
.flag { display: inline-flex; flex: none; }
.flag-svg { width: 22px; height: 15px; display: block; border-radius: 3px; box-shadow: 0 0 0 1px rgba(255,255,255,.08) inset; }
.lang-menu {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 40;
  background: var(--panel-solid); border: 1px solid var(--border-bright);
  border-radius: 11px; padding: 5px; box-shadow: var(--shadow);
}
.lang-opt {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 9px; border-radius: 8px; cursor: pointer;
  background: transparent; border: 0; color: var(--text-dim);
  font: inherit; font-size: 13px; text-align: left;
}
.lang-opt:hover { background: rgba(56,189,248,.1); color: var(--text); }
.lang-opt[aria-current="true"] { color: var(--text); background: rgba(56,189,248,.06); }
.lang-opt[aria-current="true"]::after { content: "✓"; margin-left: auto; color: var(--accent); }

/* ===== Main ===== */
.main { position: relative; overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.view { display: none; flex-direction: column; height: 100%; min-height: 0; padding: 26px 30px 0; overflow: hidden; }
.view.active { display: flex; animation: fade .26s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.view-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding-bottom: 18px; flex: none;
}
.view-head h1 { margin: 0; font-size: 23px; font-weight: 650; letter-spacing: .2px; }
.view-sub { margin: 4px 0 0; color: var(--text-dim); font-size: 13.5px; }
.updated { font-family: var(--mono); font-size: 11.5px; color: var(--text-faint); align-self: center; }

.ghost-btn, .send-btn, .btn {
  font: inherit; cursor: pointer; border-radius: 11px;
  transition: background .16s, border-color .16s, transform .1s, box-shadow .16s;
}
.ghost-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 13px; font-size: 13px; font-weight: 500;
  background: rgba(120,150,220,.06); border: 1px solid var(--border);
  color: var(--text-dim);
}
.ghost-btn:hover { color: var(--text); border-color: var(--border-bright); background: rgba(56,189,248,.08); }
.ghost-btn:active { transform: scale(.97); }
/* Refresh in flight: dim + spin the icon so the click visibly did something
   even when the data comes back unchanged (no re-render). */
.ghost-btn.busy { opacity: .55; pointer-events: none; }
.ghost-btn.busy svg { animation: refspin .8s linear infinite; }
@keyframes refspin { to { transform: rotate(360deg); } }

/* ===== Chat ===== */
.view-chat { padding-bottom: 0; }

/* ===== Chat UI switch (embedded multi-model chat engine) ===== */
/* FLUSH to the bottom edge (2026-07-12, owner: "let it touch the bottom, no gap"): zero cockpit
   padding so the iframe (and OWUI's composer inside it) sits at the very bottom of the screen. */
.chatui-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; margin: -26px -30px 0; padding-bottom: 0; }
.chatui-wrap.classic { flex: 0 0 auto; margin: 0 -30px; }
.chatui-wrap.classic .chatui-frame { display: none; }
.chatui-frame { flex: 1; width: 100%; border: 0; background: var(--bg-1); }
/* the "Plastold Chat — todos los modelos" strip is hidden by default (owner request 2026-07-12:
   more reading space, write box at the bottom); it only appears to show a retry/status message. */
.chatui-bar.chatui-bar-hidden { display: none; }
.chatui-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 6px 14px calc(6px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--text-faint);
  background: rgba(9, 12, 22, 0.6);
}
.chatui-toggle {
  background: transparent; border: none; cursor: pointer;
  color: var(--accent); font: inherit; font-size: 11.5px; padding: 4px 6px;
}
.chatui-toggle:hover { color: var(--cyan); }
.chatui-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 860px) {
  .chatui-wrap { margin: -18px -16px 0; }
  .chatui-wrap.classic { margin: 0 -16px; }
}
.chat-scroll { flex: 1; overflow-y: auto; min-height: 0; padding: 4px 2px 8px; scroll-behavior: smooth; }
.chat-scroll::-webkit-scrollbar { width: 9px; }
.chat-scroll::-webkit-scrollbar-thumb { background: rgba(120,150,220,.18); border-radius: 9px; }

.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 8vh 16px 4vh; }
.empty-state.hidden { display: none; }
.empty-orb {
  width: 92px; height: 92px; border-radius: 50%; margin-bottom: 22px;
  background: radial-gradient(circle at 35% 30%, var(--cyan), var(--blue) 50%, var(--violet));
  box-shadow: 0 0 60px -6px rgba(56,189,248,.55), inset 0 0 30px rgba(255,255,255,.18);
  animation: float 5s ease-in-out infinite;
}
@keyframes float { 0%,100%{ transform: translateY(0) } 50%{ transform: translateY(-9px) } }
.empty-state h2 { margin: 0 0 8px; font-size: 26px; font-weight: 680; background: linear-gradient(90deg, #fff, var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.empty-state p { margin: 0 0 24px; max-width: 440px; color: var(--text-dim); font-size: 14.5px; line-height: 1.55; }
.examples { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; max-width: 560px; width: 100%; }
.example {
  font: inherit; font-size: 13.5px; text-align: left;
  padding: 13px 15px; border-radius: 13px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--border); color: var(--text-dim);
  backdrop-filter: blur(10px);
  transition: border-color .16s, color .16s, transform .12s, background .16s;
}
.example:hover { color: var(--text); border-color: var(--border-bright); transform: translateY(-2px); background: rgba(56,189,248,.06); }

.messages { display: flex; flex-direction: column; gap: 18px; max-width: 820px; margin: 0 auto; width: 100%; padding: 8px 0 8px; }
.msg { display: flex; gap: 12px; align-items: flex-start; }
.msg-user { flex-direction: row-reverse; }
.avatar {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  display: grid; place-items: center; font-family: var(--mono); font-size: 12px; font-weight: 700;
  border: 1px solid var(--border);
}
.avatar-a { background: linear-gradient(145deg, rgba(34,211,238,.22), rgba(139,92,246,.22)); color: var(--cyan); border-color: var(--border-bright); }
.avatar-u { background: rgba(120,150,220,.1); color: var(--text-dim); }
.bubble {
  max-width: 80%;
  padding: 12px 15px; border-radius: 15px; line-height: 1.58; font-size: 14.5px;
  border: 1px solid var(--border);
}
.msg-user .bubble {
  background: linear-gradient(135deg, rgba(56,189,248,.16), rgba(59,130,246,.12));
  border-color: var(--border-bright);
  border-bottom-right-radius: 5px;
}
.msg-assistant .bubble {
  background: var(--panel); backdrop-filter: blur(10px);
  border-bottom-left-radius: 5px;
}

/* markdown content */
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3 { margin: 14px 0 8px; line-height: 1.3; font-weight: 650; }
.md h1 { font-size: 19px; } .md h2 { font-size: 17px; } .md h3 { font-size: 15px; color: var(--accent); }
.md p { margin: 8px 0; }
.md ul, .md ol { margin: 8px 0; padding-left: 22px; }
.md li { margin: 3px 0; }
.md a { color: var(--accent); text-decoration: none; border-bottom: 1px solid rgba(56,189,248,.4); }
.md a:hover { border-bottom-color: var(--accent); }
.md code {
  font-family: var(--mono); font-size: .88em;
  background: rgba(10,14,24,.7); border: 1px solid var(--border);
  padding: 1px 6px; border-radius: 6px;
}
.md pre {
  background: rgba(6,9,16,.85); border: 1px solid var(--border);
  border-radius: 11px; padding: 13px 15px; overflow-x: auto; margin: 10px 0;
}
.md pre code { background: none; border: none; padding: 0; font-size: 12.8px; line-height: 1.5; }
.md strong { color: #fff; font-weight: 650; }
.md em { color: var(--text); }

/* sources */
.sources { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 11px; }
.src-chip {
  font-family: var(--mono); font-size: 11.5px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px;
  background: rgba(10,14,24,.6); border: 1px solid var(--border); color: var(--text-dim);
  max-width: 260px; transition: border-color .15s, color .15s, background .15s;
}
.src-chip.openable { cursor: pointer; }
.src-chip.openable:hover { color: var(--text); border-color: var(--border-bright); background: rgba(56,189,248,.08); }
.src-chip .src-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src-chip .src-score { color: var(--accent); opacity: .8; }

/* thinking indicator */
.thinking { display: inline-flex; align-items: center; gap: 9px; color: var(--text-dim); font-size: 13.5px; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: bob 1.2s infinite ease-in-out; }
.dots i:nth-child(2){ animation-delay: .15s } .dots i:nth-child(3){ animation-delay: .3s }
@keyframes bob { 0%,80%,100%{ transform: scale(.6); opacity:.4 } 40%{ transform: scale(1); opacity:1 } }

/* composer */
.composer { flex: none; padding: 14px 0 calc(16px + env(safe-area-inset-bottom)); }
.composer-inner {
  display: flex; align-items: flex-end; gap: 10px;
  max-width: 820px; margin: 0 auto; width: 100%;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 18px; padding: 8px 8px 8px 16px;
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  transition: border-color .18s, box-shadow .18s;
}
.composer-inner:focus-within { border-color: var(--border-bright); box-shadow: 0 0 0 3px rgba(56,189,248,.08), var(--shadow); }
#input {
  flex: 1; resize: none; border: none; outline: none; background: transparent;
  color: var(--text); font: inherit; font-size: 15px; line-height: 1.5;
  max-height: 168px; padding: 8px 0;
}
#input::placeholder { color: var(--text-faint); }
.send-btn {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center;
  border: none; color: #04121e;
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  box-shadow: 0 6px 18px -6px rgba(56,189,248,.7);
}
.send-btn:hover { transform: translateY(-1px); box-shadow: 0 9px 22px -6px rgba(56,189,248,.85); }
.send-btn:active { transform: scale(.94); }
.send-btn:disabled { opacity: .45; cursor: default; transform: none; box-shadow: none; }
.composer-hint { text-align: center; font-size: 11.5px; color: var(--text-faint); margin-top: 9px; }

/* ===== Panels / stubs ===== */
.panel-grid { flex: 1; overflow-y: auto; display: grid; gap: 16px; align-content: start; padding-bottom: 24px; min-width: 0; grid-template-columns: minmax(0, 1fr); }
.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r);
  padding: 22px 22px; backdrop-filter: blur(12px); box-shadow: var(--shadow);
  min-width: 0; max-width: 100%;   /* NOTE: never set overflow-x here — it forces overflow-y:auto and makes
                                      every panel an internal scroll box. Wide children scroll/shrink themselves. */
}
@media (max-width: 600px) { .panel { padding: 14px 13px; } }
/* wide ledger/financial tables scroll WITHIN themselves on mobile, never expanding or clipping the panel */
.panel table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* the year-panel chart/table rows: let children shrink to the phone width instead of forcing a scroll */
.fz-yr > div { min-width: 0; max-width: 100%; }
.coming-soon { display: flex; align-items: center; gap: 18px; }
.coming-icon {
  width: 54px; height: 54px; border-radius: 15px; flex: none; display: grid; place-items: center;
  background: linear-gradient(145deg, rgba(34,211,238,.14), rgba(139,92,246,.14));
  border: 1px solid var(--border-bright);
}
.coming-icon svg { width: 26px; height: 26px; color: var(--accent); }
.coming-text h3 { margin: 0 0 5px; font-size: 16px; font-weight: 600; }
.coming-text p { margin: 0; color: var(--text-dim); font-size: 13.5px; line-height: 1.5; }
.tag-mono { display: inline-block; margin-top: 12px; font-family: var(--mono); font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--accent); padding: 4px 10px; border: 1px solid var(--border); border-radius: 7px; background: rgba(10,14,24,.5); }

/* approvals */
.approvals-body { flex: 1; overflow-y: auto; padding-bottom: 24px; }
.approval-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r);
  padding: 18px 20px; margin-bottom: 14px; backdrop-filter: blur(12px);
  /* stack text over a wrapping button row: a long description + many buttons never fit one line, and a flex
     row squeezed the title into a one-word column + overflowed the card. */
  display: flex; flex-direction: column; align-items: stretch; gap: 12px;
}
.approval-info { min-width: 0; overflow-wrap: anywhere; }
.approval-info h4 { margin: 0 0 4px; font-size: 15px; }
.approval-info p { margin: 0; color: var(--text-dim); font-size: 13px; }
/* Order group: one card per supplier order. Left accent ties the gasto header + its member docs together. */
.recon-group { border-left: 2px solid var(--accent); padding-left: 12px; margin-bottom: 16px; }
/* an open COMEX import (paid in USD, EUR not yet settled) gets an amber spine so it stands out as "pendiente". */
.recon-group.recon-comex { border-left-color: #f5a623; }
.recon-group-head { font-size: .8em; letter-spacing: .04em; text-transform: uppercase; opacity: .7; margin: 2px 0 6px; }
.recon-members { margin: 2px 0 4px 10px; }
.recon-members > summary { cursor: pointer; opacity: .72; font-size: .85em; padding: 4px 0; list-style: none; }
.recon-members > summary::before { content: "▸ "; }
.recon-members[open] > summary::before { content: "▾ "; }
.recon-member { padding: 9px 13px; margin: 6px 0; gap: 12px; }
.recon-member .approval-info { min-width: 0; }
.approval-amount { font-family: var(--mono); color: var(--warn); font-size: 14px; }
.approval-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { padding: 8px 15px; font-size: 13px; font-weight: 600; border: 1px solid var(--border); }
/* In-app document viewer modal (works in the native macOS WKWebView app, the PWA and browsers).
   Padding uses the SAFE-AREA insets so the close (✕) never hides under the iPhone status bar/notch
   and the bottom clears the home indicator. */
.doc-modal { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.6); display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) calc(env(safe-area-inset-right, 0px) + 10px) calc(env(safe-area-inset-bottom, 0px) + 12px) calc(env(safe-area-inset-left, 0px) + 10px); }
.doc-modal-card { flex: 1 1 auto; width: 100%; max-width: 1000px; max-height: 100%; margin: 0 auto; background: #0b0f17; border: 1px solid var(--border); border-radius: 12px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.doc-modal-bar { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); flex: none; }
.doc-modal-title { flex: 1; font-size: 13px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-modal-bar .btn { padding: 6px 14px; }
.doc-close { font-size: 16px; line-height: 1; }
.doc-frame { flex: 1 1 auto; width: 100%; border: 0; background: #fff; }

/* In-DOM dialog (uiConfirm/uiPrompt/uiAlert) — replaces window.confirm/alert/prompt, which the
   native macOS/Windows WebView does not display. Sits above everything (doc-modal is z-200). */
.ui-modal { position: fixed; inset: 0; z-index: 300; display: flex; align-items: center; justify-content: center;
  background: rgba(2,4,10,.62); backdrop-filter: blur(3px);
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 16px calc(env(safe-area-inset-bottom, 0px) + 16px) 16px; }
.ui-modal-card { width: 100%; max-width: 420px; background: var(--panel-solid); border: 1px solid var(--border);
  border-radius: 14px; padding: 18px 18px 14px; box-shadow: 0 24px 70px rgba(0,0,0,.55); }
.ui-modal-msg { font-size: 14px; line-height: 1.5; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.ui-modal-input { width: 100%; margin-top: 12px; padding: 9px 11px; font-size: 14px; color: var(--text);
  background: var(--bg-1); border: 1px solid var(--border); border-radius: 9px; box-sizing: border-box; }
.ui-modal-input:focus { outline: 0; border-color: var(--accent); }
.ui-modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 16px; flex-wrap: wrap; }
.ui-modal-btn { font-size: 13px; font-weight: 600; padding: 8px 16px; border-radius: 9px; cursor: pointer; border: 1px solid var(--border); }
.ui-modal-cancel { color: var(--text-dim); background: 0; }
.ui-modal-cancel:hover { color: var(--text); border-color: var(--text-faint); }
.ui-modal-ok { color: #04121e; background: var(--accent); border-color: transparent; }
.ui-modal-ok:hover { filter: brightness(1.06); }
.ui-modal-ok.danger { color: #1a0606; background: var(--bad); }
.btn-approve { background: rgba(52,211,153,.14); color: var(--good); border-color: rgba(52,211,153,.3); }
.btn-approve:hover { background: rgba(52,211,153,.24); }
.btn-reject { background: rgba(248,113,113,.12); color: var(--bad); border-color: rgba(248,113,113,.3); }
.btn-reject:hover { background: rgba(248,113,113,.22); }
/* "Denegar y archivar" — file-but-don't-book: amber, distinct from approve(green)/deny(red). */
.btn-file { background: rgba(245,166,35,.12); color: #f5a623; border-color: rgba(245,166,35,.32); }
.btn-file:hover { background: rgba(245,166,35,.22); }

/* finanzas (invoice ledger + review queue + bank reconciliation) */
.fz-cur { color: var(--text-faint); font-size: .82em; font-family: var(--mono); }
.fz-ref { color: var(--text-faint); font-family: var(--mono); font-size: .82em; }
.fz-sub { margin: 16px 0 8px; font-size: 12px; font-weight: 600; color: var(--text-dim); letter-spacing: .3px; }
.fz-review-panel { border-color: rgba(251,191,36,.28); }
.fz-review {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  padding: 12px 0; border-top: 1px solid var(--border);
}
.fz-review-main { min-width: 0; flex: 1; }
.fz-review-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.fz-vendor { font-weight: 600; font-size: 14px; }
.fz-inv { font-family: var(--mono); font-size: 12px; color: var(--text-dim); }
.fz-amt { font-family: var(--mono); font-size: 13px; color: var(--warn); margin-left: auto; }
.fz-flags { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.fz-flag {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .4px;
  color: var(--warn); background: rgba(251,191,36,.1); border: 1px solid rgba(251,191,36,.28);
  border-radius: 6px; padding: 2px 7px;
}
.fz-review-act { flex: none; }
.btn-review {
  padding: 7px 13px; font-size: 12.5px; font-weight: 600; border-radius: 8px; cursor: pointer;
  background: rgba(251,191,36,.12); color: var(--warn); border: 1px solid rgba(251,191,36,.3);
}
.btn-review:hover { background: rgba(251,191,36,.22); }
.btn-review:disabled { opacity: .55; cursor: default; }
.fz-pill { font-family: var(--mono); font-size: 10.5px; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--border); }
.fz-pill-held { color: var(--warn); background: rgba(251,191,36,.1); border-color: rgba(251,191,36,.28); }
.fz-pill-posted { color: var(--good); background: rgba(52,211,153,.08); border-color: rgba(52,211,153,.25); }
.fz-matched { font-size: 12.5px; color: var(--text-dim); margin: 4px 0 12px; }
.fz-match { display: inline-flex; align-items: center; gap: 6px; margin: 0 8px 6px 0; }
.fz-match-name { color: var(--text-dim); }
.fz-score { font-family: var(--mono); font-size: 11px; color: var(--good); background: rgba(52,211,153,.08); border: 1px solid rgba(52,211,153,.25); border-radius: 6px; padding: 1px 6px; }

/* #8 marketing drafts — pending outreach drafts as approve/SEND cards (autonomy gate) */
.mk-drafts-panel { border-color: rgba(56,189,248,.28); }
.mk-draft {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  padding: 12px 0; border-top: 1px solid var(--border);
}
.mk-draft-main { min-width: 0; flex: 1; }
.mk-draft-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.mk-draft-co { font-weight: 600; font-size: 14px; }
.mk-draft-when { font-family: var(--mono); font-size: 11px; color: var(--text-faint); margin-left: auto; }
.mk-draft-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.mk-draft-tags { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.mk-draft-tag {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .4px;
  color: var(--accent); background: rgba(56,189,248,.08); border: 1px solid rgba(56,189,248,.26);
  border-radius: 6px; padding: 2px 7px;
}
.mk-draft-preview { margin: 7px 0 0; font-size: 12.5px; color: var(--text-dim); line-height: 1.45; }
.mk-draft-act { flex: none; }
.btn-send-draft {
  padding: 7px 13px; font-size: 12.5px; font-weight: 600; border-radius: 8px; cursor: pointer;
  background: rgba(52,211,153,.14); color: var(--good); border: 1px solid rgba(52,211,153,.3);
}
.btn-send-draft:hover { background: rgba(52,211,153,.24); }
.btn-send-draft:disabled { opacity: .55; cursor: default; }

/* #9 partes job lifecycle — one row per job: commercial state + payment % + archive */
.job-counts { display: flex; gap: 8px; flex-wrap: wrap; margin: 2px 0 10px; }
.job-count {
  font-family: var(--mono); font-size: 11px; color: var(--text-dim);
  background: rgba(120,150,220,.06); border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px;
}
.job-count-arch { color: var(--good); border-color: rgba(52,211,153,.3); background: rgba(52,211,153,.08); }
.job-lc-card { padding: 12px 0; border-top: 1px solid var(--border); }
.job-lc-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.job-lc-client { font-weight: 600; font-size: 14px; }
.job-lc-product { font-size: 12.5px; color: var(--text-dim); }
.job-lc-head .state { margin-left: auto; }
.job-lc-pay { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.job-pay-bar { position: relative; flex: 1; min-width: 120px; height: 7px; border-radius: 4px; background: rgba(120,150,220,.12); overflow: hidden; }
.job-pay-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; }
.job-paid-full { background: var(--good); }
.job-paid-part { background: var(--warn); }
.job-paid-none { background: rgba(120,150,220,.25); }
.job-pay-pct { font-family: var(--mono); font-size: 11.5px; color: var(--text-dim); }
.job-made { font-family: var(--mono); font-size: 11.5px; color: var(--text-faint); }
.job-lc-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.job-chip {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .4px; padding: 3px 8px;
  border-radius: 6px; border: 1px solid var(--border); color: var(--text-dim);
}
.job-chip-done { color: var(--good); background: rgba(52,211,153,.08); border-color: rgba(52,211,153,.25); }
.job-chip-paid { color: var(--good); background: rgba(52,211,153,.06); border-color: rgba(52,211,153,.22); }
.job-chip-review { color: var(--warn); background: rgba(251,191,36,.1); border-color: rgba(251,191,36,.28); }
.job-chip-archived { color: var(--accent); background: rgba(56,189,248,.08); border-color: rgba(56,189,248,.26); }
.job-produced-btn {
  padding: 6px 12px; font-size: 12px; font-weight: 600; border-radius: 8px; cursor: pointer;
  background: rgba(251,191,36,.12); color: var(--warn); border: 1px solid rgba(251,191,36,.3);
}
.job-produced-btn:hover { background: rgba(251,191,36,.22); }
.job-archive-btn {
  padding: 6px 12px; font-size: 12px; font-weight: 600; border-radius: 8px; cursor: pointer;
  background: rgba(52,211,153,.14); color: var(--good); border: 1px solid rgba(52,211,153,.3);
}
.job-archive-btn:hover { background: rgba(52,211,153,.24); }
.job-produced-btn:disabled, .job-archive-btn:disabled { opacity: .55; cursor: default; }

.empty-block {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 8vh 20px; color: var(--text-dim);
}
.empty-block .eb-icon {
  width: 60px; height: 60px; border-radius: 16px; display: grid; place-items: center; margin-bottom: 16px;
  background: rgba(20,27,46,.5); border: 1px solid var(--border); color: var(--text-faint);
}
.empty-block .eb-icon svg { width: 28px; height: 28px; }
.empty-block h3 { margin: 0 0 6px; color: var(--text); font-weight: 600; }
.empty-block p { margin: 0; font-size: 13.5px; max-width: 360px; }

/* status grid */
.status-grid {
  flex: 1; overflow-y: auto; display: grid; gap: 16px; align-content: start; padding-bottom: 24px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.status-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r);
  padding: 20px; backdrop-filter: blur(12px); box-shadow: var(--shadow);
}
.status-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.status-card-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.status-card .state {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 11.5px; letter-spacing: .5px;
}
.status-detail { margin: 14px 0 0; color: var(--text-dim); font-size: 12.5px; line-height: 1.5; font-family: var(--mono); word-break: break-word; }
.status-detail.status-err { color: var(--bad); }
/* ingest-progress card (lives in the status grid) */
.status-ingest { grid-column: 1 / -1; }
.ingest-stats {
  display: flex; flex-wrap: wrap; gap: 18px; margin-top: 12px;
  font-family: var(--mono); font-size: 12.5px; color: var(--text-dim);
}
.ingest-stats b { color: var(--text); font-weight: 700; }

/* changes / jobs */
/* The Changes tab scrolls as ONE column (head stays put, everything below scrolls).
   min-height:0 is required: without it this flex child refuses to shrink below its
   content height, so it never becomes a scroller and the overflow is clipped by
   `.view { overflow: hidden }` — the 2026-08-12 "can't scroll the Changes tab" bug. */
.changes-scroll { flex: 1; min-height: 0; overflow-y: auto; padding-bottom: 24px; }
/* Inside that scroller the jobs list just flows — a nested scroller here would
   re-create the same trap (it would eat the leftover space and clip lp-wrap). */
.changes-body { flex: none; overflow: visible; }
.changes-section-h {
  font-family: var(--mono); font-size: 11px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--text-faint); margin: 6px 2px 12px;
}
.changes-section-h:not(:first-child) { margin-top: 22px; }
.job-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r);
  padding: 16px 18px; margin-bottom: 14px; backdrop-filter: blur(12px);
}
.job-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.job-title { font-size: 14.5px; font-weight: 600; line-height: 1.4; }
.job-card .state {
  display: inline-flex; align-items: center; gap: 8px; flex: none;
  font-family: var(--mono); font-size: 11.5px; letter-spacing: .5px; color: var(--text-dim);
}
.job-tier {
  display: inline-block; margin-top: 10px; font-family: var(--mono); font-size: 10.5px;
  letter-spacing: 1px; text-transform: uppercase; color: var(--accent);
  padding: 3px 9px; border: 1px solid var(--border); border-radius: 6px; background: rgba(10,14,24,.5);
}
.job-summary { margin: 10px 0 0; color: var(--text-dim); font-size: 13px; line-height: 1.5; }
.job-note { margin: 8px 0 0; color: var(--text-faint); font-size: 12px; line-height: 1.5; font-style: italic; }
.job-qs { margin: 12px 0 0; padding-left: 18px; color: var(--text-dim); font-size: 13px; line-height: 1.6; }
.job-answer-row { display: flex; gap: 8px; margin-top: 12px; }
.job-answer-in {
  flex: 1; background: rgba(10,14,24,.6); border: 1px solid var(--border); border-radius: 9px;
  padding: 8px 12px; color: var(--text); font: inherit; font-size: 13.5px;
}
.job-answer-in:focus { outline: none; border-color: var(--border-bright); }
.job-answer-in::placeholder { color: var(--text-faint); }
.job-actions { margin-top: 14px; display: flex; gap: 8px; }

/* marketing — hot replies (interested leads) */
.hot-list { display: flex; flex-direction: column; gap: 12px; }
.hot-empty { color: var(--text-dim); font-size: 13px; line-height: 1.5; }
.hot-lead {
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px;
  background: rgba(10,14,24,.4);
}
.hot-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.hot-company { font-size: 14px; font-weight: 600; color: var(--text); text-decoration: none; }
a.hot-company { color: var(--accent); border-bottom: 1px solid rgba(56,189,248,.35); }
a.hot-company:hover { border-bottom-color: var(--accent); }
.hot-when { font-family: var(--mono); font-size: 11px; color: var(--text-faint); flex: none; }
.hot-preview { margin: 8px 0 0; color: var(--text-dim); font-size: 13px; line-height: 1.5; }
.hot-addr { margin-top: 8px; font-family: var(--mono); font-size: 11.5px; color: var(--text-faint); }

/* ===== Responsive ===== */
@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .topbar { display: flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 260px; z-index: 50;
    transform: translateX(-104%); transition: transform .26s cubic-bezier(.4,0,.2,1);
    padding-top: calc(22px + env(safe-area-inset-top));
  }
  #app.nav-open .sidebar { transform: none; }
  #app.nav-open .scrim { display: block; }
  .main { grid-row: 2; }
  .view { padding: 18px 16px 0; }
  .view-head h1 { font-size: 20px; }
  .examples { grid-template-columns: 1fr; }
  .bubble { max-width: 86%; }
}
@media (max-width: 480px) {
  .view-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .bubble { max-width: 100%; }
  .msg { gap: 9px; }
  /* approval / reconciliation cards already stack (see .approval-card); on phones make the buttons fill the row */
  .approval-card { padding: 16px; }
  .approval-actions .btn { flex: 1 1 auto; text-align: center; }
}

/* ===== Marketing dashboard ===== */
.mk-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 12px; }
.mk-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; backdrop-filter: blur(12px); }
.mk-val { font-family: var(--mono); font-size: 25px; font-weight: 680; color: #fff; }
.mk-lbl { font-size: 12px; color: var(--text-dim); margin-top: 3px; }
.mk-h { margin: 0 0 12px; font-size: 13px; font-weight: 600; color: var(--accent); letter-spacing: .3px; }
.mk-bar-row { display: flex; align-items: center; gap: 12px; margin: 7px 0; }
.mk-bar-lbl { width: 88px; flex: none; font-size: 13px; color: var(--text-dim); }
.mk-bar { flex: 1; height: 10px; background: rgba(10,14,24,.6); border-radius: 6px; overflow: hidden; }
.mk-bar-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan), var(--violet)); }
.mk-bar-n { width: 56px; flex: none; text-align: right; font-family: var(--mono); font-size: 12.5px; color: var(--text); }
.mk-two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.mk-row { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.mk-row-k { width: 84px; flex: none; font-family: var(--mono); font-size: 12.5px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mk-row-bar { flex: 1; height: 7px; background: rgba(10,14,24,.6); border-radius: 5px; overflow: hidden; }
.mk-row-bar span { display: block; height: 100%; background: var(--accent); opacity: .65; }
.mk-row-n { width: 50px; flex: none; text-align: right; font-family: var(--mono); font-size: 12px; color: var(--text); }
.mk-foot { font-family: var(--mono); font-size: 11.5px; color: var(--text-faint); padding: 2px 2px 18px; }
@media (max-width: 860px) { .mk-two { grid-template-columns: 1fr; } }

/* outreach control bar (toggle + health light) */
.mk-control { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 12px 16px; margin-bottom: 16px; backdrop-filter: blur(12px); }
.mk-toggle-wrap { display: flex; align-items: center; gap: 11px; }
.mk-toggle-label { font-size: 13.5px; color: var(--text-dim); }
.ios-toggle { width: 46px; height: 27px; border-radius: 999px; border: 1px solid var(--border); background: rgba(10,14,24,.6); position: relative; cursor: pointer; padding: 0; transition: background .2s, border-color .2s; }
.ios-toggle .knob { position: absolute; top: 2px; left: 2px; width: 21px; height: 21px; border-radius: 50%; background: var(--text-dim); transition: transform .2s, background .2s; }
.ios-toggle.on { background: linear-gradient(90deg, var(--cyan), var(--good)); border-color: transparent; }
.ios-toggle.on .knob { transform: translateX(19px); background: #fff; }
.mk-toggle-state { font-family: var(--mono); font-size: 12px; color: var(--text); width: 30px; }
.mk-health { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 11.5px; color: var(--text-dim); }
/* Go-Live (auto-send) toggle — amber/red so it reads as the higher-stakes switch, never green. */
.mk-toggles { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.ios-toggle.live.on { background: linear-gradient(90deg, #f59e0b, #ef4444); }
.mk-live-state.on { color: #f59e0b; font-weight: 700; }
.mk-live-note { width: 100%; font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }
.mk-live-note.on { color: #f59e0b; }

/* Real Gmail drafts (true subject + body) — the vetting surface. */
.mk-gd { border-top: 1px solid var(--border); padding: 11px 0 4px; }
.mk-gd:first-of-type { border-top: 0; }
.mk-gd-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; cursor: pointer; }
.mk-gd-subj { font-weight: 600; font-size: 13.5px; color: var(--text); }
.mk-gd-to { font-size: 12px; color: var(--text-dim); }
.mk-gd-when { font-family: var(--mono); font-size: 11px; color: var(--text-faint); margin-left: auto; }
.mk-gd-snip { font-size: 12.5px; color: var(--text-dim); margin: 5px 0 0; line-height: 1.45; }
.mk-gd-body { display: none; white-space: pre-wrap; word-break: break-word; font-size: 12.5px; color: var(--text); line-height: 1.5; margin: 8px 0 0; padding: 10px 12px; background: rgba(10,14,24,.5); border: 1px solid var(--border); border-radius: 10px; max-height: 360px; overflow: auto; }
.mk-gd.open .mk-gd-body { display: block; }
.mk-gd.open .mk-gd-snip { display: none; }
.mk-gd-toggle { font-size: 11.5px; color: var(--cyan); background: 0; border: 0; padding: 4px 0 0; cursor: pointer; }
.mk-gd-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 4px; flex-wrap: wrap; }
.mk-gd-send { font-size: 12px; font-weight: 600; color: var(--good); background: rgba(52,211,153,.14); border: 1px solid rgba(52,211,153,.35); border-radius: 8px; padding: 5px 12px; cursor: pointer; transition: background .15s; }
.mk-gd-send:hover { background: rgba(52,211,153,.24); }
.mk-gd-send:disabled { opacity: .55; cursor: default; }
.mk-gd.sent { opacity: .6; }
/* In-DOM send confirm (replaces window.confirm — the native macOS WebView shows no JS dialogs). */
.mk-gd-confirm { flex-basis: 100%; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 8px; padding: 8px 10px; border: 1px solid rgba(248,113,113,.32); background: rgba(248,113,113,.08); border-radius: 9px; }
.mk-gd-confirm-q { flex: 1 1 200px; font-size: 12px; color: var(--text-dim); }
.mk-gd-yes { font-size: 12px; font-weight: 700; color: #1a0606; background: var(--bad); border: 0; border-radius: 8px; padding: 5px 14px; cursor: pointer; }
.mk-gd-yes:hover { filter: brightness(1.08); }
.mk-gd-cancel { font-size: 12px; font-weight: 600; color: var(--text-dim); background: 0; border: 1px solid var(--border); border-radius: 8px; padding: 5px 12px; cursor: pointer; }
.mk-gd-cancel:hover { color: var(--text); border-color: var(--text-faint); }
.mk-gd-status { flex-basis: 100%; font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }
.mk-gd-status.err { color: var(--bad); }

/* Work orders grouped by customer (Production tab) */
.wo-cust { margin-top: 12px; }
.wo-cust:first-of-type { margin-top: 4px; }
.wo-cust-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-weight: 600; font-size: 13.5px; color: var(--text); border-bottom: 1px solid var(--border); padding: 2px 6px 5px; }
.wo-cust-n { font-family: var(--mono); font-size: 11px; font-weight: 400; color: var(--text-faint); }
.wo-ref { font-family: var(--mono); font-size: 10.5px; color: var(--text-faint); margin-left: 6px; }

/* ===== Account pill + logout (sidebar foot) ===== */
.account-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px 9px 11px; margin-bottom: 9px; border-radius: 11px;
  background: rgba(10,14,24,.6); border: 1px solid var(--border);
}
.account-avatar {
  width: 28px; height: 28px; flex: none; border-radius: 8px;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--cyan);
  background: linear-gradient(145deg, rgba(34,211,238,.22), rgba(139,92,246,.22));
  border: 1px solid var(--border-bright); text-transform: uppercase;
}
.account-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.2; }
.account-email { font-size: 12.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-role { font-family: var(--mono); font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--accent); }
.logout-btn {
  flex: none; display: grid; place-items: center; cursor: pointer;
  width: 30px; height: 30px; border-radius: 9px;
  background: transparent; border: 1px solid var(--border); color: var(--text-dim);
  transition: color .15s, border-color .15s, background .15s;
}
.logout-btn:hover { color: var(--bad); border-color: rgba(248,113,113,.4); background: rgba(248,113,113,.08); }
.logout-btn:active { transform: scale(.94); }

/* ===== Settings view ===== */
.settings-body { flex: 1; overflow-y: auto; display: grid; gap: 16px; align-content: start; padding-bottom: 24px; max-width: 760px; }
.set-h { margin: 0 0 12px; font-size: 14px; font-weight: 600; color: var(--accent); letter-spacing: .3px; }
.set-sub { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--text); }
.set-note { margin: -4px 0 16px; font-size: 12.5px; color: var(--text-dim); line-height: 1.5; }
.set-account { display: flex; align-items: center; gap: 14px; }
.set-account .sa-avatar {
  width: 46px; height: 46px; flex: none; border-radius: 13px; display: grid; place-items: center;
  font-family: var(--mono); font-size: 17px; font-weight: 700; color: var(--cyan); text-transform: uppercase;
  background: linear-gradient(145deg, rgba(34,211,238,.2), rgba(139,92,246,.2)); border: 1px solid var(--border-bright);
}
.set-account .sa-text { display: flex; flex-direction: column; gap: 3px; }
.set-account .sa-email { font-size: 15px; color: var(--text); font-weight: 550; }
.set-account .sa-role { font-family: var(--mono); font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--accent); }

/* avatar photos (shared): once a real picture is set, cover-fill the tile + hide the initial */
.account-avatar.has-photo, .set-account .sa-avatar.has-photo,
.user-row .ur-avatar.has-photo, .pe-avatar.has-photo {
  background-size: cover; background-position: center; background-repeat: no-repeat;
  color: transparent; font-size: 0;
}

/* [hidden] must win over the flex/grid `display` set on button classes (else a
   hidden .ghost-btn like "Remove" still shows). Scoped to buttons to stay safe. */
.ghost-btn[hidden], .send-btn[hidden], .btn[hidden], .primary-btn[hidden] { display: none !important; }

/* "Your profile" editor (Settings) */
.profile-edit { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.pe-avatar-col { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.pe-avatar {
  width: 84px; height: 84px; flex: none; border-radius: 22px; display: grid; place-items: center;
  font-family: var(--mono); font-size: 30px; font-weight: 700; color: var(--cyan); text-transform: uppercase;
  background: linear-gradient(145deg, rgba(34,211,238,.2), rgba(139,92,246,.2)); border: 1px solid var(--border-bright);
}
.pe-avatar-actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.pe-avatar-actions .ghost-btn { font-size: 11.5px; padding: 5px 10px; white-space: nowrap; }
.pe-remove { color: var(--bad) !important; }
.pe-fields { display: flex; flex-direction: column; gap: 8px; min-width: 240px; flex: 1; }
.pe-label { font-size: 12px; color: var(--text-dim); font-weight: 600; }
.pe-fields .cf-input { max-width: 340px; }
.pe-row { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.pe-status { font-size: 12px; color: var(--text-dim); }
.pe-status.err { color: var(--bad); }

/* Claude Code connection banner + guided reconnect */
.cc-conn { margin-bottom: 14px; }
.cc-conn-row { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--text-dim);
  padding: 9px 12px; border-radius: 11px; background: var(--panel); border: 1px solid var(--border); }
.cc-conn-row.checking { color: var(--text-faint); }
.cc-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.cc-dot.ok { background: var(--good, #34d399); box-shadow: 0 0 8px rgba(52,211,153,.5); }
.cc-dot.warn { background: var(--warn, #fbbf24); box-shadow: 0 0 8px rgba(251,191,36,.5); }
.linky { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; font-size: 12px; padding: 0; margin-left: auto; text-decoration: underline; }
.cc-conn-panel { padding: 16px 18px; border-radius: 14px; background: var(--panel); border: 1px solid var(--border); }
.cc-conn-panel.warn { border-color: rgba(251,191,36,.35); background: rgba(251,191,36,.06); }
.cc-conn-head { display: flex; align-items: center; gap: 9px; font-size: 15px; color: var(--text); margin-bottom: 8px; }
.cc-conn-reason { font-size: 12px; color: var(--text-faint); margin-bottom: 10px; }
.cc-conn-steps { margin: 0 0 12px; padding-left: 20px; font-size: 13px; color: var(--text-dim); line-height: 1.7; }
.cc-conn-steps code { font-family: var(--mono); font-size: 12px; background: rgba(10,14,24,.6); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; color: var(--accent); }
.cc-conn-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.cc-conn-form .cf-input { flex: 1; min-width: 240px; }
.cc-conn-status { font-size: 12px; color: var(--text-dim); margin-top: 8px; }
.cc-conn-status.err { color: var(--bad); }
.cc-conn-cancel { margin-top: 10px; display: inline-block; }

/* users list */
.users-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.user-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px; border-radius: 11px;
  background: rgba(10,14,24,.5); border: 1px solid var(--border);
}
.user-row .ur-avatar {
  width: 30px; height: 30px; flex: none; border-radius: 9px; display: grid; place-items: center;
  font-family: var(--mono); font-size: 12px; font-weight: 700; text-transform: uppercase;
  color: var(--text-dim); background: rgba(120,150,220,.1); border: 1px solid var(--border);
}
.user-row .ur-info { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.user-row .ur-email { font-size: 13.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-row .ur-meta { font-family: var(--mono); font-size: 10.5px; color: var(--text-faint); }
.role-tag {
  flex: none; font-family: var(--mono); font-size: 10px; letter-spacing: .8px; text-transform: uppercase;
  padding: 3px 8px; border-radius: 6px; border: 1px solid var(--border);
}
.role-tag.admin { color: var(--violet); border-color: rgba(139,92,246,.4); background: rgba(139,92,246,.1); }
.role-tag.user { color: var(--text-dim); background: rgba(120,150,220,.08); }
.del-user-btn {
  flex: none; width: 28px; height: 28px; border-radius: 8px; cursor: pointer;
  display: grid; place-items: center; font-size: 15px; line-height: 1;
  background: transparent; border: 1px solid var(--border); color: var(--text-faint);
  transition: color .15s, border-color .15s, background .15s;
}
.del-user-btn:hover { color: var(--bad); border-color: rgba(248,113,113,.4); background: rgba(248,113,113,.08); }
.del-user-btn:disabled { opacity: .3; cursor: default; }
.users-empty { font-size: 12.5px; color: var(--text-faint); padding: 6px 2px; }

/* create form */
.create-form { border-top: 1px solid var(--border); padding-top: 16px; }
.cf-row { display: flex; flex-wrap: wrap; gap: 9px; }
.cf-input, .cf-select {
  font: inherit; font-size: 13.5px; color: var(--text);
  background: rgba(6,9,16,.7); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.cf-input { flex: 1; min-width: 150px; }
.cf-input::placeholder { color: var(--text-faint); }
.cf-input:focus, .cf-select:focus { border-color: var(--border-bright); box-shadow: 0 0 0 3px rgba(56,189,248,.08); }
.cf-select { flex: none; cursor: pointer; }
.cf-error { margin-top: 10px; font-size: 12.5px; color: var(--bad); }

.primary-btn {
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; flex: none;
  padding: 10px 18px; border-radius: 11px; border: none; color: #04121e;
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  box-shadow: 0 6px 18px -6px rgba(56,189,248,.6);
  transition: transform .1s, box-shadow .16s, opacity .16s;
}
.primary-btn:hover { transform: translateY(-1px); box-shadow: 0 9px 22px -6px rgba(56,189,248,.8); }
.primary-btn:active { transform: scale(.97); }
.primary-btn:disabled { opacity: .5; cursor: default; transform: none; box-shadow: none; }

/* ===== Login overlay ===== */
.login-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 24px;
  background: rgba(4,6,12,.72); backdrop-filter: blur(10px);
  animation: fade .3s ease;
}
.login-overlay[hidden] { display: none; }
.login-card {
  width: 100%; max-width: 380px;
  display: flex; flex-direction: column;
  padding: 32px 30px 28px; border-radius: 22px;
  background: linear-gradient(180deg, rgba(20,27,46,.72), rgba(11,15,28,.78));
  border: 1px solid var(--border-bright);
  box-shadow: 0 30px 80px -24px rgba(0,0,0,.8), inset 0 0 30px rgba(56,189,248,.05);
  backdrop-filter: blur(22px);
}
.login-logo {
  width: 58px; height: 58px; border-radius: 17px; margin: 0 auto 16px; display: grid; place-items: center;
  background: linear-gradient(145deg, rgba(34,211,238,.16), rgba(139,92,246,.16));
  border: 1px solid var(--border-bright); box-shadow: inset 0 0 22px rgba(56,189,248,.18);
}
.login-badge {
  display: flex; align-items: center; justify-content: center;
  width: 200px; max-width: 72%; margin: 0 auto 16px; padding: 18px 22px;
  border-radius: 20px; background: linear-gradient(145deg, #e4e6eb, #cdd1d8);
  border: 1px solid rgba(0,0,0,.10); box-shadow: inset 0 1px 0 rgba(255,255,255,.55), 0 10px 26px -14px rgba(0,0,0,.7);
}
.login-badge img { width: 100%; height: auto; display: block; }
.topbar-logo { display: inline-flex; align-items: center; }
.topbar-logo img { height: 18px; width: auto; display: block; }
.login-title { margin: 0; text-align: center; font-size: 21px; font-weight: 600; letter-spacing: .2px; }
.login-title b { font-weight: 750; }
.login-sub { margin: 6px 0 22px; text-align: center; color: var(--text-dim); font-size: 13.5px; }
.login-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.login-field span { font-size: 12px; color: var(--text-dim); font-weight: 500; letter-spacing: .2px; }
.login-field input {
  font: inherit; font-size: 14.5px; color: var(--text);
  background: rgba(6,9,16,.7); border: 1px solid var(--border); border-radius: 11px;
  padding: 12px 14px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.login-field input::placeholder { color: var(--text-faint); }
.login-field input:focus { border-color: var(--border-bright); box-shadow: 0 0 0 3px rgba(56,189,248,.08); }
.login-error {
  margin: 2px 0 14px; padding: 9px 12px; border-radius: 10px; font-size: 13px;
  color: var(--bad); background: rgba(248,113,113,.1); border: 1px solid rgba(248,113,113,.3);
}
.login-submit { width: 100%; margin-top: 4px; padding: 13px; font-size: 14.5px; }

@media (max-width: 480px) {
  .cf-row { flex-direction: column; }
  .cf-input, .cf-select, .cf-submit { width: 100%; }
}

/* ===== Production · camera grid — 3 per row so up to 6 cams fit one screen as 2 rows ===== */
.cam-grid {
  display: grid;
  /* 2026-07-24 (phone tiles collapsed to ~40px strips): the old repeat(3,1fr) + media-query cascade
     relied on the grid container being full width AND the phone rule applying — when a flex ancestor
     let the container shrink to content, the 1fr column collapsed to the tile's min-content. This
     auto-fill + minmax(min(100%,N),1fr) is intrinsically responsive and CANNOT collapse: each tile is
     at least min(container-width, 300px) -> 1 full-width column on phones, 2-4 on wider screens. No
     media queries, no dependence on ancestor stretch. width:100% pins it to the panel regardless. */
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 12px;
  margin-top: 6px;
  width: 100%;
}
.cam-tile {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  min-width: 0;                 /* never let a tile's content force it wider/narrower than its cell */
  background: rgba(6, 9, 16, 0.5);
}
.cam-tile.on { border-color: var(--border-bright); }
.cam-view {
  position: relative;
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.02) 0 10px, transparent 10px 20px),
    var(--bg-2);
}
.cam-feed { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-ph { color: var(--text-faint); font-size: 12.5px; display: flex; align-items: center; gap: 7px; }
.cam-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-faint); box-shadow: 0 0 0 3px rgba(255,255,255,.04);
}
.cam-tile.on .cam-dot { background: var(--good, #34d399); box-shadow: 0 0 8px var(--good, #34d399); }
.cam-label {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 10px; font-size: 12.5px; font-weight: 600; border-top: 1px solid var(--border);
}
.cam-zone {
  font-family: var(--mono); font-size: 10px; letter-spacing: .5px;
  text-transform: uppercase; color: var(--text-dim); font-weight: 500;
}
/* Pan/tilt D-pad overlaid on a motorised (E30) camera tile. On hover for mouse; always on touch. */
.cam-ptz {
  position: absolute; right: 6px; bottom: 6px; z-index: 2;
  display: grid; grid-template-columns: repeat(3, 28px); grid-template-rows: repeat(3, 28px); gap: 3px;
  opacity: 0; transition: opacity .15s ease;
}
.cam-tile:hover .cam-ptz, .cam-view:focus-within .cam-ptz { opacity: 1; }
@media (hover: none) { .cam-ptz { opacity: .9; } }
.cam-ptz-btn {
  border: none; border-radius: 7px; cursor: pointer; padding: 0;
  background: rgba(10, 14, 22, .72); color: #fff; font-size: 13px; line-height: 1;
  display: grid; place-items: center; -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.cam-ptz-btn:hover { background: rgba(52, 211, 153, .85); }
.cam-ptz-btn:active { transform: scale(.92); }
.cam-ptz-btn:disabled { opacity: .5; cursor: default; }
.ptz-up { grid-area: 1 / 2; }
.ptz-left { grid-area: 2 / 1; }
.ptz-home { grid-area: 2 / 2; font-size: 12px; }
.ptz-right { grid-area: 2 / 3; }
.ptz-down { grid-area: 3 / 2; }

/* clicking a live tile enlarges it */
.cam-tile.on .cam-feed { cursor: zoom-in; }

/* "Camera history / recordings" button in the Cameras panel header */
.mk-h .cam-history-btn {
  float: right;
  border: 1px solid var(--border-bright); border-radius: 8px; cursor: pointer;
  background: rgba(255, 255, 255, .06); color: inherit;
  padding: 4px 10px; font-size: 12px; font-weight: 600; line-height: 1.4;
}
.mk-h .cam-history-btn:hover { background: rgba(52, 211, 153, .15); border-color: rgba(52, 211, 153, .6); }

/* "Open in a window" button — opens the live cameras in their own OS window (?popout=cams) */
.mk-h .cam-popout-btn {
  float: right; margin-right: 8px;
  border: 1px solid var(--border-bright); border-radius: 8px; cursor: pointer;
  background: rgba(255, 255, 255, .06); color: inherit;
  padding: 4px 10px; font-size: 12px; font-weight: 600; line-height: 1.4;
}
.mk-h .cam-popout-btn:hover { background: rgba(96, 165, 250, .15); border-color: rgba(96, 165, 250, .6); }

/* ===== Frigate history overlay — the NVR's Review UI inside the cockpit ===== */
.frigate-ov {
  position: fixed; inset: 0; z-index: 1100;
  display: flex; flex-direction: column;
  background: rgba(3, 6, 12, .97);
  /* keep the header bar below the iPhone notch/status bar in the standalone PWA */
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.frigate-ov-bar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 14px; color: #fff; border-bottom: 1px solid var(--border);
}
.frigate-ov-title { font-weight: 600; font-size: 14px; }
.frigate-ov-ext { margin-left: auto; color: var(--text-dim); font-size: 12px; text-decoration: none; }
.frigate-ov-ext:hover { color: #fff; text-decoration: underline; }
.frigate-ov-close {
  border: none; border-radius: 8px; width: 34px; height: 34px; cursor: pointer;
  background: rgba(220, 70, 70, .4); color: #fff; font-size: 16px; line-height: 1;
}
.frigate-ov-close:hover { background: rgba(220, 70, 70, .7); }
/* iOS WebKit ignores flex/percentage heights on iframes (they balloon to content height, shoving
   the page upward) — pin the iframe absolutely inside a flex-1 wrapper instead. */
.frigate-ov-body { flex: 1; position: relative; min-height: 0; }
.frigate-ov-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }

/* ===== Camera FULLSCREEN viewer (click a feed; arrows switch; Esc/close/backdrop exit) ===== */
.cam-fs {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; flex-direction: column; padding: 6px;
  /* keep controls clear of the iPhone notch/home-indicator in the standalone PWA */
  padding-top: calc(6px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  background: rgba(3, 6, 12, .93);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.cam-fs-stage { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; }
/* fill the stage (scale the frame UP, letterboxed) instead of capping at the source's native size */
.cam-fs-feed {
  width: 100%; height: 100%; object-fit: contain;
  border-radius: 8px; box-shadow: 0 8px 40px rgba(0, 0, 0, .6);
}
.cam-fs-stage .cam-ptz { opacity: .92; right: 16px; bottom: 16px; }
.cam-fs-bar {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 8px 8px 2px; color: #fff; flex-wrap: wrap;
}
.cam-fs-name { font-weight: 600; font-size: 15px; }
.cam-fs-idx { color: var(--text-dim); font-family: var(--mono); font-size: 12px; margin-left: 4px; }
.cam-fs-hint { color: var(--text-faint); font-size: 11.5px; font-family: var(--mono); width: 100%; text-align: center; }
.cam-fs-prev, .cam-fs-next, .cam-fs-close {
  border: none; border-radius: 9px; cursor: pointer; color: #fff; padding: 0;
  width: 42px; height: 42px; font-size: 22px; line-height: 1; display: grid; place-items: center;
  background: rgba(255, 255, 255, .12);
}
.cam-fs-prev:hover, .cam-fs-next:hover { background: rgba(255, 255, 255, .24); }
.cam-fs-close { background: rgba(220, 70, 70, .4); }
.cam-fs-close:hover { background: rgba(220, 70, 70, .7); }

/* --- Order-driven "Under production" section ------------------------------- */
.prod-pills { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.prod-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 11px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-2);
}
.prod-pill-label { font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.prod-pill-tag {
  font-family: var(--mono); font-size: 9px; letter-spacing: .5px; text-transform: uppercase;
  color: var(--bg-0, #060911); background: var(--warn, #f59e0b); padding: 1px 5px; border-radius: 999px; font-weight: 700;
}
.prod-pill-val { font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--good, #34d399); }
.order-card { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-bottom: 10px; }
.order-head {
  display: flex; align-items: center; gap: 10px; padding: 8px 11px;
  background: var(--bg-2); border-bottom: 1px solid var(--border);
}
.order-client { font-weight: 700; font-size: 13px; }
.order-ref { font-family: var(--mono); font-size: 11px; color: var(--text-dim); }
.order-status {
  margin-left: auto; font-family: var(--mono); font-size: 10px; letter-spacing: .5px; text-transform: uppercase;
  color: var(--text-dim); border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px;
}
/* amber variant — unpaid invoices / linked-invoice chips (was referenced but never styled) */
.order-status-warn { color: var(--warn, #fbbf24); border-color: rgba(251,191,36,.32); background: rgba(251,191,36,.1); }
.ln-raw { font-size: 10.5px; color: var(--text-faint); font-family: var(--mono); margin-top: 1px; }
.ln-review, .ln-custom {
  font-family: var(--mono); font-size: 9px; letter-spacing: .5px; text-transform: uppercase;
  border-radius: 999px; padding: 1px 6px; font-weight: 700; vertical-align: middle;
}
.ln-review { color: var(--bg-0, #060911); background: var(--warn, #f59e0b); }
.ln-custom { color: var(--warn, #f59e0b); border: 1px solid var(--warn, #f59e0b); }
.review-row {
  border: 1px solid var(--warn, #f59e0b); border-radius: 12px; padding: 9px 11px; margin-bottom: 12px;
  background: color-mix(in srgb, var(--warn, #f59e0b) 9%, transparent);
}
.review-lead {
  display: inline-block; font-weight: 700; font-size: 12px; color: var(--warn, #f59e0b);
  text-transform: uppercase; letter-spacing: .5px; margin-right: 8px;
}
.review-chip {
  display: inline-block; margin: 3px 6px 3px 0; padding: 3px 9px; font-size: 12px;
  border: 1px solid var(--warn, #f59e0b); border-radius: 999px; cursor: default;
}
.review-sug { color: var(--text-dim); font-family: var(--mono); font-size: 11px; }

/* --- product confirm picker (set an order's product; sticks across harvests) --------------- */
.confirm-row { display: flex; align-items: center; gap: 7px; padding: 7px 10px; border-top: 1px solid var(--border); }
.confirm-sel {
  flex: 1; min-width: 0; font-size: 12.5px; padding: 4px 7px; border-radius: 8px;
  background: var(--bg-2); color: var(--text); border: 1px solid var(--border); font-family: var(--ui);
}
.confirm-btn {
  font-size: 12px; font-weight: 600; padding: 4px 12px; border-radius: 8px; cursor: pointer;
  background: var(--accent, #3b82f6); color: #fff; border: none;
}
.confirm-btn:disabled { opacity: .6; cursor: default; }
.confirm-done { font-size: 12.5px; font-weight: 600; color: var(--good, #34d399); padding: 4px 0; }

/* --- Production board (orders in production, grouped by client + commercial jobs not yet in production) --- */
.board-counts { margin: 4px 0 12px; }
.board-sub {
  margin: 20px 2px 8px; font-size: 12.5px; font-weight: 600; color: var(--text-dim); letter-spacing: .3px;
  border-top: 1px solid var(--border); padding-top: 16px;
}
.board-line { padding: 8px 11px; border-top: 1px solid var(--border); }
.order-card .board-line:first-of-type { border-top: 0; }
.board-line-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; font-weight: 600; }
.board-line-label { min-width: 0; overflow-wrap: anywhere; }
.board-line-prog { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.board-line-prog .job-pay-bar { min-width: 80px; }
.board-line-prog .job-pay-pct { font-family: var(--mono); font-size: 11.5px; color: var(--text-dim); white-space: nowrap; }
.board-src {
  flex: none; font-family: var(--mono); font-size: 9px; letter-spacing: .4px; text-transform: uppercase;
  padding: 1px 6px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-dim);
}
.board-src-vision { color: var(--accent); border-color: rgba(56,189,248,.32); background: rgba(56,189,248,.08); }
.board-src-human { color: var(--text-dim); background: rgba(120,150,220,.08); }
/* compact [-] [n] [+] made-count stepper -> POSTs /api/production/made */
.made-step { display: flex; align-items: center; gap: 6px; margin-left: auto; flex: none; }
.made-step-btn {
  width: 24px; height: 24px; border-radius: 7px; border: 1px solid var(--border); background: var(--bg-2);
  color: var(--text); font-size: 14px; line-height: 1; cursor: pointer; display: grid; place-items: center; padding: 0;
}
.made-step-btn:hover { background: rgba(56,189,248,.14); border-color: rgba(56,189,248,.4); }
.made-step-btn:disabled { opacity: .5; cursor: default; }
.made-step-val { font-family: var(--mono); font-size: 12.5px; min-width: 18px; text-align: center; }

/* --- Desktop tray (unconfirmed quotes + unpaid invoices, two columns) --- */
.tray-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 700px) { .tray-cols { grid-template-columns: 1fr; gap: 6px; } }
.tray-col-h { font-size: 12.5px; font-weight: 600; color: var(--text-dim); margin: 0 0 8px; letter-spacing: .3px; }
.tray-ref {
  font-family: var(--mono); font-size: 10.5px; color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px;
}
.tray-stale {
  border: 1px solid rgba(251,191,36,.32); background: rgba(251,191,36,.08); color: var(--warn, #fbbf24);
  border-radius: 10px; padding: 8px 11px; font-size: 12px; margin-bottom: 10px;
}
.tray-legacy {
  font-family: var(--mono); font-size: 9px; letter-spacing: .4px; text-transform: uppercase;
  color: #9c5a00; background: #f8ecd8; border-radius: 999px; padding: 1px 6px; margin-left: 6px;
}

/* --- Production history (day-by-day bar chart + 7d/30d/YTD range toggle) --- */
.hist-ranges { display: inline-flex; }
.hist-range {
  border: 1px solid currentColor; background: transparent; color: inherit; opacity: .6;
  border-radius: 6px; padding: 2px 9px; margin-left: 6px; font-size: 12px; cursor: pointer;
}
.hist-range.active { opacity: 1; font-weight: 700; }
.hist-totals { font-family: var(--mono); font-size: 11.5px; color: var(--text-faint); margin-top: 6px; }

/* #10 Steward updates — a Status-tab 'System updates' card (proposed self-updates + tier/ETA).
   Applying routes through the approvals gate; nothing installs from here (auto-apply is OFF). */
.status-updates { grid-column: 1 / -1; }
.upd-list { margin-top: 8px; }
.upd-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 9px 0; border-top: 1px solid var(--border);
}
.upd-main { min-width: 0; flex: 1; }
.upd-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.upd-name { font-weight: 600; font-size: 13.5px; font-family: var(--mono); }
.upd-target { font-family: var(--mono); font-size: 11.5px; color: var(--accent); }
.upd-meta { margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; }
.upd-tier, .upd-eta {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .4px; color: var(--text-dim);
  background: rgba(56,189,248,.07); border: 1px solid rgba(56,189,248,.22);
  border-radius: 6px; padding: 2px 7px;
}
.upd-apply-btn {
  flex: none; padding: 7px 13px; font-size: 12.5px; font-weight: 600; border-radius: 8px; cursor: pointer;
  background: rgba(52,211,153,.14); color: var(--good); border: 1px solid rgba(52,211,153,.3);
}
.upd-apply-btn:hover { background: rgba(52,211,153,.24); }
.upd-apply-btn:disabled { opacity: .55; cursor: default; }

/* #11 WhatsApp inbox — read-only inbound display; Reply routes through the external_message gate. */
.whatsapp-body { flex: 1; overflow-y: auto; display: grid; gap: 16px; align-content: start; padding-bottom: 24px; }
.wa-msg {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  padding: 12px 0; border-top: 1px solid var(--border);
}
.wa-msg:first-of-type { border-top: none; }
.wa-msg-main { min-width: 0; flex: 1; }
.wa-msg-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.wa-from { font-weight: 600; font-size: 14px; font-family: var(--mono); }
.wa-type {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .4px; text-transform: uppercase;
  color: var(--accent); background: rgba(56,189,248,.08); border: 1px solid rgba(56,189,248,.26);
  border-radius: 6px; padding: 1px 6px;
}
.wa-when { font-family: var(--mono); font-size: 11px; color: var(--text-faint); margin-left: auto; }
.wa-preview { margin: 7px 0 0; font-size: 13px; color: var(--text-dim); line-height: 1.45; word-break: break-word; }
.wa-msg-act { flex: none; }
.wa-reply-btn {
  padding: 7px 13px; font-size: 12.5px; font-weight: 600; border-radius: 8px; cursor: pointer;
  background: rgba(56,189,248,.12); color: var(--accent); border: 1px solid rgba(56,189,248,.3);
}
.wa-reply-btn:hover { background: rgba(56,189,248,.2); }
.wa-reply-btn:disabled { opacity: .55; cursor: default; }

/* ===== Claude Code viewer ===== */
.cc-head-actions { display: flex; gap: 8px; align-items: center; }
.cc-body { flex: 1; overflow-y: auto; min-height: 0; padding-bottom: 24px; }
.cc-list { display: flex; flex-direction: column; gap: 8px; }
.cc-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  width: 100%; text-align: left; cursor: pointer;
  padding: 13px 16px; border-radius: 13px;
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  font: inherit; transition: border-color .16s, background .16s, transform .1s;
}
.cc-row:hover { border-color: var(--border-bright); background: rgba(56,189,248,.06); }
.cc-row:active { transform: scale(.995); }
.cc-row-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.cc-row-title { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-row-preview { font-size: 12.5px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-row-meta { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.cc-row-proj { font-size: 11px; color: var(--text-dim); font-family: var(--mono); }
.cc-row-when { font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.cc-detail-head { display: flex; align-items: center; gap: 14px; padding: 2px 2px 14px; position: sticky; top: 0; background: var(--bg-0); z-index: 2; }
.cc-back { background: transparent; border: none; cursor: pointer; color: var(--accent); font: inherit; font-size: 13px; font-weight: 600; padding: 4px 2px; }
.cc-back:hover { color: var(--cyan); }
.cc-detail-title { font-size: 15px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-trunc { font-size: 12px; color: var(--warn); padding: 0 2px 12px; }
.cc-thread { display: flex; flex-direction: column; gap: 14px; }
.cc-msg { display: flex; flex-direction: column; gap: 5px; max-width: 92%; }
.cc-msg.cc-user { align-self: flex-end; align-items: flex-end; }
.cc-msg-role { font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-faint); }
.cc-user .cc-msg-role { color: var(--accent); }
.cc-msg-text {
  padding: 11px 14px; border-radius: 13px; font-size: 13.5px; line-height: 1.5;
  border: 1px solid var(--border); background: var(--panel); overflow-wrap: anywhere;
}
.cc-user .cc-msg-text { background: linear-gradient(180deg, rgba(59,130,246,.18), rgba(56,189,248,.09)); border-color: var(--border-bright); color: #eaf2ff; }
.cc-msg-text pre { overflow-x: auto; background: rgba(9,12,22,.6); border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; }
.cc-msg-text code { font-family: var(--mono); font-size: 12.5px; }

/* --- Cerebro-first boot: the classic chat markup is HIDDEN from first paint
   (it used to flash for a beat before the iframe swapped in). app.js adds
   body.classic-chat ONLY when no chat engine is configured/reachable at all —
   the classic view survives purely as that emergency fallback. */
body:not(.classic-chat) .view-chat > .view-head,
body:not(.classic-chat) .view-chat > .chat-scroll,
body:not(.classic-chat) .view-chat > .composer { display: none; }
.chatui-boot { flex: 1; display: flex; align-items: center; justify-content: center; }
body.classic-chat .chatui-boot { display: none; }
.chatui-boot-spin { width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid rgba(120,150,220,.22); border-top-color: #38bdf8;
  animation: chatuiboot .8s linear infinite; }
@keyframes chatuiboot { to { transform: rotate(360deg); } }

/* ---- Opening intro overlay (intro.js) — sits above everything until the app
       is ready; app.js calls window.__plastoldIntroDone() to dismiss it. ---- */
#introSplash {
  position: fixed; inset: 0; z-index: 10000; background: #05070f; overflow: hidden;
}
#introSplash canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#inMark {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding-top: 13vh; pointer-events: none;
  opacity: 0; transform: rotateX(26deg) translateY(66px) scale(.94);
  transition: opacity 1.1s cubic-bezier(.2,.7,.2,1), transform 1.1s cubic-bezier(.2,.7,.2,1);
}
#inMark.on { opacity: 1; transform: none; }
#inWord {
  font: 800 clamp(46px, 9vw, 88px)/1 ui-rounded, -apple-system, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif;
  letter-spacing: .5px; position: relative; display: inline-block; color: #e9eefb;
  text-shadow: 0 2px 0 rgba(9,14,27,.9), 0 4px 0 rgba(7,11,22,.7),
               0 7px 18px rgba(0,0,0,.6), 0 0 46px rgba(64,140,255,.16);
}
#inShine {
  position: absolute; inset: 0; color: transparent; pointer-events: none; text-shadow: none;
  background: linear-gradient(105deg, rgba(255,255,255,0) 42%, rgba(255,255,255,.9) 50%, rgba(190,215,255,.5) 54%, rgba(255,255,255,0) 62%);
  background-size: 280% 100%; background-position: 120% 0; background-repeat: no-repeat;
  -webkit-background-clip: text; background-clip: text;
}
#inMark.on #inShine { animation: inSweep 1.6s .5s cubic-bezier(.4,0,.2,1) 1 both; }
@keyframes inSweep { from { background-position: 120% 0; } to { background-position: -60% 0; } }
#inTag {
  margin-top: 13px; font: 500 clamp(10px, 1.6vw, 14px)/1 -apple-system, "Segoe UI", system-ui, sans-serif;
  letter-spacing: .42em; text-indent: .42em; color: #5f7db0; text-transform: uppercase;
  opacity: 0; transition: opacity .9s .55s;
}
#inMark.on #inTag { opacity: .9; }

/* ---- Security panel (passkeys + TOTP) + login extras ---- */
.sec-section { margin-top: 16px; }
.sec-h { font-size: 13.5px; margin: 0 0 6px; color: var(--text); }
.pk-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.pk-row { display: flex; align-items: center; gap: 10px; background: rgba(120,150,220,.06);
          border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; }
.pk-name { font-weight: 600; }
.pk-meta { color: var(--text-faint); font-size: 12px; margin-left: auto; }
.tp-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.tp-code { width: 110px; font: 600 16px ui-monospace, monospace; letter-spacing: 3px;
           background: var(--bg-2); border: 1px solid var(--border); border-radius: 9px;
           color: var(--text); padding: 8px 10px; text-align: center; }
.tp-secret { display: inline-block; background: #080c16; border: 1px solid var(--border);
             border-radius: 8px; padding: 7px 11px; font-size: 13px; color: #93c5fd;
             word-break: break-all; user-select: all; -webkit-user-select: all; margin: 4px 0; }
.tp-link { color: #7cc0ff; }
.ur-reset2fa { padding: 4px 9px; font-size: 11.5px; margin-right: 6px; flex: none; }
.login-passkey { width: 100%; margin-top: 10px; justify-content: center; }

/* ==========================================================================
   CHANGES · LIVE INFERENCE MONITOR (lp-*) — per-machine cards, VLM camera
   tiles with verdict overlays, doc-pipeline activity, gateway call stream.
   Consumes the existing dark-theme vars only.
   ========================================================================== */
.lp-wrap { display: flex; flex-direction: column; gap: 14px; margin-bottom: 22px; }
.lp-head { display: flex; align-items: center; gap: 10px; }
.lp-title { font-size: 13px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: var(--text-dim); }
.lp-updated { margin-left: auto; font-size: 11.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.lp-live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-faint); }
.lp-live-dot.good { background: var(--good); box-shadow: 0 0 0 0 rgba(52,211,153,.5); animation: lpPulse 2s ease-out infinite; }
.lp-live-dot.bad { background: var(--bad); }
@keyframes lpPulse { 0% { box-shadow: 0 0 0 0 rgba(52,211,153,.45); } 70% { box-shadow: 0 0 0 9px rgba(52,211,153,0); } 100% { box-shadow: 0 0 0 0 rgba(52,211,153,0); } }

.lp-machines { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.lp-machine { background: var(--panel); border: 1px solid var(--border); border-radius: var(--r);
  padding: 13px 15px; backdrop-filter: blur(10px); display: flex; flex-direction: column; gap: 8px; }
.lp-machine-planned { opacity: .62; border-style: dashed; }
.lp-machine-head { display: flex; align-items: center; gap: 8px; }
.lp-machine-head h3 { font-size: 14px; font-weight: 700; margin: 0; }
.lp-machine-act { margin-left: auto; font-size: 11px; color: var(--accent); font-variant-numeric: tabular-nums; white-space: nowrap; }
.lp-role { font-size: 11px; color: var(--text-faint); margin: 0; line-height: 1.45; }
.lp-wd { color: var(--text-dim); }

.lp-meter { display: flex; align-items: center; gap: 8px; font-size: 11px; }
.lp-meter-label { flex: 0 0 30px; color: var(--text-faint); font-weight: 700; letter-spacing: .5px; }
.lp-bar { flex: 1; height: 6px; border-radius: 4px; background: rgba(120,150,220,.14); overflow: hidden; }
.lp-bar-fill { display: block; height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), #818cf8); transition: width .7s ease; }
.lp-meter-val { flex: 0 0 auto; color: var(--text-dim); font-variant-numeric: tabular-nums; }

.lp-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.lp-chip { font-size: 10.5px; font-weight: 650; letter-spacing: .3px; padding: 3px 8px; border-radius: 999px;
  border: 1px solid var(--border); background: rgba(20,27,46,.5); color: var(--text-dim); white-space: nowrap; }
.lp-chip.pc { color: #7dd3fc; border-color: rgba(56,189,248,.35); }
.lp-chip.imac { color: #c4b5fd; border-color: rgba(167,139,250,.35); }
.lp-chip.m5 { color: #fda4af; border-color: rgba(251,113,133,.3); }
.lp-chip.claude { color: #fcd34d; border-color: rgba(251,191,36,.35); }
.lp-chip.ok { color: var(--good); border-color: rgba(52,211,153,.35); }
.lp-chip.warn { color: var(--warn); border-color: rgba(251,191,36,.35); }
.lp-chip.bad { color: var(--bad); border-color: rgba(248,113,113,.4); }
.lp-chip.idle { color: var(--text-faint); }

.lp-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
@media (max-width: 980px) { .lp-cols { grid-template-columns: 1fr; } }
.lp-col-stack { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.lp-proc { display: flex; align-items: center; gap: 8px; font-size: 11px; }
.lp-proc-name { flex: 0 0 132px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text-dim); font-weight: 600; }
.lp-proc .lp-bar { flex: 1; }
.lp-proc-val { flex: 0 0 auto; min-width: 74px; text-align: right; color: var(--text-faint);
  font-variant-numeric: tabular-nums; }
.lp-panel { display: flex; flex-direction: column; gap: 10px; }
.lp-panel-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lp-panel-head h3 { font-size: 13px; font-weight: 700; margin: 0; color: var(--text); }
.lp-pill { margin-left: auto; font-size: 10.5px; font-weight: 700; letter-spacing: .5px; padding: 3px 9px;
  border-radius: 999px; border: 1px solid var(--border); color: var(--text-dim); white-space: nowrap; }
.lp-pill.ok { color: var(--good); border-color: rgba(52,211,153,.4); background: rgba(52,211,153,.08); }
.lp-pill.warn { color: var(--warn); border-color: rgba(251,191,36,.4); background: rgba(251,191,36,.07); }
.lp-pill.bad { color: var(--bad); border-color: rgba(248,113,113,.45); background: rgba(248,113,113,.08); }
.lp-pill.idle { color: var(--text-faint); }

.lp-cam-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 9px; }
.lp-cam { position: relative; margin: 0; border-radius: 12px; overflow: hidden;
  border: 1px solid var(--border); background: #090c16; aspect-ratio: 16/10; }
.lp-cam-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lp-cam.stale::after { content: "frozen"; position: absolute; top: 7px; right: 8px; font-size: 9.5px;
  font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: var(--bad);
  background: rgba(9,12,22,.75); border: 1px solid rgba(248,113,113,.5); border-radius: 999px; padding: 2px 7px; }
.lp-cam-cap { position: absolute; inset: auto 0 0 0; padding: 14px 9px 7px;
  background: linear-gradient(transparent, rgba(5,7,15,.88)); display: flex; flex-direction: column; gap: 1px; }
.lp-cam-cap b { font-size: 11px; letter-spacing: .3px; }
.lp-cam-verdict { font-size: 10px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lp-cam-verdict.on { color: var(--good); }
.lp-cam-verdict.off { color: var(--text-faint); }

.lp-vrow { display: flex; align-items: baseline; gap: 9px; font-size: 12px; flex-wrap: wrap;
  padding: 6px 2px; border-bottom: 1px dashed var(--border); }
.lp-vrow b { font-size: 12.5px; }
.lp-vstate { font-size: 10px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; }
.lp-vstate.on { color: var(--good); }
.lp-vstate.off { color: var(--text-faint); }
.lp-vnote { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 34ch; }
.lp-vnum { margin-left: auto; color: var(--text-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
.lp-prods { padding-top: 2px; }

.lp-sub { font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase;
  color: var(--text-faint); margin: 4px 0 0; }
.lp-events { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.lp-events li { font-size: 12px; color: var(--text); display: flex; align-items: baseline; gap: 7px;
  flex-wrap: wrap; line-height: 1.45; }
.lp-mono { font-family: var(--mono); font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.lp-old { color: var(--text-dim); text-decoration: line-through rgba(154,166,194,.5); }
.lp-dim { color: var(--text-faint); font-size: 11px; }
.lp-age { font-variant-numeric: tabular-nums; }
.lp-stream-list { max-height: 220px; overflow-y: auto; }
.lp-section-h { font-size: 13px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase;
  color: var(--text-dim); margin: 6px 0 10px; }
