:root {
  color-scheme: dark;
  --bg: #0b0f0d;
  --surface: #121815;
  --surface-2: #18201c;
  --surface-3: #202a25;
  --line: #29352f;
  --text: #f2f5f3;
  --muted: #91a098;
  --green: #69e0a7;
  --green-deep: #173d2c;
  --orange: #f6b86c;
  --red: #ff8e8e;
  --shadow: 0 22px 60px rgba(0, 0, 0, .28);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 7px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(25px, 3vw, 34px); letter-spacing: -.04em; }
h2 { margin-bottom: 16px; font-size: 20px; letter-spacing: -.025em; }
h3 { margin-bottom: 5px; font-size: 15px; }
code { padding: 2px 5px; border-radius: 5px; background: var(--surface-3); color: var(--green); }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 25% 10%, #153426 0, transparent 35%), var(--bg); }
.login-card { width: min(440px, 100%); padding: 42px; border: 1px solid var(--line); border-radius: 22px; background: rgba(18, 24, 21, .92); box-shadow: var(--shadow); }
.login-card h1 { margin: 12px 0 10px; }
.brand-mark { width: 58px; height: 58px; display: grid; place-items: center; border: 1px solid #8ff0bd; border-radius: 18px 18px 18px 5px; background: linear-gradient(145deg, #63dba2, #2a8158); color: #07110c; font: 900 27px/1 Georgia, serif; box-shadow: 0 8px 35px rgba(79, 206, 143, .18); }
.brand-mark.small { width: 38px; height: 38px; border-radius: 12px 12px 12px 4px; font-size: 18px; }
.stack-lg { display: grid; gap: 18px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 230px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 16px; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: #0e1311; }
.brand-row { display: flex; align-items: center; gap: 12px; padding: 0 8px 28px; }
.brand-row strong, .brand-row span { display: block; }
.brand-row strong { font: 800 18px/1.2 Georgia, serif; }
.brand-row span { margin-top: 3px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .11em; }
nav { display: grid; gap: 5px; }
.nav-item { width: 100%; padding: 11px 12px; display: flex; align-items: center; gap: 11px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); text-align: left; cursor: pointer; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--green-deep); color: #c7f7dc; }
.nav-item > span { width: 20px; color: var(--green); font-size: 18px; text-align: center; }
.count { margin-left: auto; min-width: 21px; padding: 2px 6px; border-radius: 99px; background: var(--green); color: #08100c; font-size: 11px; text-align: center; }
.sidebar-foot { margin-top: auto; padding: 14px 10px 0; display: flex; align-items: flex-start; gap: 9px; border-top: 1px solid var(--line); color: #bbc5c0; font-size: 12px; line-height: 1.4; }
.sidebar-foot small { color: var(--muted); }
.privacy-dot { width: 8px; height: 8px; margin-top: 4px; flex: 0 0 auto; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px var(--green); }

.workspace { min-width: 0; }
.topbar { height: 100px; padding: 22px clamp(20px, 4vw, 52px); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(11, 15, 13, .86); backdrop-filter: blur(14px); position: sticky; top: 0; z-index: 10; }
.top-actions, .button-row { display: flex; align-items: center; gap: 10px; }
.panel { display: none; padding: 34px clamp(20px, 4vw, 52px) 60px; }
.panel.active { display: block; }
.card, .metric-card { border: 1px solid var(--line); background: linear-gradient(145deg, rgba(24, 32, 28, .92), rgba(16, 22, 19, .95)); box-shadow: 0 12px 38px rgba(0, 0, 0, .14); }
.card { padding: 24px; border-radius: 16px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.metric-card { min-height: 150px; padding: 20px; border-radius: 15px; }
.metric-card span, .metric-card small { display: block; color: var(--muted); }
.metric-card span { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.metric-card strong { display: block; margin: 18px 0 13px; font: 700 38px/1 Georgia, serif; }
.metric-card small { font-size: 12px; }
.metric-card.accent { border-color: #3b7659; background: linear-gradient(145deg, #183626, #13251b); }
.two-column { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, .8fr); gap: 20px; }
.card-heading, .pane-head, .section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.section-heading { margin-bottom: 20px; }
.section-heading h2 { margin: 0; font-size: 26px; }
.guide-card ol { padding: 0; margin: 8px 0 22px; list-style: none; counter-reset: guide; }
.guide-card li { display: grid; grid-template-columns: 64px 1fr; gap: 8px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.guide-card li b { color: var(--green); }
.guide-card li span { color: var(--muted); font-size: 13px; line-height: 1.5; }
.small-copy { font-size: 12px; line-height: 1.55; }

label { display: grid; gap: 7px; color: #b8c2bd; font-size: 12px; font-weight: 650; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 9px; outline: none; background: #0e1411; color: var(--text); }
input, select { min-height: 42px; padding: 0 12px; }
textarea { padding: 12px; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { border-color: #559b73; box-shadow: 0 0 0 3px rgba(105, 224, 167, .09); }
.button, .status-button, .icon-button, .text-button { border: 0; cursor: pointer; }
.button { min-height: 42px; padding: 0 16px; border-radius: 9px; font-weight: 750; }
.button.primary { background: var(--green); color: #08110c; }
.button.primary:hover { background: #83e9b6; }
.button.secondary { border: 1px solid var(--line); background: var(--surface-3); color: var(--text); }
.button.danger { border: 1px solid #643939; background: #2e1c1c; color: #ffc0c0; }
.button.wide { width: 100%; }
.button:disabled, button:disabled { opacity: .45; cursor: not-allowed; }
.icon-button { width: 39px; height: 39px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); color: var(--muted); }
.text-button { padding: 5px; background: transparent; color: var(--green); font-size: 12px; }
.status-button { min-width: 126px; height: 40px; padding: 0 15px; display: flex; align-items: center; justify-content: center; gap: 9px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface-2); }
.status-button span { width: 8px; height: 8px; border-radius: 50%; background: var(--orange); }
.status-button.on { border-color: #32694e; background: var(--green-deep); color: #c7f7dc; }
.status-button.on span { background: var(--green); box-shadow: 0 0 10px var(--green); }
.save-indicator { color: var(--muted); font-size: 12px; }
.error-text { min-height: 20px; color: var(--red); font-size: 13px; }

.warning-box { margin-bottom: 20px; padding: 15px 18px; border: 1px solid #71562e; border-radius: 11px; background: #2b2317; color: #ffd79b; font-size: 13px; line-height: 1.5; }
.connection-row, .diagnostic-row { padding: 14px 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.connection-row:last-child, .diagnostic-row:last-child { border-bottom: 0; }
.connection-row p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.badge { padding: 5px 8px; border-radius: 99px; background: var(--surface-3); color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.badge.good { background: var(--green-deep); color: var(--green); }
.badge.bad { background: #332020; color: var(--red); }
.list-state { color: var(--muted); font-size: 13px; }

.chat-layout { min-height: calc(100vh - 195px); padding: 0; display: grid; grid-template-columns: 330px 1fr; overflow: hidden; }
.chat-list-pane { border-right: 1px solid var(--line); }
.pane-head { padding: 22px 20px 8px; }
.pane-head h2 { margin-bottom: 0; }
.search { width: calc(100% - 32px); margin: 10px 16px 13px; }
.chat-list { max-height: calc(100vh - 315px); overflow: auto; }
.chat-item { width: 100%; padding: 15px 18px; display: grid; grid-template-columns: 38px 1fr auto; gap: 10px; align-items: center; border: 0; border-top: 1px solid var(--line); background: transparent; text-align: left; cursor: pointer; }
.chat-item:hover, .chat-item.active { background: var(--surface-3); }
.avatar { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: #254437; color: #b8f4d3; font-weight: 800; }
.chat-copy { min-width: 0; }
.chat-copy b, .chat-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-copy b { margin-bottom: 5px; font-size: 13px; }
.chat-copy span { color: var(--muted); font-size: 11px; }
.chat-meta { display: grid; justify-items: end; gap: 7px; }
.chat-detail { min-width: 0; display: flex; flex-direction: column; }
.empty-state { min-height: 430px; display: grid; place-items: center; padding: 40px; color: var(--muted); text-align: center; }
.empty-state h2 { margin: 14px 0 7px; color: var(--text); }
.empty-icon { color: var(--green); font-size: 50px; }
.detail-head { padding: 18px 22px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); }
.detail-head h2 { margin: 0 0 3px; }
.detail-head p { margin: 0; color: var(--muted); font-size: 12px; }
.detail-controls { display: flex; gap: 8px; }
.detail-controls select { min-width: 130px; }
.messages { padding: 24px; display: flex; flex: 1; flex-direction: column; gap: 10px; overflow: auto; background: #0d1210; }
.message { max-width: min(76%, 640px); padding: 10px 13px; border: 1px solid var(--line); border-radius: 13px 13px 13px 4px; background: var(--surface-2); line-height: 1.5; font-size: 13px; white-space: pre-wrap; }
.message.outbound_human, .message.outbound_ai { align-self: flex-end; border-radius: 13px 13px 4px 13px; }
.message.outbound_human { border-color: #42604f; background: #21352a; }
.message.outbound_ai { border-color: #355e4a; background: var(--green-deep); }
.message small { display: block; margin-top: 5px; color: var(--muted); font-size: 9px; text-align: right; }
.composer { padding: 14px; display: grid; grid-template-columns: 1fr auto; gap: 10px; border-top: 1px solid var(--line); }
.composer textarea { min-height: 46px; max-height: 130px; }
.contact-instructions { padding: 14px; border-top: 1px solid var(--line); background: var(--surface); }

.draft-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.draft-card { padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.draft-card header { display: flex; justify-content: space-between; gap: 12px; }
.draft-card textarea { min-height: 125px; margin: 8px 0 12px; }
.draft-card .button-row { justify-content: flex-end; }
.draft-error { color: var(--red); font-size: 12px; }

.settings-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(310px, .75fr); gap: 20px; }
.settings-main textarea { min-height: 405px; }
.settings-main > label { margin-top: 25px; }
.prompt-note { margin-top: 14px; padding: 12px; display: grid; grid-template-columns: 34px 1fr; gap: 8px; border-left: 2px solid var(--green); background: #132019; color: var(--muted); font-size: 12px; line-height: 1.5; }
.prompt-note b { color: var(--green); }
.card label + label, .card .field-row, .card .check-row { margin-top: 15px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check-row { grid-template-columns: auto 1fr; align-items: start; }
.check-row input { width: 18px; min-height: 18px; accent-color: var(--green); }
.check-row b, .check-row small { display: block; }
.check-row small { margin-top: 4px; color: var(--muted); font-weight: 400; }

.setup-columns { margin-bottom: 20px; }
.diagnostic { min-height: 150px; margin-bottom: 20px; }
.diagnostic-row strong, .diagnostic-row span { font-size: 12px; }
.diagnostic-row span { color: var(--muted); text-align: right; word-break: break-word; }
.setup-list { margin: 0; padding: 0; list-style: none; }
.setup-list li { padding: 11px 0; display: grid; grid-template-columns: 28px 1fr; gap: 11px; border-bottom: 1px solid var(--line); }
.setup-list li > span { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; background: var(--green-deep); color: var(--green); font-size: 11px; font-weight: 800; }
.setup-list b, .setup-list small { display: block; }
.setup-list small { margin-top: 4px; color: var(--muted); line-height: 1.45; }
.boundary-card { display: grid; grid-template-columns: minmax(250px, .7fr) 1fr; gap: 30px; align-items: center; border-color: #4d593b; }
.boundary-card h2, .boundary-card p { margin-bottom: 0; }
.boundary-card > p { color: var(--muted); font-size: 13px; line-height: 1.65; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 50; max-width: 380px; padding: 13px 16px; border: 1px solid #47735c; border-radius: 10px; background: #183426; box-shadow: var(--shadow); font-size: 13px; }
.toast.error { border-color: #714242; background: #342020; }

@media (max-width: 1000px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .settings-grid, .two-column { grid-template-columns: 1fr; }
  .draft-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app-shell { display: block; padding-bottom: 72px; }
  .sidebar { position: fixed; inset: auto 0 0; z-index: 30; width: 100%; height: 66px; padding: 7px; display: block; border: 1px solid var(--line); border-width: 1px 0 0; }
  .brand-row, .sidebar-foot { display: none; }
  nav { height: 100%; display: grid; grid-template-columns: repeat(5, 1fr); }
  .nav-item { padding: 5px 2px; display: grid; place-items: center; gap: 0; font-size: 9px; text-align: center; }
  .nav-item > span { height: 20px; font-size: 17px; }
  .count { position: absolute; margin: -20px 0 0 19px; }
  .topbar { height: 82px; padding: 16px 18px; }
  .topbar .eyebrow, .save-indicator { display: none; }
  .status-button { min-width: 102px; }
  .panel { padding: 20px 14px 35px; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .metric-card { min-height: 125px; padding: 16px; }
  .metric-card strong { margin: 14px 0 10px; font-size: 31px; }
  .chat-layout { display: block; min-height: 640px; }
  .chat-list-pane { border-right: 0; }
  .chat-list-pane.detail-open { display: none; }
  .chat-detail { min-height: 640px; }
  .message { max-width: 88%; }
  .boundary-card { grid-template-columns: 1fr; gap: 12px; }
  .button-row { flex-wrap: wrap; }
  .login-card { padding: 30px 24px; }
}

