:root {
  color-scheme: dark;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  --bg: #080910;
  --bg-elevated: #0d0f19;
  --panel: #121521;
  --panel-soft: #191d2c;
  --panel-hover: #252a40;
  --line: #373d5d;
  --line-soft: #272b40;
  --text: #f4f5fb;
  --muted: #989eb6;
  --muted-bright: #c7cbe0;
  --accent: #19dff2;
  --accent-strong: #65ecfa;
  --accent-ink: #061317;
  --danger: #ff7f79;
  --warning: #f3c969;
  --info: #8a19ff;
  --brand-violet: #8a19ff;
  --brand-fusion: #19dff2;
  --sidebar-width: 272px;
  --shadow: 0 24px 70px rgb(0 0 0 / 30%);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 95% 0, rgb(101 54 244 / 24%), transparent 38rem),
    var(--bg);
}

button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.login-screen {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 100vh;
  place-items: center;
  padding: 32px;
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(320px, .92fr) minmax(360px, 1.08fr);
  min-width: 0;
  width: min(980px, 100%);
  min-height: 610px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-brand-panel {
  position: relative;
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: space-between;
  padding: 52px;
  overflow: hidden;
  background:
    linear-gradient(150deg, rgb(101 54 244 / 58%), transparent 57%),
    linear-gradient(160deg, #19122e, #0b0c16);
}

.login-brand-panel::after {
  position: absolute;
  right: -120px;
  bottom: -120px;
  width: 380px;
  height: 380px;
  border: 1px solid rgb(25 223 242 / 16%);
  border-radius: 50%;
  box-shadow: 0 0 0 52px rgb(138 25 255 / 7%), 0 0 0 105px rgb(25 223 242 / 3%);
  content: "";
}

.brand-lockup { display: flex; align-items: center; gap: 16px; }
.brand-lockup--hero { max-width: 100%; margin: 13px 0 14px; gap: clamp(10px, 1.5vw, 14px); }
.login-logo { width: clamp(48px, 5vw, 60px); height: clamp(48px, 5vw, 60px); flex: none; }
.brand-wordmark { font-family: Inter, "Segoe UI", system-ui, sans-serif; font-weight: 800; white-space: nowrap; }
.brand-grid, .brand-fusion { font: inherit; letter-spacing: inherit; }
.brand-fusion { color: var(--brand-fusion); }
.login-brand-panel h1 { min-width: 0; margin: 0; font-size: clamp(1.7rem, 3.2vw, 2.35rem); line-height: 1; letter-spacing: -.04em; }
.login-brand-panel p:not(.eyebrow) { max-width: 34rem; color: var(--muted-bright); font-size: 1.03rem; line-height: 1.7; }
.login-brand-foot { position: relative; z-index: 1; display: flex; align-items: center; gap: 10px; color: var(--muted-bright); font-size: .86rem; }
.signal-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 6px rgb(25 223 242 / 12%); }

.login-form-panel {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: flex-start;
  padding: 52px clamp(38px, 7vw, 80px);
  background: linear-gradient(160deg, rgb(255 255 255 / 2%), transparent);
}

.login-copy { min-width: 0; }
.login-copy h2 { margin: 0; font-size: clamp(2rem, 4vw, 3rem); letter-spacing: -.035em; }
.login-copy > p:last-child { margin: 13px 0 34px; color: var(--muted); line-height: 1.6; }
.login-form { display: flex; min-width: 0; flex: 1; flex-direction: column; gap: 10px; }
.login-form label { margin-top: 7px; color: var(--muted-bright); font-size: .84rem; font-weight: 700; }
.login-copyright { margin: auto 0 0; color: var(--muted-bright); font-size: .86rem; text-align: right; }

input, select, textarea {
  width: 100%;
  min-height: 45px;
  border: 1px solid #3b4264;
  border-radius: 11px;
  outline: 0;
  color: var(--text);
  background: #0b0d17;
  padding: 11px 13px;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); background: #101421; box-shadow: 0 0 0 3px rgb(25 223 242 / 14%); }
input:disabled, select:disabled { opacity: .62; cursor: not-allowed; }

.button, .icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 750;
  transition: transform .16s ease, background .16s ease, border-color .16s ease, opacity .16s ease;
}

.button { padding: 9px 15px; }
.button svg, .icon-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.button:hover:not(:disabled), .icon-button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled, .icon-button:disabled { opacity: .45; cursor: not-allowed; }
.button.primary { color: var(--accent-ink); background: var(--accent); }
.button.primary:hover:not(:disabled) { background: var(--accent-strong); }
.button.secondary { border-color: var(--line); color: var(--text); background: var(--panel-soft); }
.button.secondary:hover:not(:disabled), .button.ghost:hover:not(:disabled) { border-color: #6655a0; background: var(--panel-hover); }
.button.ghost { border-color: var(--line); color: var(--muted-bright); background: transparent; }
.button.danger { border-color: rgb(255 127 121 / 35%); color: #ffd2cf; background: rgb(116 32 32 / 28%); }
.button.small { min-height: 32px; padding: 6px 10px; border-radius: 8px; font-size: .8rem; }
.login-submit { min-height: 49px; margin-top: 17px; }
.icon-button { width: 40px; min-height: 40px; padding: 0; border-color: var(--line); background: var(--panel-soft); }
.form-message { margin: 8px 0 0; padding: 10px 12px; border-radius: 9px; font-size: .84rem; }
.error-message { border: 1px solid rgb(255 127 121 / 28%); color: #ffc1bd; background: rgb(120 37 35 / 23%); }

.portal-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  z-index: 50;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: var(--sidebar-width);
  border-right: 1px solid var(--line-soft);
  background: rgb(11 12 22 / 97%);
  box-shadow: 14px 0 50px rgb(0 0 0 / 15%);
}
.sidebar-top { min-height: 0; overflow-y: auto; padding: 25px 20px 18px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand img { width: 43px; height: 43px; }
.brand-copy { display: grid; }
.brand strong { font-size: 1.17rem; letter-spacing: .01em; }
.brand small { margin-top: 1px; color: var(--muted); font-size: .73rem; }
.sidebar-caption { display: grid; gap: 3px; margin: 23px 7px 12px; }
.sidebar-caption span { color: var(--accent); font-size: .64rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.sidebar-caption strong { font-size: 1.24rem; }
.navigation { display: grid; gap: 2px; }
.nav-section-label { margin: 12px 10px 3px; color: #777e9d; font-size: .62rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.nav-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin: 13px 0 4px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: #9ba2bf;
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-size: .9rem;
  font-weight: 760;
  letter-spacing: .01em;
}
.nav-section-toggle:hover { color: var(--text); background: rgb(255 255 255 / 6%); }
.nav-section-toggle.is-active { border-color: rgb(138 25 255 / 22%); color: var(--accent-strong); background: rgb(138 25 255 / 10%); }
.nav-section-title { display: flex; min-width: 0; align-items: center; gap: 9px; }
.nav-section-title svg { width: 19px; height: 19px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-section-chevron { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 2; transition: transform .18s ease; }
.nav-section-toggle[aria-expanded="true"] .nav-section-chevron { transform: rotate(90deg); }
.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 39px;
  padding: 7px 11px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--muted-bright);
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-weight: 680;
}
.nav-link svg { width: 19px; height: 19px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-link:hover { color: var(--text); background: rgb(255 255 255 / 7%); }
.nav-link.is-active { border-color: rgb(138 25 255 / 28%); color: var(--accent-strong); background: linear-gradient(90deg, rgb(138 25 255 / 18%), rgb(25 223 242 / 5%)); }
.nav-link.is-child { min-height: 35px; padding-left: 30px; font-size: .84rem; }
.nav-link.is-child svg { width: 16px; height: 16px; }
.sidebar-bottom { position: relative; border-top: 1px solid var(--line-soft); padding: 15px; }
.profile-button { display: flex; align-items: center; width: 100%; gap: 10px; border: 0; border-radius: 12px; padding: 8px; color: var(--text); background: transparent; cursor: pointer; text-align: left; }
.profile-button:hover { background: var(--panel-hover); }
.profile-avatar { display: grid; flex: 0 0 39px; width: 39px; height: 39px; place-items: center; border: 1px solid #654bb4; border-radius: 10px; color: var(--accent-strong); background: #221a3c; font-size: .77rem; font-weight: 850; }
.profile-meta { display: grid; min-width: 0; flex: 1; }
.profile-meta strong, .profile-meta small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-meta strong { font-size: .86rem; }
.profile-meta small { margin-top: 2px; color: var(--muted); font-size: .7rem; }
.profile-button > svg { width: 17px; height: 17px; fill: none; stroke: var(--muted); stroke-width: 1.8; transition: transform .18s; }
.profile-button[aria-expanded="true"] > svg { transform: rotate(180deg); }
.profile-menu { position: absolute; right: 15px; bottom: 74px; left: 15px; display: grid; gap: 3px; padding: 7px; border: 1px solid var(--line); border-radius: 12px; background: #151827; box-shadow: var(--shadow); }
.profile-menu button { padding: 10px; border: 0; border-radius: 8px; color: var(--muted-bright); background: transparent; cursor: pointer; text-align: left; font-size: .82rem; }
.profile-menu button:hover { color: var(--text); background: var(--panel-hover); }

.workspace { min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar { display: flex; align-items: center; min-height: 118px; gap: 22px; padding: 24px clamp(24px, 4vw, 58px); border-bottom: 1px solid var(--line-soft); background: rgb(8 9 16 / 84%); backdrop-filter: blur(16px); }
.page-heading { min-width: 0; flex: 1; }
.page-heading h1 { margin: 0; font-size: clamp(1.7rem, 3vw, 2.25rem); letter-spacing: -.035em; }
.page-heading > p:last-child { margin: 7px 0 0; color: var(--muted); font-size: .9rem; }
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; }
.activity-indicator { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 7px 11px; color: var(--muted-bright); font-size: .78rem; white-space: nowrap; }
.spinner { display: inline-block; width: 24px; height: 24px; flex: 0 0 auto; background: transparent url("./gridfusion-loading.gif") center / contain no-repeat; }
.menu-button { display: none; }
.view-content { width: min(1550px, 100%); margin: 0 auto; padding: 32px clamp(24px, 4vw, 58px) 70px; outline: none; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 25px; }
.stat-card, .panel, .definition-card { border: 1px solid var(--line-soft); background: linear-gradient(145deg, rgb(24 27 43 / 96%), rgb(14 16 27 / 98%)); box-shadow: 0 14px 36px rgb(0 0 0 / 14%); }
.stat-card { min-height: 148px; padding: 20px; border-radius: 16px; }
.stat-card > span { color: var(--muted); font-size: .76rem; font-weight: 700; }
.stat-card strong { display: block; margin: 15px 0 8px; font-size: 2.15rem; line-height: 1; letter-spacing: -.045em; }
.stat-card p { margin: 0; color: var(--muted); font-size: .76rem; line-height: 1.45; }
.stat-card.accent strong { color: var(--accent-strong); }
.panel { margin-bottom: 20px; overflow: hidden; border-radius: 16px; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 19px 21px; border-bottom: 1px solid var(--line-soft); }
.panel-header h2, .panel-header h3 { margin: 0; font-size: 1.05rem; }
.panel-header p { margin: 5px 0 0; color: var(--muted); font-size: .78rem; }
.panel-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.panel-body { padding: 21px; }
.two-column { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.definition-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.definition-card { padding: 19px; border-radius: 14px; }
.definition-card > span { color: var(--muted); font-size: .72rem; font-weight: 750; text-transform: uppercase; letter-spacing: .08em; }
.definition-card strong { display: block; margin-top: 9px; overflow-wrap: anywhere; font-size: .94rem; }
.definition-card p { margin: 8px 0 0; color: var(--muted); font-size: .77rem; line-height: 1.5; }

.list-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.search-field { position: relative; flex: 1 1 auto; min-width: 0; width: 100%; }
.list-toolbar > .button { flex: 0 0 auto; }
.search-field svg { position: absolute; top: 50%; left: 13px; width: 18px; height: 18px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 1.8; }
.search-field input { padding-left: 40px; background: var(--panel); }
.table-wrap { width: 100%; overflow-x: auto; }
.lazy-load-sentinel { min-height: 52px; padding: 16px 20px; color: var(--muted); font-size: .75rem; text-align: center; }
table { width: 100%; border-collapse: collapse; font-size: .82rem; }
th, td { padding: 13px 15px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: middle; }
th { color: #858ca9; background: rgb(8 9 16 / 46%); font-size: .68rem; font-weight: 820; letter-spacing: .07em; text-transform: uppercase; white-space: nowrap; }
tbody tr { transition: background .14s; }
tbody tr:hover { background: rgb(138 25 255 / 9%); }
tbody tr:last-child td { border-bottom: 0; }
.clickable-row { cursor: pointer; }
.clickable-row:focus { outline: 2px solid var(--accent); outline-offset: -2px; background: rgb(25 223 242 / 9%); }
.clickable-row:focus:not(:focus-visible) { outline: 0; }
.primary-cell { min-width: 170px; }
.primary-cell strong, .primary-cell span { display: block; }
.primary-cell span { margin-top: 3px; color: var(--muted); font-size: .7rem; }

.release-items-row > td { padding: 0 14px 14px; border-top: 0; }
.release-items { padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(4, 14, 24, .56); }
.release-items-title { margin-bottom: 9px; color: var(--muted); font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.release-items-table { min-width: 700px; }
.release-items-table th, .release-items-table td { padding: 9px 10px; }
.release-items-table tbody tr:last-child td { border-bottom: 0; }
.release-item-order { width: 44px; color: var(--muted); font-variant-numeric: tabular-nums; }
.release-item-kind { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 9px; border-radius: 999px; color: var(--muted); background: rgba(118, 138, 154, .16); font-size: .68rem; font-weight: 700; white-space: nowrap; }
.release-item-kind.is-bugfix { color: #ffb1a6; background: rgba(220, 74, 57, .17); }
.release-item-kind.is-feature { color: #78e5b8; background: rgba(28, 176, 116, .17); }
.release-item-kind.is-change { color: #8ad8ff; background: rgba(38, 148, 210, .17); }
.firmware-digest { overflow-wrap: anywhere; }
.mono { font-family: "Cascadia Mono", Consolas, monospace; font-size: .74rem; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted-bright); background: #1b1e30; font-size: .68rem; font-weight: 800; white-space: nowrap; }
.status-pill::before { width: 6px; height: 6px; border-radius: 50%; background: currentColor; content: ""; }
.status-good { border-color: rgb(25 223 242 / 28%); color: var(--accent-strong); background: rgb(10 105 126 / 20%); }
.status-warn { border-color: rgb(243 201 105 / 27%); color: var(--warning); background: rgb(111 83 22 / 18%); }
.status-bad { border-color: rgb(255 127 121 / 28%); color: #ffaaa5; background: rgb(119 38 35 / 20%); }
.status-info { border-color: rgb(138 25 255 / 32%); color: #c5a0ff; background: rgb(83 29 141 / 22%); }
.status-neutral { color: var(--muted-bright); }

.empty-state, .loading-state, .error-state { display: grid; min-height: 220px; place-items: center; padding: 35px; color: var(--muted); text-align: center; }
.empty-state strong, .error-state strong { display: block; margin-bottom: 7px; color: var(--text); font-size: 1rem; }
.error-state { color: #ffaaa5; }
.loading-state .spinner { width: 24px; height: 24px; }

@media (prefers-reduced-motion: reduce) {
  .login-logo { content: url("./gridfusion-mark.svg"); }
  .spinner { background-image: url("./gridfusion-mark.svg"); }
}
.range-toolbar { display: grid; grid-template-columns: repeat(2, minmax(180px, 1fr)) auto; align-items: end; gap: 10px; width: min(700px, 100%); }
.field { display: grid; gap: 6px; }
.field label { color: var(--muted-bright); font-size: .74rem; font-weight: 700; }
.field-hint { color: var(--muted); font-size: .71rem; line-height: 1.45; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.span-all { grid-column: 1 / -1; }
.inline-note { margin: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted-bright); background: #10131f; font-size: .77rem; line-height: 1.55; }
.inline-note.warning { border-color: rgb(243 201 105 / 25%); color: #efd898; }
.action-stack { display: flex; flex-wrap: wrap; gap: 7px; }
.button-row { display: flex; flex-wrap: wrap; gap: 9px; }
.credential-button { margin-top: 7px; }
.provider-count { color: var(--muted-bright); font-size: .76rem; white-space: nowrap; }
.detail-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.detail-toolbar > span { color: var(--muted); font-size: .78rem; }
.detail-tabs { display: flex; gap: 4px; padding: 0 18px; overflow-x: auto; border-bottom: 1px solid var(--line-soft); background: rgb(8 9 16 / 28%); }
.user-detail-shell { display: grid; grid-template-rows: auto auto auto; }
.user-detail-shell > .panel-header { grid-row: 1; }
.user-detail-shell > .detail-tabs { grid-row: 2; }
.user-detail-shell > .detail-tab-panel { min-width: 0; grid-column: 1; grid-row: 3; }
.user-detail-shell > .detail-tab-panel[hidden] { display: block !important; visibility: hidden; pointer-events: none; }
.service-tabs-panel { width: 100%; overflow: hidden; }
.service-tabs { width: 100%; padding: 0; }
.service-tabs .detail-tab { flex: 1 1 0; justify-content: center; }
.detail-tab { position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 52px; padding: 0 15px; border: 0; color: var(--muted); background: transparent; font: inherit; font-size: .8rem; font-weight: 780; white-space: nowrap; cursor: pointer; }
.detail-tab:hover { color: var(--text); background: var(--panel-hover); }
.detail-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
.detail-tab.is-active { color: var(--accent-strong); }
.detail-tab.is-active::after { position: absolute; right: 12px; bottom: 0; left: 12px; height: 3px; border-radius: 3px 3px 0 0; background: var(--accent); content: ""; }
.detail-tab span { min-width: 23px; padding: 3px 7px; border-radius: 999px; color: var(--muted-bright); background: #27213f; font-size: .66rem; text-align: center; }
.detail-tab-panel[hidden] { display: none; }
.tab-section { padding: 21px; border-top: 1px solid var(--line-soft); }
.detail-tab-panel > .tab-section:first-child { border-top: 0; }
.tab-section h3 { margin: 0; font-size: .98rem; }
.tab-section > p { margin: 6px 0 16px; font-size: .77rem; }
.read-only-control { min-height: 42px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted-bright); background: #10131f; }
.toggle-control { display: flex; align-items: flex-start; gap: 12px; margin: 0 21px 18px; padding: 15px 16px; border: 1px solid var(--line); border-radius: 11px; background: #10131f; cursor: pointer; }
.toggle-control input { width: 18px; height: 18px; flex: 0 0 auto; margin: 2px 0 0; accent-color: var(--accent); }
.toggle-control span { display: grid; gap: 4px; }
.toggle-control strong { color: var(--text); font-size: .84rem; }
.toggle-control small { color: var(--muted); font-size: .74rem; line-height: 1.5; }
.debug-control-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; margin-top: 15px; }
.toggle-control.compact { min-height: 100%; margin: 0; align-items: center; }
.debug-channel-field { margin-top: 15px; }
#device-panel-debug .inline-note,
#device-panel-ai-data .error-message { margin: 0 21px 18px; }

.app-dialog { width: min(720px, calc(100% - 30px)); max-height: min(850px, calc(100vh - 30px)); padding: 0; overflow: hidden; border: 1px solid #4a4772; border-radius: 18px; color: var(--text); background: #121521; box-shadow: 0 35px 100px rgb(0 0 0 / 55%); }
.app-dialog::backdrop { background: rgb(4 5 10 / 74%); backdrop-filter: blur(4px); }
.dialog-shell { display: flex; max-height: inherit; flex-direction: column; }
.dialog-header, .dialog-footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 17px 20px; }
.dialog-header { border-bottom: 1px solid var(--line-soft); }
.dialog-header h2 { margin: 0; font-size: 1.2rem; }
.dialog-content { min-height: 0; overflow-y: auto; padding: 21px; }
.dialog-footer { justify-content: flex-end; border-top: 1px solid var(--line-soft); }
.dialog-footer:empty { display: none; }
.dialog-wide { width: min(960px, calc(100% - 30px)); }

.toast-region { position: fixed; z-index: 100; right: 22px; bottom: 22px; display: grid; gap: 9px; width: min(380px, calc(100% - 44px)); }
.toast { padding: 13px 15px; border: 1px solid #4d6d91; border-radius: 11px; color: var(--text); background: #16243a; box-shadow: var(--shadow); font-size: .82rem; line-height: 1.45; animation: toast-in .2s ease-out; }
.toast.error { border-color: rgb(255 127 121 / 45%); background: #3b1b1a; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.sidebar-backdrop { position: fixed; z-index: 40; inset: 0; background: rgb(4 5 10 / 68%); backdrop-filter: blur(2px); }

@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .definition-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .activity-indicator span:last-child { display: none; }
}

@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr; min-height: 0; }
  .login-brand-panel { min-height: 275px; padding: 34px; }
  .login-brand-panel p:not(.eyebrow) { max-width: 40rem; }
  .sidebar { transform: translateX(-105%); transition: transform .22s ease; }
  .sidebar.is-open { transform: translateX(0); }
  .workspace { margin-left: 0; }
  .menu-button { display: inline-flex; }
  .topbar { min-height: 104px; padding: 18px 22px; }
  .view-content { padding: 24px 22px 58px; }
  .desktop-logout { display: none; }
  .two-column { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .login-screen { padding: 14px; }
  .login-shell { border-radius: 20px; }
  .login-brand-panel { min-height: 245px; padding: 27px; }
  .brand-lockup--hero { gap: 10px; }
  .login-brand-panel h1 { font-size: clamp(1.55rem, 8.2vw, 2.15rem); }
  .login-logo { width: 46px; height: 46px; }
  .login-brand-panel p:not(.eyebrow) { font-size: .88rem; }
  .login-brand-foot { font-size: .74rem; }
  .login-form-panel { padding: 32px 25px; }
  .topbar { align-items: flex-start; flex-wrap: wrap; gap: 12px; }
  .page-heading { width: calc(100% - 55px); }
  .topbar-actions { width: 100%; justify-content: flex-end; }
  .topbar-actions .button span { display: none; }
  .view-content { padding-right: 15px; padding-left: 15px; }
  .stat-grid, .definition-grid, .form-grid, .debug-control-grid { grid-template-columns: 1fr; }
  .span-all { grid-column: auto; }
  .stat-card { min-height: 128px; }
  .list-toolbar, .panel-header { align-items: stretch; flex-direction: column; }
  .list-toolbar > .button { width: 100%; }
  .detail-tabs { padding: 0 8px; }
  .detail-tab { padding: 0 11px; }
  .panel-actions { justify-content: flex-start; }
  .range-toolbar { grid-template-columns: 1fr; }
  th, td { padding: 11px 12px; }
  .dialog-footer { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
