:root {
    --bg: #070b12;
    --bg-soft: #0b111b;
    --surface: rgba(16, 24, 38, .86);
    --surface-solid: #101826;
    --surface-2: #151f30;
    --surface-3: #1b2739;
    --border: rgba(157, 178, 211, .14);
    --border-strong: rgba(98, 224, 184, .28);
    --text: #f3f7fb;
    --muted: #8f9db1;
    --muted-2: #647087;
    --primary: #54e4b1;
    --primary-strong: #21c992;
    --primary-soft: rgba(84, 228, 177, .12);
    --blue: #6ea8ff;
    --danger: #ff6b7d;
    --warning: #ffcc66;
    --success: #54e4b1;
    --shadow: 0 26px 90px rgba(0, 0, 0, .36);
    --radius: 18px;
    --radius-sm: 11px;
    --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="light"] {
    --bg: #eef2f7;
    --bg-soft: #f7f9fc;
    --surface: rgba(255, 255, 255, .9);
    --surface-solid: #ffffff;
    --surface-2: #f2f5f9;
    --surface-3: #e8edf4;
    --border: rgba(36, 50, 73, .12);
    --border-strong: rgba(14, 157, 113, .3);
    --text: #101828;
    --muted: #59657a;
    --muted-2: #7f8a9c;
    --primary: #0fa978;
    --primary-strong: #078860;
    --primary-soft: rgba(15, 169, 120, .1);
    --shadow: 0 26px 70px rgba(40, 54, 78, .13);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); }
body { font-size: 14px; line-height: 1.5; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(30px, 4vw, 48px); line-height: 1.08; letter-spacing: -.04em; margin-bottom: 12px; }
h2 { font-size: 20px; letter-spacing: -.02em; }
.muted { color: var(--muted); }
.eyebrow { display: block; color: var(--primary); font-weight: 800; font-size: 10px; letter-spacing: .18em; margin-bottom: 8px; }
.hidden { display: none !important; }
.mobile-only { display: none !important; }
.full-width { width: 100%; }
.full { grid-column: 1 / -1; }

.ambient { position: fixed; width: 500px; height: 500px; filter: blur(110px); opacity: .16; border-radius: 50%; pointer-events: none; }
.ambient-one { top: -220px; right: -120px; background: #4f76ff; }
.ambient-two { bottom: -240px; left: -160px; background: #34e2aa; }

.brand-lockup { display: inline-flex; align-items: center; gap: 11px; }
.brand-lockup strong { font-size: 17px; letter-spacing: -.02em; display: block; }
.brand-lockup small { color: var(--muted); display: block; font-size: 11px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; color: #04130e; background: linear-gradient(145deg, #8fffd8, #35c998); border-radius: 12px; font-weight: 900; font-size: 19px; box-shadow: 0 10px 25px rgba(33, 201, 146, .25), inset 0 1px rgba(255,255,255,.6); transform: perspective(70px) rotateY(-7deg); }

.btn { border: 1px solid transparent; border-radius: 10px; min-height: 40px; padding: 0 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 750; cursor: pointer; transition: .2s ease; white-space: nowrap; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-strong)); color: #04130e; box-shadow: 0 9px 25px rgba(33, 201, 146, .18); }
.btn-secondary { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.btn-danger { background: rgba(255, 107, 125, .1); border-color: rgba(255, 107, 125, .25); color: var(--danger); }
.btn-small { min-height: 32px; padding: 0 11px; font-size: 12px; }
.btn.disabled { pointer-events: none; opacity: .4; }
.icon-button { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--border); background: var(--surface-2); border-radius: 10px; cursor: pointer; }

label { display: grid; gap: 7px; font-size: 12px; font-weight: 700; color: var(--muted); }
label small { font-weight: 500; color: var(--muted-2); }
input, select, textarea { width: 100%; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; outline: none; padding: 11px 12px; transition: .2s; }
input:focus, select:focus, textarea:focus { border-color: var(--border-strong); box-shadow: 0 0 0 3px var(--primary-soft); }
input:disabled { opacity: .65; }
textarea { resize: vertical; }
.stack-form { display: grid; gap: 15px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.form-grid.compact { gap: 10px; }
.form-divider { border-top: 1px solid var(--border); text-align: center; margin: 8px 0; height: 10px; }
.form-divider span { background: var(--surface-solid); color: var(--muted); padding: 0 10px; position: relative; top: -11px; font-size: 11px; }

.alert { padding: 12px 14px; border: 1px solid; border-radius: 11px; margin: 15px 0; }
.alert.success { color: var(--success); background: rgba(84, 228, 177, .08); border-color: rgba(84, 228, 177, .2); }
.alert.error { color: var(--danger); background: rgba(255, 107, 125, .08); border-color: rgba(255, 107, 125, .2); }
.alert.warning { color: var(--warning); background: rgba(255, 204, 102, .08); border-color: rgba(255, 204, 102, .2); }

/* Authentication and installation */
.minimal-body { overflow-x: hidden; }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(380px, 560px) 1fr; position: relative; z-index: 1; }
.auth-card { background: var(--surface-solid); border-right: 1px solid var(--border); padding: clamp(34px, 6vw, 80px); display: flex; flex-direction: column; justify-content: center; }
.auth-card .brand-lockup { position: absolute; top: 34px; }
.auth-copy { margin: 70px 0 28px; max-width: 410px; }
.auth-copy h1 { font-size: clamp(36px, 5vw, 56px); }
.auth-card .stack-form { max-width: 420px; }
.auth-switch { color: var(--muted); margin: 22px 0 0; }
.auth-switch a { color: var(--primary); font-weight: 750; }
.auth-art { min-width: 0; overflow: hidden; position: relative; display: flex; flex-direction: column; justify-content: flex-end; padding: 10vw; background: radial-gradient(circle at 70% 22%, rgba(90, 130, 255, .25), transparent 28%), radial-gradient(circle at 35% 60%, rgba(46, 222, 169, .15), transparent 35%), linear-gradient(155deg, #0b1220, #06090f); }
.auth-art h2 { font-size: clamp(38px, 6vw, 78px); line-height: .96; letter-spacing: -.055em; margin-bottom: 25px; max-width: 750px; }
.auth-art p { color: #8e9baf; font-size: 17px; max-width: 510px; }
.orbital { position: absolute; width: min(40vw, 520px); aspect-ratio: 1; top: 5%; right: 5%; display: grid; place-items: center; animation: float 7s ease-in-out infinite; }
.orbital-core { width: 110px; height: 110px; border-radius: 32px; display: grid; place-items: center; background: linear-gradient(145deg, #82ffd4, #1cb886); color: #03120d; font-size: 32px; font-weight: 900; box-shadow: 0 30px 100px rgba(58, 226, 174, .3); transform: perspective(250px) rotateX(12deg) rotateY(-16deg); }
.orbital i { position: absolute; inset: 14%; border: 1px solid rgba(115, 236, 196, .2); border-radius: 50%; transform: rotateX(65deg) rotateZ(10deg); }
.orbital i:nth-child(3) { inset: 25%; transform: rotateX(72deg) rotateZ(70deg); border-color: rgba(110, 168, 255, .3); }
.orbital i:nth-child(4) { inset: 4%; transform: rotateY(72deg) rotateZ(40deg); }
@keyframes float { 50% { transform: translateY(15px) rotate(2deg); } }
.install-shell { display: grid; place-items: center; padding: 50px 20px; }
.install-shell .auth-card { position: relative; width: min(860px, 100%); border: 1px solid var(--border); border-radius: 24px; box-shadow: var(--shadow); }
.install-shell .brand-lockup { position: static; margin-bottom: 35px; }
.requirement-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 25px 0; }
.requirement { display: flex; align-items: center; gap: 8px; padding: 9px 11px; background: var(--surface-2); border-radius: 9px; color: var(--muted); }
.requirement span { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; }
.requirement.passed span { background: var(--primary-soft); color: var(--primary); }
.requirement.failed span { background: rgba(255,107,125,.1); color: var(--danger); }
.centered { align-items: center; text-align: center; gap: 18px; }
.error-code { color: var(--primary); font-size: 70px; font-weight: 900; letter-spacing: -.06em; }

/* User chat */
.announcement { padding: 8px 20px; text-align: center; color: #06150f; font-size: 12px; font-weight: 750; background: linear-gradient(90deg, #51ddb0, #7fb4ff); }
.chat-shell { height: 100vh; display: grid; grid-template-columns: 280px minmax(0, 1fr); overflow: hidden; }
.announcement + .chat-shell { height: calc(100vh - 34px); }
.chat-sidebar, .admin-sidebar { background: linear-gradient(180deg, rgba(14,21,33,.98), rgba(8,13,21,.98)); border-right: 1px solid var(--border); min-width: 0; }
html[data-theme="light"] .chat-sidebar, html[data-theme="light"] .admin-sidebar { background: rgba(249,251,253,.98); }
.chat-sidebar { display: flex; flex-direction: column; padding: 16px 12px; }
.sidebar-brand { margin: 3px 8px 21px; }
.new-chat-button { height: 45px; display: flex; align-items: center; gap: 9px; border: 1px solid var(--border-strong); color: var(--text); background: linear-gradient(135deg, var(--primary-soft), transparent); padding: 0 12px; border-radius: 12px; font-weight: 700; }
.new-chat-button span { font-size: 20px; color: var(--primary); }
.new-chat-button kbd { margin-left: auto; color: var(--muted-2); font-size: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 2px 5px; }
.sidebar-search { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; margin: 12px 0; padding: 0 10px; min-width: 0; }
.sidebar-search input { border: 0; padding: 9px 0; background: transparent; box-shadow: none; }
.conversation-list { flex: 1; overflow: auto; padding: 5px 0; }
.conversation-item { position: relative; border-radius: 10px; margin: 2px 0; }
.conversation-item > a { display: flex; gap: 10px; align-items: center; padding: 10px 36px 10px 10px; min-width: 0; }
.conversation-item:hover, .conversation-item.active { background: var(--surface-2); }
.conversation-item.active:before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 2px; background: var(--primary); border-radius: 2px; }
.conversation-icon { width: 25px; color: var(--primary); font-weight: 800; font-size: 12px; }
.conversation-item a > span:last-child { min-width: 0; }
.conversation-item strong, .conversation-item small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conversation-item strong { font-size: 12px; }
.conversation-item small { color: var(--muted-2); font-size: 10px; }
.conversation-menu { position: absolute; right: 7px; top: 12px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.conversation-actions { position: absolute; z-index: 20; top: 38px; right: 5px; width: 110px; padding: 5px; display: none; background: var(--surface-solid); border: 1px solid var(--border); box-shadow: var(--shadow); border-radius: 9px; }
.conversation-actions.open { display: grid; }
.conversation-actions button { border: 0; background: transparent; text-align: left; border-radius: 6px; padding: 7px 8px; cursor: pointer; font-size: 12px; }
.conversation-actions button:hover { background: var(--surface-2); }
.conversation-actions .danger { color: var(--danger); }
.sidebar-footer { border-top: 1px solid var(--border); padding-top: 10px; display: grid; gap: 4px; }
.sidebar-footer > a { color: var(--muted); padding: 7px 9px; border-radius: 8px; font-size: 12px; }
.sidebar-footer > a:hover { color: var(--text); background: var(--surface-2); }
.mini-user { display: flex; align-items: center; gap: 9px; padding: 10px 7px 2px; }
.mini-user > div { min-width: 0; flex: 1; }
.mini-user strong, .mini-user small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.mini-user strong { font-size: 12px; }
.mini-user small { color: var(--muted); font-size: 10px; text-transform: capitalize; }
.avatar { width: 31px; height: 31px; border-radius: 10px; display: inline-grid; place-items: center; flex: 0 0 auto; background: linear-gradient(145deg, #293a52, #162133); color: var(--primary); border: 1px solid var(--border); font-weight: 850; }
.avatar.large { width: 48px; height: 48px; font-size: 18px; }
.chat-workspace { min-width: 0; display: flex; flex-direction: column; background: radial-gradient(circle at 50% -40%, rgba(77, 122, 194, .12), transparent 40%), var(--bg); }
.chat-topbar { height: 64px; flex: 0 0 auto; display: flex; align-items: center; gap: 14px; padding: 0 20px; border-bottom: 1px solid var(--border); background: rgba(7,11,18,.7); backdrop-filter: blur(18px); }
html[data-theme="light"] .chat-topbar { background: rgba(247,249,252,.75); }
.model-control { display: flex; align-items: center; gap: 8px; min-width: 0; }
.model-control select { width: min(390px, 42vw); border: 0; background: transparent; font-weight: 700; padding: 8px 25px 8px 0; box-shadow: none; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.mode-switch { margin-left: auto; display: flex; padding: 3px; border: 1px solid var(--border); background: var(--surface-2); border-radius: 10px; }
.mode-switch button { border: 0; background: transparent; padding: 7px 10px; border-radius: 7px; color: var(--muted); cursor: pointer; font-size: 12px; }
.mode-switch button.active { color: var(--text); background: var(--surface-3); box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.messages { flex: 1; overflow-y: auto; min-height: 0; scroll-behavior: smooth; }
.welcome-state { min-height: 100%; max-width: 920px; margin: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 50px 25px 150px; }
.welcome-state h1 { max-width: 730px; font-size: clamp(37px, 6vw, 67px); background: linear-gradient(110deg, var(--text), var(--muted)); -webkit-background-clip: text; color: transparent; }
.welcome-state > p { color: var(--muted); font-size: 16px; max-width: 650px; }
.hero-symbol { width: 70px; height: 70px; display: grid; place-items: center; border-radius: 24px; margin-bottom: 24px; color: #03140e; font-size: 25px; background: linear-gradient(145deg, #a2ffe0, #35ca99); box-shadow: 0 25px 70px rgba(52, 220, 168, .2); transform: perspective(100px) rotateX(6deg) rotateY(-8deg); }
.prompt-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; margin-top: 30px; }
.prompt-grid button { text-align: left; color: var(--text); padding: 17px; min-height: 112px; border: 1px solid var(--border); border-radius: 14px; background: linear-gradient(145deg, var(--surface), transparent); cursor: pointer; transition: .2s; }
.prompt-grid button:hover { transform: translateY(-3px); border-color: var(--border-strong); }
.prompt-grid button > span { color: var(--primary); font-size: 16px; }
.prompt-grid strong, .prompt-grid small { display: block; margin-top: 9px; }
.prompt-grid small { color: var(--muted); margin-top: 2px; }
.message { width: min(860px, calc(100% - 40px)); margin: 0 auto; padding: 24px 0; display: grid; grid-template-columns: 35px minmax(0,1fr); gap: 15px; border-bottom: 1px solid var(--border); }
.message:last-child { border-bottom: 0; }
.message-avatar { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: var(--surface-3); border: 1px solid var(--border); color: var(--primary); font-weight: 900; }
.message.user .message-avatar { color: var(--blue); }
.message-label { font-weight: 800; margin: 5px 0 10px; }
.message-label small { color: var(--muted-2); font-weight: 500; margin-left: 8px; }
.markdown-body { font-size: 15px; line-height: 1.72; overflow-wrap: anywhere; }
.markdown-body p { margin: 0 0 13px; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { font-size: 1.25em; letter-spacing: -.02em; margin: 22px 0 10px; }
.markdown-body pre { position: relative; overflow: auto; background: #050910; color: #d8e3f2; border: 1px solid rgba(150,170,200,.16); border-radius: 12px; padding: 42px 15px 15px; margin: 14px 0; }
.markdown-body pre:before { content: attr(data-language); position: absolute; left: 14px; top: 10px; color: #76849a; font-size: 10px; text-transform: uppercase; letter-spacing: .1em; }
.markdown-body code { font-family: "SFMono-Regular", Consolas, monospace; font-size: .9em; }
.markdown-body :not(pre) > code { background: var(--surface-3); color: var(--primary); border-radius: 5px; padding: 2px 5px; }
.markdown-body ul, .markdown-body ol { padding-left: 22px; }
.message-tools { opacity: 0; margin-top: 8px; transition: .2s; }
.message:hover .message-tools { opacity: 1; }
.message-tools button { background: transparent; border: 0; color: var(--muted); cursor: pointer; font-size: 11px; }
.typing-caret:after { content: ""; display: inline-block; width: 8px; height: 16px; margin-left: 3px; vertical-align: -2px; background: var(--primary); animation: blink .8s infinite; }
@keyframes blink { 50% { opacity: 0; } }
.composer-wrap { position: relative; flex: 0 0 auto; padding: 10px 20px 18px; background: linear-gradient(transparent, var(--bg) 28%); }
.composer { width: min(860px, 100%); margin: auto; background: var(--surface-solid); border: 1px solid var(--border); border-radius: 17px; padding: 6px; box-shadow: 0 16px 50px rgba(0,0,0,.22); transition: .2s; }
.composer:focus-within { border-color: var(--border-strong); box-shadow: 0 18px 55px rgba(0,0,0,.25), 0 0 0 3px var(--primary-soft); }
.composer textarea { min-height: 50px; max-height: 190px; resize: none; border: 0; background: transparent; box-shadow: none; padding: 13px; }
.attachment-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 10px; }
.attachment-chip { display: inline-flex; align-items: center; gap: 7px; max-width: 240px; padding: 6px 8px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); border: 1px solid var(--border-strong); font-size: 10px; }
.attachment-chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attachment-chip button { border: 0; background: transparent; color: inherit; cursor: pointer; }
.composer-bottom { display: flex; align-items: center; padding: 0 6px 3px; }
.composer-tools { display: flex; align-items: center; gap: 9px; color: var(--muted-2); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.tool-button { width: 31px; height: 31px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); cursor: pointer; color: var(--muted); }
.send-button { margin-left: auto; width: 36px; height: 36px; border: 0; border-radius: 11px; background: var(--primary); color: #04130e; font-size: 20px; font-weight: 900; cursor: pointer; }
.send-button:disabled { opacity: .35; cursor: default; }
.stop-button { margin-left: auto; border: 1px solid rgba(255,107,125,.25); background: rgba(255,107,125,.1); color: var(--danger); border-radius: 9px; padding: 8px 11px; cursor: pointer; font-size: 11px; }
.composer-note { text-align: center; color: var(--muted-2); font-size: 10px; margin: 7px 0 0; }
.empty-mini, .empty-cell { color: var(--muted); text-align: center; padding: 30px 10px; }

/* Settings */
.settings-shell { min-height: 100vh; background: radial-gradient(circle at 80% -20%, rgba(74,117,190,.14), transparent 35%), var(--bg); }
.settings-topbar { height: 70px; display: flex; align-items: center; justify-content: space-between; padding: 0 max(20px, calc((100vw - 1180px)/2)); border-bottom: 1px solid var(--border); background: var(--surface); backdrop-filter: blur(18px); }
.settings-topbar > div { display: flex; gap: 8px; }
.settings-content { width: min(1180px, calc(100% - 40px)); margin: auto; padding: 65px 0 80px; }
.page-heading { margin-bottom: 28px; }
.page-heading h1 { font-size: clamp(32px, 4vw, 47px); }
.page-heading p { color: var(--muted); max-width: 700px; }
.split-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: 0 12px 35px rgba(0,0,0,.08); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.panel-heading h2 { margin: 0; }
.panel-heading a { color: var(--primary); font-size: 12px; font-weight: 750; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; }
.full-panel { margin-top: 17px; }
.new-key-panel { padding: 22px; margin-bottom: 18px; background: linear-gradient(120deg, var(--primary-soft), rgba(110,168,255,.09)); border: 1px solid var(--border-strong); border-radius: var(--radius); display: flex; align-items: center; justify-content: space-between; gap: 25px; }
.new-key-panel h2 { margin-bottom: 5px; }
.new-key-panel p { color: var(--muted); margin: 0; }
.secret-display { display: flex; align-items: center; gap: 10px; min-width: 0; }
.secret-display code { max-width: 430px; overflow: auto; background: var(--bg); padding: 12px; border-radius: 9px; color: var(--primary); }
.feature-icon { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 12px; color: var(--primary); background: var(--primary-soft); }
.endpoint-box { display: grid; grid-template-columns: 95px 1fr; gap: 7px 10px; margin-top: 20px; padding-top: 17px; border-top: 1px solid var(--border); font-size: 11px; }
.endpoint-box span { color: var(--muted); }
.endpoint-box code { overflow-wrap: anywhere; color: var(--primary); }
.code-example { margin-top: 17px; display: grid; grid-template-columns: 260px 1fr; gap: 25px; }
.code-example pre { margin: 0; overflow: auto; background: #050910; color: #b9c7d9; border-radius: 12px; padding: 18px; }

/* Admin */
.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 246px minmax(0,1fr); }
.admin-sidebar { position: sticky; top: 0; height: 100vh; padding: 18px 13px; display: flex; flex-direction: column; }
.admin-nav { display: grid; gap: 3px; }
.admin-nav a { display: flex; align-items: center; gap: 10px; padding: 10px 11px; border-radius: 9px; color: var(--muted); font-weight: 650; font-size: 12px; }
.admin-nav a span { width: 20px; color: var(--muted-2); font-size: 15px; }
.admin-nav a:hover, .admin-nav a.active { color: var(--text); background: var(--surface-2); }
.admin-nav a.active span { color: var(--primary); }
.admin-sidebar .sidebar-footer { margin-top: auto; }
.admin-workspace { min-width: 0; }
.admin-topbar { height: 66px; position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; border-bottom: 1px solid var(--border); background: rgba(7,11,18,.8); backdrop-filter: blur(18px); }
html[data-theme="light"] .admin-topbar { background: rgba(247,249,252,.82); }
.admin-topbar > div:first-of-type strong { display: block; }
.admin-topbar .eyebrow { margin: 0; font-size: 8px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.notification-button { position: relative; }
.notification-button b { position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px; padding: 0 4px; display: grid; place-items: center; border-radius: 10px; background: var(--danger); color: white; font-size: 8px; }
.admin-content { padding: 35px; max-width: 1600px; margin: auto; }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; margin-bottom: 17px; }
.metric-card { position: relative; overflow: hidden; min-height: 142px; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.metric-card:after { content: ""; position: absolute; width: 100px; height: 100px; right: -45px; top: -50px; border-radius: 50%; background: rgba(110,168,255,.07); }
.metric-card.accent { border-color: var(--border-strong); background: linear-gradient(145deg, var(--primary-soft), var(--surface)); }
.metric-card.danger-accent { border-color: rgba(255,107,125,.3); }
.metric-card > span, .metric-card small { color: var(--muted); display: block; }
.metric-card strong { display: block; font-size: 34px; letter-spacing: -.04em; margin: 13px 0 2px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0,1.5fr) minmax(300px,.8fr); gap: 17px; margin-bottom: 17px; }
.bottom-grid { grid-template-columns: 1fr 1fr; }
.chart-panel { min-height: 310px; }
.bar-chart { height: 220px; display: flex; align-items: flex-end; gap: 8px; padding-top: 18px; }
.bar-column { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 7px; }
.bar-column span { width: min(28px, 80%); min-height: 5px; background: linear-gradient(180deg, var(--primary), rgba(84,228,177,.25)); border-radius: 6px 6px 2px 2px; transition: .2s; }
.bar-column:hover span { filter: brightness(1.2); }
.bar-column small { color: var(--muted-2); font-size: 8px; writing-mode: vertical-rl; transform: rotate(180deg); height: 34px; }
.rank-list, .compact-list, .provider-health-list { display: grid; gap: 7px; }
.rank-list > div, .compact-list > div, .provider-health-list > div { display: flex; align-items: center; gap: 11px; padding: 10px; border-bottom: 1px solid var(--border); }
.rank-list > div:last-child, .compact-list > div:last-child, .provider-health-list > div:last-child { border-bottom: 0; }
.rank-list > div > div, .compact-list > div > div, .provider-health-list > div > div { flex: 1; min-width: 0; }
.rank-list strong, .compact-list strong, .provider-health-list strong, .rank-list small, .compact-list small, .provider-health-list small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.rank-list strong, .compact-list strong, .provider-health-list strong { font-size: 12px; }
.rank-list small, .compact-list small, .provider-health-list small { color: var(--muted); font-size: 10px; }
.rank-number { color: var(--muted-2); font-size: 10px; }
.progress-track { height: 3px; display: block; margin-top: 7px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.progress-track i { display: block; height: 100%; background: var(--primary); }
.provider-logo { width: 33px; height: 33px; display: grid; place-items: center; border-radius: 10px; background: var(--surface-3); color: var(--blue); font-weight: 900; border: 1px solid var(--border); }
.provider-logo.large { width: 45px; height: 45px; font-size: 17px; }
.health-state { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 10px; text-transform: capitalize; }
.health-state i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted-2); }
.health-state.healthy { color: var(--success); }
.health-state.healthy i { background: var(--success); box-shadow: 0 0 0 3px var(--primary-soft); }
.health-state.unhealthy { color: var(--danger); }
.health-state.unhealthy i { background: var(--danger); }
.live-pill { display: inline-flex; align-items: center; gap: 7px; padding: 8px 11px; background: var(--primary-soft); color: var(--primary); border: 1px solid var(--border-strong); border-radius: 20px; font-size: 11px; font-weight: 700; }
.live-pill i { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px transparent; } 0%,100% { box-shadow: 0 0 0 0 var(--primary-soft); } }

.filter-bar { display: flex; gap: 9px; margin-bottom: 18px; }
.filter-bar .sidebar-search { flex: 1; max-width: 450px; margin: 0; }
.filter-bar select { width: 170px; }
.responsive-table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th { text-align: left; color: var(--muted-2); font-size: 9px; letter-spacing: .11em; text-transform: uppercase; padding: 10px; border-bottom: 1px solid var(--border); }
td { padding: 12px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 12px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(130,150,180,.025); }
.table-user { display: flex; align-items: center; gap: 9px; }
.table-user strong, .table-user small, .table-subtext { display: block; }
.table-user small, .table-subtext { color: var(--muted); font-size: 10px; margin-top: 2px; }
.badge, .role-badge, .free-pill, .status-badge { display: inline-flex; align-items: center; justify-content: center; padding: 4px 8px; border-radius: 20px; background: var(--surface-3); color: var(--muted); border: 1px solid var(--border); font-size: 9px; font-weight: 800; text-transform: capitalize; white-space: nowrap; }
.free-pill, .status-badge.active, .status-badge.complete, .status-badge.reviewed { color: var(--success); background: var(--primary-soft); border-color: var(--border-strong); }
.status-badge.suspended, .status-badge.pending { color: var(--warning); background: rgba(255,204,102,.09); border-color: rgba(255,204,102,.2); }
.status-badge.banned, .status-badge.revoked, .status-badge.error, .status-badge.actioned { color: var(--danger); background: rgba(255,107,125,.09); border-color: rgba(255,107,125,.2); }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 18px; color: var(--muted); }
.tiny-input { width: 67px; padding: 7px; }
.inline-form { display: flex; align-items: center; gap: 6px; }
.inline-form select { width: 105px; padding: 7px; }
.truncate-text { display: block; max-width: 300px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.error-detail { display: block; color: var(--danger); max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }

.modal { width: min(460px, calc(100% - 30px)); color: var(--text); background: var(--surface-solid); border: 1px solid var(--border); border-radius: 18px; padding: 0; box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(2,5,9,.7); backdrop-filter: blur(4px); }
.modal form { display: grid; gap: 14px; padding: 22px; }
.modal-heading { display: flex; align-items: flex-start; justify-content: space-between; }
.modal-heading h2 { margin: 0; }
.modal-heading button { border: 0; background: transparent; color: var(--muted); font-size: 25px; cursor: pointer; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 5px; }

.moderation-thread { display: grid; gap: 1px; padding: 0; overflow: hidden; }
.moderation-message { display: grid; grid-template-columns: 36px 1fr; gap: 12px; padding: 20px; border-bottom: 1px solid var(--border); }
.moderation-message.assistant { background: var(--primary-soft); }
.moderation-message pre { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--font); font-size: 13px; line-height: 1.65; }
.back-link { display: block; color: var(--muted); font-size: 11px; margin-bottom: 15px; }
.provider-card-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; margin-bottom: 17px; }
.provider-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; min-width: 0; }
.provider-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.provider-card-head > div { flex: 1; min-width: 0; }
.provider-card-head h2 { font-size: 15px; margin: 0 0 3px; }
.provider-message { display: block; color: var(--muted-2); margin-top: 10px; overflow-wrap: anywhere; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 11px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.switch-row span strong, .switch-row span small { display: block; }
.switch-row input[type="checkbox"] { appearance: none; width: 38px; height: 22px; padding: 0; background: var(--surface-3); border-radius: 20px; position: relative; cursor: pointer; flex: 0 0 auto; }
.switch-row input[type="checkbox"]:after { content: ""; position: absolute; width: 16px; height: 16px; top: 2px; left: 2px; border-radius: 50%; background: var(--muted); transition: .2s; }
.switch-row input[type="checkbox"]:checked { background: var(--primary); }
.switch-row input[type="checkbox"]:checked:after { left: 18px; background: #04130e; }
.models-layout { display: grid; grid-template-columns: minmax(0,1fr) 310px; gap: 17px; }
.toggle-list { display: grid; gap: 9px; }
.admin-settings-grid { align-items: start; }
.sticky-save { position: sticky; bottom: 12px; margin-top: 17px; display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 12px 14px 12px 19px; color: var(--muted); background: rgba(18,27,42,.88); backdrop-filter: blur(18px); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); }
html[data-theme="light"] .sticky-save { background: rgba(255,255,255,.9); }
.notification-list { padding: 0; overflow: hidden; }
.notification-item { display: flex; align-items: center; gap: 14px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.notification-item:last-child { border-bottom: 0; }
.notification-item.unread { background: var(--primary-soft); }
.notification-item > div { flex: 1; }
.notification-item h2 { font-size: 14px; margin: 0 0 3px; }
.notification-item p, .notification-item small { color: var(--muted); margin: 0; }
.notification-item small { font-size: 10px; }

.toast-root { position: fixed; z-index: 999; right: 20px; bottom: 20px; display: grid; gap: 8px; }
.toast { min-width: 240px; max-width: 390px; padding: 12px 14px; color: var(--text); background: var(--surface-solid); border: 1px solid var(--border); border-left: 3px solid var(--primary); border-radius: 10px; box-shadow: var(--shadow); animation: toast-in .25s ease; }
.toast.error { border-left-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

@media (max-width: 1180px) {
    .provider-card-grid { grid-template-columns: repeat(2, 1fr); }
    .metric-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 860px) {
    .mobile-only { display: grid !important; }
    .auth-shell { grid-template-columns: 1fr; }
    .auth-art { display: none; }
    .auth-card { min-height: 100vh; border: 0; }
    .chat-shell { grid-template-columns: 1fr; }
    .chat-sidebar { position: fixed; z-index: 100; inset: 0 auto 0 0; width: 285px; transform: translateX(-102%); transition: .25s; box-shadow: var(--shadow); }
    .chat-sidebar.open { transform: translateX(0); }
    .admin-shell { grid-template-columns: 1fr; }
    .admin-sidebar { position: fixed; z-index: 100; inset: 0 auto 0 0; width: 250px; transform: translateX(-102%); transition: .25s; box-shadow: var(--shadow); }
    .admin-sidebar.open { transform: translateX(0); }
    .admin-content { padding: 25px 18px; }
    .dashboard-grid, .bottom-grid, .settings-grid, .code-example, .models-layout { grid-template-columns: 1fr; }
    .prompt-grid { grid-template-columns: 1fr; }
    .prompt-grid button { min-height: 82px; }
    .mode-switch button { padding: 7px; font-size: 0; }
    .mode-switch button:first-letter { font-size: 12px; }
    .welcome-state { padding-bottom: 80px; }
    .new-key-panel { align-items: stretch; flex-direction: column; }
    .secret-display { align-items: stretch; flex-direction: column; }
    .secret-display code { max-width: 100%; }
}

@media (max-width: 620px) {
    .form-grid, .requirement-grid, .metric-grid, .provider-card-grid { grid-template-columns: 1fr; }
    .auth-card { padding: 80px 24px 35px; }
    .auth-card .brand-lockup { top: 24px; }
    .chat-topbar { padding: 0 10px; gap: 7px; }
    .model-control { flex: 1; }
    .model-control select { width: 100%; }
    .chat-topbar > .icon-button:last-child { display: none; }
    .message { width: calc(100% - 24px); padding: 18px 0; grid-template-columns: 29px 1fr; gap: 10px; }
    .message-avatar { width: 29px; height: 29px; border-radius: 9px; }
    .composer-wrap { padding: 8px 10px 12px; }
    .settings-content { width: calc(100% - 24px); padding-top: 35px; }
    .settings-topbar { padding: 0 12px; }
    .settings-topbar .brand-lockup small { display: none; }
    .split-heading { align-items: flex-start; flex-direction: column; }
    .filter-bar { align-items: stretch; flex-direction: column; }
    .filter-bar select { width: 100%; }
    .admin-content { padding: 22px 12px; }
    .admin-topbar { padding: 0 12px; }
    .admin-topbar .btn-ghost { padding: 0 10px; }
    .panel { padding: 16px; border-radius: 14px; }
    .sticky-save { align-items: stretch; flex-direction: column; }
}
