/* British AI Bookkeeper: a calm, white workspace. Navy for actions, British red only for the mark and danger. */
:root {
  --ink: #14213D;
  --ink-2: #3A4560;
  --muted: #6E7791;
  --faint: #9AA1B5;
  --line: #ECEEF3;
  --line-2: #DADEE7;
  --bg: #FFFFFF;
  --side: #F7F8FA;
  --tint: #F3F5F9;
  --accent: #1D3A8A;       /* navy-blue for the active word and links */
  --signal: #C8102E;
  --ok: #18794E;  --ok-bg: #E7F5EE;
  --attn: #A35B00; --attn-bg: #FFF4E0;
  --bad: #B42318; --bad-bg: #FDEDEB;
  --live: #2557D6; --live-bg: #EBF0FF;
  --r: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font: 15px/1.6 Inter, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--accent); text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: .3rem 0 .8rem; }
code { font-family: var(--mono); font-size: .85em; background: var(--tint); padding: .1em .35em; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pad { padding: 0 .9rem; }
.i { width: 18px; height: 18px; flex: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; z-index: 99; background: #fff; padding: .5rem 1rem; }
:focus-visible { outline: 2px solid var(--live); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---- shell ---- */
.shell { display: grid; grid-template-columns: 272px 1fr; min-height: 100vh; }
.side { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 1.1rem .8rem .8rem; gap: .25rem; }
.brand { display: flex; align-items: center; gap: .7rem; padding: 0 .4rem .8rem; }
.brand .mark { width: 40px; height: 40px; flex: none; }
.brand b { display: block; font-size: .98rem; }
.brand span { display: block; font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 175px; }
.side-link, .nav a { display: flex; align-items: center; gap: .7rem; padding: .5rem .7rem; border-radius: 10px; color: var(--ink-2); text-decoration: none; font-weight: 500; }
.side-link:hover, .nav a:hover { background: #EEF0F4; }
.side-link.new { background: #fff; border: 1px solid var(--line-2); color: var(--ink); font-weight: 600; margin: .2rem 0 .5rem; box-shadow: 0 1px 2px rgba(20, 33, 61, .04); }
.side-link.new:hover { border-color: var(--faint); }
.nav { display: grid; gap: 1px; }
.nav a.on { background: #E8EBF2; color: var(--ink); font-weight: 600; }
.badge { margin-left: auto; font-style: normal; font-size: .72rem; font-weight: 700; background: var(--attn); color: #fff; border-radius: 999px; padding: 0 .45rem; }
.threads { flex: 1; overflow: auto; margin-top: .8rem; min-height: 0; }
.threads-h { display: flex; justify-content: space-between; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); font-weight: 600; padding: 0 .7rem .5rem; }
.threads-h a { color: var(--faint); text-transform: none; letter-spacing: 0; }
.day { background: #fff; border: 1px solid var(--line); border-radius: 12px; margin-bottom: .6rem; overflow: hidden; }
.day-h { font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); font-weight: 600; padding: .55rem .8rem .3rem; }
.thread { display: block; padding: .5rem .8rem .55rem; text-decoration: none; color: var(--ink); border-left: 3px solid transparent; border-top: 1px solid var(--line); }
.day-h + .thread { border-top: 0; }
.thread:hover, .thread.on { background: #F5F7FB; }
.thread.st-running, .thread.st-queued, .thread.st-waiting_approval, .thread.st-waiting_input, .thread.st-paused { border-left-color: #E0A23B; }
.thread .t { display: block; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread .m { display: flex; gap: .3rem; align-items: center; font-size: .75rem; color: var(--muted); }
.thread .m em { font-style: normal; font-weight: 600; }
.thread .m em.w, .thread .m em.a { color: var(--attn); }
.thread .m em.b { color: var(--bad); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: #5BA3A0; display: inline-block; }
.me { margin-top: .5rem; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: .55rem .7rem; display: flex; align-items: center; gap: .6rem; }
.me > div { min-width: 0; flex: 1; }
.me b { display: block; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me span:not(.avatar) { display: block; font-size: .74rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: #fff; font-size: .72rem; font-weight: 700; display: grid; place-items: center; flex: none; }
.main { padding: 2rem 2.5rem 7rem; min-width: 0; width: 100%; max-width: 1180px; }
.main.wide { max-width: none; padding-left: 1.5rem; padding-right: 1.5rem; }
.head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.head h1 { margin: 0; }
.banner { background: var(--attn-bg); color: var(--attn); padding: .55rem .9rem; border-radius: 10px; margin-bottom: 1rem; font-size: .9rem; }
.banner.bad { background: var(--bad-bg); color: var(--bad); }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; gap: .45rem; justify-content: center; border: 1px solid var(--line-2); background: #fff; color: var(--ink); border-radius: 10px; padding: .5rem .9rem; font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--faint); background: #FAFBFC; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: #0C1630; border-color: #0C1630; }
.btn-danger, .btn.danger { color: var(--bad); border-color: #F1C7C2; }
.btn-ghost { background: transparent; }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { background: #12623F; }
.btn-stop { color: var(--bad); border-color: #F1C7C2; }
.btn-sm { padding: .28rem .6rem; font-size: .82rem; border-radius: 8px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.link { background: none; border: 0; color: var(--muted); font: inherit; font-size: .78rem; cursor: pointer; padding: 0; }
.link:hover { color: var(--ink); }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.row form { margin: 0; }

/* ---- surfaces ---- */
.card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 1.3rem 1.4rem; margin-bottom: 1rem; }
.card > h2:first-child { margin-bottom: .3rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.grid-2 { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; }
.pill { display: inline-block; font-size: .7rem; font-weight: 700; padding: .05rem .5rem; border-radius: 999px; white-space: nowrap; }
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-attn { background: var(--attn-bg); color: var(--attn); }
.pill-bad { background: var(--bad-bg); color: var(--bad); }
.pill-live { background: var(--live-bg); color: var(--live); }
.pill-wait, .pill-muted { background: var(--tint); color: var(--muted); }
.flash { padding: .7rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-size: .92rem; }
.flash-success { background: var(--ok-bg); color: var(--ok); }
.flash-error { background: var(--bad-bg); color: var(--bad); }
.flash-info { background: var(--live-bg); color: #1F3F9E; }
.empty { text-align: center; padding: 3rem 1rem; border: 1px dashed var(--line-2); border-radius: 14px; }
.empty p { color: var(--muted); max-width: 520px; margin: .3rem auto 1rem; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .8rem; margin-bottom: 1.2rem; }
.stat { border: 1px solid var(--line); border-radius: 14px; padding: 1rem 1.1rem; }
.stat b { display: block; font-size: 1.45rem; }
.stat span { font-size: .8rem; color: var(--muted); }

/* ---- forms ---- */
.field { display: block; margin-bottom: 1rem; }
.lbl { display: block; font-weight: 600; font-size: .86rem; margin-bottom: .35rem; }
.hint { display: block; font-size: .8rem; color: var(--muted); margin-top: .3rem; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=date], input[type=search], input:not([type]), select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line-2); border-radius: 10px; padding: .55rem .75rem; min-height: 42px;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { outline: 2px solid #B9C7F2; outline-offset: 0; border-color: var(--live); }
.check { display: flex; gap: .55rem; align-items: flex-start; margin: .45rem 0; font-size: .92rem; }
.check input { margin-top: .3rem; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .1rem 1rem; }
.form-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1.2rem; flex-wrap: wrap; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 650; margin-bottom: .4rem; }
details > summary { cursor: pointer; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font-size: .74rem; color: var(--muted); font-weight: 600; padding: .65rem .9rem; border-bottom: 1px solid var(--line); background: #FAFBFC; }
td { padding: .7rem .9rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
.search-row { margin-bottom: 1rem; max-width: 520px; }

/* ---- chips and agents ---- */
.chips { display: flex; gap: .45rem; flex-wrap: wrap; margin-bottom: 1.2rem; align-items: center; }
.chip { border: 1px solid var(--line-2); background: #fff; border-radius: 999px; padding: .3rem .85rem; font-size: .85rem; color: var(--ink-2); text-decoration: none; }
.chip:hover { border-color: var(--faint); }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip em { font-style: normal; color: var(--faint); margin-left: .35rem; }
.chip.on em { color: #C7CDE0; }
.group { margin-bottom: 1.4rem; border: 1px solid var(--line); border-radius: 18px; padding: 1.1rem 1.2rem 1.2rem; }
.group-h { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .8rem; }
.group-h h2 { font-size: .98rem; font-weight: 600; color: var(--ink-2); }
.group-h .small { letter-spacing: .08em; text-transform: uppercase; font-size: .7rem; color: var(--faint); }
.agent { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 1.1rem 1.2rem; display: flex; flex-direction: column; gap: .45rem; min-height: 180px; transition: border-color .15s; }
.agent:hover { border-color: var(--line-2); }
.agent h3 { margin: 0; font-size: 1.05rem; }
.agent h3 a { color: var(--ink); text-decoration: none; }
.agent p { color: var(--muted); font-size: .88rem; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.agent .foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: .5rem; font-size: .78rem; color: var(--faint); }
.trig { font-size: .72rem; font-weight: 600; color: var(--ink-2); background: var(--tint); border-radius: 6px; padding: .1rem .45rem; }

/* ---- home ---- */
.home { max-width: 820px; margin: 0 auto; min-height: calc(100vh - 9rem); display: flex; flex-direction: column; justify-content: center; }
.hero { font-size: 2.35rem; font-weight: 650; letter-spacing: -.025em; margin: 0 0 1.4rem; line-height: 1.15; }
.verb { color: var(--accent); display: inline-block; transition: opacity .25s, transform .25s; }
.verb.out { opacity: 0; transform: translateY(6px); }
.tasks { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; margin-top: 1.1rem; }
.task { display: flex; align-items: center; gap: .7rem; text-align: left; font: inherit; font-weight: 600; color: var(--ink); background: #fff; border: 1px solid var(--line-2); border-radius: 14px; padding: .95rem 1.1rem; cursor: pointer; }
.task:hover { border-color: var(--faint); background: #FAFBFC; }
.task .i { color: var(--muted); }
.home-note { margin-top: 1.4rem; color: var(--muted); font-size: .9rem; }
.home-wait { margin-top: 1.6rem; border: 1px solid #F2D6A8; background: #FFFBF3; border-radius: 14px; padding: .9rem 1.1rem; display: grid; gap: .4rem; }
.home-wait b { font-size: .85rem; color: var(--attn); }
.home-wait a { text-decoration: none; color: var(--ink); font-weight: 600; font-size: .92rem; }
.home-wait a span { display: block; font-weight: 400; color: var(--muted); font-size: .82rem; }

/* ---- composer ---- */
.composer form { display: flex; gap: .5rem; align-items: flex-end; background: #fff; border: 1px solid var(--line-2); border-radius: 18px; padding: .55rem .55rem .55rem .7rem; box-shadow: 0 6px 24px rgba(20, 33, 61, .06); }
.composer form:focus-within { border-color: #B9C7F2; }
.composer textarea { border: 0; min-height: 44px; max-height: 240px; padding: .6rem .3rem; resize: none; font-size: 1rem; }
.composer textarea:focus { outline: none; }
.cbtn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-2); cursor: pointer; position: relative; overflow: hidden; flex: none; }
.cbtn:hover { background: var(--tint); }
.cbtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.client-pick { width: auto; max-width: 170px; min-height: 36px; border-radius: 999px; font-size: .82rem; padding: .3rem .7rem; background: var(--tint); border-color: transparent; color: var(--ink-2); align-self: center; }
.send { display: inline-flex; align-items: center; gap: .4rem; border: 0; background: var(--ink); color: #fff; font: inherit; font-weight: 600; border-radius: 999px; padding: .6rem 1.1rem; cursor: pointer; flex: none; }
.send:hover { background: #0C1630; }
.send:disabled { background: #A9B0C2; cursor: not-allowed; }
.file-names { padding: .35rem .9rem 0; }
.dock { position: fixed; left: 272px; right: 0; bottom: 0; padding: .8rem 1.5rem 1.1rem; background: linear-gradient(to top, #fff 75%, rgba(255, 255, 255, 0)); }
.dock > div { max-width: 860px; margin: 0 auto; }

/* ---- thread ---- */
.run { max-width: 860px; margin: 0 auto; display: grid; gap: 1rem; }
.run-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; padding-bottom: .4rem; }
.run-head h1 { font-size: 1.55rem; margin-bottom: .25rem; }
.run-meta { color: var(--muted); font-size: .86rem; margin: 0; }
.run-meta a { color: var(--muted); }
.feed { display: grid; gap: 1.4rem; }
.turn { display: grid; gap: .7rem; }
.you { justify-self: end; max-width: 80%; background: var(--tint); border: 1px solid var(--line); border-radius: 18px; padding: .7rem 1.1rem; white-space: pre-wrap; word-wrap: break-word; }
.work { color: var(--muted); font-size: .86rem; }
.work > summary { list-style: none; display: inline-flex; align-items: center; gap: .45rem; padding: .15rem 0; }
.work > summary::-webkit-details-marker { display: none; }
.work > summary::after { content: "›"; font-size: 1rem; transition: transform .15s; }
.work[open] > summary::after { transform: rotate(90deg); }
.steps { list-style: none; margin: .5rem 0 0; padding: 0 0 0 .9rem; border-left: 2px solid var(--line); display: grid; gap: .25rem; }
.s { font-size: .84rem; color: var(--ink-2); }
.s summary { list-style: none; }
.s summary::-webkit-details-marker { display: none; }
.s.tool summary { color: var(--ink); font-weight: 500; }
.s.res summary { color: var(--faint); }
.s.err, .s.err summary { color: var(--bad); }
.s.sys { color: var(--attn); }
.s.note { color: var(--muted); font-style: italic; }
.s pre { white-space: pre-wrap; font-family: var(--mono); font-size: .75rem; background: #FAFBFC; border: 1px solid var(--line); padding: .6rem .7rem; border-radius: 8px; max-height: 260px; overflow: auto; margin: .3rem 0 .2rem; }
.reply { border: 1px solid var(--line); border-radius: 16px; padding: 1rem 1.2rem; white-space: pre-wrap; word-wrap: break-word; line-height: 1.7; }
.reply.ask { border-color: #F2D6A8; background: #FFFBF3; }
.spin { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--ink-2); display: inline-block; animation: spin .9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.live-line { display: flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .88rem; margin: -.4rem 0 0; }
.browser { border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: #fff; }
.browser .screen { background: #0B0F1A; position: relative; }
.browser .screen img { display: block; width: 100%; height: auto; min-height: 120px; }
.browser.human .screen img { cursor: crosshair; }
.browser .ctrl { display: flex; gap: .6rem; align-items: center; justify-content: space-between; padding: .65rem .8rem .65rem 1.1rem; background: #FAFBFC; border-top: 1px solid var(--line); flex-wrap: wrap; }
.browser .ctrl .state { font-size: .9rem; color: var(--ink-2); }
.browser .ctrl select { width: auto; min-height: 34px; padding: .25rem .5rem; }
.browser.full { position: fixed; inset: 1rem; z-index: 50; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.browser.full .screen { flex: 1; overflow: auto; }
.typebar { display: flex; gap: .4rem; padding: .55rem .8rem; border-top: 1px solid var(--line); }
.approval { border: 1px solid #F2D6A8; background: #FFFBF3; border-radius: 16px; padding: 1.1rem 1.2rem; margin-bottom: .8rem; }
.approval h3 { color: var(--attn); font-size: .95rem; }
.approval img { max-width: 100%; max-height: 320px; object-fit: contain; object-position: left top; border: 1px solid var(--line); border-radius: 8px; margin: .5rem 0; }
.approval pre { white-space: pre-wrap; font-family: var(--mono); font-size: .78rem; background: #fff; border: 1px solid var(--line); padding: .7rem; border-radius: 8px; max-height: 280px; overflow: auto; }
.files { display: flex; gap: .45rem; flex-wrap: wrap; }
.file { display: inline-flex; gap: .45rem; align-items: center; border: 1px solid var(--line); padding: .35rem .7rem; border-radius: 10px; font-size: .85rem; text-decoration: none; color: var(--ink); }
.file:hover { border-color: var(--line-2); background: #FAFBFC; }
.file .i { width: 15px; height: 15px; color: var(--muted); }
.cost { font-variant-numeric: tabular-nums; }

/* ---- auth ---- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: var(--side); }
.auth-card { width: 100%; max-width: 420px; background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 2rem; box-shadow: 0 10px 40px rgba(20, 33, 61, .06); }
.auth-card .brand { margin-bottom: 1.2rem; padding: 0; }
.auth-card .btn-primary { width: 100%; margin-top: .3rem; padding: .65rem; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .threads { max-height: 240px; }
  .main { padding: 1.2rem 1rem 7rem; }
  .dock { left: 0; padding: .6rem .8rem .8rem; }
  .grid-2, .stats, .tasks { grid-template-columns: 1fr; }
  .hero { font-size: 1.7rem; }
  .you { max-width: 92%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
