:root {
  color-scheme: dark;
  --bg: #07110e;
  --panel: #0c1b16;
  --panel-2: #12271f;
  --line: #203a30;
  --text: #edf7f1;
  --muted: #8fa89d;
  --accent: #76f5b5;
  --danger: #ff8f86;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; background: var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error, .danger { color: var(--danger); }
.eyebrow { margin: 0 0 .3rem; color: var(--accent); font-size: .68rem; font-weight: 900; letter-spacing: .14em; }

.login-shell { min-height: 100dvh; display: grid; place-items: center; padding: 1.25rem; }
.login-card { width: min(100%, 440px); padding: 2rem; border: 1px solid var(--line); border-radius: 26px; background: var(--panel); box-shadow: 0 28px 90px #0008; }
.mark, .pulse { display: grid; place-items: center; width: 54px; height: 54px; margin-bottom: 1.4rem; border-radius: 17px; background: var(--accent); color: #052017; font-weight: 950; }
.login-card h1 { margin: 0; font-size: clamp(2.3rem, 11vw, 3.8rem); line-height: .98; letter-spacing: -.06em; }
label { display: block; margin: 1.1rem 0 .4rem; color: var(--muted); font-size: .76rem; font-weight: 800; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 14px; outline: 0; background: #08130f; color: var(--text); }
input, select { min-height: 46px; padding: .75rem .9rem; }
textarea { min-height: 48px; max-height: 160px; padding: .75rem .9rem; resize: none; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #76f5b51b; }
.login-card button, .primary, .panel > button, .panel form > button { min-height: 46px; margin-top: .75rem; padding: .75rem 1rem; border: 0; border-radius: 14px; background: var(--accent); color: #052017; font-weight: 900; }
.wide { width: 100%; }

.shell { min-height: 100dvh; }
.topbar { position: sticky; z-index: 12; top: 0; display: flex; align-items: center; gap: .8rem; min-height: 68px; padding: max(.8rem, env(safe-area-inset-top)) 1rem .7rem; border-bottom: 1px solid var(--line); background: #07110ef2; backdrop-filter: blur(18px); }
.topbar h1 { margin: 0; font-size: 1.05rem; }
.icon-button { display: none; place-items: center; width: 42px; height: 42px; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: transparent; color: var(--text); font-size: 1.2rem; }
.connection { margin-left: auto; color: var(--muted); font-size: .75rem; white-space: nowrap; }
.connection i { display: inline-block; width: 7px; height: 7px; margin-right: .4rem; border-radius: 50%; background: #f2b84b; }
.connection.online i { background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.tabs { position: sticky; z-index: 11; top: 68px; display: flex; justify-content: center; gap: .3rem; padding: .45rem; border-bottom: 1px solid var(--line); background: #07110ef2; }
.tab { min-width: 92px; min-height: 38px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); font-weight: 800; }
.tab.active { background: var(--panel-2); color: var(--text); }

.work-view { min-height: calc(100dvh - 115px); display: grid; grid-template: 1fr auto / 280px minmax(0, 1fr); }
aside { grid-row: 1 / 3; padding: 1rem; border-right: 1px solid var(--line); background: var(--panel); overflow-y: auto; }
.aside-title, .section-title { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.aside-title h2, .section-title h2, .panel h2 { margin: 0; }
#thread-list { display: grid; gap: .4rem; margin-top: 1rem; }
.thread { width: 100%; min-height: 58px; padding: .7rem; border: 1px solid transparent; border-radius: 13px; background: transparent; color: var(--muted); text-align: left; }
.thread:hover, .thread.active { border-color: var(--line); background: var(--panel-2); color: var(--text); }
.thread strong, .thread small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread small { margin-top: .25rem; color: var(--muted); font-size: .68rem; }

.conversation { min-height: 0; overflow-y: auto; padding: 1.1rem max(1rem, calc((100vw - 1050px) / 2)); }
.empty { min-height: 54vh; display: grid; place-content: center; justify-items: center; text-align: center; color: var(--muted); }
.empty h2 { margin: 0; color: var(--text); }
.pulse { animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 14px #76f5b510; } }
#feed { display: grid; gap: .75rem; max-width: 800px; margin: auto; }
.event { padding: .85rem 1rem; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.event.user { margin-left: 12%; background: #16382b; border-color: #285a47; }
.event.agent { margin-right: 6%; }
.event.tool { color: #bfd1c9; font: .76rem/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; }
.event.status { padding: .3rem 0; border: 0; background: transparent; color: var(--muted); font-size: .72rem; }

.composer-shell { padding: .65rem max(1rem, calc((100vw - 1050px) / 2)) max(.7rem, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #07110ef6; backdrop-filter: blur(18px); }
.active-label { margin-bottom: .35rem; color: var(--muted); font-size: .68rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#composer { display: grid; grid-template-columns: minmax(0, 1fr) 48px; gap: .5rem; }
#send { border: 0; border-radius: 14px; background: var(--accent); color: #052017; font-size: 1.25rem; font-weight: 950; }
.turn-actions { display: flex; justify-content: flex-end; gap: 1rem; margin-top: .35rem; }
.text-button { min-height: 34px; padding: .25rem; border: 0; background: none; color: var(--muted); font-size: .7rem; }
button:disabled, textarea:disabled { cursor: not-allowed; opacity: .4; }

.dashboard { width: min(100%, 780px); margin: auto; padding: 1rem 1rem 4rem; }
.secondary { min-height: 40px; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: 11px; background: transparent; color: var(--text); }
.summary, .panel { margin-top: 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: 17px; background: var(--panel); }
.summary { font-weight: 850; }
.services { display: grid; gap: .6rem; margin-top: .65rem; }
.service { display: grid; grid-template-columns: 1fr auto; gap: .3rem 1rem; padding: .9rem; border: 1px solid var(--line); border-radius: 15px; background: var(--panel); }
.service span { color: var(--accent); font-weight: 850; }
.service.bad { border-color: #6f3b38; }
.service.bad span { color: var(--danger); }
.service small { grid-column: 1 / 3; color: var(--muted); overflow-wrap: anywhere; }
.danger-panel { border-color: #68423e; }
.approval-check { display: flex; align-items: flex-start; gap: .6rem; }
.approval-check input { flex: 0 0 auto; width: 1.1rem; height: 1.1rem; min-height: 0; margin: .1rem 0 0; accent-color: var(--accent); }
.analysis { min-height: 4rem; margin-top: .8rem; padding: .8rem; border-radius: 12px; background: #07110e; white-space: pre-wrap; line-height: 1.5; }
.audit { display: grid; gap: .45rem; margin-top: .7rem; color: var(--muted); font-size: .75rem; }
.audit div { padding: .6rem 0; border-top: 1px solid var(--line); }

.approval { position: fixed; z-index: 30; inset: auto 1rem max(1rem, env(safe-area-inset-bottom)); width: min(calc(100% - 2rem), 640px); margin: auto; padding: 1.1rem; border: 1px solid #446c5d; border-radius: 20px; background: #10231c; box-shadow: 0 24px 80px #000d; }
.approval h2 { margin: 0; }
.approval pre { max-height: 180px; overflow: auto; padding: .8rem; border-radius: 12px; background: #07110e; color: #cee4da; white-space: pre-wrap; }
.approval-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; }
.approval-actions button { min-height: 42px; padding: .65rem .8rem; border: 0; border-radius: 11px; background: var(--accent); color: #052017; font-weight: 850; }
.approval-actions .secondary { border: 1px solid var(--line); background: transparent; color: var(--text); }

@media (max-width: 760px) {
  .icon-button { display: grid; }
  .work-view { grid-template-columns: 1fr; }
  aside { position: fixed; z-index: 20; inset: 0 15% 0 0; transform: translateX(-105%); transition: transform .2s ease; box-shadow: 20px 0 70px #000c; }
  aside.open { transform: translateX(0); }
  .conversation { padding: .9rem; }
  .composer-shell { padding-inline: .8rem; }
  .event.user { margin-left: 8%; }
  .event.agent { margin-right: 2%; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }
