/* Consoliko — calm, dense, keyboard-first. One accent for actions (blue),
   one for the assistant (indigo), red/amber/green only for status. */
:root {
  --bg: #f6f8fb; --bg2: #eef2f7; --panel: #ffffff; --panel2: #f4f6f9; --line: #e3e8ef; --line2: #cbd3de;
  --ink: #0f172a; --ink2: #44516a; --ink3: #64748b;
  --acc: #0369a1; --acc-hover: #075985; --acc-ink: #ffffff; --acc-soft: #e6f2fa; --acc-ring: rgba(3,105,161,.28);
  --ai: #4f46e5; --ai-soft: #eef0ff; --ai-ink: #ffffff;
  --good: #15803d; --good-soft: #e3f6e9; --bad: #b91c1c; --bad-soft: #fde8e8; --warn: #a15c07; --warn-soft: #fdf1d8; --info: #3730a3; --info-soft: #eceefe;
  --side: var(--bg2); --side-ink: #44516a; --side-on: #0f172a; --side-hl: #ffffff;
  --r: 10px; --r-sm: 8px;
  --sh-1: 0 1px 2px rgba(15,23,42,.05); --sh-2: 0 1px 2px rgba(15,23,42,.05), 0 6px 20px rgba(15,23,42,.06); --sh-3: 0 18px 50px rgba(15,23,42,.18);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2,.8,.2,1); --t: 160ms;
  --ctl: 34px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120; --bg2: #0e1526; --panel: #121a2b; --panel2: #18223a; --line: #223049; --line2: #31415f;
    --ink: #e7ebf3; --ink2: #b3bfd2; --ink3: #8d9ab0;
    --acc: #38bdf8; --acc-hover: #7dd3fc; --acc-ink: #06121f; --acc-soft: #0d2a40; --acc-ring: rgba(56,189,248,.3);
    --ai: #a5b4fc; --ai-soft: #1d2150; --ai-ink: #0b1120;
    --good: #4ade80; --good-soft: #0f2a1c; --bad: #fca5a5; --bad-soft: #3a1518; --warn: #fbbf24; --warn-soft: #33260a; --info: #c7d2fe; --info-soft: #1e1f4a;
    --side: #0e1526; --side-ink: #b3bfd2; --side-on: #ffffff; --side-hl: #18223a;
    --sh-1: none; --sh-2: none; --sh-3: 0 18px 50px rgba(0,0,0,.5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1120; --bg2: #0e1526; --panel: #121a2b; --panel2: #18223a; --line: #223049; --line2: #31415f;
  --ink: #e7ebf3; --ink2: #b3bfd2; --ink3: #8d9ab0;
  --acc: #38bdf8; --acc-hover: #7dd3fc; --acc-ink: #06121f; --acc-soft: #0d2a40; --acc-ring: rgba(56,189,248,.3);
  --ai: #a5b4fc; --ai-soft: #1d2150; --ai-ink: #0b1120;
  --good: #4ade80; --good-soft: #0f2a1c; --bad: #fca5a5; --bad-soft: #3a1518; --warn: #fbbf24; --warn-soft: #33260a; --info: #c7d2fe; --info-soft: #1e1f4a;
  --side: #0e1526; --side-ink: #b3bfd2; --side-on: #ffffff; --side-hl: #18223a;
  --sh-1: none; --sh-2: none; --sh-3: 0 18px 50px rgba(0,0,0,.5); color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; touch-action: manipulation; font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
a { color: var(--acc); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3 { margin: 0; letter-spacing: -.012em; }
code { font: 12px var(--mono); }
kbd { font: 11px var(--mono); border: 1px solid var(--line2); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; background: var(--panel); color: var(--ink2); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; border-radius: 4px; }
.ic { width: 18px; height: 18px; flex: none; }
.muted { color: var(--ink3); } .small { font-size: 12.5px; } .bad { color: var(--bad); } .good { color: var(--good); } .due { color: var(--warn); font-weight: 600; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 300; background: var(--acc); color: var(--acc-ink); padding: 8px 12px; border-radius: 8px; }
.skip:focus { left: 8px; }

/* ---------- layout ---------- */
#app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100dvh; }
#side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh; padding: 14px 10px 12px; border-right: 1px solid var(--line); }
.brand { display: flex; gap: 10px; align-items: center; padding: 2px 8px 16px; color: var(--ink); text-decoration: none !important; }
.brand b { font-size: 15px; display: block; letter-spacing: -.01em; } .brand small { color: var(--ink3); font-size: 12px; display: block; line-height: 1.3; }
.logo { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(140deg, #0284c7, #0c4a6e); color: #fff; display: grid; place-items: center; flex: none; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.logo svg { width: 22px; height: 22px; }
#nav { display: flex; flex-direction: column; gap: 1px; flex: 1; overflow-y: auto; }
.nav-g { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--ink3); padding: 14px 10px 4px; }
#nav a { color: var(--side-ink); padding: 0 10px; height: 34px; border-radius: 8px; display: flex; gap: 10px; align-items: center; text-decoration: none; font-weight: 500; transition: background var(--t) var(--ease), color var(--t) var(--ease); }
#nav a .ic { width: 17px; height: 17px; opacity: .8; }
#nav a:hover { background: color-mix(in srgb, var(--side-hl) 70%, transparent); color: var(--side-on); }
#nav a.on { background: var(--side-hl); color: var(--side-on); box-shadow: var(--sh-1), inset 0 0 0 1px var(--line); }
#nav a.on .ic { color: var(--acc); opacity: 1; }
.nav-sep { height: 1px; background: var(--line); margin: 12px 8px; }
.side-foot { border-top: 1px solid var(--line); padding: 12px 6px 0; font-size: 12.5px; }
.who { display: flex; gap: 10px; align-items: center; }
.who b { color: var(--ink); display: block; font-size: 13px; } .who small { color: var(--ink3); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--acc-soft); color: var(--acc); display: grid; place-items: center; font-weight: 700; font-size: 11.5px; flex: none; }
.side-btns { display: flex; gap: 4px; margin: 10px 0 6px; flex-wrap: wrap; }
.sbtn { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--ink2); font: 500 12.5px var(--font); padding: 5px 8px; border-radius: 7px; cursor: pointer; }
.sbtn .ic { width: 15px; height: 15px; }
.sbtn:hover { background: var(--panel); color: var(--ink); }
.poc { font-size: 11.5px; color: var(--ink3); padding: 0 2px; }
#content { min-width: 0; display: flex; flex-direction: column; }
#top { position: sticky; top: 0; z-index: 30; display: flex; gap: 10px; align-items: center; padding: 10px 28px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
#omni-host { flex: 1; display: flex; justify-content: center; min-width: 0; }
#menu { display: none; }
main#main { padding: 24px 28px 72px; outline: none; max-width: 1440px; width: 100%; margin: 0 auto; }

/* ---------- omnibar: search or ask ---------- */
.omni { position: relative; width: 100%; max-width: 760px; }
.omni-line { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 8px 0 12px; border: 1px solid var(--line2); background: var(--panel); border-radius: 11px; box-shadow: var(--sh-1); transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease); cursor: text; }
.omni-line:hover { border-color: var(--ink3); }
.omni.open .omni-line { border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-ring); border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.omni.chatting .omni-line { border-color: var(--ai); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ai) 22%, transparent); }
.omni.chatting .omni-ic { color: var(--ai); }
.omni-ic { color: var(--ink3); display: grid; place-items: center; }
.omni-line input { flex: 1; border: 0; background: transparent; height: 100%; padding: 0; font-size: 14.5px; outline: none; box-shadow: none; min-width: 0; }
.omni-line input:focus { outline: none; box-shadow: none; }
.omni-chip { display: inline-flex; align-items: center; gap: 6px; border: 0; background: var(--ai-soft); color: var(--ai); font: 600 12px var(--font); padding: 4px 9px; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.omni-chip .ic { width: 14px; height: 14px; }
.omni-pop { position: absolute; left: 0; right: 0; top: 100%; background: var(--panel); border: 1px solid var(--acc); border-top: 1px solid var(--line); border-radius: 0 0 12px 12px; box-shadow: var(--sh-3); overflow: hidden; display: flex; flex-direction: column; max-height: min(72vh, 680px); animation: drop 160ms var(--ease); }
.omni.chatting .omni-pop { border-color: var(--ai); border-top-color: var(--line); height: min(72vh, 680px); }
@keyframes drop { from { opacity: 0; transform: translateY(-6px); } }
body.omni-open::after { content: ""; position: fixed; inset: 0; background: rgba(15,23,42,.28); z-index: 20; animation: fade 160ms var(--ease); }
@keyframes fade { from { opacity: 0; } }
.omni-list { overflow-y: auto; padding: 6px; }
.og + .og { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }
.og-t { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--ink3); padding: 6px 10px 4px; }
.oi { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 6px 10px; border-radius: 8px; color: var(--ink); text-decoration: none !important; }
.oi .ic { color: var(--ink3); }
.oi-l { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.oi-l small { color: var(--ink3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.oi-type { width: 92px; flex: none; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink3); }
.oi-k { color: var(--ink3); opacity: 0; } .oi.on .oi-k { opacity: 1; }
.oi.on { background: var(--acc-soft); }
.oi.ask .ic { color: var(--ai); }
.oi.ask.on { background: var(--ai-soft); }
.oi.ask b { font-weight: 600; }
.o-empty { padding: 18px 14px; color: var(--ink2); }
.omni-foot { font-size: 11.5px; color: var(--ink3); padding: 8px 14px; border-top: 1px solid var(--line); background: var(--panel2); }

/* chat */
.chat-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.chat-title { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; color: var(--ai); }
.chat-title .ic { width: 16px; height: 16px; }
.chat-note { color: var(--ink3); font-size: 12px; flex: 1; min-width: 160px; }
.chat-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth; }
.chat-foot { padding: 8px 14px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--ink3); display: flex; justify-content: center; background: var(--panel2); }
.msg { display: flex; gap: 10px; max-width: 100%; }
.msg.me { justify-content: flex-end; }
.msg.me .bubble { background: var(--acc-soft); color: var(--ink); border-radius: 14px 14px 4px 14px; padding: 8px 12px; max-width: 78%; white-space: pre-wrap; }
.msg.ai .bubble { flex: 1; min-width: 0; padding-top: 3px; }
.ai-av { width: 26px; height: 26px; border-radius: 8px; background: var(--ai-soft); color: var(--ai); display: grid; place-items: center; flex: none; }
.ai-av .ic { width: 15px; height: 15px; }
.md p { margin: 0 0 6px; } .md p:last-child { margin: 0; }
.md ul { margin: 2px 0 8px; padding-left: 18px; } .md li { margin: 2px 0; }
.md b { font-weight: 650; }
.msg.err .md { color: var(--bad); }
a.ref { font-family: var(--mono); font-size: 12.5px; background: var(--panel2); border: 1px solid var(--line); border-radius: 5px; padding: 0 4px; color: var(--acc); }
.srcs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.src { font: 12px var(--mono); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; color: var(--ink2); }
.src:hover { border-color: var(--acc); color: var(--acc); text-decoration: none; }
.thinking { display: flex; align-items: center; gap: 8px; color: var(--ink3); font-size: 13px; }
.dots { display: inline-flex; gap: 3px; } .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--ai); animation: blink 1.1s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
.chat-empty { margin: auto; text-align: center; max-width: 520px; color: var(--ink2); }
.ai-badge { width: 40px; height: 40px; border-radius: 12px; background: var(--ai-soft); color: var(--ai); display: inline-grid; place-items: center; }
.ai-badge .ic { width: 22px; height: 22px; }
.sugs { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 10px; }
.sug { border: 1px solid var(--line2); background: var(--panel); color: var(--ink); border-radius: 999px; padding: 7px 13px; font: 13px var(--font); cursor: pointer; transition: border-color var(--t), background var(--t); }
.sug:hover { border-color: var(--ai); background: var(--ai-soft); }

/* ---------- page head ---------- */
.ph { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.ph h1 { font-size: 23px; font-weight: 700; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; line-height: 1.25; }
.ph .sub { color: var(--ink2); margin-top: 5px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.ph-r { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumb { font-size: 12.5px; color: var(--ink3); margin-bottom: 4px; }
.crumb a { color: var(--ink2); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: var(--ctl); border: 1px solid var(--line2); background: var(--panel); color: var(--ink); padding: 0 13px; border-radius: var(--r-sm); font: 550 13px var(--font); cursor: pointer; text-decoration: none !important; white-space: nowrap; box-shadow: var(--sh-1); transition: background var(--t) var(--ease), border-color var(--t) var(--ease), transform 80ms; }
.btn .ic { width: 16px; height: 16px; }
.btn:hover { border-color: var(--ink3); background: var(--panel2); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); }
.btn.primary:hover { background: var(--acc-hover); border-color: var(--acc-hover); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; color: var(--ink2); }
.btn.ghost:hover { background: var(--panel2); color: var(--ink); border-color: var(--line); }
.btn.danger.ghost { color: var(--bad); }
.btn.sm { height: 28px; padding: 0 9px; font-size: 12.5px; }
.btn.wide { width: 100%; height: 40px; }
.btn:disabled { opacity: .5; cursor: progress; }
.btn-group { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-sm); }
.btn-group .btn { border: 0; height: 32px; border-radius: 0; } .btn-group .btn + .btn { border-left: 1px solid var(--line); }
.icon { border: 0; background: transparent; color: var(--ink2); cursor: pointer; padding: 6px; border-radius: 7px; display: inline-grid; place-items: center; }
.icon .ic { width: 17px; height: 17px; }
.icon:hover { background: var(--panel2); color: var(--ink); }
td .icon .ic { width: 15px; height: 15px; }

/* ---------- cards & grids ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; margin-bottom: 16px; box-shadow: var(--sh-1); min-width: 0; }
.card h2 { font-size: 14.5px; font-weight: 650; margin-bottom: 12px; display: flex; gap: 8px; align-items: center; }
.count { background: var(--panel2); color: var(--ink2); border-radius: 10px; padding: 0 8px; font-size: 12px; font-weight: 600; }
.cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.cols.even { grid-template-columns: 1fr 1fr; }
.cols.dash { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); }
.grid { display: grid; gap: 12px 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid .wide { grid-column: span 2; } .grid .full, .grid h3.sec { grid-column: 1 / -1; }
h3.sec { font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .08em; color: var(--ink3); border-bottom: 1px solid var(--line); padding: 12px 0 6px; margin-top: 2px; }
.grid h3.sec:first-child { padding-top: 0; }

/* folding section (progressive disclosure) */
details.fold { margin-bottom: 16px; }
details.fold > summary { list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 18px; cursor: pointer; box-shadow: var(--sh-1); }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary b { display: block; font-size: 14.5px; }
details.fold > summary small { color: var(--ink3); }
.fold-act { display: inline-flex; align-items: center; gap: 6px; color: var(--acc); font-weight: 550; font-size: 13px; white-space: nowrap; }
.fold-act .ic { width: 15px; height: 15px; }
details.fold[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-bottom-color: transparent; }
details.fold[open] > summary .fold-act { visibility: hidden; }
details.fold > .card { border-top-left-radius: 0; border-top-right-radius: 0; border-top: 0; }

/* ---------- fields ---------- */
.fld { display: flex; flex-direction: column; gap: 5px; min-width: 0; position: relative; }
.fld > span, .fld legend { font-size: 12.5px; color: var(--ink2); font-weight: 550; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line2); border-radius: var(--r-sm); padding: 0 10px; height: var(--ctl); width: 100%; min-width: 0; transition: border-color var(--t), box-shadow var(--t); }
textarea { resize: vertical; padding: 8px 10px; height: auto; line-height: 1.45; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--acc); }
input:focus, select:focus, textarea:focus { border-color: var(--acc); outline: none; box-shadow: 0 0 0 3px var(--acc-ring); }
input:disabled, select:disabled, textarea:disabled { background: var(--panel2); color: var(--ink2); border-color: var(--line); -webkit-text-fill-color: var(--ink2); opacity: 1; cursor: default; }
/* A locked document reads like a document, not a greyed-out form. */
.form.locked input:disabled, .form.locked select:disabled, .form.locked textarea:disabled { background: transparent; border-color: transparent; padding-left: 0; color: var(--ink); -webkit-text-fill-color: var(--ink); appearance: none; -webkit-appearance: none; box-shadow: none; height: auto; min-height: 22px; resize: none; }
.form.locked .fld { border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.form.locked .money input { text-align: left; }
.fld.invalid input, .fld.invalid select, .fld.invalid textarea, tr.invalid input { border-color: var(--bad); background: var(--bad-soft); }
.fld.invalid::after { content: attr(data-err); color: var(--bad); font-size: 12px; font-weight: 500; }
.fld.check { flex-direction: row; align-items: center; gap: 8px; }
fieldset.roles { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 0; }
fieldset.roles legend { padding: 0 4px; }
label.check { display: inline-flex; gap: 7px; align-items: center; font-size: 13.5px; cursor: pointer; min-height: 28px; }
label.check input { width: 16px; height: 16px; }
.money { display: flex; align-items: center; position: relative; }
.money input { text-align: right; padding-right: 48px; font-variant-numeric: tabular-nums; }
.money em { position: absolute; right: 10px; font-style: normal; color: var(--ink3); font-size: 12px; pointer-events: none; }
.form.locked .money em { position: static; margin-left: 4px; }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.form.dirty .form-actions .btn.primary { box-shadow: 0 0 0 3px var(--acc-ring); }
.hint { font-size: 12px; color: var(--ink3); }
.note { display: flex; gap: 8px; align-items: flex-start; padding: 10px 13px; border-radius: var(--r-sm); background: var(--info-soft); color: var(--info); margin-bottom: 14px; font-size: 13px; }
.note .ic { width: 16px; height: 16px; margin-top: 1px; }
.note.bad { background: var(--bad-soft); color: var(--bad); } .note.good { background: var(--good-soft); color: var(--good); } .note.lock { background: var(--panel2); color: var(--ink2); }
.margin-hint { margin: 0; align-self: end; }

/* ---------- autocomplete ---------- */
.ac-list { position: absolute; top: 100%; left: 0; right: 0; z-index: 40; background: var(--panel); border: 1px solid var(--line2); border-radius: 10px; box-shadow: var(--sh-3); margin-top: 4px; max-height: 330px; overflow-y: auto; padding: 4px; animation: drop 120ms var(--ease); }
.ac-item { padding: 7px 10px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; border-radius: 7px; }
.ac-item small { color: var(--ink3); display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.ac-item.on { background: var(--acc-soft); }
.ac-item.new { color: var(--acc); font-weight: 600; }
.ac-item.blocked b { text-decoration: line-through; color: var(--ink3); }

/* ---------- tables ---------- */
.tw { overflow-x: auto; margin: 0 -6px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-weight: 600; font-size: 11.5px; color: var(--ink3); text-transform: uppercase; letter-spacing: .05em; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td small { color: var(--ink3); }
.tbl td b { white-space: nowrap; font-weight: 600; }
.tbl .n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tr[data-href] { cursor: pointer; transition: background var(--t); }
.tbl tr[data-href]:hover td, .tbl tr[data-href]:focus td { background: var(--panel2); }
.tbl tr[data-href]:focus { outline: none; } .tbl tr[data-href]:focus td:first-child { box-shadow: inset 2px 0 0 var(--acc); }
.tbl tr.sum td { font-weight: 600; border-top: 2px solid var(--line2); }
.tbl.lines input, .tbl.lines select { height: 30px; padding: 0 8px; }
.tbl.lines input.n { text-align: right; min-width: 96px; }
.tbl.lines input.sm { min-width: 56px; max-width: 72px; }
.tbl.lines input[data-f=description] { min-width: 220px; }
.tbl.lines select { min-width: 120px; }
.tbl.keys td { border: 0; padding: 6px 8px; }
.empty-row { color: var(--ink3); padding: 14px 2px; font-size: 13.5px; }
.toolbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 10px; }
.filter { max-width: 300px; }
.tabs { display: inline-flex; gap: 2px; background: var(--panel2); padding: 3px; border-radius: 9px; flex-wrap: wrap; border: 1px solid var(--line); }
.tabs a { padding: 5px 12px; border-radius: 7px; color: var(--ink2); font-weight: 550; font-size: 13px; text-decoration: none; transition: background var(--t), color var(--t); }
.tabs a:hover { color: var(--ink); }
.tabs a.on { background: var(--panel); color: var(--ink); box-shadow: var(--sh-1), 0 0 0 1px var(--line); }
.tabs a small { color: var(--ink3); margin-left: 4px; font-weight: 500; }
.tabs.big { margin-bottom: 14px; }
.tabs.big a { padding: 7px 16px; font-size: 14px; }

/* ---------- pills & chips (text + colour, never colour alone) ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px 1px 7px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--panel2); color: var(--ink2); white-space: nowrap; vertical-align: middle; line-height: 18px; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
h1 .pill { font-size: 12px; padding: 2px 10px 2px 8px; }
.s-DRAFT, .s-NEW, .s-OPEN, .s-BOOKED { background: var(--panel2); color: var(--ink2); }
.s-SENT, .s-ORDERED, .s-CONTACTED, .s-QUOTED, .s-QUOTING, .s-RECEIVED, .s-QUALIFIED, .s-PARTIAL { background: var(--info-soft); color: var(--info); }
.s-CONFIRMED, .s-LOADED, .s-ISSUED, .s-APPROVED { background: var(--acc-soft); color: var(--acc); }
.s-DELIVERED, .s-ACCEPTED, .s-COMPLETED, .s-WON, .s-PAID, .s-ACTIVE { background: var(--good-soft); color: var(--good); }
.s-REJECTED, .s-CANCELLED, .s-LOST, .s-BLOCKED, .s-OVERDUE, .s-MISMATCH { background: var(--bad-soft); color: var(--bad); }
.s-INACTIVE { background: var(--warn-soft); color: var(--warn); }
.chip { display: inline-block; font-size: 11.5px; padding: 0 7px; border-radius: 5px; border: 1px solid var(--line2); color: var(--ink2); white-space: nowrap; line-height: 18px; }
.chip.AR { border-color: color-mix(in srgb, var(--good) 50%, transparent); color: var(--good); } .chip.AP { border-color: color-mix(in srgb, var(--warn) 50%, transparent); color: var(--warn); }

/* ---------- dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpis.sm { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: flex; flex-direction: column; gap: 3px; color: var(--ink); text-decoration: none !important; box-shadow: var(--sh-1); min-width: 0; transition: border-color var(--t), box-shadow var(--t); }
a.kpi:hover { border-color: var(--acc); box-shadow: var(--sh-2); }
.kpi span { font-size: 12.5px; color: var(--ink2); font-weight: 500; }
.kpi b { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi small { color: var(--ink3); font-size: 12.5px; } .kpi small.bad { color: var(--bad); font-weight: 550; }
.att-list { list-style: none; padding: 0; margin: 0 -6px; }
.att a { display: grid; grid-template-columns: 10px 1fr; column-gap: 12px; padding: 9px 8px; color: var(--ink); text-decoration: none; border-radius: 8px; transition: background var(--t); }
.att + .att a { border-top: 1px solid var(--line); border-radius: 0; }
.att a:hover { background: var(--panel2); border-radius: 8px; }
.att .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink3); margin-top: 7px; grid-row: span 2; }
.att.high .dot { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); } .att.warning .dot { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); } .att.info .dot { background: var(--acc); }
.att-t { font-weight: 550; } .att-s { color: var(--ink3); font-size: 12.5px; }

/* ---------- shipment ---------- */
.stepper { display: flex; gap: 4px; margin: -4px 0 18px; flex-wrap: wrap; }
.step { flex: 1; min-width: 92px; text-align: center; font-size: 12px; font-weight: 600; padding: 7px 4px; border-radius: 7px; background: var(--panel2); color: var(--ink3); border: 1px solid var(--line); }
.step.done { background: var(--good-soft); color: var(--good); border-color: transparent; }
.step.on { background: var(--acc); color: var(--acc-ink); border-color: var(--acc); }
.step.bad.on { background: var(--bad); color: #fff; border-color: var(--bad); }
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.checklist li { display: flex; gap: 8px; align-items: center; color: var(--ink2); }
.checklist li .ic { width: 16px; height: 16px; color: var(--ink3); }
.checklist li.ok { color: var(--ink); } .checklist li.ok .ic { color: var(--good); }
.events { list-style: none; margin: 0; padding: 0; font-size: 12.5px; max-height: 320px; overflow-y: auto; }
.events li { padding: 5px 0; border-bottom: 1px dashed var(--line); }
.events small { color: var(--ink3); margin-right: 4px; font-variant-numeric: tabular-nums; }
.docs { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; }
.docs li { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.docs li > a { display: inline-flex; gap: 6px; align-items: center; }
.docs li > a .ic { width: 16px; height: 16px; }
.docs li small { color: var(--ink3); margin-left: auto; }
.upload { display: flex; gap: 8px; }
.upload select { width: auto; }
.drop { flex: 1; display: flex; gap: 8px; align-items: center; justify-content: center; border: 1.5px dashed var(--line2); border-radius: var(--r-sm); padding: 8px 12px; color: var(--ink2); font-size: 13px; cursor: pointer; min-height: var(--ctl); transition: border-color var(--t), background var(--t), color var(--t); }
.drop .ic { width: 16px; height: 16px; }
.drop:hover, .drop.over { border-color: var(--acc); color: var(--acc); background: var(--acc-soft); }
.totals { display: flex; justify-content: flex-end; gap: 32px; padding-top: 12px; margin-top: 10px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.totals div { display: flex; flex-direction: column; align-items: flex-end; }
.totals span { font-size: 12px; color: var(--ink3); } .totals b { font-size: 18px; font-variant-numeric: tabular-nums; }
.totals.col { flex-direction: column; gap: 7px; border: 0; margin: 0; padding: 0; }
.totals.col div { flex-direction: row; justify-content: space-between; align-items: baseline; }
.totals.col .g b { font-size: 20px; }
.lines-ed .btn { margin-top: 10px; }

/* ---------- modal, toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 100; display: grid; place-items: start center; padding: 10vh 16px 16px; overflow-y: auto; animation: fade 140ms var(--ease); }
.modal { background: var(--panel); border-radius: 14px; width: min(520px, 100%); box-shadow: var(--sh-3); border: 1px solid var(--line); animation: pop 180ms var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.modal.wide { width: min(840px, 100%); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 6px; }
.modal h3 { font-size: 16.5px; }
.mbody { padding: 8px 18px 14px; }
.mbody p { margin: 0 0 8px; }
.modal footer { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal footer .ghost:first-child { margin-right: auto; }
#toasts { position: fixed; bottom: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; max-width: calc(100vw - 32px); }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--sh-3); font-size: 13.5px; transition: opacity .3s, transform .3s; max-width: 520px; animation: pop 180ms var(--ease); }
.toast.bad { background: #b91c1c; color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); }
.empty { text-align: center; padding: 64px 20px; color: var(--ink2); }

/* ---------- login ---------- */
body.login #app { display: grid; grid-template-columns: 1fr; place-items: center; background: radial-gradient(1200px 600px at 20% 0%, #0c4a6e 0%, #0f172a 55%, #0b1120 100%); min-height: 100dvh; padding: 16px; }
.login-box { background: var(--panel); border-radius: 16px; padding: 30px; width: min(390px, 100%); box-shadow: 0 30px 80px rgba(0,0,0,.45); border: 1px solid var(--line); }
.login-box form { display: grid; gap: 14px; margin: 22px 0 12px; }
.brand.big { padding: 0; } .brand.big b { font-size: 20px; } .brand.big .logo { width: 40px; height: 40px; } .brand.big .logo svg { width: 28px; height: 28px; }
.login-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .cols, .cols.even { grid-template-columns: minmax(0, 1fr); }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  #app { grid-template-columns: minmax(0, 1fr); }
  #side { position: fixed; z-index: 90; left: 0; top: 0; bottom: 0; width: 264px; transform: translateX(-100%); transition: transform 200ms var(--ease); background: var(--panel); }
  body.nav-open #side { transform: none; box-shadow: 0 0 0 100vmax rgba(15,23,42,.45); }
  #menu { display: inline-grid; }
  #top { padding: 8px 12px; gap: 6px; }
  .omni-kbd { display: none; }
  .omni.open { position: fixed; inset: 8px 8px auto 8px; width: auto; max-width: none; z-index: 40; }
  .omni-pop { max-height: calc(100dvh - 72px); }
  .omni.chatting .omni-pop { height: calc(100dvh - 72px); max-height: none; }
  main#main { padding: 16px 16px 72px; }
  .g3, .g2 { grid-template-columns: minmax(0, 1fr); }
  .grid .wide { grid-column: 1 / -1; }
  .ph h1 { font-size: 20px; }
  .ph-r { width: 100%; }
  .oi-type { width: 64px; }
  .upload { flex-direction: column; }
  .filter { max-width: none; }
  .chat-note { display: none; }
}
@media (max-width: 480px) {
  .g4, .kpis { grid-template-columns: minmax(0, 1fr); }
  .totals { justify-content: space-between; gap: 12px; }
}
/* Touch screens: 44px targets, 16px inputs (no iOS zoom). */
@media (pointer: coarse) {
  :root { --ctl: 44px; }
  body { font-size: 15px; }
  input, select, textarea, .omni-line input { font-size: 16px; }
  .btn.sm { height: 36px; }
  #nav a { height: 44px; }
  .omni-line { height: 46px; }
  .icon { padding: 10px; }
  .oi { min-height: 48px; }
}
/* Lists become cards on phones: number as title, status top right, details below. */
@media (max-width: 640px) {
  .tw:has(.tbl.cards) { overflow: visible; margin: 0 -4px; }
  .tbl.cards thead { display: none; }
  .tbl.cards, .tbl.cards tbody { display: block; }
  .tbl.cards tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 12px; padding: 12px 6px; border-bottom: 1px solid var(--line); }
  .tbl.cards tr:last-child { border-bottom: 0; }
  .tbl.cards td { display: block; border: 0; padding: 0; text-align: left; white-space: normal; background: none !important; }
  .tbl.cards td:empty { display: none; }
  .tbl.cards td:first-child { font-size: 15.5px; grid-column: 1; }
  .tbl.cards td:last-child { grid-column: 2; grid-row: 1; justify-self: end; align-self: start; text-align: right; }
  .tbl.cards td:not(:first-child):not(:last-child) { grid-column: 1 / -1; color: var(--ink2); font-size: 13.5px; padding-left: 96px; text-indent: -96px; }
  .tbl.cards td:not(:first-child):not(:last-child) > * { text-indent: 0; }
  .tbl.cards td:not(:first-child):not(:last-child)::before { content: attr(data-label); display: inline-block; width: 96px; text-indent: 0; color: var(--ink3); font-size: 12px; vertical-align: baseline; }
  .tbl.cards td[data-label=""] { padding-left: 0; text-indent: 0; }
  .tbl.cards td[data-label=""]::before { display: none !important; }
  .tbl.cards td.n { text-align: left; }
  .tbl.cards tr[data-href]:active { background: var(--panel2); }
  .card:has(> .tw > .tbl.cards), .card:has(> .toolbar) { padding-left: 12px; padding-right: 12px; }
}

/* ---------- phone & home-screen app ---------- */
#tabs { display: none; }
#install { display: none; }
@media (max-width: 820px) {
  #top { padding: calc(8px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) 8px calc(12px + env(safe-area-inset-left)); }
  #menu { display: none; }
  #side { padding-top: calc(14px + env(safe-area-inset-top)); padding-bottom: calc(12px + env(safe-area-inset-bottom)); padding-left: calc(10px + env(safe-area-inset-left)); }
  main#main { padding-left: calc(16px + env(safe-area-inset-left)); padding-right: calc(16px + env(safe-area-inset-right)); padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
  .omni.open { top: calc(8px + env(safe-area-inset-top)); left: calc(8px + env(safe-area-inset-left)); right: calc(8px + env(safe-area-inset-right)); }
  .omni-pop { max-height: calc(100dvh - 72px - env(safe-area-inset-top)); }
  .omni.chatting .omni-pop { height: calc(100dvh - 72px - env(safe-area-inset-top)); }
  #tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    padding: 6px calc(6px + env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) calc(6px + env(safe-area-inset-left));
    background: color-mix(in srgb, var(--panel) 88%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); border-top: 1px solid var(--line); }
  #tabs a, #tabs button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 48px; border: 0; background: none; color: var(--ink3); font: 600 10.5px var(--font); text-decoration: none; border-radius: 10px; cursor: pointer; padding: 0 2px; }
  #tabs .ic { width: 23px; height: 23px; }
  #tabs a.on { color: var(--acc); }
  #tabs a:active, #tabs button:active { background: var(--panel2); }
  body.omni-open #tabs { display: none; }
  #toasts { bottom: calc(76px + env(safe-area-inset-bottom)); right: 12px; left: 12px; align-items: stretch; }
  #install { display: flex; position: fixed; z-index: 60; left: 12px; right: 12px; bottom: calc(74px + env(safe-area-inset-bottom)); gap: 12px; align-items: center;
    background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; box-shadow: var(--sh-3); animation: pop 220ms var(--ease); }
  #install img { border-radius: 10px; flex: none; }
  #install div { flex: 1; display: flex; flex-direction: column; font-size: 13px; color: var(--ink2); }
  #install b { color: var(--ink); font-size: 14px; }
  #install .ic { width: 15px; height: 15px; vertical-align: -2px; color: var(--acc); }
  .modal-bg { padding-top: calc(6vh + env(safe-area-inset-top)); }
}
@media (pointer: coarse) { #help { display: none; } }
/* Installed app: the page should not rubber-band away from its own chrome. */
html.standalone body { overscroll-behavior-y: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
}
