:root {
  --ink: #18202a;
  --muted: #68717d;
  --line: #dfe3e8;
  --soft: #f5f6f7;
  --paper: #ffffff;
  --night: #151b22;
  --accent: #304c67;
  --accent-strong: #20394f;
  --success: #1f6b4f;
  --warning: #8b5a17;
  --danger: #8b3030;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(17, 25, 34, .08);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; line-height: 1.5; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(2rem, 5vw, 4.35rem); line-height: 1.02; letter-spacing: -.055em; }
h2 { letter-spacing: -.025em; }

.wordmark { display: flex; align-items: center; gap: 10px; font-size: .73rem; font-weight: 800; letter-spacing: .13em; }
.mark { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid currentColor; border-radius: 50%; letter-spacing: -.05em; }
.eyebrow { margin-bottom: 12px; color: var(--accent); font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.muted { color: var(--muted); }
.fineprint { margin: 0; color: var(--muted); font-size: .75rem; }
.hidden { display: none !important; }

.button { border: 1px solid transparent; border-radius: 9px; padding: 11px 17px; cursor: pointer; font-weight: 750; text-decoration: none; transition: transform .15s, background .15s, border-color .15s; }
.button:hover { transform: translateY(-1px); }
.button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, .suggestion:focus-visible, .voice-button:focus-visible, .send-button:focus-visible, .nav-link:focus-visible { outline: 3px solid rgba(48,76,103,.22); outline-offset: 2px; }
.button.primary { color: white; background: var(--accent); }
.button.primary:hover { background: var(--accent-strong); }
.button.secondary { color: var(--ink); background: #eef1f4; border-color: #d5dbe1; }
.button.ghost { color: inherit; background: transparent; border-color: var(--line); }
.button.small { padding: 7px 11px; font-size: .83rem; }
.button.full { width: 100%; }
.button:disabled { opacity: .55; cursor: wait; transform: none; }

.alert { border: 1px solid #c8d5df; border-radius: 10px; padding: 12px 14px; color: var(--accent-strong); background: #f1f6f9; font-size: .88rem; }
.alert.error { border-color: #e0b7b7; color: var(--danger); background: #fff7f7; }
.alert.success { border-color: #afd5c6; color: var(--success); background: #f3fbf7; }

/* Login */
.login-body { min-height: 100vh; background: var(--soft); }
.login-shell { display: grid; grid-template-columns: 1.18fr .82fr; min-height: 100vh; }
.login-copy { display: flex; flex-direction: column; justify-content: center; padding: clamp(40px, 8vw, 130px); color: #f7f8fa; background: var(--night); overflow: hidden; position: relative; }
.login-copy::after { content: ""; position: absolute; width: 55vw; aspect-ratio: 1; right: -27vw; bottom: -33vw; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; box-shadow: 0 0 0 70px rgba(255,255,255,.025), 0 0 0 140px rgba(255,255,255,.02); }
.login-copy .wordmark { position: absolute; top: 38px; left: clamp(40px, 8vw, 130px); }
.login-copy .eyebrow { color: #aebbc6; }
.login-copy h1 { max-width: 720px; margin-bottom: 24px; }
.login-copy > p:not(.eyebrow) { max-width: 570px; color: #bdc4cc; font-size: 1.04rem; }
.trust-list { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 26px; }
.trust-list span { border: 1px solid rgba(255,255,255,.15); border-radius: 999px; padding: 7px 11px; color: #d9dde2; font-size: .76rem; }
.login-card { align-self: center; width: min(430px, calc(100% - 48px)); margin: 40px auto; padding: 42px; background: var(--paper); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.login-card h2 { margin-bottom: 6px; font-size: 1.7rem; }
.login-card .stack { margin: 28px 0 20px; }

/* Forms */
.stack { display: flex; flex-direction: column; gap: 17px; }
.stack.compact { gap: 13px; }
label { display: grid; gap: 7px; color: #3e4751; font-size: .78rem; font-weight: 750; }
input, textarea, select { width: 100%; border: 1px solid #cfd5db; border-radius: 9px; padding: 11px 12px; color: var(--ink); background: white; font-weight: 500; }
textarea { resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr .8fr; gap: 12px; }

/* Chat */
.app-shell { display: grid; grid-template-columns: 272px 1fr; min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 272px; display: flex; flex-direction: column; padding: 25px 19px 18px; color: #e8ebee; background: var(--night); }
.sidebar .wordmark { padding: 0 7px 25px; border-bottom: 1px solid rgba(255,255,255,.09); }
.assistant-name { display: flex; align-items: center; gap: 11px; margin: 24px 6px 16px; }
.assistant-name strong, .profile strong { display: block; font-size: .9rem; }
.assistant-name small, .profile small { display: block; color: #96a0aa; font-size: .7rem; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #7bb498; box-shadow: 0 0 0 4px rgba(123,180,152,.12); }
.sidebar nav { display: grid; gap: 5px; }
.nav-link { border-radius: 8px; padding: 10px 12px; color: #b9c0c7; text-decoration: none; font-size: .84rem; font-weight: 650; }
.nav-link:hover, .nav-link.active { color: white; background: rgba(255,255,255,.075); }
.sidebar-note { margin-top: auto; border: 1px solid rgba(255,255,255,.1); border-radius: 11px; padding: 14px; background: rgba(255,255,255,.035); }
.sidebar-note strong { font-size: .8rem; }
.sidebar-note p { margin: 6px 0 0; color: #9fa8b0; font-size: .71rem; line-height: 1.5; }
.profile { display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 10px; margin-top: 16px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.09); }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: var(--night); background: #d8dde1; font-size: .82rem; font-weight: 850; }
.icon-button { border: 0; padding: 8px; color: #aeb5bc; background: transparent; cursor: pointer; }
.chat-main { grid-column: 2; position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 100vh; padding-bottom: 124px; }
.mobile-header { display: none; }
.welcome { width: min(860px, calc(100% - 52px)); margin: auto; padding: 70px 0 25px; }
.welcome h1 { margin-bottom: 22px; }
.lead { max-width: 680px; color: var(--muted); font-size: 1.02rem; }
.suggestions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 11px; margin-top: 35px; }
.suggestion { display: grid; gap: 5px; border: 1px solid var(--line); border-radius: 11px; padding: 15px 16px; text-align: left; color: var(--ink); background: white; cursor: pointer; font-weight: 720; transition: border-color .15s, transform .15s, box-shadow .15s; }
.suggestion:hover { transform: translateY(-2px); border-color: #b5bec7; box-shadow: 0 8px 24px rgba(28,39,51,.06); }
.suggestion span { color: var(--muted); font-size: .71rem; font-weight: 500; }
.conversation { display: none; width: min(860px, calc(100% - 52px)); margin: 0 auto; padding: 45px 0 20px; }
.conversation.active { display: block; }
.message { margin-bottom: 30px; }
.message.user { display: flex; justify-content: flex-end; }
.user-bubble { max-width: 78%; border-radius: 16px 16px 3px 16px; padding: 12px 16px; color: white; background: var(--accent); font-size: .91rem; }
.answer-card { border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: white; box-shadow: 0 12px 36px rgba(20,30,40,.055); }
.answer-head { padding: 21px 24px 18px; border-bottom: 1px solid var(--line); }
.answer-head h2 { margin-bottom: 7px; font-size: 1.3rem; }
.answer-head p { margin: 0; color: var(--muted); font-size: .88rem; }
.meta-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.confidence { border-radius: 99px; padding: 4px 8px; font-size: .63rem; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.confidence.high { color: var(--success); background: #e9f5ef; }
.confidence.medium { color: var(--warning); background: #fbf2e3; }
.confidence.low { color: var(--danger); background: #faeaea; }
.mode-label { color: var(--muted); font-size: .68rem; }
.steps { padding: 8px 24px; }
.step { display: grid; grid-template-columns: 30px 1fr; gap: 12px; padding: 17px 0; border-bottom: 1px solid #ebedef; }
.step:last-child { border-bottom: 0; }
.step-number { display: grid; place-items: center; width: 27px; height: 27px; border: 1px solid #bac3cb; border-radius: 50%; color: var(--accent); font-size: .72rem; font-weight: 850; }
.step h3 { margin-bottom: 3px; font-size: .91rem; }
.step p { margin: 0; color: #454e58; font-size: .87rem; white-space: pre-line; }
.step-images { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; margin-top: 13px; }
.step-images figure { margin: 0; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.step-images img { display: block; width: 100%; height: auto; }
.step-images figcaption { padding: 7px 9px; color: var(--muted); font-size: .68rem; }
.warnings { margin: 0 24px 18px; border-left: 3px solid #c58b38; padding: 11px 13px; color: #6f4b18; background: #fff9ef; font-size: .8rem; }
.warnings strong { display: block; margin-bottom: 4px; }
.warnings ul { margin: 0; padding-left: 17px; }
.sources { padding: 13px 24px; background: var(--soft); }
.sources strong { display: block; margin-bottom: 6px; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; }
.sources a { display: block; padding: 3px 0; font-size: .77rem; text-decoration: none; }
.sources a:hover { text-decoration: underline; }
.empty-answer { padding: 20px 24px; color: var(--muted); }
.typing { display: inline-flex; gap: 5px; padding: 14px 17px; border: 1px solid var(--line); border-radius: 14px 14px 14px 3px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: #8d969f; animation: blink 1s infinite alternate; }
.typing i:nth-child(2) { animation-delay: .2s; }.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { to { opacity: .2; transform: translateY(-2px); } }
.composer-wrap { position: fixed; z-index: 5; right: 0; bottom: 0; left: 272px; padding: 17px 24px 14px; background: linear-gradient(to top, white 78%, rgba(255,255,255,0)); }
.composer { display: flex; align-items: flex-end; gap: 12px; width: min(860px, 100%); margin: 0 auto; border: 1px solid #bdc5cc; border-radius: 15px; padding: 9px 9px 9px 15px; background: white; box-shadow: 0 12px 36px rgba(20,30,40,.11); }
.composer textarea { flex: 1 1 auto; min-width: 0; min-height: 44px; max-height: 150px; border: 0; padding: 11px 2px; outline: 0; resize: none; font-size: .91rem; }
.voice-button { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; gap: 7px; min-width: 84px; height: 42px; border: 1px solid #c9d2da; border-radius: 10px; padding: 0 12px; color: var(--accent); background: #f5f7f9; cursor: pointer; font-size: .78rem; font-weight: 800; transition: color .15s, background .15s, border-color .15s, transform .15s; }
.voice-button:hover { border-color: #aeb9c3; background: #edf1f4; transform: translateY(-1px); }
.voice-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.voice-button.recording { color: white; border-color: #a63333; background: #b43b3b; animation: voice-pulse 1.15s infinite; }
.voice-button.processing { color: var(--warning); border-color: #dec796; background: #fff8e9; }
.voice-button:disabled { opacity: .58; cursor: wait; transform: none; animation: none; }
@keyframes voice-pulse { 50% { box-shadow: 0 0 0 7px rgba(180,59,59,.14); } }
.send-button { flex: 0 0 auto; display: grid; place-items: center; width: 42px; height: 42px; border: 0; border-radius: 10px; color: white; background: var(--accent); cursor: pointer; font-size: 1.15rem; font-weight: 900; }
.send-button:disabled { opacity: .5; cursor: wait; }
.voice-status { width: min(860px, 100%); margin: 7px auto 0; color: var(--accent); text-align: center; font-size: .7rem; font-weight: 650; }
.voice-status.recording { color: #9a3131; }
.voice-status.processing { color: var(--warning); }
.voice-status.ready { color: var(--success); }
.voice-status.error { color: var(--danger); }
.composer-note { margin: 7px auto 0; color: #838b94; text-align: center; font-size: .67rem; }

/* Admin */
.admin-body { min-height: 100vh; background: var(--soft); }
.topbar { display: flex; align-items: center; justify-content: space-between; height: 70px; padding: 0 max(24px, calc((100vw - 1200px)/2)); color: white; background: var(--night); }
.topbar .button { color: white; border-color: rgba(255,255,255,.2); }
.admin-actions { display: flex; gap: 8px; }
.admin-main { width: min(1200px, calc(100% - 40px)); margin: 0 auto; padding: 48px 0 75px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 30px; }
.page-heading h1 { margin-bottom: 9px; font-size: clamp(2rem, 5vw, 3.25rem); }
.page-heading p { margin-bottom: 0; }
.stats-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 11px; margin: 22px 0; }
.stat, .skeleton-card { min-height: 105px; border: 1px solid var(--line); border-radius: 12px; padding: 17px; background: white; }
.skeleton-card { background: linear-gradient(90deg,#fff,#f1f3f5,#fff); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.stat strong { display: block; margin: 4px 0; font-size: 1.65rem; letter-spacing: -.04em; }
.stat span { color: var(--muted); font-size: .7rem; font-weight: 750; text-transform: uppercase; letter-spacing: .07em; }
.stat small { color: var(--muted); font-size: .68rem; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.panel { border: 1px solid var(--line); border-radius: 14px; padding: 23px; background: white; box-shadow: 0 8px 24px rgba(22,31,41,.035); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 20px; }
.panel-heading .eyebrow { margin-bottom: 5px; }
.panel-heading h2 { margin: 0; font-size: 1.2rem; }
.access-note { display: grid; gap: 16px; align-items: start; }
.access-note p { margin: 0; color: var(--muted); }
.access-note .button { justify-self: start; }
.full-panel { margin-top: 18px; padding: 0; overflow: hidden; }
.full-panel .panel-heading { padding: 22px 23px 0; }
.badge { border-radius: 99px; padding: 5px 9px; color: var(--warning); background: #fbf1df; font-size: .66rem; font-weight: 800; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .77rem; }
th { padding: 10px 14px; color: var(--muted); background: var(--soft); text-align: left; font-size: .65rem; letter-spacing: .06em; text-transform: uppercase; }
td { max-width: 320px; border-top: 1px solid var(--line); padding: 12px 14px; vertical-align: top; }
td.question-cell { min-width: 230px; }
.empty { color: var(--muted); text-align: center; padding: 28px; }
.status-text.warn { color: var(--warning); font-weight: 750; }
.status-text.ok { color: var(--success); font-weight: 750; }

@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-copy { min-height: 45vh; padding: 95px 28px 45px; }
  .login-copy .wordmark { top: 27px; left: 28px; }
  .login-copy h1 { font-size: clamp(2.4rem, 11vw, 4rem); }
  .login-card { margin: 28px auto; }
  .app-shell { display: block; }
  .sidebar { display: none; }
  .chat-main { min-height: 100vh; padding-bottom: 120px; }
  .mobile-header { display: flex; align-items: center; justify-content: space-between; height: 64px; padding: 0 18px; border-bottom: 1px solid var(--line); }
  .welcome, .conversation { width: min(100% - 32px, 760px); }
  .welcome { padding-top: 60px; }
  .welcome h1 { font-size: clamp(2.45rem, 10vw, 4rem); }
  .composer-wrap { left: 0; padding-inline: 14px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 620px) {
  .login-copy { min-height: 390px; }
  .login-card { width: calc(100% - 28px); padding: 28px 22px; }
  .suggestions { grid-template-columns: 1fr; }
  .welcome { padding-top: 38px; }
  .user-bubble { max-width: 92%; }
  .answer-head, .steps { padding-inline: 17px; }
  .warnings { margin-inline: 17px; }
  .sources { padding-inline: 17px; }
  .step-images { grid-template-columns: 1fr; }
  .admin-main { width: min(100% - 24px, 1200px); padding-top: 30px; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .admin-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .composer { gap: 8px; padding-left: 12px; }
  .voice-button { min-width: 76px; padding-inline: 10px; }
}
