:root {
  --bg: #f4f6fb; --card: #ffffff; --fg: #0f172a; --muted: #5b6477; --line: #e2e6ef; --accent: #0369a1; --accent-fg: #fff;
  --ok: #15803d; --warn: #b45309; --bad: #b91c1c; --info: #1d4ed8; --chip: #eef2f8; --shadow: 0 1px 2px rgb(15 23 42 / .06), 0 2px 8px rgb(15 23 42 / .05);
  --r: 14px; --nav: 232px; font-size: 16px;
}
@media (prefers-color-scheme: dark) { :root { --bg: #0b1120; --card: #131c2e; --fg: #e6ebf5; --muted: #98a2b8; --line: #243049; --accent: #38bdf8; --accent-fg: #06263a; --chip: #1c2740; --ok: #4ade80; --warn: #fbbf24; --bad: #f87171; --info: #93c5fd; --shadow: none; } }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 1rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6rem; } h2 { font-size: 1.1rem; } h3 { font-size: 1rem; margin-top: 1rem; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { width: 100%; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--card); min-height: 44px; }
input[type=checkbox] { width: 1.2rem; min-height: 1.2rem; height: 1.2rem; }
textarea { resize: vertical; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.boot, .center { display: grid; place-items: center; min-height: 100vh; color: var(--muted); padding: 1rem; text-align: center; }

/* layout */
#nav { position: fixed; inset: 0 auto 0 0; width: var(--nav); background: var(--card); border-right: 1px solid var(--line); overflow-y: auto; padding: .75rem .5rem 2rem; z-index: 30; }
#nav .brand { font-weight: 800; letter-spacing: .08em; padding: .5rem .75rem 1rem; color: var(--accent); }
#nav a { display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; border-radius: 10px; text-decoration: none; color: var(--fg); }
#nav a.active, #nav a:hover { background: var(--chip); }
#nav .ico { width: 1.4rem; text-align: center; }
.count:not(:empty) { margin-left: auto; background: var(--bad); color: #fff; border-radius: 999px; font-size: .75rem; padding: 0 .45rem; min-width: 1.3rem; text-align: center; font-weight: 700; }
#col { margin-left: var(--nav); min-height: 100vh; }
#top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem; padding-top: max(.6rem, env(safe-area-inset-top)); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
#top h1 { font-size: 1.15rem; margin: 0; white-space: nowrap; }
.topsearch { flex: 1; max-width: 520px; margin-left: auto; } .topsearch input { min-height: 38px; }
.bell { position: relative; font-size: 1.3rem; text-decoration: none; } .bell .count:not(:empty) { position: absolute; top: -6px; right: -10px; }
.iconbtn { background: none; border: 0; font-size: 1.4rem; padding: .25rem .5rem; cursor: pointer; }
.menu { display: none; }
main#main { padding: 1rem; max-width: 1200px; margin: 0 auto; padding-bottom: 6rem; }
#bottom { display: none; }
#scrim { display: none; }

@media (max-width: 860px) {
  #nav { transform: translateX(-100%); transition: transform .2s; width: 270px; }
  body.navopen #nav { transform: none; box-shadow: 0 0 40px rgb(0 0 0 / .3); }
  body.navopen #scrim { display: block; position: fixed; inset: 0; background: rgb(0 0 0 / .35); z-index: 25; }
  #col { margin-left: 0; }
  .menu { display: block; }
  .topsearch { display: none; }
  #bottom { display: flex; position: fixed; inset: auto 0 0 0; z-index: 20; background: var(--card); border-top: 1px solid var(--line); justify-content: space-around; align-items: center; padding: .3rem .25rem calc(.3rem + env(safe-area-inset-bottom)); }
  #bottom a { display: flex; flex-direction: column; align-items: center; text-decoration: none; color: var(--muted); font-size: .72rem; min-width: 60px; position: relative; padding: .2rem; }
  #bottom a.active { color: var(--accent); } #bottom .ico { font-size: 1.35rem; }
  #bottom .count:not(:empty) { position: absolute; top: 0; right: 10px; }
  .mic { width: 62px; height: 62px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-fg); font-size: 1.7rem; margin-top: -26px; box-shadow: 0 4px 14px rgb(3 105 161 / .4); cursor: pointer; }
  .mic.rec { background: var(--bad); }
  main#main { padding: .75rem; padding-bottom: 7rem; }
}

/* components */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 1rem; align-items: start; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem; box-shadow: var(--shadow); margin-bottom: 1rem; overflow-wrap: anywhere; }
.grid > .card { margin-bottom: 0; }
.card.error { border-color: var(--bad); }
.stack > .card { margin-bottom: .75rem; }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .5rem 0; } .row.end { justify-content: flex-end; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; min-height: 44px; padding: .5rem 1rem; border-radius: 10px; border: 1px solid var(--line); background: var(--chip); cursor: pointer; text-decoration: none; color: var(--fg); font-weight: 600; }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: transparent; }
.btn.danger { background: var(--bad); color: #fff; border-color: transparent; } .btn.danger.ghost { background: transparent; color: var(--bad); border-color: var(--line); }
.btn.ghost { background: transparent; }
.btn.big { min-height: 52px; font-size: 1.05rem; padding: .6rem 1.3rem; }
.btn.small { min-height: 36px; padding: .25rem .7rem; font-size: .9rem; }
.btn:disabled, .btn.busy { opacity: .55; cursor: progress; }
.linkbtn { background: none; border: 0; color: var(--accent); cursor: pointer; padding: .2rem; text-decoration: underline; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0; }
.chip { border: 1px solid var(--line); background: var(--chip); padding: .35rem .8rem; border-radius: 999px; cursor: pointer; min-height: 36px; }
.chip.on { background: var(--accent); color: var(--accent-fg); border-color: transparent; }
.tabs { display: flex; gap: .3rem; overflow-x: auto; margin-bottom: 1rem; } .tab { border: 0; background: none; padding: .6rem .9rem; border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; } .tab.on { border-color: var(--accent); font-weight: 700; }
.badge { display: inline-block; font-size: .75rem; padding: .05rem .5rem; border-radius: 999px; background: var(--chip); color: var(--muted); font-weight: 600; vertical-align: middle; white-space: nowrap; }
.badge.done, .badge.ok, .badge.executed, .badge.paid, .badge.processed { color: var(--ok); }
.badge.running, .badge.queued, .badge.info, .badge.testing, .badge.pending { color: var(--info); }
.badge.warn, .badge.interrupted, .badge.needs_review, .badge.executing { color: var(--warn); }
.badge.alert, .badge.failed, .badge.error, .badge.denied, .badge.cancelled, .badge.overdue { color: var(--bad); }
.muted { color: var(--muted); } .small { font-size: .88rem; } .err { color: var(--bad); } .warn { color: var(--warn); } .alert { color: var(--bad); }
.pre { white-space: pre-wrap; } pre.pre { background: var(--chip); padding: .7rem; border-radius: 10px; overflow-x: auto; font-size: .85rem; }
.empty { color: var(--muted); padding: .8rem 0; } .empty p { margin: 0 0 .5rem; }
.list { list-style: none; padding: 0; margin: 0; } .list li { padding: .45rem 0; border-bottom: 1px solid var(--line); }
.alerts { list-style: none; padding: 0; margin: 0; } .alerts li { padding: .55rem .7rem; border-radius: 10px; background: var(--chip); margin-bottom: .4rem; }
.alerts li.alert { background: color-mix(in srgb, var(--bad) 12%, var(--card)); color: var(--fg); } .alerts li.warn { background: color-mix(in srgb, var(--warn) 12%, var(--card)); color: var(--fg); }
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .5rem; } .quick a { text-decoration: none; } .quick a .btn, .quick .btn { width: 100%; }
.agenda { list-style: none; margin: 0; padding: 0; } .entry { display: grid; grid-template-columns: 1.6rem 7.5rem 1fr auto; gap: .4rem; padding: .4rem 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.entry .when { color: var(--muted); font-size: .88rem; } .entry .amt { font-variant-numeric: tabular-nums; font-weight: 600; } .entry.done .what { text-decoration: line-through; color: var(--muted); }
.agenda.overdue .what { color: var(--bad); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: .6rem; margin: .5rem 0; }
.stat { background: var(--chip); border-radius: 12px; padding: .6rem .75rem; } .stat .v { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; } .stat .l { color: var(--muted); font-size: .8rem; }
.tbl { width: 100%; border-collapse: collapse; font-size: .93rem; } .tbl td, .tbl th { padding: .45rem .35rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; } .tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; } .tbl tr.bad td, td.bad { color: var(--bad); font-weight: 600; } td.in { color: var(--ok); }
@media (max-width: 600px) { .tbl { display: block; overflow-x: auto; } }
.recs { list-style: none; padding: 0; margin: .5rem 0 0; } .rec { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: space-between; padding: .6rem 0; border-bottom: 1px solid var(--line); } .rec .main { flex: 1 1 260px; min-width: 0; } .rec .acts, .file .acts { display: flex; flex-wrap: wrap; gap: .3rem; }
.rec.overdue strong { color: var(--bad); } .rec.focus, .approval.focus { outline: 3px solid var(--accent); border-radius: 10px; }
.recform { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .6rem .8rem; margin: .8rem 0; }
.recform label, .dialog-form label, .authcard label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; } .recform label span, .dialog-form label span { color: var(--muted); }
.recform label.check { flex-direction: row-reverse; justify-content: flex-end; align-items: center; gap: .5rem; } .recform .row { grid-column: 1 / -1; }
details.add > summary { list-style: none; display: inline-flex; } details.add > summary::-webkit-details-marker { display: none; }
.kindgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .5rem 1rem; } .kindgrid h3 { margin: .3rem 0 0; font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.toggle { display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; }
.kv { display: grid; grid-template-columns: minmax(120px, 190px) 1fr; gap: .35rem .9rem; margin: .5rem 0; } .kv dt { color: var(--muted); font-size: .9rem; } .kv dd { margin: 0; } .kv ul { margin: 0; padding-left: 1rem; }
@media (max-width: 560px) { .kv { grid-template-columns: 1fr; } .kv dd { margin-bottom: .4rem; } }
.warnbox { background: color-mix(in srgb, var(--warn) 13%, var(--card)); border-radius: 10px; padding: .6rem .8rem; }
.feature.risky { border-color: var(--warn); border-width: 2px; }
.split { display: grid; grid-template-columns: minmax(220px, 300px) 1fr; gap: 1rem; } @media (max-width: 760px) { .split { grid-template-columns: 1fr; } }
.lifelog { list-style: none; padding: 0; } .lifelog li { padding: .45rem .7rem; margin: .3rem 0; border-radius: 12px; background: var(--chip); max-width: 85%; } .lifelog li.out { margin-left: auto; background: color-mix(in srgb, var(--accent) 16%, var(--card)); }
.help p { margin: .3rem 0; font-size: .92rem; }

/* chat */
.chat { display: flex; flex-direction: column; height: calc(100vh - 140px); height: calc(100dvh - 140px); }
@media (max-width: 860px) { .chat { height: calc(100dvh - 200px); } }
.chatlog { flex: 1; overflow-y: auto; padding: .5rem; display: flex; flex-direction: column; gap: .5rem; }
.msg { max-width: 82%; } .msg.user { align-self: flex-end; } .msg.system { align-self: center; color: var(--muted); font-size: .85rem; }
.bubble { padding: .6rem .85rem; border-radius: 16px; background: var(--card); border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--accent); color: var(--accent-fg); border-color: transparent; }
.msg .meta { font-size: .75rem; color: var(--muted); margin-top: .15rem; display: flex; gap: .3rem; align-items: center; flex-wrap: wrap; } .msg.user .meta { justify-content: flex-end; }
.composer { display: flex; gap: .4rem; align-items: flex-end; padding-top: .5rem; } .composer textarea { flex: 1; }

/* tasks / terminal / audit */
.events { padding-left: 1.2rem; font-size: .88rem; } .events li { margin: .25rem 0; overflow-wrap: anywhere; }
.term { background: #05080f; color: #d1fae5; font: .8rem/1.35 ui-monospace, SFMono-Regular, Menlo, monospace; padding: .8rem; border-radius: 10px; height: 65vh; overflow: auto; white-space: pre-wrap; }
.audit { list-style: none; padding: 0; } .audit .a { border-bottom: 1px solid var(--line); padding: .4rem 0; } .audit .a.inj { background: color-mix(in srgb, var(--bad) 8%, transparent); }
.notifs { list-style: none; padding: 0; } .notifs .n { border-left: 4px solid var(--line); padding: .5rem .8rem; margin: .4rem 0; background: var(--chip); border-radius: 0 10px 10px 0; } .notifs .n.read { opacity: .65; }
.notifs .n.alert { border-color: var(--bad); } .notifs .n.warn { border-color: var(--warn); } .notifs .n.success { border-color: var(--ok); } .notifs .n p { margin: .2rem 0; }

/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; } .cal.week { grid-template-columns: 1fr; }
.dow { font-size: .8rem; color: var(--muted); text-align: center; }
.day { background: var(--chip); border-radius: 8px; min-height: 92px; padding: .3rem; font-size: .78rem; overflow: hidden; } .day.other { opacity: .45; } .day.today { outline: 2px solid var(--accent); }
.cal.week .day { min-height: 0; font-size: .92rem; } .dnum { font-weight: 700; margin-bottom: .2rem; }
.ev { padding: .1rem .25rem; border-radius: 5px; margin-bottom: 2px; background: var(--card); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .cal.week .ev { white-space: normal; padding: .3rem .4rem; }
.ev.done { text-decoration: line-through; opacity: .6; } .ev.overdue { color: var(--bad); font-weight: 700; } .ev a { color: inherit; text-decoration: none; }
@media (max-width: 600px) { .cal.month .day { min-height: 60px; font-size: .65rem; } .cal.month .ev { padding: 0 .1rem; } }
.calnav strong { min-width: 10rem; text-align: center; }

/* banking & charts */
.bank.relink_required { border-color: var(--bad); border-width: 2px; }
.bars { display: grid; gap: .35rem; } .bar { display: grid; grid-template-columns: minmax(90px, 160px) 1fr auto; gap: .5rem; align-items: center; font-size: .88rem; }
.bar .l { text-transform: capitalize; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .bar .track { background: var(--chip); border-radius: 6px; height: 12px; overflow: hidden; } .bar .fill { display: block; height: 100%; background: var(--accent); } .bar .fill.drift { background: var(--warn); } .bar .fill.over { background: var(--bad); } .bar .v { font-variant-numeric: tabular-nums; white-space: nowrap; }
.chart { width: 100%; height: auto; } .chart .band { fill: color-mix(in srgb, var(--ok) 13%, transparent); } .chart .grid { stroke: var(--line); } .chart .lbl { fill: var(--muted); font-size: 11px; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; } .chart circle.ok { fill: var(--accent); } .chart circle.high { fill: var(--bad); } .chart circle.low { fill: var(--warn); } .chart .meal { stroke: var(--warn); stroke-dasharray: 3 3; opacity: .6; }
.spark { width: 100%; max-width: 420px; height: 60px; } .spark polyline { fill: none; stroke: var(--accent); stroke-width: 2; }

/* files */
.crumbs { margin-bottom: .4rem; overflow-x: auto; white-space: nowrap; }
.files { list-style: none; padding: 0; margin: 0; } .file { display: flex; flex-wrap: wrap; gap: .4rem .8rem; align-items: center; justify-content: space-between; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.fname { flex: 1 1 240px; display: flex; gap: .6rem; align-items: center; background: none; border: 0; cursor: pointer; text-align: left; padding: .2rem; min-height: 40px; min-width: 0; } .fname span:last-child { overflow-wrap: anywhere; }
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; background: var(--chip); }
.dropzone { min-height: 120px; border-radius: 10px; } .dropzone.over { outline: 3px dashed var(--accent); }
form.inline { flex: 1 1 200px; }
.preview img, .preview video { max-width: 100%; max-height: 75vh; display: block; margin: auto; } .preview iframe { width: 100%; height: 75vh; border: 0; }

/* dialogs, toasts, auth, voice */
dialog.dlg { border: 0; border-radius: 16px; padding: 1.2rem; width: min(520px, 94vw); max-height: 90vh; overflow: auto; background: var(--card); color: var(--fg); box-shadow: 0 20px 60px rgb(0 0 0 / .35); }
dialog.dlg.wide { width: min(900px, 96vw); } dialog::backdrop { background: rgb(0 0 0 / .45); }
.dialog-form { display: flex; flex-direction: column; gap: .7rem; }
#toasts { position: fixed; z-index: 100; left: 50%; transform: translateX(-50%); bottom: calc(5.5rem + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: .4rem; width: min(560px, 92vw); }
.toast { background: var(--fg); color: var(--bg); padding: .7rem 1rem; border-radius: 12px; box-shadow: 0 6px 20px rgb(0 0 0 / .25); } .toast.error { background: var(--bad); color: #fff; } .toast.success { background: var(--ok); color: #fff; } .toast.warn { background: var(--warn); color: #fff; }
main.auth { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.authcard { width: min(440px, 100%); display: flex; flex-direction: column; gap: .8rem; } .authcard h1 { color: var(--accent); }
.qr { width: 240px; height: 240px; image-rendering: pixelated; align-self: center; border-radius: 8px; } code.secret { word-break: break-all; font-size: 1rem; }
.voice-overlay { position: fixed; inset: 0; z-index: 90; background: rgb(3 7 18 / .88); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.2rem; font-size: 1.1rem; }
.pulse { font-size: 4rem; width: 140px; height: 140px; border-radius: 50%; display: grid; place-items: center; background: var(--bad); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgb(248 113 113 / .6); } 50% { box-shadow: 0 0 0 28px rgb(248 113 113 / 0); } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } #nav { transition: none; } }
.briefing { font-size: 1.2rem; line-height: 1.6; }
.result { background: var(--chip); padding: .7rem; border-radius: 10px; }
