@import url("./aero-clinical.tokens.css");

/* Shared application theme. Loaded after legacy inline styles during migration. */
.aero-page {
  --bg: var(--aero-canvas);
  --panel: var(--aero-surface);
  --panel-2: #f5f8fc;
  --border: var(--aero-border);
  --text: var(--aero-ink-900);
  --text-dim: var(--aero-ink-500);
  --accent: var(--aero-primary-600);
  --accent-soft: var(--aero-primary-50);
  --accent-text: #fff;
  --bubble-user: #edf4ff;
  --bubble-user-text: var(--aero-ink-900);
  --bubble-agent: rgba(255, 255, 255, 0.92);
  --bubble-agent-text: var(--aero-ink-900);
  --danger: var(--aero-danger);
  --danger-bg: #fff1f2;
  --ok: var(--aero-success);
  --ok-bg: #edf9f3;
  --shadow-sm: var(--aero-shadow-xs);
  --shadow-md: var(--aero-shadow-md);
  color: var(--aero-ink-900);
  font-family: var(--aero-font-sans);
  background:
    radial-gradient(circle at 8% 4%, rgba(124, 175, 214, 0.16), transparent 27%),
    radial-gradient(circle at 94% 94%, rgba(91, 184, 177, 0.1), transparent 25%),
    var(--aero-canvas);
  -webkit-font-smoothing: antialiased;
}

html, body.aero-page { width: 100%; max-width: none; }

.aero-page * { scrollbar-color: var(--aero-border-strong) transparent; }
.aero-page ::-webkit-scrollbar { width: 8px; height: 8px; }
.aero-page ::-webkit-scrollbar-thumb { background: var(--aero-border-strong); border-radius: 999px; }
.aero-page button, .aero-page input, .aero-page textarea, .aero-page select { font-family: inherit; }
.aero-page button:focus-visible, .aero-page a:focus-visible,
.aero-page input:focus-visible, .aero-page textarea:focus-visible,
.aero-page select:focus-visible { outline: none; box-shadow: var(--aero-shadow-focus); }

/* Login */
.login-page {
  width: 100%;
  min-width: 100%;
  display: grid;
  min-height: 100vh;
  height: auto;
  padding: clamp(18px, 4vw, 64px);
  place-items: center;
  background-image: url("/assets/backgrounds/aero-mesh.svg");
  background-size: cover;
  background-position: center;
}

.login-page .login-shell {
  display: grid;
  width: min(960px, 100%);
  grid-template-columns: minmax(0, 1.08fr) minmax(340px, .92fr);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: var(--aero-radius-xl);
  background: rgba(255, 255, 255, 0.58);
  box-shadow: var(--aero-shadow-lg);
  backdrop-filter: blur(24px) saturate(110%);
}

.login-page .login-brand {
  position: relative;
  display: flex;
  min-height: 520px;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 56px;
  border-right: 1px solid rgba(215, 226, 237, 0.76);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.54), rgba(227, 243, 250, 0.28));
}

.login-page .login-brand img {
  position: absolute;
  top: 42px;
  left: 56px;
  width: 104px;
  height: auto;
  flex: 0 0 auto;
}
.login-page .login-brand h1 {
  margin: 8px 0 12px;
  color: var(--aero-ink-950);
  font-size: clamp(28px, 3.15vw, 40px);
  line-height: 1.08;
  letter-spacing: -.04em;
}
.login-page .medical-line { white-space: nowrap; }
.login-page .login-brand p { max-width: 390px; margin: 0; color: var(--aero-ink-500); font-size: 14px; line-height: 1.6; }
.login-page .eyebrow { color: var(--aero-primary-700); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.login-page .brand-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 22px; }
.login-page .brand-chips span { padding: 6px 10px; color: var(--aero-primary-700); border: 1px solid var(--aero-primary-100); border-radius: 999px; background: rgba(241, 246, 253, .82); font-size: 11px; }

.login-page form {
  align-self: center;
  width: auto;
  max-width: none;
  margin: 34px;
  padding: 38px;
  gap: 17px;
  border: 1px solid rgba(220, 229, 239, 0.88);
  border-radius: var(--aero-radius-lg);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--aero-shadow-md);
}
.login-page .form-heading { margin-bottom: 5px; }
.login-page .form-heading h2 { margin: 7px 0 6px; color: var(--aero-ink-950); font-size: 22px; letter-spacing: -.02em; }
.login-page .form-heading p { margin: 0; color: var(--aero-ink-500); font-size: 12px; line-height: 1.5; }
.login-page label { color: var(--aero-ink-500); font-size: 11px; font-weight: 600; }
.login-page input { min-height: 44px; padding: 10px 13px; color: var(--aero-ink-900); border-color: var(--aero-border); border-radius: var(--aero-radius-sm); outline: none; background: rgba(247, 250, 253, .9); }
.login-page input:focus { outline: none; border-color: var(--aero-primary-300); box-shadow: var(--aero-shadow-focus); }
.login-page form button { min-height: 44px; margin-top: 3px; border-radius: var(--aero-radius-sm); background: var(--aero-gradient-brand); box-shadow: 0 8px 20px rgba(79, 118, 181, .18); font-weight: 600; }

/* Main chat */
.chat-page { padding: 14px; overflow: hidden; }
.chat-page #app {
  width: min(1500px, 100%);
  max-width: none;
  height: calc(100vh - 28px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: var(--aero-radius-lg);
  background: rgba(255, 255, 255, .58);
  box-shadow: var(--aero-shadow-md);
  backdrop-filter: blur(22px);
}
.chat-page #sidebar {
  width: 304px;
  min-width: 272px;
  padding: 20px 16px 16px;
  gap: 12px;
  border-right: 1px solid rgba(215, 225, 236, .82);
  background: #fff;
  backdrop-filter: none;
}
.chat-page #sidebarBrand { display: flex; align-items: center; gap: 10px; min-height: 50px; margin-bottom: 4px; padding: 0 4px; }
.chat-page #sidebarBrand img { width: 52px; height: auto; }
.chat-page #sidebarBrand div { display: flex; flex-direction: column; gap: 2px; }
.chat-page #sidebarBrand strong { color: var(--aero-ink-950); font-size: 16px; letter-spacing: -.02em; }
.chat-page #sidebarBrand span { color: var(--aero-ink-500); font-size: 11px; }
.chat-page #newChatBtn { min-height: 42px; color: #fff; border: 0; border-radius: var(--aero-radius-sm); background: var(--aero-gradient-brand); box-shadow: 0 8px 18px rgba(79, 118, 181, .16); font-weight: 600; }
.chat-page #newChatBtn:hover { color: #fff; border-color: transparent; background: var(--aero-gradient-brand); transform: translateY(-1px); }
.chat-page #searchInput { min-height: 40px; padding: 9px 12px 9px 34px; border-color: var(--aero-border); border-radius: var(--aero-radius-sm); background: rgba(255, 255, 255, .82); }
.chat-page #searchInput:focus { outline: none; border-color: var(--aero-primary-300); box-shadow: var(--aero-shadow-focus); }
.chat-page .tag-filter-chip { padding: 4px 9px; color: var(--aero-ink-500); border-color: var(--aero-border); background: rgba(255, 255, 255, .66); }
.chat-page .tag-filter-chip.active { color: var(--aero-primary-700); border-color: var(--aero-primary-100); background: var(--aero-primary-50); }
.chat-page #convList { gap: 4px; }
.chat-page .conv-item { padding: 10px; border-radius: var(--aero-radius-sm); }
.chat-page .conv-item:hover { background: rgba(255, 255, 255, .88); }
.chat-page .conv-item.active { color: var(--aero-primary-700); background: linear-gradient(135deg, var(--aero-primary-50), rgba(239, 250, 249, .74)); }
.chat-page #sidebarFooter { padding-top: 14px; border-color: var(--aero-border); }
.chat-page #userCard { padding: 9px; border: 1px solid var(--aero-border); border-radius: var(--aero-radius-sm); background: rgba(255, 255, 255, .68); }
.chat-page #userAvatar { width: 34px; height: 34px; border-radius: 11px; background: var(--aero-gradient-soft); }
.chat-page #footerActions .icon-btn, .chat-page .icon-btn { width: 32px; height: 32px; border-radius: 10px; }
.chat-page #footerActions .icon-btn:hover { color: var(--aero-primary-700); background: var(--aero-primary-50); }

.chat-page #main { background: rgba(248, 251, 254, .7); }
.chat-page #main > header { min-height: 68px; padding: 0 22px; border-color: var(--aero-border); background: rgba(255, 255, 255, .76); backdrop-filter: blur(16px); }
.chat-page .chat-heading { display: flex; flex: 1; align-items: baseline; gap: 12px; }
.chat-page .chat-heading strong { color: var(--aero-ink-950); font-size: 17px; letter-spacing: -.02em; }
.chat-page .chat-heading span { color: var(--aero-ink-500); font-size: 12px; }
.chat-page .chat-heading i { display: inline-flex; align-items: center; gap: 6px; color: var(--aero-ink-500); font-size: 11px; font-style: normal; }
.chat-page .chat-heading i::before { width: 7px; height: 7px; border-radius: 50%; background: var(--aero-success); content: ""; }
.chat-page .header-mark { display: none; }
.chat-page #chat { padding: 26px clamp(18px, 4vw, 52px); gap: 16px; background-image: radial-gradient(circle at 92% 20%, rgba(100, 186, 183, .08), transparent 23%); }
.chat-page .bubble { max-width: min(82%, 1000px); padding: 14px 18px; color: var(--aero-ink-900); border: 1px solid var(--aero-border); border-radius: var(--aero-radius-md); background: rgba(255, 255, 255, .92); box-shadow: var(--aero-shadow-xs); line-height: 1.55; }
.chat-page .msg.user .bubble { color: var(--aero-ink-900); border: 1px solid var(--aero-primary-100); border-bottom-right-radius: 6px; background: var(--aero-gradient-message); box-shadow: var(--aero-shadow-xs); }
.chat-page .msg.agent, .chat-page .msg.agent .msg-row { width: 100%; }
.chat-page .msg.agent .bubble { width: 100%; max-width: none; border-bottom-left-radius: 6px; background: rgba(255, 255, 255, .94); }
.chat-page .bubble.md .md-table-scroll { max-width: 100%; overflow-x: auto; }
.chat-page .bubble.md table { display: table; width: max-content; max-width: none; border: 1px solid var(--aero-border); border-radius: 10px; border-collapse: separate; border-spacing: 0; }
.chat-page .bubble.md th { color: var(--aero-ink-700); background: #f5f8fc; }
.chat-page .bubble.md th, .chat-page .bubble.md td { border: 0; border-bottom: 1px solid var(--aero-border); }
.chat-page .bubble.md .answer-summary, .oversight-page .bubble .answer-summary {
  position: relative;
  display: block;
  margin: 16px -3px 5px;
  padding: 17px 18px 16px 20px;
  color: var(--aero-ink-950);
  border: 1px solid rgba(79, 118, 181, .32);
  border-left: 6px solid var(--aero-primary-500);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(226, 237, 255, .92), rgba(231, 249, 247, .9));
  box-shadow: 0 7px 18px rgba(46, 85, 139, .09);
  font-size: 1.02em;
}
.chat-page .bubble.md .answer-summary strong:first-child, .oversight-page .bubble .answer-summary strong:first-child {
  color: var(--aero-primary-700);
  letter-spacing: .035em;
  text-transform: uppercase;
}
.chat-page .empty { max-width: 720px; }
.chat-page .empty::before { width: 620px; height: 360px; background: url("/assets/backgrounds/aero-mesh.svg") center/cover; opacity: .62; border-radius: 50%; filter: blur(4px); }
.chat-page .empty h2 { color: var(--aero-ink-950); font-size: clamp(26px, 3vw, 36px); letter-spacing: -.04em; }
.chat-page .empty p.sub { margin-bottom: 28px; }
.chat-page .suggestions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: min(650px, 100%); margin: 0 auto; }
.chat-page .suggestion-chip { min-height: 54px; padding: 11px 14px; color: var(--aero-ink-700); border-color: var(--aero-border); border-radius: var(--aero-radius-sm); background: rgba(255, 255, 255, .82); box-shadow: var(--aero-shadow-xs); }
.chat-page .suggestion-chip:hover { color: var(--aero-primary-700); border-color: var(--aero-primary-200); background: var(--aero-primary-50); }
.chat-page footer { padding: 14px clamp(18px, 4vw, 52px) 20px; border-top: 0; background: linear-gradient(180deg, rgba(248, 251, 254, 0), rgba(248, 251, 254, .96) 30%); }
.chat-page #inputCard { max-width: none; min-height: 54px; padding: 8px 8px 8px 16px; border-color: var(--aero-border); border-radius: var(--aero-radius-md); background: rgba(255, 255, 255, .9); box-shadow: var(--aero-shadow-sm); }
.chat-page #inputCard:focus-within { border-color: var(--aero-primary-300); box-shadow: var(--aero-shadow-focus), var(--aero-shadow-sm); }
.chat-page #sendBtn { width: 40px; height: 40px; border-radius: 12px; background: var(--aero-gradient-brand); box-shadow: 0 7px 16px rgba(79, 118, 181, .2); }

/* Admin and operational screens */
.admin-page { min-height: 100vh; padding: 22px; }
.admin-page #app {
  width: min(1180px, 100%);
  max-width: none;
  min-height: calc(100vh - 44px);
  margin: 0 auto;
  padding: clamp(24px, 4vw, 44px);
  border: 1px solid rgba(255, 255, 255, .86);
  border-radius: var(--aero-radius-lg);
  background: rgba(255, 255, 255, .67);
  box-shadow: var(--aero-shadow-md);
  backdrop-filter: blur(20px);
}
.admin-page header { align-items: flex-start; margin-bottom: 28px; }
.admin-page header h1 { color: var(--aero-ink-950); font-size: 25px; letter-spacing: -.03em; }
.admin-page nav { gap: 7px; justify-content: flex-end; }
.admin-page nav a, .admin-page header > a {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  padding: 0 11px;
  color: var(--aero-ink-700);
  border: 1px solid var(--aero-border);
  border-radius: 10px;
  background: rgba(255, 255, 255, .7);
  font-size: 12px;
}
.admin-page nav a:hover, .admin-page header > a:hover { color: var(--aero-primary-700); border-color: var(--aero-primary-200); background: var(--aero-primary-50); }
.admin-page table { border-color: var(--aero-border); border-radius: var(--aero-radius-md); background: rgba(255,255,255,.9); box-shadow: var(--aero-shadow-sm); }
.admin-page th { color: var(--aero-ink-500); border-color: var(--aero-border); background: #f5f8fc; }
.admin-page td { border-color: var(--aero-border); }
.admin-page tbody tr:hover { background: rgba(241,246,253,.55); }
.admin-page .card, .admin-page .form-card { border-color: var(--aero-border); border-radius: var(--aero-radius-md); background: rgba(255,255,255,.86); box-shadow: var(--aero-shadow-sm); }
.admin-page input, .admin-page select, .admin-page textarea { min-height: 40px; color: var(--aero-ink-900); border-color: var(--aero-border); border-radius: 10px; background: #f8fafc; }
.admin-page input:focus, .admin-page select:focus, .admin-page textarea:focus { outline: none; border-color: var(--aero-primary-300); box-shadow: var(--aero-shadow-focus); }
.admin-page button { min-height: 38px; border-color: transparent; border-radius: 10px; background: var(--aero-gradient-brand); box-shadow: 0 6px 14px rgba(79, 118, 181, .14); font-weight: 600; }
.admin-page button.secondary { color: var(--aero-primary-700); border-color: var(--aero-primary-200); background: var(--aero-primary-50); box-shadow: none; }
.admin-page button.ghost { color: var(--aero-danger); border-color: #f2dadd; background: #fff6f7; box-shadow: none; }
.admin-page .modal { border-color: var(--aero-border); border-radius: var(--aero-radius-lg); background: rgba(255,255,255,.96); box-shadow: var(--aero-shadow-lg); }
.admin-page .modal-backdrop { background: rgba(13, 29, 58, .38); backdrop-filter: blur(7px); }
.admin-page .summary-bar { color: var(--aero-warning); border: 1px solid #f2e3cf; background: #fff9f0; }
.admin-page .card.new { border-left-color: var(--aero-warning); }
.admin-page .badge.new { color: var(--aero-warning); background: #fff5e8; }
.admin-page .badge.resolved { color: var(--aero-success); background: #edf9f3; }
.admin-page .note, .admin-page .role-note { color: var(--aero-ink-500); line-height: 1.55; }
.settings-page #app { width: min(1120px, 100%); }
.users-page #app { width: min(1440px, 100%); }
.settings-page .card { padding: 26px; gap: 20px; }
.settings-page .field label { color: var(--aero-ink-700); font-weight: 600; }
.settings-page #saveBtn { min-width: 140px; }

/* Shared mobile navigation for operational pages */
.app-menu-toggle, .app-menu-drawer, .app-menu-backdrop { display: none; }
@media (min-width: 801px) {
  .aero-page .app-menu-toggle { position: fixed; top: 16px; right: 18px; z-index: 102; display: inline-flex; width: 42px; height: 42px; min-height: 42px; align-items: center; justify-content: center; flex-direction: column; gap: 4px; padding: 0; border: 1px solid var(--aero-border); border-radius: 12px; background: #fff; box-shadow: var(--aero-shadow-sm); }
  .app-menu-toggle span { width: 18px; height: 2px; border-radius: 999px; background: var(--aero-ink-700); transition: transform .2s ease, opacity .2s ease; }
  .app-menu-toggle.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  .app-menu-toggle.open span:nth-child(2) { opacity: 0; }
  .app-menu-toggle.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
  .app-menu-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(13,29,58,.42); backdrop-filter: blur(3px); }
  .app-menu-backdrop.open { display: block; }
  .app-menu-drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 101; display: flex; width: 330px; padding: 72px 18px 18px; flex-direction: column; transform: translateX(105%); transition: transform .22s ease; border-left: 1px solid var(--aero-border); background: #fff; box-shadow: var(--aero-shadow-lg); }
  .app-menu-drawer.open { transform: translateX(0); }
  .app-menu-brand { display: flex; align-items: center; gap: 11px; padding: 0 5px 18px; border-bottom: 1px solid var(--aero-border); }
  .app-menu-brand img { width: 48px; height: auto; }
  .app-menu-brand div { display: grid; gap: 2px; }
  .app-menu-brand strong { color: var(--aero-ink-950); font-size: 15px; }
  .app-menu-brand span { color: var(--aero-ink-500); font-size: 11px; }
  .app-menu-drawer nav { display: grid; gap: 5px; margin-top: 18px; }
  .app-menu-drawer nav a { display: flex; min-height: 44px; align-items: center; padding: 0 13px; color: var(--aero-ink-700); border: 0; border-radius: 10px; background: transparent; font-size: 14px; text-decoration: none; }
  .app-menu-drawer nav a.active { color: var(--aero-primary-700); background: var(--aero-primary-50); font-weight: 600; }
  .aero-page .app-menu-logout { margin-top: auto; min-height: 42px; color: var(--aero-danger); border: 1px solid #f2dadd; border-radius: 10px; background: #fff6f7; box-shadow: none; font-size: 13px; }
  body.app-menu-open { overflow: hidden; }
}
@media (max-width: 800px) {
  .aero-page .app-menu-toggle {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 102;
    display: inline-flex;
    width: 42px;
    height: 42px;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    padding: 0;
    border: 1px solid var(--aero-border);
    border-radius: 12px;
    background: #fff;
    box-shadow: var(--aero-shadow-sm);
  }
  .app-menu-toggle span { width: 18px; height: 2px; border-radius: 999px; background: var(--aero-ink-700); transition: transform .2s ease, opacity .2s ease; }
  .app-menu-toggle.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  .app-menu-toggle.open span:nth-child(2) { opacity: 0; }
  .app-menu-toggle.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
  .app-menu-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(13,29,58,.42); backdrop-filter: blur(3px); }
  .app-menu-backdrop.open { display: block; }
  .app-menu-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 101;
    display: flex;
    width: min(86vw, 330px);
    padding: 72px 18px 18px;
    flex-direction: column;
    transform: translateX(105%);
    transition: transform .22s ease;
    border-left: 1px solid var(--aero-border);
    background: #fff;
    box-shadow: var(--aero-shadow-lg);
  }
  .app-menu-drawer.open { transform: translateX(0); }
  .app-menu-brand { display: flex; align-items: center; gap: 11px; padding: 0 5px 18px; border-bottom: 1px solid var(--aero-border); }
  .app-menu-brand img { width: 48px; height: auto; }
  .app-menu-brand div { display: grid; gap: 2px; }
  .app-menu-brand strong { color: var(--aero-ink-950); font-size: 15px; }
  .app-menu-brand span { color: var(--aero-ink-500); font-size: 11px; }
  .app-menu-drawer nav { display: grid; gap: 5px; margin-top: 18px; }
  .app-menu-drawer nav a { display: flex; min-height: 44px; align-items: center; padding: 0 13px; color: var(--aero-ink-700); border: 0; border-radius: 10px; background: transparent; font-size: 14px; text-decoration: none; }
  .app-menu-drawer nav a.active { color: var(--aero-primary-700); background: var(--aero-primary-50); font-weight: 600; }
  .aero-page .app-menu-logout { margin-top: auto; min-height: 42px; color: var(--aero-danger); border: 1px solid #f2dadd; border-radius: 10px; background: #fff6f7; box-shadow: none; font-size: 13px; }
  body.app-menu-open { overflow: hidden; }
  .admin-page > #app > header { padding-right: 54px; }
  .admin-page > #app > header nav, .admin-page > #app > header > a { display: none; }
}

/* Admin drawer is anchored to the left on every screen. */
.aero-page .app-menu-toggle { right: auto !important; left: 18px; }
.app-menu-drawer { right: auto !important; left: 0; transform: translateX(-105%) !important; border-right: 1px solid var(--aero-border); border-left: 0 !important; }
.app-menu-drawer.open { transform: translateX(0) !important; }
.app-menu-drawer nav { justify-content: start !important; text-align: left; }
.app-menu-drawer nav a { width: 100%; justify-content: flex-start; text-align: left; }
.aero-page .app-menu-logout { text-align: left; }
@media (max-width: 800px) {
  .aero-page .app-menu-toggle { left: 12px; }
  .admin-page > #app > header { padding-right: 0; padding-left: 54px; }
}

/* Analytics dashboard */
.stats-page #content { overflow: visible; }
.stats-page .metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.stats-page .metric-card { position: relative; min-height: 122px; overflow: hidden; padding: 18px; border: 1px solid var(--aero-border); border-radius: var(--aero-radius-md); background: rgba(255,255,255,.88); box-shadow: var(--aero-shadow-xs); }
.stats-page .metric-card::after { position: absolute; right: -18px; bottom: -28px; width: 90px; height: 90px; border-radius: 50%; background: var(--metric-glow, rgba(79,118,181,.09)); content: ""; }
.stats-page .metric-label { color: var(--aero-ink-500); font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.stats-page .metric-value { margin-top: 10px; color: var(--aero-ink-950); font-size: 29px; font-weight: 700; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.stats-page .metric-note { margin-top: 5px; color: var(--aero-ink-500); font-size: 11px; }
.stats-page .analytics-card .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stats-page .analytics-grid { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(260px, .85fr); gap: 14px; margin-bottom: 14px; }
.stats-page .analytics-card, .stats-page .stats-table-section { padding: 20px; border: 1px solid var(--aero-border); border-radius: var(--aero-radius-md); background: rgba(255,255,255,.88); box-shadow: var(--aero-shadow-xs); }
.stats-page .card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.stats-page .card-heading h2 { margin: 0; color: var(--aero-ink-950); font-size: 15px; letter-spacing: -.015em; }
.stats-page .card-heading p { margin: 4px 0 0; color: var(--aero-ink-500); font-size: 11px; }
.stats-page .chart-legend { display: flex; gap: 12px; color: var(--aero-ink-500); font-size: 10px; white-space: nowrap; }
.stats-page .chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.stats-page .chart-legend i { width: 14px; height: 3px; border-radius: 999px; background: var(--aero-primary-500); }
.stats-page .chart-legend span:last-child i { background: var(--aero-accent-500); }
.stats-page .chart-wrap { min-height: 230px; overflow: hidden; }
.stats-page .line-chart { display: block; width: 100%; height: 230px; }
.stats-page .chart-grid { stroke: #e7eef6; stroke-width: 1; }
.stats-page .chart-axis-label { fill: var(--aero-ink-400); font-size: 9px; }
.stats-page .topic-list { display: grid; gap: 15px; }
.stats-page .topic-row { display: grid; gap: 7px; }
.stats-page .topic-meta { display: flex; justify-content: space-between; gap: 12px; color: var(--aero-ink-700); font-size: 11px; }
.stats-page .topic-meta strong { color: var(--aero-ink-950); font-variant-numeric: tabular-nums; }
.stats-page .topic-track { height: 5px; overflow: hidden; border-radius: 999px; background: #edf2f7; }
.stats-page .topic-fill { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--aero-accent-500), var(--aero-primary-500)); }
.stats-page .unresolved-list { display: grid; gap: 8px; }
.stats-page .unresolved-item { padding: 10px 12px; border: 1px solid var(--aero-border); border-radius: 10px; background: #f8fbfd; }
.stats-page .unresolved-item strong { display: block; overflow: hidden; color: var(--aero-ink-800); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.stats-page .unresolved-item span { display: block; margin-top: 4px; color: var(--aero-ink-500); font-size: 10px; }
.stats-page .stats-table-section { margin-top: 14px; overflow: hidden; }
.stats-page .stats-table-scroll { overflow-x: auto; }
.stats-page .stats-table-section table { box-shadow: none; }
.stats-page .empty.compact { padding: 20px 8px; }

/* Read-only oversight */
.oversight-page { padding: 14px; overflow: hidden; }
.oversight-page #app { width: min(1500px, 100%); max-width: none; height: calc(100vh - 28px); overflow: hidden; border: 1px solid rgba(255,255,255,.9); border-radius: var(--aero-radius-lg); background: rgba(255,255,255,.64); box-shadow: var(--aero-shadow-md); }
.oversight-page #col1, .oversight-page #col2 { width: 250px; padding: 20px 14px; border-color: var(--aero-border); background: rgba(255,255,255,.74); }
.oversight-page .col-title { color: var(--aero-ink-500); font-weight: 700; }
.oversight-page .item { padding: 10px; border-radius: var(--aero-radius-sm); }
.oversight-page .item:hover { background: var(--aero-surface); }
.oversight-page .item.active { color: var(--aero-primary-700); background: var(--aero-primary-50); }
.oversight-page #main { background: rgba(248,251,254,.72); }
.oversight-page header { min-height: 68px; padding: 0 22px; border-color: var(--aero-border); background: rgba(255,255,255,.78); }
.oversight-page header h1 { color: var(--aero-ink-950); }
.oversight-page a.back, .oversight-page .back-btn { color: var(--aero-primary-700); }
.oversight-page #transcript { padding: 26px clamp(18px,4vw,52px); }
.oversight-page .bubble { padding: 14px 18px; color: var(--aero-ink-900); border: 1px solid var(--aero-border); border-radius: var(--aero-radius-md); background: rgba(255,255,255,.92); box-shadow: var(--aero-shadow-xs); }
.oversight-page .msg.user .bubble { color: var(--aero-ink-900); border-color: var(--aero-primary-100); background: var(--aero-gradient-message); }

@media (max-width: 800px) {
  html:has(body.admin-page:not(.oversight-page)) { height: auto; min-height: 100%; overflow-x: hidden; overflow-y: auto; }
  body.admin-page:not(.oversight-page) { position: static; width: 100%; height: auto !important; min-height: 100dvh; overflow-x: hidden !important; overflow-y: auto !important; touch-action: pan-y; -webkit-overflow-scrolling: touch; }
  body.admin-page:not(.oversight-page) > #app { height: auto !important; min-height: calc(100dvh - 20px); overflow: visible !important; }
  .login-page .login-shell { grid-template-columns: 1fr; }
  .login-page .login-brand { min-height: auto; align-items: center; justify-content: center; flex-direction: column; gap: 16px; padding: 34px 28px; border-right: 0; border-bottom: 1px solid var(--aero-border); text-align: center; }
  .login-page .login-brand img { position: static; order: -1; width: 80px; height: auto; transform: none; }
  .login-page .login-brand-copy { display: grid; justify-items: center; }
  .login-page .login-brand h1 { font-size: 28px; }
  .login-page .brand-chips { display: none; }
  .login-page form { margin: 18px; padding: 26px; }
  .admin-page { padding: 10px; }
  .admin-page #app { min-height: calc(100vh - 20px); padding: 22px 16px; }
  .admin-page header { gap: 14px; }
  .admin-page nav { justify-content: flex-start; }
  .stats-page .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-page .analytics-grid { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  html, body.chat-page { width: 100%; max-width: 100vw; height: 100%; overflow: hidden; overscroll-behavior: none; }
  .chat-page, .oversight-page { padding: 0; }
  .chat-page #app { position: fixed; inset: 0; width: 100%; height: var(--app-height, 100svh); min-height: 0; border: 0; border-radius: 0; }
  .oversight-page #app { height: 100dvh; border: 0; border-radius: 0; }
  .chat-page #sidebar { width: min(88%, 330px); padding-top: 18px; }
  .chat-page #main, .chat-page #chat, .chat-page footer, .chat-page .empty, .chat-page .suggestions, .chat-page #inputCard { width: 100%; max-width: 100%; min-width: 0; }
  .chat-page #chat { overflow-x: hidden; }
  .chat-page .empty { overflow: hidden; margin: clamp(16px, 5vh, 44px) auto 0; padding: 8px 16px 12px; }
  .chat-page .empty::before { width: min(620px, 100vw); max-width: 100%; }
  .chat-page #main > header { position: relative; z-index: 20; display: grid; min-height: calc(64px + env(safe-area-inset-top)); flex: 0 0 auto; grid-template-columns: 32px minmax(0, 1fr) auto auto; gap: 10px; padding: env(safe-area-inset-top) 12px 0; background: #fff; backdrop-filter: none; }
  .chat-page .chat-heading { min-width: 0; }
  .chat-page .chat-heading span { display: none; }
  .chat-page .chat-heading strong { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
  .chat-page #chatCostBadge { display: none !important; }
  .chat-page .header-mark { display: block; }
  .chat-page .header-mark img { display: block; width: 40px; height: auto; }
  .chat-page .active-topic-badge { max-width: min(42vw, 180px); margin-right: 4px; overflow: hidden; text-overflow: ellipsis; }
  .chat-page #chat { padding: 10px 12px; }
  .chat-page .empty h2 { margin-bottom: 6px; font-size: clamp(21px, 6.4vw, 27px); }
  .chat-page .topic-hero-picker { margin: 14px auto 12px; padding: 12px; }
  .chat-page .empty p.sub { margin-bottom: 12px; }
  .chat-page .suggestions { gap: 7px; }
  .chat-page .suggestion-chip { padding: 9px 11px; }
  .chat-page .bubble { max-width: 92%; font-size: 14px; }
  .chat-page .msg.agent .bubble { max-width: none; }
  .chat-page .suggestions { grid-template-columns: 1fr; }
  .chat-page .suggestion-chip { min-width: 0; overflow-wrap: anywhere; }
  .chat-page .suggestion-chip:nth-child(n+4) { display: none; }
  .chat-page footer { flex: 0 0 auto; padding: 10px 10px max(12px, env(safe-area-inset-bottom)); background: rgba(248,251,254,.98); }
  .chat-page #inputCard { min-height: 50px; }
  .chat-page #inputCard textarea { min-width: 0; }
  .chat-page #sidebarBackdrop { background: rgba(13,29,58,.48); backdrop-filter: none; }
  .oversight-page #col1, .oversight-page #col2 {
    position: absolute;
    inset: 0;
    width: 100%;
    max-width: none;
    padding: 68px 14px 18px;
    border-right: 0;
    background: #fff;
  }
  .oversight-page #col2 { transform: translateX(100%); }
  .oversight-page #app.show-col2 #col1 { transform: translateX(-100%); }
  .oversight-page #app.show-col2 #col2 { transform: translateX(0); }
  .oversight-page #app.show-main #col1,
  .oversight-page #app.show-main #col2 { transform: translateX(-100%); }
  .oversight-page #main > header { min-height: 64px; padding: 10px 12px 10px 62px; }
  .oversight-page #main > header a.back { display: none; }
  .oversight-page #main > header h1 { display: none; }
  .oversight-page #main > header .chat-export { margin-left: auto; }
}

@media (max-width: 480px) {
  .login-page { min-height: 100dvh; height: auto; padding: 0; place-items: stretch; overflow-y: auto; }
  .login-page .login-shell { min-height: 100dvh; align-content: start; border: 0; border-radius: 0; background: transparent; box-shadow: none; backdrop-filter: none; }
  .login-page .login-brand { padding: max(28px, env(safe-area-inset-top)) 22px 22px; border: 0; background: transparent; }
  .login-page .login-brand p { display: none; }
  .login-page form { align-self: start; margin: 8px 16px max(24px, env(safe-area-inset-bottom)); padding: 24px 20px; }
  .admin-page header h1 { font-size: 22px; }
  .admin-page nav a { min-height: 34px; padding: 0 9px; }
  .stats-page .metric-grid { grid-template-columns: 1fr; }
  .stats-page .analytics-card .metric-grid { grid-template-columns: 1fr; }
  .stats-page .metric-card { min-height: 104px; }
  .stats-page .analytics-card, .stats-page .stats-table-section { padding: 15px; }
  .stats-page .card-heading { flex-direction: column; }
}
.pwa-suggestion{position:fixed;z-index:2500;left:max(14px,env(safe-area-inset-left));right:max(14px,env(safe-area-inset-right));bottom:max(14px,calc(env(safe-area-inset-bottom) + 10px));display:flex;align-items:center;gap:11px;padding:12px;border:1px solid var(--aero-border-strong,#c8d7e8);border-radius:18px;background:rgba(255,255,255,.98);box-shadow:0 18px 50px rgba(31,67,104,.2);color:var(--aero-text,#10233f)}
.pwa-suggestion img{width:42px;height:42px;border-radius:12px}.pwa-suggestion-copy{display:flex;min-width:0;flex:1;flex-direction:column;gap:2px}.pwa-suggestion-copy strong{font-size:13px}.pwa-suggestion-copy span{font-size:11px;line-height:1.35;color:var(--aero-text-secondary,#64748b)}.pwa-suggestion-actions{display:flex;align-items:center;gap:5px}.pwa-suggestion-action,.pwa-suggestion-close{border:0;border-radius:12px;cursor:pointer}.pwa-suggestion-action{padding:9px 11px;background:linear-gradient(135deg,#6993d8,#4d9bc4);color:#fff;font-weight:700}.pwa-suggestion-close{width:30px;height:30px;background:#edf4fb;color:#49637f;font-size:20px;line-height:1}
@media(min-width:761px){.pwa-suggestion{left:auto;width:430px}}
