/* Satsyil AI — swap --accent and /mark.svg to re-brand. */
:root {
  --bg: #f8f7f4;
  --side: #f0eee9;
  --surface: #ffffff;
  --raised: #ffffff;
  --hover: rgba(30, 28, 22, 0.055);
  --active: rgba(30, 28, 22, 0.09);
  --border: #e4e1d9;
  --border-strong: #d3cfc4;
  --text: #1d1c19;
  --muted: #6d6a62;
  --faint: #9a968c;
  --accent: #1f4fa3;
  --accent-hover: #193f84;
  --accent-soft: #e6edf9;
  --accent-text: #ffffff;
  --gold: #c98d17;
  --user-bubble: #ebe8e0;
  --code-bg: #f3f1ec;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --success: #1f7a4d;
  --success-soft: #e6f4ec;
  --warn: #9a6200;
  --warn-soft: #fdf3dc;
  --shadow: 0 1px 2px rgba(20, 18, 12, .04), 0 6px 24px rgba(20, 18, 12, .07);
  --shadow-lg: 0 8px 40px rgba(20, 18, 12, .16);
  --radius: 12px;
  --font: ui-sans-serif, -apple-system, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1f1f1d; --side: #181816; --surface: #2a2a27; --raised: #30302c;
    --hover: rgba(255, 255, 250, .06); --active: rgba(255, 255, 250, .1);
    --border: #383733; --border-strong: #4a4943;
    --text: #ecebe6; --muted: #a8a59c; --faint: #7d7a72;
    --accent: #6f9cf0; --accent-hover: #8aaff4; --accent-soft: #24324d; --accent-text: #0e1626;
    --gold: #f2b33d; --user-bubble: #34332f; --code-bg: #262624;
    --danger: #f97066; --danger-soft: #3a1f1d; --success: #5fcf95; --success-soft: #1c3328; --warn: #f2b33d; --warn-soft: #3a2f17;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 24px rgba(0, 0, 0, .3); --shadow-lg: 0 8px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1f1f1d; --side: #181816; --surface: #2a2a27; --raised: #30302c;
  --hover: rgba(255, 255, 250, .06); --active: rgba(255, 255, 250, .1);
  --border: #383733; --border-strong: #4a4943;
  --text: #ecebe6; --muted: #a8a59c; --faint: #7d7a72;
  --accent: #6f9cf0; --accent-hover: #8aaff4; --accent-soft: #24324d; --accent-text: #0e1626;
  --gold: #f2b33d; --user-bubble: #34332f; --code-bg: #262624;
  --danger: #f97066; --danger-soft: #3a1f1d; --success: #5fcf95; --success-soft: #1c3328; --warn: #f2b33d; --warn-soft: #3a2f17;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 24px rgba(0, 0, 0, .3); --shadow-lg: 0 8px 40px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.icon { display: inline-flex; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.right { text-align: right; }
.center { text-align: center; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#root { height: 100%; }
.boot { height: 100%; display: grid; place-items: center; }
.boot img { width: 44px; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; transform: scale(.94); } }

/* ---------- buttons & inputs */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--border-strong);
  background: var(--surface); cursor: pointer; font-weight: 500; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  border: 1px solid var(--border-strong); background: var(--surface); border-radius: 9px; padding: 0 12px; height: 36px; min-width: 0; }
textarea { padding: 10px 12px; height: auto; resize: vertical; }
textarea.big { width: 100%; line-height: 1.5; }
input.full { width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.inline-form { display: flex; gap: 8px; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 14px; }
.field-label { display: block; font-weight: 500; margin-bottom: 8px; }
.notice { padding: 12px 14px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 14px; }
.notice.error { background: var(--danger-soft); color: var(--danger); }

/* ---------- brand (Satsyil wordmark + "AI") */
:root { --logo-ink: #00125C; --logo-sky: #9CD4FC; }
:root[data-theme="dark"] { --logo-ink: #FFFFFF; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --logo-ink: #FFFFFF; } }
.brand-lockup { display: inline-flex; align-items: center; gap: 10px; }
.logo-wrap { display: inline-flex; }
.satsyil-logo { width: 118px; height: auto; display: block; }
.satsyil-logo .ink { fill: var(--logo-ink); }
.satsyil-logo .sky { fill: var(--logo-sky); }
.satsyil-logo .lg-ink { stop-color: var(--logo-ink); }
.satsyil-logo .lg-sky { stop-color: var(--logo-sky); }
.brand-ai { padding: 3px 7px 2px; border-radius: 6px; background: var(--logo-ink); color: var(--bg); font: 700 13px/1 var(--font); letter-spacing: .04em; }

/* ---------- sign-in / waiting */
.gate { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.gate-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 36px 32px; box-shadow: var(--shadow); text-align: center; }
.gate-logo { margin-bottom: 26px; }
.gate-logo .satsyil-logo { width: 160px; }
.gate-logo .brand-ai { font-size: 15px; }
.gate-card h1 { font: 500 26px/1.25 var(--serif); margin: 0 0 10px; }
.gate-card p { margin: 0 0 22px; }
.gsi-host { display: flex; justify-content: center; min-height: 44px; }
.gate-error { color: var(--danger); font-size: 14px; min-height: 1em; margin: 14px 0 0 !important; }
.gate-user { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 20px; text-align: left; }
.gate-user div { display: flex; flex-direction: column; font-size: 14px; }
.dev-login { margin-top: 22px; padding-top: 18px; border-top: 1px dashed var(--border-strong); display: grid; gap: 8px; }
.dev-login input { flex: 1; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-actions.center { justify-content: center; }
.row-actions.end { justify-content: flex-end; margin-top: 12px; }

/* ---------- avatar */
.avatar { position: relative; display: inline-grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 600; overflow: hidden; flex: none; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* ---------- app shell */
.app { display: grid; grid-template-columns: 272px 1fr; grid-template-rows: minmax(0, 1fr); height: 100%; height: 100dvh; overflow: hidden; transition: grid-template-columns .2s ease; }
.app.collapsed { grid-template-columns: 0 1fr; }
.app.collapsed .sidebar { visibility: hidden; }
.sidebar { background: var(--side); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; position: relative; }
.topbar { display: flex; align-items: center; gap: 6px; height: 52px; padding: 0 12px; flex: none; }
.top-title { flex: 1; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 14px; }
.show-sidebar { display: none; }
.app.collapsed .show-sidebar { display: inline-grid; }
.mobile-only { display: none !important; }
.scrim { display: none; }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.side-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 8px 16px; }
.brand { text-decoration: none; }
.new-chat { display: flex; align-items: center; gap: 10px; margin: 6px 10px 4px; padding: 8px 10px; border: 0; border-radius: 10px; background: none; cursor: pointer; font-weight: 500; text-align: left; }
.new-chat:hover { background: var(--hover); }
.new-dot { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: var(--accent-text); }
.side-link { display: flex; align-items: center; gap: 10px; margin: 0 10px; padding: 8px 12px; border-radius: 10px; color: var(--text); text-decoration: none; font-weight: 500; }
.side-link:hover { background: var(--hover); }
.side-link.active { background: var(--active); }
.badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--gold); color: #1b1404; font-size: 12px; font-weight: 700; display: inline-grid; place-items: center; }
.side-search { margin: 10px 12px 6px; height: 34px !important; background: var(--surface) !important; font-size: 14px; }
.conv-list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.conv-group { margin-top: 12px; }
.conv-group-label { font-size: 12px; font-weight: 600; color: var(--faint); padding: 0 10px 4px; }
.conv { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 4px 0 10px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: 14px; }
.conv:hover { background: var(--hover); }
.conv.active { background: var(--active); }
.conv-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-more { width: 26px; height: 26px; opacity: 0; }
.conv:hover .conv-more, .conv.active .conv-more, .conv-more[data-menu-anchor]:focus { opacity: 1; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s infinite; flex: none; }
.side-empty { color: var(--faint); font-size: 13px; padding: 12px; }
.side-foot { border-top: 1px solid var(--border); padding: 8px; }
.me { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 0; background: none; border-radius: 10px; cursor: pointer; text-align: left; }
.me:hover { background: var(--hover); }
.me-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.me-text strong { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-transform: capitalize; }
.me-text span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- menus, modal, toast */
.menu { position: fixed; z-index: 50; min-width: 200px; max-width: min(340px, calc(100vw - 16px)); max-height: 70vh; overflow-y: auto; background: var(--raised); border: 1px solid var(--border); border-radius: 12px; padding: 5px; box-shadow: var(--shadow-lg); }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: none; cursor: pointer; text-align: left; font-size: 14px; }
.menu-item:hover, .menu-item:focus { background: var(--hover); outline: none; }
.menu-item.danger { color: var(--danger); }
.menu-item.active > .icon:last-child { color: var(--accent); }
.menu-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.menu-detail { font-size: 12px; color: var(--muted); }
.menu-sep { height: 1px; background: var(--border); margin: 5px 6px; }
.model-menu { min-width: 280px; }
.modal-wrap { position: fixed; inset: 0; z-index: 60; background: rgba(15, 14, 10, .45); display: grid; place-items: center; padding: 16px; animation: fade .12s; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(520px, 100%); background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 6px 22px; }
.modal-head h2 { margin: 0; font: 500 19px/1.3 var(--serif); }
.modal-body { padding: 8px 22px 6px; }
.modal-body p { margin: 0; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 22px 20px; }
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 70; display: grid; gap: 8px; width: min(440px, calc(100vw - 32px)); }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow-lg); animation: rise .18s ease-out; transition: opacity .3s, transform .3s; }
.toast.error { background: var(--danger); color: #fff; }
.toast.success { background: var(--success); color: #fff; }
.toast.out { opacity: 0; transform: translateY(6px); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ---------- chat */
.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.chat.dropping::after { content: "Drop files to attach"; position: absolute; inset: 12px; border: 2px dashed var(--accent); border-radius: 16px; background: color-mix(in srgb, var(--accent-soft) 80%, transparent); display: grid; place-items: center; font-weight: 600; color: var(--accent); z-index: 5; pointer-events: none; }
.chat.empty { justify-content: center; align-items: center; padding: 0 16px 12vh; gap: 0; }
.hero { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; text-align: center; }
.hero-mark { width: 46px; height: 40px; }
.hero h1 { margin: 0; font: 400 clamp(28px, 4.2vw, 40px)/1.15 var(--serif); letter-spacing: -.015em; }
.chat.empty .composer { width: min(680px, 100%); }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 16px; width: min(680px, 100%); }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 7px 14px; font-size: 13.5px; color: var(--muted); cursor: pointer; }
.chip:hover { color: var(--text); border-color: var(--border-strong); background: var(--hover); }

.thread { flex: 1; overflow-y: auto; scroll-behavior: auto; }
.thread-inner { width: min(760px, 100%); margin: 0 auto; padding: 16px 20px 32px; display: flex; flex-direction: column; gap: 22px; }
.loading-thread { display: grid; place-items: center; padding: 48px; }
.dock { flex: none; padding: 0 16px 10px; display: flex; flex-direction: column; align-items: center; background: linear-gradient(to bottom, transparent, var(--bg) 22px); }
.dock .composer { width: min(728px, 100%); }
.disclaimer { margin: 8px 0 0; font-size: 12px; color: var(--faint); text-align: center; }

.msg.user { align-self: flex-end; max-width: min(85%, 640px); display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.bubble { background: var(--user-bubble); padding: 10px 16px; border-radius: 18px 18px 6px 18px; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.msg-actions { opacity: 0; transition: opacity .12s; }
.msg.user:hover .msg-actions { opacity: 1; }
.msg-actions .icon-btn, .msg-foot .icon-btn { width: 28px; height: 28px; }
.msg-files { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.att-thumb img { display: block; max-width: 220px; max-height: 160px; border-radius: 10px; border: 1px solid var(--border); }
.att-file { display: inline-flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); text-decoration: none; font-size: 13px; max-width: 280px; }
.att-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.att-size { color: var(--faint); font-size: 12px; flex: none; }

.msg.assistant { display: grid; grid-template-columns: 28px 1fr; gap: 14px; }
.msg-mark img { width: 26px; height: 22px; margin-top: 3px; }
.msg-body { min-width: 0; }
.msg-foot { display: flex; align-items: center; gap: 2px; margin-top: 4px; margin-left: -6px; color: var(--faint); font-size: 12px; }
.foot-model { margin-left: 8px; }
.foot-note { margin-left: 6px; padding: 1px 8px; border-radius: 6px; background: var(--hover); }
.msg-error { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: 14px; }
.pending { padding: 6px 0; display: flex; align-items: center; gap: 10px; }
.pending-status { color: var(--muted); font-size: 13.5px; }
.foot-note.compacted { background: var(--accent-soft); color: var(--accent); cursor: help; }
.dots { display: inline-flex; gap: 5px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); animation: blink 1.2s infinite both; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.caret { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); margin-left: 4px; vertical-align: middle; animation: pulse 1s infinite; }
.thinking { margin-bottom: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.thinking summary { display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer; color: var(--muted); font-size: 13.5px; list-style: none; }
.thinking summary::-webkit-details-marker { display: none; }
.thinking-body { padding: 0 14px 12px; color: var(--muted); font-size: 13.5px; white-space: pre-wrap; max-height: 320px; overflow-y: auto; }

/* ---------- markdown */
.md { overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 .85em; }
.md h1, .md h2, .md h3, .md h4 { font-family: var(--serif); font-weight: 600; line-height: 1.3; margin: 1.3em 0 .5em; }
.md h1 { font-size: 1.45em; } .md h2 { font-size: 1.25em; } .md h3 { font-size: 1.1em; } .md h4, .md h5, .md h6 { font-size: 1em; }
.md ul, .md ol { margin: 0 0 .85em; padding-left: 1.5em; }
.md li { margin: .25em 0; }
.md li > p { margin: 0 0 .3em; }
.md li > ul, .md li > ol { margin-bottom: .2em; }
.md blockquote { margin: 0 0 .85em; padding: 2px 0 2px 14px; border-left: 3px solid var(--border-strong); color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 1.4em 0; }
.md code { font-family: var(--mono); font-size: .88em; background: var(--code-bg); border: 1px solid var(--border); border-radius: 5px; padding: .08em .35em; }
.md a { text-underline-offset: 2px; }
.code { margin: 0 0 .9em; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--code-bg); }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 5px 8px 5px 14px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border); }
.copy-code { border: 0; background: none; color: var(--muted); font-size: 12px; cursor: pointer; padding: 3px 8px; border-radius: 6px; }
.copy-code:hover { background: var(--hover); color: var(--text); }
.code pre { margin: 0; padding: 12px 14px; overflow-x: auto; }
.code pre code { background: none; border: 0; padding: 0; font-size: 13px; line-height: 1.55; }
.table-wrap { overflow-x: auto; margin: 0 0 .9em; }
.md table { border-collapse: collapse; font-size: 14px; min-width: 50%; }
.md th, .md td { border: 1px solid var(--border); padding: 7px 11px; text-align: left; vertical-align: top; }
.md th { background: var(--code-bg); font-weight: 600; }

/* ---------- composer */
.composer { background: var(--surface); border: 1px solid var(--border-strong); border-radius: 20px; box-shadow: var(--shadow); padding: 10px 10px 8px 14px; transition: border-color .12s, box-shadow .12s; }
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 45%, var(--border-strong)); }
.composer textarea { display: block; width: 100%; border: 0 !important; box-shadow: none !important; background: none !important; padding: 6px 2px; resize: none; max-height: 40vh; font-size: 15.5px; line-height: 1.5; }
.composer-bar { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.spacer { flex: 1; }
.attach { margin-left: -6px; }
.model-btn { display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 8px 0 10px; border: 0; background: none; border-radius: 8px; color: var(--muted); font-size: 13.5px; cursor: pointer; max-width: 220px; }
.model-btn span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-btn:hover { background: var(--hover); color: var(--text); }
.send-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; border: 0; background: var(--accent); color: var(--accent-text); cursor: pointer; transition: background .12s, opacity .12s; }
.send-btn:hover:not(:disabled) { background: var(--accent-hover); }
.send-btn:disabled { opacity: .35; cursor: default; }
.send-btn.stop { background: var(--text); color: var(--bg); }
.att-row { display: none; flex-wrap: wrap; gap: 8px; padding: 2px 0 8px; }
.att-row.has { display: flex; }
.att-chip { display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 4px 0 6px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); font-size: 13px; max-width: 260px; }
.att-chip img { width: 32px; height: 32px; object-fit: cover; border-radius: 6px; }
.att-chip .icon { color: var(--muted); padding-left: 4px; }
.att-chip.uploading { opacity: .75; }
.att-chip.error { border-color: var(--danger); color: var(--danger); }
.att-x { width: 26px; height: 26px; }

/* ---------- admin */
.admin { flex: 1; overflow-y: auto; }
.admin-head { width: min(1040px, 100%); margin: 0 auto; padding: 8px 24px 0; }
.admin-head h1 { font: 500 30px/1.2 var(--serif); margin: 4px 0 16px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab { display: inline-flex; align-items: center; gap: 7px; padding: 10px 14px; color: var(--muted); text-decoration: none; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab .badge { margin-left: 2px; }
.admin-body { width: min(1040px, 100%); margin: 0 auto; padding: 20px 24px 48px; display: grid; gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px; min-width: 0; }
.card h2 { margin: 0 0 4px; font-size: 16px; font-weight: 600; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pending-card { border-color: color-mix(in srgb, var(--gold) 55%, var(--border)); background: color-mix(in srgb, var(--warn-soft) 55%, var(--surface)); }
.pending-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pending-row:first-of-type { border-top: 0; margin-top: 8px; }
.who { flex: 1; min-width: 180px; display: flex; flex-direction: column; line-height: 1.35; }
.who span, .who small { color: var(--muted); font-size: 13px; }
.who strong { text-transform: capitalize; }
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.grid td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid th.right, table.grid td.right { text-align: right; }
table.grid td.center { text-align: center; }
table.grid tr.off td { color: var(--muted); }
.who-cell { display: flex; align-items: center; gap: 10px; }
.who-cell div { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.who-cell strong { text-transform: capitalize; font-weight: 500; }
.who-cell span { color: var(--muted); font-size: 13px; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; text-transform: capitalize; }
.pill.approved { background: var(--success-soft); color: var(--success); }
.pill.pending { background: var(--warn-soft); color: var(--warn); }
.pill.denied { background: var(--danger-soft); color: var(--danger); }
.tag { display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 600; }
.cell-input { height: 32px !important; width: 100%; max-width: 280px; }
.cell-input.num { max-width: 110px; }
.toolbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; color: var(--muted); cursor: pointer; }
.switch { position: relative; display: inline-block; width: 36px; height: 21px; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--border-strong); transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(15px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.stat span { color: var(--muted); font-size: 13px; }
.stat strong { font: 500 26px/1.2 var(--serif); font-variant-numeric: tabular-nums; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 10px 0 0; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }


/* ---------- company budget */
.budget-hero .card-head { align-items: flex-start; margin-bottom: 8px; }
.status-pill { display: inline-block; margin-top: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.status-pill.ok { background: var(--success-soft); color: var(--success); }
.status-pill.risk { background: var(--warn-soft); color: var(--warn); }
.status-pill.locked { background: var(--danger-soft); color: var(--danger); }
.status-pill.neutral { background: var(--hover); color: var(--muted); }
.hero-num { margin: 6px 0 12px; font-variant-numeric: tabular-nums; }
.hero-num strong { font: 500 40px/1.1 var(--serif); }
.hero-num span { color: var(--muted); font-size: 18px; }
.stat strong.over { color: var(--danger); }
.chart { position: relative; padding: 8px 0 22px; }
.bars { position: relative; height: 180px; display: flex; align-items: flex-end; gap: 2px; border-bottom: 1px solid var(--border-strong); }
.bar-col { flex: 1; height: 100%; display: flex; align-items: flex-end; cursor: default; }
.bar-col:hover { background: var(--hover); }
.bar { display: block; width: 100%; min-height: 0; background: var(--accent); border-radius: 4px 4px 0 0; }
.bar-col.future .bar { background: transparent; }
.pace-line { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--muted); pointer-events: none; }
.pace-line span { position: absolute; right: 0; bottom: 4px; font-size: 11px; color: var(--muted); background: var(--surface); padding: 0 4px; }
.chart-tip { position: absolute; top: -6px; transform: translateX(-50%); background: var(--text); color: var(--bg); font-size: 12px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; pointer-events: none; }
.chart-tip[hidden] { display: none; }
.bar-ticks { position: relative; height: 18px; font-size: 11px; color: var(--muted); }
.bar-ticks span { position: absolute; top: 4px; transform: translateX(-50%); }
.commit { margin: 6px 0 0; font-size: 15px; }
.commit strong { font: 500 22px/1.2 var(--serif); }
.warn-card { border-color: color-mix(in srgb, var(--gold) 55%, var(--border)); }
.share { display: flex; align-items: center; gap: 8px; }
.share .meter-bar.thin { margin: 0; width: 140px; }

/* ---------- approvals */
.approve-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.btn.danger-outline { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--border-strong)); }
.btn.danger-outline:hover { background: var(--danger-soft); }

/* ---------- budgets & usage meters */
.meter { display: grid; gap: 6px; }
.meter-top { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.meter-top span:first-child { font-weight: 600; }
.meter-num { color: var(--muted); font-variant-numeric: tabular-nums; }
.meter-bar { height: 8px; border-radius: 99px; background: var(--active); overflow: hidden; }
.meter-bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .3s ease; }
.meter-bar.warn i { background: var(--gold); }
.meter-bar.full i { background: var(--danger); }
.meter-bar.thin { height: 5px; margin-top: 4px; width: 120px; }
.meter.compact { gap: 5px; }
.meter.compact .meter-top { font-size: 12px; }
.meter.compact .meter-top span:first-child { font-weight: 500; color: var(--muted); }
.meter.compact .meter-bar { height: 5px; }
.budget-chip { display: block; width: 100%; padding: 8px 10px 10px; margin-bottom: 4px; border: 0; background: none; border-radius: 10px; cursor: pointer; text-align: left; }
.budget-chip:hover { background: var(--hover); }
.usage-modal { display: grid; gap: 20px; padding-bottom: 4px; }
.usage-modal .hint { margin: 0; }
.limit-note { margin: 0 0 8px; padding: 9px 12px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: 13.5px; }
.limit-note[hidden] { display: none; }
.spend-cell { display: flex; flex-direction: column; font-variant-numeric: tabular-nums; white-space: nowrap; }
.over { color: var(--danger); font-size: 12px; }
.strong { font-weight: 600; }
.link-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 4px 6px; margin-left: -6px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text); white-space: nowrap; }
.link-btn:hover { background: var(--hover); }
.link-btn .icon { color: var(--faint); }
.limit-form { display: grid; gap: 4px; padding-bottom: 6px; }
.radio-row { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.radio-row:hover { background: var(--hover); }
.radio-row input { margin-top: 4px; }
.radio-row span { display: flex; flex-direction: column; }
.radio-row small { color: var(--muted); }
.limit-fields { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-end; padding: 2px 12px 10px 38px; }
.limit-fields[hidden] { display: none; }
.limit-fields.wide { padding: 4px 0 14px; }
.limit-fields label { display: grid; gap: 6px; font-size: 13px; font-weight: 500; }
.limit-fields small { flex-basis: 100%; }
.dollar { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.dollar input { width: 110px; color: var(--text); }
.price-pair { display: flex; gap: 8px; }
.cell-input.price { width: 84px !important; }
.budget-preview { max-width: 420px; padding: 14px 16px 2px; border: 1px dashed var(--border-strong); border-radius: 12px; }

/* ---------- small screens */
@media (max-width: 860px) {
  .app, .app.collapsed { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 40; transform: translateX(-102%); transition: transform .2s ease; visibility: visible !important; box-shadow: var(--shadow-lg); }
  .app.drawer .sidebar { transform: none; }
  .app.drawer .scrim { display: block; position: fixed; inset: 0; z-index: 39; background: rgba(15, 14, 10, .4); }
  .mobile-only { display: inline-grid !important; }
  .hide-sidebar, .show-sidebar, .app.collapsed .show-sidebar { display: none !important; }
  .topbar { border-bottom: 1px solid var(--border); }
  .top-title { text-align: center; color: var(--text); }
  .thread-inner { padding: 14px 16px 24px; }
  .msg.assistant { grid-template-columns: 1fr; gap: 6px; }
  .msg-mark { display: none; }
  .msg.user { max-width: 92%; }
  .hero { flex-direction: column; gap: 10px; }
  .chat.empty { padding-bottom: 6vh; }
  .admin-head, .admin-body { padding-left: 16px; padding-right: 16px; }
  .conv-more { opacity: 1; }
  .msg-actions { opacity: 1; }
  .inline-form { flex-wrap: wrap; }
  .inline-form input { flex: 1 1 200px; }
}
