/* Alfred dashboard. One accent: the active workspace colour (--ws), carried by the spine. */
:root {
  --paper: #f3f6f7;
  --surface: #ffffff;
  --sunken: #e9eef0;
  --ink: #1b2830;
  --muted: #5b6b76;
  --faint: #8a98a1;
  --line: #d5dde1;
  --red: #b8322b;
  --red-bg: #fbeceb;
  --amber: #a86b12;
  --amber-bg: #fbf2e2;
  --green: #2c7656;
  --green-bg: #e8f4ee;
  --blue: #2f5f9e;
  --ws: #1b2830;
  --ws-ink: #ffffff;
  --radius-s: 4px;
  --radius-m: 8px;
  --shadow-pop: 0 10px 30px rgba(20, 35, 45, 0.18);
  --font: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121a1f; --surface: #19232a; --sunken: #0f161a; --ink: #e3e9ec; --muted: #9aa9b2; --faint: #6f7f88; --line: #2b3841;
    --red: #ef7b73; --red-bg: #3a1f1d; --amber: #e3ad55; --amber-bg: #372b17; --green: #6cc49c; --green-bg: #183128; --blue: #86b1e8;
    --shadow-pop: 0 10px 30px rgba(0, 0, 0, 0.5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #121a1f; --surface: #19232a; --sunken: #0f161a; --ink: #e3e9ec; --muted: #9aa9b2; --faint: #6f7f88; --line: #2b3841;
  --red: #ef7b73; --red-bg: #3a1f1d; --amber: #e3ad55; --amber-bg: #372b17; --green: #6cc49c; --green-bg: #183128; --blue: #86b1e8;
  --shadow-pop: 0 10px 30px rgba(0, 0, 0, 0.5); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--paper); color: var(--ink); font: 15px/1.5 var(--font); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.6rem; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; font-weight: 650; }
h3 { font-size: 0.98rem; font-weight: 650; }
p { margin: 0 0 0.6em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 0.85rem; }
.mono { font-family: var(--mono); font-size: 0.86em; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 64px 216px minmax(0, 1fr); min-height: 100vh; }
.spine { background: var(--ws); color: var(--ws-ink); position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 14px 0; gap: 14px; transition: background 0.35s ease; }
.spine-switch { width: 40px; height: 40px; border-radius: 50%; border: 2px solid currentColor; background: transparent; color: inherit; cursor: pointer; display: grid; place-items: center; font-weight: 700; font-size: 1rem; }
.spine-switch:hover { background: rgba(255, 255, 255, 0.15); }
.spine-name { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 1.55rem; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap; flex: 1; overflow: hidden; text-overflow: ellipsis; cursor: pointer; background: none; border: 0; color: inherit; padding: 0; }
.spine-foot { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.spine-dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid currentColor; opacity: 0.85; }
.spine-dot.live { background: currentColor; }

.nav { border-right: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 18px 10px 18px; display: flex; flex-direction: column; gap: 2px; }
.brand { font-weight: 700; font-size: 1.05rem; padding: 0 10px 14px; display: flex; align-items: baseline; justify-content: space-between; }
.brand small { font-weight: 500; color: var(--muted); font-size: 0.8rem; }
.nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; text-decoration: none; padding: 7px 10px; border-radius: var(--radius-s); color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--sunken); color: var(--ink); }
.nav a.active { color: var(--ink); background: var(--sunken); box-shadow: inset 3px 0 0 var(--ws); }
.nav .group { margin: 14px 10px 4px; color: var(--faint); font-size: 0.8rem; }
.count { min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--ws); color: var(--ws-ink); font-size: 0.75rem; font-weight: 700; text-align: center; line-height: 20px; }
.count.alert { background: var(--red); color: #fff; }
.nav-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line); font-size: 0.85rem; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.nav-foot button { background: none; border: 0; padding: 0; text-align: left; color: var(--muted); cursor: pointer; }
.nav-foot button:hover { color: var(--ink); }

.main { min-width: 0; padding: 26px 34px 60px; max-width: 1240px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.spine .mobilebar { display: none; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); padding: 6px 12px; border-radius: var(--radius-s); cursor: pointer; font-weight: 550; white-space: nowrap; text-decoration: none; }
.btn:hover { border-color: var(--faint); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--ws); border-color: var(--ws); color: var(--ws-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 45%, var(--line)); }
.btn.good { color: var(--green); border-color: color-mix(in srgb, var(--green) 45%, var(--line)); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: 3px 9px; font-size: 0.85rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="number"], input[type="datetime-local"], input[type="search"], input[type="time"], input[type="tel"], select, textarea {
  width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface);
}
textarea { resize: vertical; min-height: 80px; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 18%, transparent); }
label.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-weight: 550; font-size: 0.9rem; }
label.field .help { font-weight: 400; color: var(--muted); font-size: 0.82rem; }
label.check { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 10px; cursor: pointer; }
label.check input { margin-top: 4px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 180px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 5px 11px; cursor: pointer; color: var(--muted); font-weight: 550; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--sunken); color: var(--ink); box-shadow: inset 0 -2px 0 var(--ws); }

/* ---------- surfaces ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 16px 18px; }
.panel + .panel { margin-top: 16px; }
.panel h2 { margin-bottom: 10px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.grid-even { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 2px; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 550; overflow-wrap: anywhere; }
.list .meta { color: var(--muted); font-size: 0.85rem; display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 2px; }
.list .side { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.clickable { cursor: pointer; }
.clickable:hover .title { text-decoration: underline; text-underline-offset: 3px; }

.wsmark { display: inline-flex; align-items: center; gap: 6px; font-size: 0.82rem; color: var(--muted); white-space: nowrap; }
.wsmark::before { content: ""; width: 9px; height: 9px; border-radius: 2px; background: var(--c, var(--ws)); }

.pill { display: inline-block; padding: 0 8px; border-radius: 10px; font-size: 0.78rem; font-weight: 600; line-height: 20px; background: var(--sunken); color: var(--muted); white-space: nowrap; }
.pill.red { background: var(--red-bg); color: var(--red); }
.pill.amber { background: var(--amber-bg); color: var(--amber); }
.pill.green { background: var(--green-bg); color: var(--green); }
.pill.blue { background: color-mix(in srgb, var(--blue) 14%, transparent); color: var(--blue); }

/* priority rail on the overview: the one place with a strong graphic weight besides the spine */
.priorities > li { padding: 12px 2px 12px 0; }
.prio-score { width: 4px; align-self: stretch; border-radius: 2px; background: var(--c); flex-shrink: 0; }

/* decision cards (approvals, drafts, incidents) */
.decision { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--c, var(--ws)); border-radius: var(--radius-m); padding: 14px 16px; }
.decision + .decision { margin-top: 12px; }
.decision .head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.decision .what { font-weight: 650; font-size: 1.02rem; margin: 6px 0 4px; }
.decision .exact { background: var(--sunken); border-radius: var(--radius-s); padding: 10px 12px; font-size: 0.9rem; white-space: pre-wrap; overflow-wrap: anywhere; margin: 8px 0; max-height: 320px; overflow: auto; }
.decision .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; font-size: 0.88rem; margin: 6px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* stats strip */
.strip { display: flex; gap: 0; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); margin-bottom: 18px; overflow: hidden; flex-wrap: wrap; }
.strip a { flex: 1 1 140px; padding: 12px 16px; text-decoration: none; border-left: 1px solid var(--line); }
.strip a:first-child { border-left: 0; }
.strip a:hover { background: var(--sunken); }
.strip .n { font-size: 1.5rem; font-weight: 700; display: block; line-height: 1.2; }
.strip .l { color: var(--muted); font-size: 0.85rem; }
.strip .n.red { color: var(--red); }

/* ---------- chat ---------- */
.chat { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 18px; height: calc(100vh - 140px); min-height: 480px; }
.convs { overflow-y: auto; border-right: 1px solid var(--line); padding-right: 12px; }
.convs button.conv { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: var(--radius-s); cursor: pointer; }
.convs button.conv:hover { background: var(--sunken); }
.convs button.conv.on { background: var(--sunken); box-shadow: inset 3px 0 0 var(--ws); }
.convs .t { display: block; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convs .p { display: block; color: var(--muted); font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread { display: flex; flex-direction: column; min-height: 0; }
.messages { flex: 1; overflow-y: auto; padding: 4px 4px 16px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 72ch; }
.msg.user { align-self: flex-end; background: var(--ws); color: var(--ws-ink); padding: 9px 13px; border-radius: 14px 14px 4px 14px; }
.msg.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); padding: 10px 14px; border-radius: 14px 14px 14px 4px; }
.msg.tool { align-self: flex-start; color: var(--muted); font-size: 0.85rem; display: flex; gap: 8px; align-items: center; padding-left: 4px; }
.msg.tool::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.msg.tool.error::before { background: var(--red); }
.msg.system, .msg.error { align-self: center; color: var(--muted); font-size: 0.85rem; text-align: center; max-width: 60ch; }
.msg.error { color: var(--red); }
.msg .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .body a { color: var(--blue); }
.msg .body code { font-family: var(--mono); font-size: 0.88em; background: var(--sunken); padding: 0 4px; border-radius: 3px; }
.composer { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-m); padding: 8px; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { border: 0; min-height: 44px; max-height: 240px; padding: 6px 8px; box-shadow: none !important; }
.composer-ws { font-size: 0.82rem; color: var(--muted); margin: 6px 4px 0; }
.typing { color: var(--muted); font-size: 0.88rem; padding-left: 4px; }
.typing::after { content: "…"; animation: blink 1.2s steps(3) infinite; display: inline-block; width: 1em; overflow: hidden; vertical-align: bottom; }
@keyframes blink { from { width: 0; } to { width: 1em; } }

/* ---------- states ---------- */
.empty { text-align: left; padding: 22px 4px; color: var(--muted); }
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; }
.loading { color: var(--muted); padding: 18px 4px; }
.errorbox { border: 1px solid color-mix(in srgb, var(--red) 40%, var(--line)); background: var(--red-bg); color: var(--red); padding: 10px 14px; border-radius: var(--radius-m); margin-bottom: 14px; }
.notice { border: 1px solid var(--line); background: var(--surface); border-left: 4px solid var(--amber); padding: 10px 14px; border-radius: var(--radius-m); margin-bottom: 14px; }
.notice.mock { border-left-color: var(--blue); }

/* ---------- overlays ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: var(--paper); padding: 10px 14px; border-radius: var(--radius-m); box-shadow: var(--shadow-pop); max-width: 380px; animation: toastin 0.18s ease-out; }
.toast.err { background: var(--red); color: #fff; }
@keyframes toastin { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-back { position: fixed; inset: 0; background: rgba(15, 25, 32, 0.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: var(--radius-m); box-shadow: var(--shadow-pop); width: min(620px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 20px 22px; }
.modal.wide { width: min(900px, 100%); }
.modal h2 { margin-bottom: 12px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.ws-picker { display: flex; flex-direction: column; gap: 4px; }
.ws-picker button { display: flex; align-items: center; gap: 12px; border: 1px solid transparent; background: none; text-align: left; padding: 10px 12px; border-radius: var(--radius-m); cursor: pointer; }
.ws-picker button:hover, .ws-picker button.on { border-color: var(--line); background: var(--sunken); }
.ws-swatch { width: 26px; height: 26px; border-radius: 6px; background: var(--c); flex-shrink: 0; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 64px 1fr; }
.auth .spine { position: static; height: auto; min-height: 100vh; }
.auth-card { align-self: center; justify-self: center; width: min(420px, calc(100% - 32px)); }
.auth-card h1 { margin-bottom: 6px; }
.auth-card .panel { margin-top: 18px; }

/* tables */
table.t { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.t th { text-align: left; font-weight: 600; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.t td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.bar { height: 6px; border-radius: 3px; background: var(--sunken); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ws); }
.bar > i.over { background: var(--red); }
iframe.proto { width: 100%; height: 520px; border: 1px solid var(--line); border-radius: var(--radius-m); background: #fff; }
pre.out { background: var(--sunken); padding: 10px 12px; border-radius: var(--radius-s); white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: 0.82rem; max-height: 360px; overflow: auto; margin: 6px 0; }
details > summary { cursor: pointer; color: var(--muted); }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .grid2 { grid-template-columns: 1fr; }
  .shell { grid-template-columns: 56px 190px minmax(0, 1fr); }
  .main { padding: 22px 20px 60px; }
}
@media (max-width: 760px) {
  .shell { display: block; }
  .spine { position: sticky; top: 0; z-index: 30; width: 100%; height: auto; flex-direction: row; padding: 8px 16px; }
  .spine-name { writing-mode: horizontal-tb; transform: none; font-size: 1.1rem; text-align: left; }
  .spine-foot { flex-direction: row; }
  .nav { display: none; position: fixed; inset: 56px 0 0 0; z-index: 40; height: auto; border-right: 0; }
  .nav.open { display: flex; }
  .spine .mobilebar { display: inline-flex; }
  .main { padding: 18px 16px 60px; }
  .chat { grid-template-columns: 1fr; height: auto; }
  .convs { border-right: 0; padding-right: 0; max-height: 160px; border-bottom: 1px solid var(--line); }
  .messages { max-height: calc(100vh - 330px); }
  h1 { font-size: 1.35rem; }
  .auth { grid-template-columns: 1fr; }
  .auth .spine { min-height: 0; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

.boot { padding: 24px; color: var(--muted); }
.main:focus { outline: none; }
