  :root {
    color-scheme: dark;
    --bg: #08090d;
    --panel: #11131a;
    --panel-raised: #171a22;
    --border: #252a35;
    --border-strong: #353c49;
    --text: #eef1f6;
    --muted: #8a93a3;
    --accent: #8ca2ff;
    --accent-strong: #6f86ef;
    --danger: #f0917f;
  }
  * { box-sizing: border-box; }
  [hidden] { display: none !important; }
  html { min-height: 100%; background: var(--bg); }
  body {
    min-height: 100vh;
    margin: 0;
    padding: 2.2rem 1.25rem 4rem;
    background:
      radial-gradient(circle at 50% -10%, rgba(91, 111, 190, .2), transparent 34rem),
      linear-gradient(180deg, #0b0d13 0, var(--bg) 34rem);
    color: var(--text);
    font: 14px/1.55 ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  }
  input, select, textarea, button { font: inherit; }
  input, select, textarea {
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #0d0f15;
    color: var(--text);
    padding: .55rem .7rem;
    outline: none;
    transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
  }
  input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(140, 162, 255, .14);
    background: #10131a;
  }
  select { padding-right: 1.8rem; }
  textarea { resize: vertical; }
  button {
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    background: #1a1e27;
    color: #e8ebf1;
    padding: .5rem .9rem;
    cursor: pointer;
    transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
  }
  button:hover { border-color: #4a5262; background: #222733; }
  button:active { transform: translateY(1px); }
  button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  button:disabled { cursor: wait; opacity: .58; transform: none; }
  button.primary {
    border-color: #7d91ed;
    background: linear-gradient(180deg, #8ea4ff, #7188ef);
    color: #090b11;
    font-weight: 700;
  }
  button.primary:hover { border-color: #9cacff; background: linear-gradient(180deg, #9badff, #7d93f6); }
  a { color: #a7b8ff; text-decoration: none; }
  .muted { color: var(--muted); }
  .bad { color: var(--danger); }
  .brandMark {
    display: inline-grid;
    width: 2.35rem;
    height: 2.35rem;
    place-items: center;
    flex: 0 0 auto;
    border: 1px solid rgba(161, 177, 255, .52);
    border-radius: 11px;
    background: linear-gradient(145deg, rgba(140, 162, 255, .2), rgba(65, 75, 119, .14));
    color: #cbd4ff;
    font-size: .8rem;
    font-weight: 800;
    letter-spacing: -.03em;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08);
  }
  #gate {
    display: flex;
    min-height: calc(100vh - 6.2rem);
    align-items: center;
    justify-content: center;
    padding: 2rem 0;
  }
  #loginForm {
    position: relative;
    display: block;
    width: min(100%, 27rem);
    margin: 0;
    overflow: hidden;
    border: 1px solid rgba(126, 139, 169, .3);
    border-radius: 20px;
    background: rgba(16, 19, 27, .94);
    padding: 2rem;
    box-shadow: 0 28px 80px rgba(0, 0, 0, .42), inset 0 1px 0 rgba(255, 255, 255, .04);
    backdrop-filter: blur(18px);
  }
  #loginForm::before {
    position: absolute;
    inset: 0 0 auto;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(160, 176, 255, .72), transparent);
    content: '';
  }
  .loginBrand { display: flex; align-items: center; gap: .75rem; font-weight: 700; letter-spacing: -.01em; }
  .loginHead { margin: 2.1rem 0 1.5rem; }
  .loginHead h1 { margin: 0; font-size: 1.65rem; line-height: 1.2; letter-spacing: -.035em; }
  #loginRecipient { margin-top: .45rem; color: var(--muted); overflow-wrap: anywhere; }
  .fieldLabel { display: block; margin: 0 0 .5rem; color: #b8bfcc; font-size: .8rem; font-weight: 650; }
  #loginEmail { width: 100%; height: 3.1rem; }
  .codeGrid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .5rem; }
  .codeCell {
    width: 100%;
    min-width: 0;
    aspect-ratio: 1 / 1.08;
    padding: 0;
    border-radius: 11px;
    text-align: center;
    caret-color: var(--accent);
    font-size: 1.55rem;
    font-weight: 720;
    font-variant-numeric: tabular-nums;
  }
  .loginActions { display: flex; align-items: center; gap: .65rem; margin-top: 1.25rem; }
  #loginRun { min-height: 2.8rem; flex: 1; }
  #loginReset { border-color: transparent; background: transparent; color: var(--muted); }
  #loginReset:hover { border-color: var(--border); color: var(--text); }
  #loginError { display: block; min-height: 1.35rem; margin-top: .8rem; font-size: .8rem; }
  #googleLogin, #loginPendingReset { width: 100%; min-height: 2.8rem; margin-top: .75rem; }
  #loginPending { min-height: 4.35rem; padding-top: 1.1rem; color: #cbd4ff; text-align: center; font-weight: 650; }
  #app { display: none; width: min(100%, 72rem); margin: 0 auto; }
  header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 1.4rem;
  }
  .portalBrand { display: flex; align-items: center; gap: .7rem; }
  .brandCopy { display: grid; line-height: 1.2; }
  .brandCopy strong { font-size: .92rem; }
  .brandCopy small { margin-top: .2rem; color: var(--muted); font-size: .68rem; }
  #who { display: flex; justify-self: end; align-items: center; gap: .7rem; }
  #version { color: #687080; font-size: 12px; }
  nav { display: flex; gap: .25rem; border: 1px solid var(--border); border-radius: 11px; background: rgba(17, 19, 26, .9); padding: .25rem; }
  nav button { border: 0; border-radius: 7px; background: none; color: #929aaa; padding: .38rem .95rem; }
  .connectionLink { border: 0; background: transparent; padding: .15rem 0; color: var(--text); text-align: left; }
  .connectionLink:hover { border-color: transparent; background: transparent; color: #b8c5ff; }
  .occupancyCue { width: 1%; white-space: nowrap; text-align: right; }
  .availabilityCue {
    display: inline-grid; place-items: center; width: 1.2rem; height: 1.2rem; min-height: 0;
    padding: 0; border-color: #765052; border-radius: 50%; background: #2a191b; color: #f0a59a;
    font-size: .72rem; font-weight: 800; line-height: 1;
  }
  .availabilityCue:hover { border-color: #a96a6d; background: #352023; }
  .rowUsage { min-width: 20rem; }
  .rowUsage .lim { display: block; }
  #providerSummaries td:nth-child(3) { white-space: nowrap; }
  #providerSummaries .providerNote td { border-top: 0; padding-top: 0; font-size: 12px; }
  #connectionFilters { display: flex; flex-wrap: wrap; gap: .5rem; }
  .pinList { display: grid; gap: .45rem; margin: 0; padding: 0; list-style: none; }
  .pinList li { display: grid; grid-template-columns: 1fr auto; gap: 0 .65rem; align-items: center; }
  .pinList li .muted { grid-column: 1; font-size: 11px; }
  .pinList li button { grid-column: 2; grid-row: 1 / span 2; padding: .25rem .5rem; font-size: 11px; }
  .controlGroup { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: .45rem; margin: .65rem 0; }
  .controlGroup input { width: 5rem; }
  .skeletonLine {
    display: inline-block; width: min(24rem, 72%); height: .8rem; border-radius: 99px;
    background: linear-gradient(90deg, #171a22 20%, #242936 45%, #171a22 70%);
    background-size: 220% 100%; animation: skeleton 1.25s ease-in-out infinite;
  }
  .skeletonLine.short { width: 4rem; }
  .skeletonLine.usage { width: min(18rem, 90%); }
  @keyframes skeleton { from { background-position: 100% 0; } to { background-position: -120% 0; } }
  nav button:hover { background: #1c2029; }
  nav button.on { background: #292e3a; color: #f4f6fa; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04); }
  section {
    margin-bottom: 1.1rem;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 15px;
    background: rgba(15, 17, 23, .92);
    padding: 1.1rem 1.25rem;
    box-shadow: 0 18px 45px rgba(0, 0, 0, .14);
  }
  table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
  td, th { border-top: 1px solid #20242d; padding: .52rem .9rem .52rem 0; text-align: left; vertical-align: top; font-size: 13px; font-weight: normal; }
  th { border-top: 0; color: #7f8796; font-size: 11px; letter-spacing: .05em; text-transform: uppercase; }
  .bar { display: inline-block; width: 9rem; height: .5rem; overflow: hidden; margin-right: .5rem; border: 1px solid #2a303a; border-radius: 99px; background: #191d25; vertical-align: middle; }
  .bar i { display: block; height: 100%; border-radius: 99px; background: #758df5; }
  .bar i.warn { background: #d9a03f; }
  .bar i.full { background: #e05f52; }
  .bar.trackLow { background: #1c2650; border-color: #2a3a78; }
  .bar.trackWarn { background: #3f2c0c; border-color: #6b4a14; }
  .bar.trackFull { background: #431a16; border-color: #6f2822; }
  .lim { white-space: nowrap; }
  td.act { white-space: nowrap; }
  td.act button { padding: .3rem .6rem; font-size: 12px; margin-right: .35rem; }
  .chip {
    display: inline-block; max-width: 22rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    vertical-align: middle; border: 1px solid #5a4a2e; border-radius: 999px; background: #1e1a14; color: #e8c98a;
    padding: .2rem .65rem; font-size: 12px; line-height: 1.4; cursor: pointer;
  }
  .chip:hover { border-color: #8a7042; background: #262019; }
  .chip.stale { border-color: #6b3d3d; background: #1f1414; color: #f0a59a; }
  #snack { position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); display: grid; gap: .45rem; z-index: 40; pointer-events: none; }
  .toast {
    min-width: 16rem; max-width: 34rem; border: 1px solid var(--border-strong); border-radius: 10px; background: #171a22;
    color: var(--text); padding: .55rem .9rem; font-size: 13px; box-shadow: 0 8px 28px rgba(0, 0, 0, .45);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; animation: toastIn 140ms ease-out;
  }
  .toast.ok { border-color: #3f7a4c; }
  .toast.bad { border-color: #8a3f3a; }
  @keyframes toastIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
  dialog#inspect { border: 1px solid var(--border-strong); border-radius: 12px; background: var(--panel-raised); color: var(--text); padding: 1.1rem 1.25rem; max-width: 30rem; width: calc(100vw - 2rem); }
  dialog#inspect::backdrop { background: rgba(4, 5, 8, .6); }
  dialog#inspect h3 { margin: 0 0 .6rem; font-size: 15px; }
  dialog#inspect dl { display: grid; grid-template-columns: 8rem 1fr; gap: .3rem .8rem; margin: 0 0 .9rem; font-size: 13px; }
  dialog#inspect dt { color: var(--muted); }
  dialog#inspect dd { margin: 0; overflow-wrap: anywhere; }
  dialog#inspect .actions { display: flex; gap: .5rem; justify-content: flex-end; }
  button[data-revoke] { color: #f0a59a; }
  #minted { display: block; margin: .6rem 0 0; word-break: break-all; color: #9fdca4; font: 13px ui-monospace, Menlo, monospace; }
  #consoleSessions { margin-top: 1.4rem; }
  .cardBar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .9rem; }
  .cardBar span, #performanceMetricLabel { color: #7d8594; font-size: 12px; letter-spacing: .05em; text-transform: uppercase; }
  #performanceMetricLabel { text-decoration: underline dotted; text-underline-offset: .25em; }
  #spendChart svg, #performanceChart svg { display: block; width: 100%; height: auto; }
  #spendChart, #performanceChart { position: relative; }
  .xhair { position: absolute; top: 0; bottom: 16px; display: none; width: 1px; background: #43434f; pointer-events: none; }
  .tip { position: absolute; top: 8px; z-index: 2; display: none; min-width: 12rem; border: 1px solid #303642; border-radius: 9px; background: #171a22; padding: .5rem .7rem; font-size: 12px; pointer-events: none; }
  .tip .tipDay { margin-bottom: .3rem; color: #7d8594; font-size: 11px; letter-spacing: .05em; text-transform: uppercase; }
  .tip .tipRow { display: flex; justify-content: space-between; gap: 1.2rem; }
  .tip .tipRow b { color: #e8e8ee; font-weight: 500; font-variant-numeric: tabular-nums; }
  .legend { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; margin-top: .7rem; color: #969eac; font-size: 12px; }
  .dot { display: inline-block; width: 8px; height: 8px; margin-right: .45rem; border-radius: 2px; vertical-align: 0; }
  #spendStats, #performanceStats, #performanceCounts { display: grid; grid-template-columns: repeat(auto-fit, minmax(7.2rem, 1fr)); gap: .7rem; margin-top: 1rem; }
  .stat { border: 1px solid #252a34; border-radius: 10px; background: #151820; padding: .65rem .8rem; }
  .stat b { display: block; color: #f4f4f8; font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
  .stat span { color: #7b8493; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
  #performanceChart { min-height: 240px; touch-action: none; user-select: none; }
  #performanceChart:focus-visible { outline: 2px solid #758df5; outline-offset: 4px; border-radius: 4px; }
  #performanceChart .tip { max-width: calc(100% - 1rem); min-width: min(12rem, calc(100% - 1rem)); }
  #performanceStatus { margin: .7rem 0 0; font-size: 12px; }
  #performanceControls { display: flex; gap: .5rem; }
  #performanceControls select { min-width: 0; max-width: 100%; }
  #performanceChart .emptyChart { padding-top: 6rem; text-align: center; }
  .percentileLine { display: inline-block; width: 1rem; margin-right: .4rem; border-top: 2px solid; vertical-align: middle; }
  #paceRows { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: .7rem; margin-bottom: 1rem; }
  #paceRows:empty { display: none; }
  .pace { border: 1px solid #252a34; border-radius: 10px; background: #151820; padding: .65rem .8rem; }
  .paceTop { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
  .paceName { color: #7b8493; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
  .paceVal { color: #7b8493; font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .paceVal b { color: #f4f4f8; font-size: 15px; font-weight: 600; }
  .pace svg { display: block; width: 100%; height: 34px; margin-top: .45rem; }
  form { display: flex; align-items: center; gap: .5rem; margin-top: .9rem; }
  dialog {
    width: min(calc(100% - 2rem), 29rem);
    border: 1px solid var(--border-strong);
    border-radius: 16px;
    background: #12151c;
    color: var(--text);
    padding: 0;
    box-shadow: 0 32px 90px rgba(0, 0, 0, .62);
  }
  dialog::backdrop { background: rgba(3, 5, 9, .72); backdrop-filter: blur(5px); }
  .dialogForm { display: block; margin: 0; padding: 1.25rem; }
  .dialogHead { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
  .dialogHead h2 { margin: 0; font-size: 1.1rem; letter-spacing: -.015em; }
  .dialogHead p { margin: .2rem 0 0; color: var(--muted); font-size: .78rem; }
  .iconButton { width: 2rem; height: 2rem; border-color: transparent; background: transparent; padding: 0; color: var(--muted); font-size: 1.2rem; line-height: 1; }
  .field { display: grid; gap: .45rem; margin-bottom: 1rem; }
  .field label { color: #b8bfcc; font-size: .78rem; font-weight: 650; }
  .field input, .field select, .field textarea { width: 100%; }
  .field textarea { min-height: 7rem; }
  .dialogActions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.2rem; }
  .dialogError { min-height: 1.35rem; margin: .75rem 0 0; font-size: .78rem; }
  @media (max-width: 760px) {
    body { padding: 1rem .75rem 2.5rem; }
    #gate { min-height: calc(100vh - 3.5rem); }
    #loginForm { padding: 1.5rem; }
    header { grid-template-columns: 1fr auto; }
    nav { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; min-width: 0; flex-wrap: wrap; }
    nav button { flex: 1; }
    #who { grid-column: 2; grid-row: 1; }
    #version { display: none; }
    section { padding: 1rem; }
    .cardBar { align-items: stretch; flex-direction: column; }
    .cardBar > div { flex-wrap: wrap; }
    #connections tr:first-child { display: none; }
    #connections tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
    #connections td { padding-right: 0; }
    #connections td:first-child { min-width: 0; grid-column: 1; grid-row: 1; }
    #connections .connectionLink { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
    #connections .occupancyCue { grid-column: 2; grid-row: 1; padding-left: .6rem; }
    #connections .rowUsage { min-width: 0; grid-column: 1 / -1; grid-row: 2; padding-top: .2rem; }
    #connections .rowUsage .lim { white-space: normal; }
    #connections .rowUsage .bar { width: min(9rem, 38vw); }
  }
  @media (max-width: 390px) {
    .codeGrid { gap: .35rem; }
    .codeCell { border-radius: 9px; font-size: 1.3rem; }
    #userLabel { display: none; }
  }

#performanceControls { align-items: center; flex-wrap: wrap; }
#performanceCoverage { font-size: 12px; white-space: nowrap; }
