:root {
  color-scheme: light;
  --navy-950: #0b1120;
  --navy-900: #101827;
  --navy-850: #152034;
  --navy-800: #1b2940;
  --ink: #172033;
  --muted: #667085;
  --muted-2: #98a2b3;
  --surface: #ffffff;
  --surface-soft: #f7f8fc;
  --surface-tint: #f0edff;
  --line: #e5e8ef;
  --line-strong: #d4d9e3;
  --purple: #7257e8;
  --purple-dark: #5b41ce;
  --mint: #3bd1ae;
  --green: #16856a;
  --amber: #b86200;
  --red: #c43552;
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-md: 0 14px 36px rgba(16, 24, 40, .12);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --sidebar: 252px;
  --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--surface-soft); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.55; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
input, textarea, select { width: 100%; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: #fff; color: var(--ink); padding: 11px 13px; outline: none; transition: border-color .18s, box-shadow .18s; }
input:focus, textarea:focus, select:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(114, 87, 232, .13); }
textarea { resize: vertical; }
label { display: grid; gap: 7px; color: #344054; font-size: 13px; font-weight: 650; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(28px, 4vw, 42px); line-height: 1.12; letter-spacing: -.035em; }
h2 { margin-bottom: 6px; font-size: 20px; line-height: 1.25; letter-spacing: -.018em; }
h3 { margin-bottom: 4px; font-size: 15px; }
p { margin-bottom: 12px; }
a { color: var(--purple-dark); }
.is-hidden { display: none !important; }
.muted { color: var(--muted); }
.small-note { color: var(--muted); font-size: 12px; }
.eyebrow { color: var(--purple-dark); font-size: 11px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.stack { display: grid; gap: 16px; }

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 28px; background: radial-gradient(circle at 12% 10%, rgba(114,87,232,.25), transparent 31%), radial-gradient(circle at 88% 84%, rgba(59,209,174,.16), transparent 30%), var(--navy-950); }
.login-card { width: min(100%, 440px); padding: 34px; border: 1px solid rgba(255,255,255,.13); border-radius: 28px; background: rgba(255,255,255,.97); box-shadow: 0 30px 80px rgba(0,0,0,.32); }
.brand-lockup { display: flex; align-items: center; gap: 11px; color: #fff; }
.brand-lockup img { flex: none; border-radius: 12px; }
.brand-lockup div { display: grid; line-height: 1.2; }
.brand-lockup strong { font-size: 16px; }
.brand-lockup span { margin-top: 4px; color: #9aa8bf; font-size: 11px; }
.brand-lockup--login { color: var(--ink); }
.brand-lockup--login span { color: var(--muted); }
.login-copy { margin: 38px 0 24px; }
.login-copy h1 { margin-top: 7px; font-size: 34px; }
.login-copy p { color: var(--muted); }
.form-error { min-height: 22px; margin: -5px 0 0; color: var(--red); font-size: 13px; }
.privacy-note { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 22px; color: var(--muted); font-size: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 4px rgba(59,209,174,.13); }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; z-index: 30; inset: 0 auto 0 0; display: flex; flex-direction: column; width: var(--sidebar); padding: 22px 16px 14px; overflow-y: auto; background: var(--navy-900); color: #fff; }
.sidebar .brand-lockup { padding: 0 6px; }
.sidebar > .button { margin-top: 25px; }
.sidebar-spacer { flex: 1; min-height: 22px; }
.primary-nav { display: grid; gap: 5px; margin-top: 20px; }
.nav-item { display: flex; align-items: center; gap: 11px; width: 100%; padding: 10px 12px; border: 0; border-radius: 10px; background: transparent; color: #aebbd0; text-align: left; transition: color .18s, background .18s, transform .18s; }
.nav-item span { display: grid; place-items: center; width: 21px; color: #8392ac; font-size: 16px; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.is-active { background: rgba(126,102,244,.18); color: #fff; }
.nav-item.is-active span { color: #a997ff; }
.server-card { display: grid; gap: 5px; margin: 0 2px 11px; padding: 12px; border: 1px solid rgba(255,255,255,.08); border-radius: 12px; background: rgba(255,255,255,.035); }
.server-card div { display: flex; align-items: center; gap: 8px; }
.server-card strong { font-size: 12px; }
.server-card > span { padding-left: 17px; color: #91a0b7; font-size: 11px; }
.health-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #ef9b45; box-shadow: 0 0 0 3px rgba(239,155,69,.12); }
.health-dot.is-ready { background: var(--mint); box-shadow: 0 0 0 3px rgba(59,209,174,.14); }
.health-dot.is-error { background: #f06179; box-shadow: 0 0 0 3px rgba(240,97,121,.14); }
.user-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 9px; padding: 12px 6px 0; border-top: 1px solid rgba(255,255,255,.08); }
.user-card > div:nth-child(2) { display: grid; min-width: 0; }
.user-card strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.user-card span { color: #8f9db3; font-size: 10px; text-transform: capitalize; }
.avatar { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 10px; background: linear-gradient(135deg, var(--purple), #4f9be8); font-size: 12px; font-weight: 800; }
.icon-button { display: grid; place-items: center; min-width: 34px; height: 34px; padding: 0; border: 0; border-radius: 9px; background: transparent; color: inherit; font-size: 20px; }
.icon-button:hover { background: rgba(128,128,128,.12); }
.sidebar-scrim, .mobile-header { display: none; }

.main-panel { min-height: 100vh; margin-left: var(--sidebar); }
.view { display: none; min-height: 100vh; padding: 42px clamp(24px, 4vw, 64px); }
.view.is-active { display: block; }
.view--chat { padding: 0; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; max-width: 1400px; margin: 0 auto 30px; }
.page-header h1 { margin-top: 5px; }
.page-header p { max-width: 700px; margin-bottom: 0; color: var(--muted); }
.two-column { display: grid; grid-template-columns: minmax(300px, .75fr) minmax(440px, 1.4fr); gap: 22px; max-width: 1400px; margin: 0 auto; }
.card { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 17px; }
.card-heading p { margin-bottom: 0; }
.feature-icon { display: grid; place-items: center; width: 42px; height: 42px; margin-bottom: 18px; border-radius: 13px; background: var(--surface-tint); color: var(--purple-dark); font-size: 20px; font-weight: 800; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 9px 15px; border: 1px solid transparent; border-radius: 10px; font-weight: 720; transition: transform .15s, box-shadow .15s, background .15s; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button--full { width: 100%; }
.button--primary { background: var(--purple); color: #fff; box-shadow: 0 6px 14px rgba(114,87,232,.18); }
.button--primary:hover:not(:disabled) { background: var(--purple-dark); }
.button--accent { background: linear-gradient(135deg, #7b62ed, #6350cf); color: #fff; }
.button--soft { border-color: var(--line); background: #fff; color: #344054; }
.button--danger { border-color: #facbd3; background: #fff6f7; color: var(--red); }
.quiet-button { padding: 4px; border: 0; background: none; color: var(--purple-dark); font-size: 11px; font-weight: 700; }
.round-button { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border: 0; border-radius: 50%; background: #eef0f6; color: #586174; font-size: 14px; }
.round-button--send { background: var(--navy-900); color: #fff; font-size: 21px; }
.round-button.is-recording { background: #ffe4e9; color: var(--red); animation: pulse 1.5s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(196,53,82,.1); } }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 5px 9px; border-radius: 999px; background: #eef0f5; color: #536075; font-size: 10px; font-weight: 800; letter-spacing: .025em; }
.badge--online { background: #e8f8f3; color: var(--green); }

.chat-layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); height: 100vh; }
.conversation-panel { overflow-y: auto; border-right: 1px solid var(--line); background: #f3f5f9; }
.panel-heading { display: flex; justify-content: space-between; padding: 22px 16px 12px; color: #4b5669; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.conversation-list { display: grid; gap: 4px; padding: 0 8px 22px; }
.conversation-item { position: relative; width: 100%; padding: 11px 34px 11px 11px; overflow: hidden; border: 1px solid transparent; border-radius: 10px; background: transparent; color: #495468; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.conversation-item:hover { background: #fff; }
.conversation-item.is-active { border-color: #ddd7ff; background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }
.conversation-delete { position: absolute; z-index: 2; right: 4px; width: 26px; height: 26px; margin-top: -36px; border: 0; border-radius: 8px; background: transparent; color: var(--muted-2); }
.conversation-delete:hover { background: #feeef1; color: var(--red); }
.chat-panel { position: relative; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto auto; min-width: 0; height: 100vh; background: #fff; }
.chat-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 78px; padding: 14px clamp(18px, 4vw, 42px); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.95); }
.chat-header h2 { margin: 3px 0 0; }
.chat-header-actions { display: flex; align-items: center; gap: 10px; }
.agent-picker { position: absolute; z-index: 10; top: 70px; right: 26px; display: grid; width: min(440px, calc(100% - 40px)); max-height: 70vh; padding: 8px; overflow-y: auto; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: var(--shadow-md); }
.agent-option { display: grid; grid-template-columns: auto 1fr; gap: 11px; padding: 11px; border: 0; border-radius: 11px; background: transparent; text-align: left; }
.agent-option:hover, .agent-option.is-active { background: var(--surface-soft); }
.agent-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; color: #fff; font-size: 11px; font-weight: 850; }
.agent-option span:last-child { display: grid; color: var(--ink); font-weight: 750; }
.agent-option small { color: var(--muted); font-size: 11px; font-weight: 450; }
.message-list { overflow-y: auto; padding: 32px max(22px, calc((100% - 860px) / 2)); scroll-behavior: smooth; }
.empty-chat { display: grid; place-items: center; max-width: 760px; margin: min(10vh, 80px) auto 0; text-align: center; }
.empty-chat h1 { margin-top: 10px; font-size: clamp(30px, 4vw, 46px); }
.empty-chat > p { max-width: 570px; color: var(--muted); }
.hero-orb { display: grid; place-items: center; width: 66px; height: 66px; margin-bottom: 22px; border: 1px solid #dfd9ff; border-radius: 23px; background: linear-gradient(145deg, #f7f4ff, #e7fff8); color: var(--purple); box-shadow: 0 15px 35px rgba(114,87,232,.12); font-size: 28px; }
.starter-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; width: 100%; margin-top: 24px; }
.starter { padding: 13px 15px; border: 1px solid var(--line); border-radius: 13px; background: #fff; color: #4b5669; text-align: left; }
.starter:hover { border-color: #cfc7f9; background: #faf9ff; }
.message { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; max-width: 860px; margin: 0 auto 24px; }
.message--user { grid-template-columns: minmax(0, 1fr) 34px; }
.message-avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: var(--navy-900); color: #fff; font-size: 10px; font-weight: 850; }
.message--user .message-avatar { grid-column: 2; background: #ece8ff; color: var(--purple-dark); }
.message-body { min-width: 0; }
.message--user .message-body { grid-column: 1; grid-row: 1; justify-self: end; max-width: 82%; }
.message-content { padding: 12px 15px; border: 1px solid var(--line); border-radius: 4px 15px 15px; background: #fff; color: #273247; white-space: pre-wrap; overflow-wrap: anywhere; }
.message--user .message-content { border-color: #e6e1ff; border-radius: 15px 4px 15px 15px; background: #f3f0ff; }
.message-meta { margin-top: 5px; color: var(--muted-2); font-size: 10px; }
.message-citations { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.citation { display: inline-flex; max-width: 260px; padding: 4px 8px; overflow: hidden; border-radius: 7px; background: #eef7f5; color: #26735f; font-size: 10px; text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
.typing-indicator { display: flex; align-items: center; gap: 5px; padding: 7px max(22px, calc((100% - 860px) / 2)); color: var(--muted); font-size: 11px; }
.typing-indicator i { width: 6px; height: 6px; border-radius: 50%; background: var(--purple); animation: bounce 1.1s infinite; }
.typing-indicator i:nth-child(2) { animation-delay: .12s; }.typing-indicator i:nth-child(3) { animation-delay: .24s; }
.typing-indicator span { margin-left: 5px; }
@keyframes bounce { 0%, 65%, 100% { transform: translateY(0); opacity: .45; } 32% { transform: translateY(-4px); opacity: 1; } }
.composer { position: relative; width: min(900px, calc(100% - 36px)); margin: 0 auto 18px; padding: 9px 9px 7px 14px; border: 1px solid var(--line-strong); border-radius: 17px; background: #fff; box-shadow: 0 8px 22px rgba(16,24,40,.08); }
.composer:focus-within { border-color: #b6aaf2; box-shadow: 0 8px 25px rgba(114,87,232,.1), 0 0 0 3px rgba(114,87,232,.08); }
.composer textarea { min-height: 50px; max-height: 190px; padding: 7px 95px 4px 2px; border: 0; box-shadow: none; resize: none; }
.composer textarea:focus { box-shadow: none; }
.composer-actions { position: absolute; top: 10px; right: 9px; display: flex; gap: 6px; }
.composer-meta { display: flex; justify-content: space-between; gap: 12px; padding: 4px 2px 0; color: var(--muted-2); font-size: 9px; }
.mini-toggle { display: flex; align-items: center; gap: 6px; font-size: 9px; font-weight: 550; }
.mini-toggle input { width: auto; }

.drop-zone { display: grid; place-items: center; min-height: 150px; margin: 18px 0; border: 1px dashed #b8bfd0; border-radius: 14px; background: #fafbfe; color: var(--ink); text-align: center; cursor: pointer; }
.drop-zone:hover, .drop-zone.is-dragging { border-color: var(--purple); background: #faf8ff; }
.drop-zone span { color: var(--muted); font-size: 12px; font-weight: 450; }
.field-row { margin-bottom: 16px; }
.inline-status { min-height: 22px; margin-top: 10px; color: var(--muted); font-size: 12px; }
.inline-status.is-error { color: var(--red); }
.inline-status.is-success { color: var(--green); }
.data-list { display: grid; gap: 8px; }
.data-list.compact { margin-top: 15px; }
.data-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 11px; padding: 11px; border: 1px solid var(--line); border-radius: 11px; background: #fff; }
.data-row-icon { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 10px; background: #f1effc; color: var(--purple-dark); font-size: 11px; font-weight: 800; }
.data-row-main { display: grid; min-width: 0; }
.data-row-main strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.data-row-main span { color: var(--muted); font-size: 10px; }
.row-actions { display: flex; gap: 5px; }
.row-button { padding: 6px 8px; border: 0; border-radius: 7px; background: #f2f4f7; color: #576174; font-size: 10px; font-weight: 700; }
.row-button:hover { background: #e9ecf2; }
.row-button--danger:hover { background: #feecef; color: var(--red); }
.memory-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 15px; max-width: 1400px; margin: 0 auto; }
.memory-card { position: relative; min-height: 170px; padding: 20px; border: 1px solid var(--line); border-radius: 15px; background: #fff; box-shadow: var(--shadow-sm); }
.memory-card p { display: -webkit-box; overflow: hidden; color: #4d586b; font-size: 13px; -webkit-box-orient: vertical; -webkit-line-clamp: 5; }
.memory-card footer { display: flex; justify-content: space-between; margin-top: 14px; color: var(--muted-2); font-size: 9px; }
.memory-card .row-button { position: absolute; top: 13px; right: 13px; }
.consent-box { grid-template-columns: auto 1fr; align-items: flex-start; gap: 10px; margin: 17px 0; padding: 13px; border-radius: 11px; background: #fff9ed; color: #734b17; font-size: 12px; font-weight: 550; }
.consent-box input { width: auto; margin-top: 3px; }
.call-guide ol { display: grid; gap: 12px; padding-left: 22px; color: #4e596b; }
.call-guide li::marker { color: var(--purple); font-weight: 800; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; max-width: 1400px; margin: 0 auto; }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; max-width: 1400px; margin: 0 auto 22px; }
.stat-card { padding: 17px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.stat-card strong { display: block; margin-top: 5px; font-size: 23px; letter-spacing: -.03em; }
.stat-card span { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.admin-columns { grid-template-columns: 1fr 1fr; }
.audit-list { max-height: 570px; overflow-y: auto; }

.dialog { width: min(640px, calc(100% - 28px)); max-height: 90vh; padding: 0; overflow: auto; border: 0; border-radius: 19px; background: transparent; box-shadow: var(--shadow-md); }
.dialog::backdrop { background: rgba(7,12,24,.58); backdrop-filter: blur(3px); }
.dialog-card { display: grid; gap: 17px; padding: 24px; background: #fff; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
.dialog-heading h2 { margin-top: 4px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toast-region { position: fixed; z-index: 100; right: 18px; bottom: 18px; display: grid; gap: 8px; width: min(360px, calc(100% - 36px)); }
.toast { padding: 12px 14px; border: 1px solid var(--line); border-radius: 11px; background: #fff; color: #344054; box-shadow: var(--shadow-md); font-size: 12px; animation: toast-in .2s ease-out; }
.toast.is-error { border-color: #f3c0c9; color: #9d2940; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
.empty-state { padding: 28px 15px; border: 1px dashed var(--line-strong); border-radius: 12px; color: var(--muted); text-align: center; }

@media (max-width: 1050px) {
  .two-column, .admin-columns { grid-template-columns: 1fr; }
  .conversation-panel { width: 190px; }
  .chat-layout { grid-template-columns: 190px minmax(0,1fr); }
}

@media (max-width: 760px) {
  .mobile-header { position: fixed; z-index: 25; inset: 0 0 auto; display: flex; align-items: center; justify-content: space-between; height: 58px; padding: env(safe-area-inset-top) 14px 0; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); }
  .mobile-brand { display: flex; align-items: center; gap: 8px; font-size: 13px; }
  .sidebar { transform: translateX(-105%); width: min(290px, 86vw); padding-top: calc(20px + env(safe-area-inset-top)); box-shadow: var(--shadow-md); transition: transform .24s ease; }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-scrim { position: fixed; z-index: 29; inset: 0; display: none; width: 100%; border: 0; background: rgba(5,10,20,.46); }
  .sidebar-scrim.is-visible { display: block; }
  .main-panel { margin-left: 0; padding-top: 58px; }
  .view { min-height: calc(100vh - 58px); padding: 25px 16px calc(28px + env(safe-area-inset-bottom)); }
  .view--chat { padding: 0; }
  .chat-layout { display: block; height: calc(100vh - 58px); }
  .conversation-panel { display: none; }
  .chat-panel { height: calc(100vh - 58px); }
  .chat-header { min-height: 67px; padding: 10px 14px; }
  .chat-header .eyebrow { display: none; }
  .chat-header h2 { font-size: 16px; }
  .chat-header .badge { display: none; }
  .chat-header .button { min-height: 35px; padding: 7px 10px; font-size: 11px; }
  .agent-picker { top: 61px; right: 10px; width: calc(100% - 20px); }
  .message-list { padding: 20px 13px; }
  .message { gap: 8px; margin-bottom: 18px; }
  .message-avatar { width: 30px; height: 30px; }
  .message-content { padding: 10px 12px; font-size: 14px; }
  .message--user .message-body { max-width: 90%; }
  .empty-chat { margin-top: 4vh; }
  .empty-chat > .eyebrow { font-size: 9px; }
  .empty-chat h1 { font-size: 30px; }
  .starter-grid { grid-template-columns: 1fr; }
  .composer { width: calc(100% - 20px); margin-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .composer-meta > span { display: none; }
  .composer-meta { justify-content: flex-end; }
  .typing-indicator { padding: 6px 16px; }
  .page-header { align-items: flex-start; flex-direction: column; margin-bottom: 22px; }
  .page-header h1 { font-size: 32px; }
  .card { padding: 19px; }
  .dialog-card { padding: 19px; }
  .dialog-actions { flex-wrap: wrap; }
  .dialog-actions .button { flex: 1; }
  .login-screen { padding: 15px; }
  .login-card { padding: 25px 21px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
