:root {
  color-scheme: dark;
  --bg: #070d18;
  --bg-soft: #0b1424;
  --panel: #0f192b;
  --panel-2: #121f34;
  --line: #22314a;
  --line-soft: #19263b;
  --text: #edf4ff;
  --muted: #8fa1b9;
  --cyan: #3dd6d0;
  --blue: #5e7df6;
  --violet: #9f7aea;
  --green: #43d39e;
  --amber: #f5b84b;
  --danger: #ff7184;
  --shadow: 0 24px 80px rgb(0 0 0 / .32);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; background: var(--bg); }
body { min-height: 100vh; margin: 0; background: radial-gradient(circle at 20% -10%, rgb(60 93 185 / .16), transparent 34%), var(--bg); color: var(--text); }
button, input { font: inherit; }
button { cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; inset: 10px auto auto 10px; z-index: 100; padding: 10px 14px; transform: translateY(-160%); border-radius: 8px; background: #fff; color: #07101e; font-weight: 800; }
.skip-link:focus { transform: translateY(0); }
.kicker, .section-tag { margin: 0; direction: ltr; color: var(--cyan); font-size: .72rem; font-weight: 850; letter-spacing: .12em; text-align: right; }

/* Developer login */
.login-body { display: grid; place-items: center; padding: 28px; }
.login-shell { width: min(1120px, 100%); min-height: 650px; display: grid; grid-template-columns: 1.12fr .88fr; overflow: hidden; border: 1px solid var(--line); border-radius: 28px; background: var(--panel); box-shadow: var(--shadow); }
.login-visual { position: relative; padding: 74px 64px; display: flex; flex-direction: column; justify-content: center; overflow: hidden; background: linear-gradient(145deg, #101f3c, #0b1425 64%); }
.login-visual::before { content: ""; position: absolute; width: 440px; height: 440px; inset: -180px -130px auto auto; border: 1px solid rgb(61 214 208 / .18); border-radius: 50%; box-shadow: 0 0 0 70px rgb(61 214 208 / .03), 0 0 0 140px rgb(94 125 246 / .025); }
.login-visual::after { content: ""; position: absolute; inset: auto 45px 38px auto; width: 180px; height: 90px; opacity: .16; background-image: radial-gradient(var(--cyan) 1px, transparent 1px); background-size: 12px 12px; }
.developer-mark { width: 64px; height: 64px; margin-bottom: 40px; display: flex; align-items: center; justify-content: center; gap: 2px; border: 1px solid rgb(61 214 208 / .28); border-radius: 18px; background: rgb(61 214 208 / .08); color: var(--cyan); box-shadow: inset 0 0 24px rgb(61 214 208 / .05); font: 800 1.1rem Consolas, monospace; }
.login-visual h1 { max-width: 610px; margin: 16px 0 18px; font-size: clamp(2rem, 4vw, 3.45rem); line-height: 1.22; letter-spacing: -.045em; }
.login-visual > p:not(.kicker) { max-width: 590px; margin: 0; color: #a9b9d0; font-size: 1rem; line-height: 1.95; }
.login-signals { margin: 42px 0 0; padding: 0; display: grid; gap: 14px; list-style: none; color: #b8c6da; font-size: .88rem; }
.login-signals li { display: flex; align-items: center; gap: 10px; }
.login-signals i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgb(67 211 158 / .1); }
.login-panel { padding: 48px; display: grid; place-items: center; background: #0b1422; }
.login-card { width: min(380px, 100%); }
.login-card__head { margin-bottom: 34px; display: flex; align-items: center; gap: 14px; }
.lock-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 13px; background: rgb(94 125 246 / .12); color: #9aafff; font-size: 1.35rem; }
.login-card__head p { margin: 0 0 4px; direction: ltr; color: var(--muted); font-size: .7rem; letter-spacing: .09em; text-align: right; text-transform: uppercase; }
.login-card__head h2 { margin: 0; font-size: 1.25rem; }
.login-card form { display: grid; gap: 18px; }
.login-card label { display: grid; gap: 8px; color: #b7c6da; font-size: .8rem; font-weight: 700; }
.login-card input { width: 100%; min-height: 50px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; outline: 0; background: #0a1220; color: var(--text); direction: ltr; }
.login-card input:focus { border-color: var(--cyan); box-shadow: 0 0 0 4px rgb(61 214 208 / .09); }
.login-card form button { min-height: 52px; margin-top: 5px; padding: 10px 18px; display: flex; align-items: center; justify-content: center; gap: 14px; border: 0; border-radius: 12px; background: linear-gradient(135deg, #4f70ec, #6d55d8); color: #fff; font-weight: 850; box-shadow: 0 16px 32px rgb(75 96 218 / .24); }
.login-card form button:hover { filter: brightness(1.1); }
.login-card form button:focus-visible { outline: 3px solid #b5c2ff; outline-offset: 3px; }
.login-note { margin: 24px 0 0; color: #71839c; font-size: .72rem; line-height: 1.8; text-align: center; }
.form-error { margin: 0 0 18px; padding: 11px 13px; border: 1px solid rgb(255 113 132 / .35); border-radius: 10px; background: rgb(255 113 132 / .08); color: #ff9eaa; font-size: .78rem; line-height: 1.7; }

/* Monitor */
.topbar { min-height: 76px; padding: 0 max(24px, calc((100vw - 1440px) / 2)); display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line-soft); background: rgb(7 13 24 / .86); backdrop-filter: blur(18px); position: sticky; inset-block-start: 0; z-index: 20; }
.brand, .topbar__actions { display: flex; align-items: center; gap: 12px; }
.brand__mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: linear-gradient(140deg, var(--cyan), var(--blue)); color: #07101e; font: 950 .9rem Consolas, monospace; }
.brand div { display: grid; gap: 3px; direction: ltr; }
.brand strong { font-size: .88rem; letter-spacing: .03em; }
.brand small { color: var(--muted); font-size: .65rem; }
.live-pill, .model-pill { min-height: 30px; padding: 6px 10px; display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 99px; background: var(--panel); color: #b7c5d9; direction: ltr; font-size: .68rem; font-weight: 750; }
.live-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgb(67 211 158 / .1); }
.model-pill { color: #a9b9ff; }
.logout-button { min-height: 32px; padding: 6px 11px; border: 1px solid var(--line); border-radius: 9px; background: transparent; color: var(--muted); font-size: .68rem; font-weight: 700; }
.logout-button:hover, .logout-button:focus-visible { border-color: var(--danger); outline: 0; color: #ff9aa8; }
.dashboard-shell { width: min(1440px, calc(100% - 48px)); margin: 0 auto; padding: 36px 0 64px; display: grid; gap: 18px; }
.overview-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 22px; }
.overview-heading h1 { margin: 9px 0 8px; font-size: clamp(1.65rem, 3vw, 2.55rem); letter-spacing: -.035em; }
.overview-heading > div > p:last-child { margin: 0; color: var(--muted); font-size: .84rem; }
.range-control { padding: 5px; display: flex; gap: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.range-control button { min-height: 34px; padding: 7px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: .72rem; font-weight: 750; }
.range-control button:hover, .range-control button:focus-visible { outline: 2px solid rgb(61 214 208 / .35); color: var(--text); }
.range-control button.is-active { background: #25395f; color: #fff; }
.range-control .refresh-button { width: 34px; padding: 0; color: var(--cyan); font-size: 1.1rem; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metrics article { min-height: 124px; padding: 18px; display: flex; align-items: flex-start; gap: 14px; border: 1px solid var(--line-soft); border-radius: 16px; background: linear-gradient(145deg, #101c30, #0d1727); box-shadow: 0 12px 40px rgb(0 0 0 / .12); }
.metric-icon { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 12px; font: 900 1rem Consolas, monospace; }
.metric-icon--cyan { background: rgb(61 214 208 / .11); color: var(--cyan); }
.metric-icon--violet { background: rgb(159 122 234 / .12); color: #b89afb; }
.metric-icon--green { background: rgb(67 211 158 / .11); color: var(--green); }
.metric-icon--amber { background: rgb(245 184 75 / .11); color: var(--amber); }
.metrics article div { min-width: 0; display: grid; gap: 5px; }
.metrics small { color: var(--muted); font-size: .7rem; font-weight: 700; }
.metrics strong { direction: ltr; font-size: 1.28rem; text-align: right; letter-spacing: -.02em; }
.metrics p { margin: 0; color: #7487a0; font-size: .66rem; }
.panel { overflow: hidden; border: 1px solid var(--line-soft); border-radius: 18px; background: var(--panel); box-shadow: 0 18px 55px rgb(0 0 0 / .14); }
.chart-card > header, .chats-header { min-height: 76px; padding: 17px 20px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line-soft); }
.panel h2 { margin: 5px 0 0; font-size: 1rem; }
.chart-total { display: grid; gap: 4px; direction: ltr; text-align: right; }
.chart-total small { color: var(--muted); font-size: .65rem; }
.chart-total strong { font-size: 1rem; }
.chart-wrap { min-height: 310px; padding: 22px 16px 12px; position: relative; direction: ltr; }
#usage-chart { width: 100%; height: 280px; overflow: visible; }
.chart-grid { stroke: #1d2b41; stroke-width: 1; }
.chart-area { fill: url(#usage-gradient); }
.chart-line { fill: none; stroke: var(--cyan); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.chart-point { fill: #0f192b; stroke: var(--cyan); stroke-width: 3; }
.chart-label { fill: #71849e; font: 12px "Segoe UI", sans-serif; }
.chart-value { fill: #cbd8e9; font: 11px "Segoe UI", sans-serif; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: .8rem; }
.chats-header > div > p:last-child { margin: 7px 0 0; color: var(--muted); font-size: .74rem; }
.search-box { width: min(330px, 100%); min-height: 42px; padding: 0 12px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 11px; background: #091321; }
.search-box b { color: var(--muted); font-size: 1.1rem; }
.search-box input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); font-size: .76rem; }
.search-box:focus-within { border-color: var(--cyan); box-shadow: 0 0 0 3px rgb(61 214 208 / .07); }
.category-tabs { padding: 12px 16px; display: flex; gap: 7px; overflow-x: auto; border-bottom: 1px solid var(--line-soft); }
.category-tabs button { min-height: 34px; padding: 6px 11px; display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 99px; background: #0b1627; color: #9aabc1; font-size: .7rem; font-weight: 750; white-space: nowrap; }
.category-tabs button span { min-width: 20px; height: 20px; padding: 0 5px; display: grid; place-items: center; border-radius: 99px; background: #192942; color: #cbd8e9; font-size: .62rem; }
.category-tabs button:hover, .category-tabs button:focus-visible { border-color: var(--cyan); outline: 0; color: #fff; }
.category-tabs button.is-active { border-color: #3b5d8f; background: #20375c; color: #fff; }
.chat-grid { padding: 14px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.chat-card { width: 100%; min-height: 112px; padding: 14px; display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 12px; border: 1px solid var(--line-soft); border-radius: 14px; background: #0b1626; color: var(--text); text-align: right; }
.chat-card:hover, .chat-card:focus-visible { border-color: #3e5e89; outline: 0; background: #101e33; transform: translateY(-1px); }
.chat-avatar { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 13px; background: linear-gradient(145deg, #26436b, #1b2b48); color: #cbe0ff; font-size: .76rem; font-weight: 900; }
.chat-main { min-width: 0; display: grid; gap: 5px; }
.chat-main strong { overflow: hidden; font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
.chat-main small { color: var(--muted); direction: ltr; font-size: .67rem; text-align: right; }
.chat-badges { display: flex; gap: 5px; flex-wrap: wrap; }
.chat-badges i { padding: 3px 7px; border-radius: 99px; background: #15263f; color: #8fa9ca; font-size: .59rem; font-style: normal; }
.chat-cost { display: grid; gap: 6px; direction: ltr; text-align: left; }
.chat-cost strong { color: var(--cyan); font-size: .78rem; }
.chat-cost span { color: #7f91a8; font-size: .62rem; }
.loading-card, .empty-card { min-height: 150px; grid-column: 1 / -1; display: grid; place-items: center; color: var(--muted); font-size: .8rem; }
.pricing-note { margin: 0; color: #6f829b; direction: ltr; font-size: .66rem; text-align: center; }
.alert-banner { padding: 12px 14px; display: flex; align-items: center; gap: 10px; border: 1px solid rgb(245 184 75 / .3); border-radius: 12px; background: rgb(245 184 75 / .07); color: #f4cb7c; }
.alert-banner span { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 8px; background: rgb(245 184 75 / .13); font-weight: 900; }
.alert-banner p { margin: 0; font-size: .76rem; }

/* Chat message dialog */
.chat-dialog { width: min(860px, calc(100% - 30px)); max-height: min(88vh, 900px); padding: 0; overflow: hidden; border: 1px solid #2a3c59; border-radius: 20px; background: #0c1626; color: var(--text); box-shadow: 0 30px 100px rgb(0 0 0 / .6); }
.chat-dialog::backdrop { background: rgb(2 6 12 / .78); backdrop-filter: blur(6px); }
.dialog-head { padding: 18px 20px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line-soft); }
.dialog-head h2 { margin: 5px 0; font-size: 1.08rem; }
.dialog-head p:last-child { margin: 0; color: var(--muted); direction: ltr; font-size: .68rem; text-align: right; }
.dialog-head button { width: 36px; height: 36px; flex: none; border: 1px solid var(--line); border-radius: 10px; background: #111f34; color: var(--muted); font-size: 1.25rem; }
.dialog-head button:hover, .dialog-head button:focus-visible { border-color: var(--danger); outline: 0; color: #fff; }
.dialog-summary { padding: 10px 20px; display: flex; gap: 7px; flex-wrap: wrap; border-bottom: 1px solid var(--line-soft); }
.dialog-summary span { padding: 5px 9px; border-radius: 99px; background: #15263f; color: #9cb1cd; font-size: .64rem; }
.message-timeline { max-height: calc(88vh - 155px); padding: 22px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; background: radial-gradient(circle at 0 0, rgb(94 125 246 / .05), transparent 30%); }
.message { max-width: 78%; display: grid; gap: 5px; }
.message--customer { align-self: flex-start; }
.message--ai, .message--employee, .message--system { align-self: flex-end; }
.message__meta { padding: 0 4px; display: flex; align-items: center; gap: 8px; color: #74879f; font-size: .61rem; }
.message--ai .message__meta, .message--employee .message__meta, .message--system .message__meta { justify-content: flex-end; }
.message__bubble { padding: 11px 13px; border: 1px solid var(--line); border-radius: 14px 14px 4px 14px; background: #121f34; color: #dce7f5; font-size: .76rem; line-height: 1.85; white-space: pre-wrap; overflow-wrap: anywhere; }
.message--customer .message__bubble { border-color: #254b4b; border-radius: 14px 14px 14px 4px; background: #102a2b; }
.message--employee .message__bubble { border-color: #3b376b; background: #201e40; }
.message--system .message__bubble { border-style: dashed; background: #111a28; color: #a1b0c3; }
.usage-chip { width: fit-content; padding: 5px 8px; display: flex; gap: 8px; border: 1px solid #263a57; border-radius: 8px; background: #0b1423; color: #91a6c2; direction: ltr; font: 600 .59rem Consolas, monospace; }
.message--ai .usage-chip { justify-self: end; }
.toast { position: fixed; inset: auto 20px 20px auto; z-index: 100; padding: 11px 14px; border: 1px solid #4a3340; border-radius: 10px; background: #291722; color: #ff9dac; font-size: .74rem; box-shadow: var(--shadow); }

@media (max-width: 1000px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-visual { min-height: 410px; padding: 48px; }
  .login-panel { padding: 44px 28px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .topbar { min-height: auto; padding: 13px 16px; align-items: flex-start; }
  .brand small, .live-pill, .model-pill { display: none; }
  .dashboard-shell { width: min(100% - 24px, 1440px); padding-top: 24px; }
  .overview-heading, .chats-header { align-items: stretch; flex-direction: column; }
  .range-control { width: 100%; }
  .range-control button { flex: 1; }
  .metrics, .chat-grid { grid-template-columns: 1fr; }
  .chart-wrap { min-height: 260px; overflow-x: auto; }
  #usage-chart { min-width: 720px; height: 240px; }
  .chat-card { grid-template-columns: 42px minmax(0, 1fr); }
  .chat-cost { grid-column: 2; grid-row: 2; display: flex; justify-content: space-between; }
  .search-box { width: 100%; }
  .message { max-width: 92%; }
}
@media (max-width: 520px) {
  .login-body { padding: 0; }
  .login-shell { min-height: 100vh; border: 0; border-radius: 0; }
  .login-visual { min-height: 355px; padding: 36px 25px; }
  .developer-mark { width: 52px; height: 52px; margin-bottom: 26px; }
  .login-panel { padding: 36px 24px; }
  .metrics { grid-template-columns: 1fr; }
  .metrics article { min-height: 102px; }
  .topbar__actions { gap: 7px; }
  .logout-button { padding-inline: 8px; }
  .chart-card > header { align-items: flex-start; }
}
