/* Cloud RADIUS portal. Visual system: docs/portal-design.md section 1. No inline styles anywhere (CSP), so every
   component's look lives here, one block per macro in templates/_ui.html. */

/* --- tokens ---------------------------------------------------------------------------------------------------- */
:root {
  color-scheme: light;
  --canvas: #f2f4f7; --surface: #ffffff; --surface-2: #f8f9fb; --border: #e2e5ea; --border-strong: #c9ced6;
  --text: #121826; --text-2: #3a4352; --muted: #586274;
  --accent: #2563eb; --accent-hover: #1d4ed8; --accent-tint: #eaf1fe; --accent-ink: #1e4fc2; --on-accent: #ffffff;
  --good: #067647; --good-tint: #e7f6ee; --warn: #8a3a00; --warn-tint: #fff4dc;
  --bad: #b42318; --bad-tint: #fdeceb; --neutral: #4a5567; --neutral-tint: #eef0f3;
  --chart-allowed: #2563eb; --chart-blocked: #d92d20; --chart-grid: #e2e5ea;
  --focus: #2563eb; --shadow-hover: 0 1px 3px rgba(16, 24, 40, .08);
  --viewas: #fff1c2; --viewas-ink: #6b3a00;
  --r-control: 8px; --r-card: 12px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --t12: 12px; --t13: 13px; --t14: 14px; --t16: 16px; --t20: 20px; --t24: 24px;
  --sidebar: 232px; --content-max: 1200px; --gutter: 24px;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --canvas: #0b0f17; --surface: #131a26; --surface-2: #19212f; --border: #263042; --border-strong: #3a465b;
    --text: #e7eaf0; --text-2: #c4cad5; --muted: #9ba5b6;
    --accent: #7aa7ff; --accent-hover: #a3c1ff; --accent-tint: #172744; --accent-ink: #a9c5ff; --on-accent: #ffffff;
    --good: #6fdca6; --good-tint: #10291e; --warn: #f6c453; --warn-tint: #2e230b;
    --bad: #ff9b91; --bad-tint: #3a1716; --neutral: #b7c0cf; --neutral-tint: #212a39;
    --chart-allowed: #6c9dff; --chart-blocked: #f2766b; --chart-grid: #263042;
    --focus: #7aa7ff; --shadow-hover: 0 1px 3px rgba(0, 0, 0, .4);
    --viewas: #3d2c06; --viewas-ink: #f9d77a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #0b0f17; --surface: #131a26; --surface-2: #19212f; --border: #263042; --border-strong: #3a465b;
  --text: #e7eaf0; --text-2: #c4cad5; --muted: #9ba5b6;
  --accent: #7aa7ff; --accent-hover: #a3c1ff; --accent-tint: #172744; --accent-ink: #a9c5ff; --on-accent: #ffffff;
  --good: #6fdca6; --good-tint: #10291e; --warn: #f6c453; --warn-tint: #2e230b;
  --bad: #ff9b91; --bad-tint: #3a1716; --neutral: #b7c0cf; --neutral-tint: #212a39;
  --chart-allowed: #6c9dff; --chart-blocked: #f2766b; --chart-grid: #263042;
  --focus: #7aa7ff; --shadow-hover: 0 1px 3px rgba(0, 0, 0, .4);
  --viewas: #3d2c06; --viewas-ink: #f9d77a;
}
/* The primary button keeps a dark-enough blue in both themes so white text stays readable (AA). */
:root { --button-primary: #2563eb; --button-primary-hover: #1d4ed8; }

/* --- base ------------------------------------------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--canvas); color: var(--text);
  font: 400 var(--t14)/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.3; }
h1 { font-size: var(--t20); }
h2 { font-size: var(--t16); }
h3 { font-size: var(--t14); }
p { margin: 0 0 var(--s3); }
p:last-child { margin-bottom: 0; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
strong, b { font-weight: 600; }
code, pre, .mono { font-family: var(--mono); font-size: var(--t13); }
pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-control); padding: var(--s3);
      overflow: auto; max-height: 420px; margin: 0; white-space: pre; }
ol, ul { margin: 0; padding-left: 20px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0);
           white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.small { font-size: var(--t13); }
.lead { color: var(--text-2); max-width: 72ch; margin-bottom: var(--s4); }
.nowrap { white-space: nowrap; }
.stack > :not(:first-child) { margin-top: var(--s4); }
.stack-sm > :not(:first-child) { margin-top: var(--s2); }
.row { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: var(--s3); align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); align-items: start; }
.section { margin-bottom: var(--s5); }
.section-title { font-size: var(--t13); font-weight: 600; color: var(--muted); margin: 0 0 var(--s2); }

/* --- icon ------------------------------------------------------------------------------------------------------ */
.icon { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.75;
        stroke-linecap: round; stroke-linejoin: round; vertical-align: -4px; }
.icon.sm { width: 16px; height: 16px; vertical-align: -3px; }
.icon.lg { width: 24px; height: 24px; }

/* --- app shell: sidebar, top bar, content ---------------------------------------------------------------------- */
.skip { position: absolute; left: var(--s2); top: -48px; z-index: 50; background: var(--surface); color: var(--accent);
        padding: var(--s2) var(--s3); border-radius: var(--r-control); border: 1px solid var(--border); }
.skip:focus { top: var(--s2); }
.viewas { display: flex; gap: var(--s2); align-items: center; justify-content: center; flex-wrap: wrap;
          background: var(--viewas); color: var(--viewas-ink); font-size: var(--t13); padding: 6px var(--s4);
          text-align: center; }
.viewas a { color: inherit; font-weight: 600; }
.viewas.info { background: var(--neutral-tint); color: var(--text-2); }
.shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar); flex: 0 0 var(--sidebar); background: var(--surface); border-right: 1px solid var(--border); }
.sidebar-inner { position: sticky; top: 0; max-height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
                 gap: var(--s3); padding: var(--s4) var(--s3); }
.brand { display: flex; align-items: center; gap: var(--s2); color: var(--text); text-decoration: none; font-weight: 600;
         font-size: var(--t16); padding: 0 var(--s2); }
.brand:hover { color: var(--text); }
.brand .mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--r-control);
               background: var(--button-primary); color: #fff; }
.brand .mark .icon { width: 18px; height: 18px; }
.main-col { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.content { width: 100%; max-width: calc(var(--content-max) + 2 * var(--gutter)); margin: 0 auto;
           padding: var(--s5) var(--gutter) var(--s6); flex: 1 0 auto; }
.footer { color: var(--muted); font-size: var(--t12); padding: var(--s3) var(--gutter) var(--s4); text-align: center; }

/* organization switcher */
.org { position: relative; }
.org-name { display: flex; align-items: center; gap: var(--s2); padding: var(--s2); border: 1px solid var(--border);
            border-radius: var(--r-control); font-weight: 600; min-width: 0; }
.org-name .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 auto; }
.org-name .eyebrow { display: block; font-size: var(--t12); font-weight: 400; color: var(--muted); }
details.menu > summary { list-style: none; cursor: pointer; }
details.menu > summary::-webkit-details-marker { display: none; }
details.org > summary:hover { background: var(--surface-2); }
details.org > summary .chev { margin-left: auto; color: var(--muted); }
details.menu[open] > summary .chev { transform: rotate(180deg); }
.menu-panel { position: absolute; z-index: 30; background: var(--surface); border: 1px solid var(--border);
              border-radius: var(--r-control); box-shadow: 0 8px 24px rgba(16, 24, 40, .14); padding: var(--s1);
              min-width: 100%; margin-top: var(--s1); }
.menu-panel ul { list-style: none; margin: 0; padding: 0; }
.menu-panel a, .menu-panel button.menu-item { display: flex; align-items: center; gap: var(--s2); width: 100%;
              padding: 6px var(--s2); border-radius: 6px; color: var(--text); text-decoration: none; background: none;
              border: 0; font: inherit; text-align: left; cursor: pointer; }
.menu-panel a:hover, .menu-panel button.menu-item:hover { background: var(--surface-2); color: var(--text); }
.menu-panel a[aria-current="page"] { background: var(--accent-tint); color: var(--accent-ink); }
.menu-panel hr { border: 0; border-top: 1px solid var(--border); margin: var(--s1) 0; }
.menu-panel .menu-head { padding: 6px var(--s2); }

/* navigation */
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: var(--s3); padding: 7px var(--s2); border-radius: var(--r-control);
         color: var(--text-2); text-decoration: none; }
.nav a .icon { color: var(--muted); }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent-tint); color: var(--accent-ink); font-weight: 600; }
.nav a[aria-current="page"] .icon { color: var(--accent-ink); }
.nav .ring { margin-left: auto; }
.nav-note { font-size: var(--t12); color: var(--muted); padding: 0 var(--s2); }

/* top bar */
.topbar { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; background: var(--surface);
          border-bottom: 1px solid var(--border); padding: var(--s3) var(--gutter); min-height: 64px; }
.topbar .titles { flex: 1 1 240px; min-width: 0; }
.crumbs { font-size: var(--t13); color: var(--muted); margin: 0 0 2px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }
.crumbs .sep { margin: 0 6px; }
.topbar h1 { overflow-wrap: anywhere; }
.topbar-actions { display: flex; align-items: center; gap: var(--s2); flex: 0 1 auto; min-width: 0; }
.menu-toggle { display: none; }
.hsearch { position: relative; margin: 0; width: 320px; max-width: 100%; }
.hsearch .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted);
                 pointer-events: none; }
.hsearch input { padding-left: 34px; }
.account { position: relative; }
.account > summary { display: flex; align-items: center; gap: var(--s2); padding: 4px; border-radius: 999px; }
.account > summary:hover { background: var(--surface-2); }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--accent-tint);
          color: var(--accent-ink); font-weight: 600; font-size: var(--t13); }
.account .menu-panel { right: 0; min-width: 240px; }
.theme-choice { display: flex; gap: var(--s1); padding: var(--s1) var(--s2) var(--s2); }
.theme-choice button { flex: 1; display: inline-flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px;
                       font: inherit; font-size: var(--t12); color: var(--text-2); background: var(--surface);
                       border: 1px solid var(--border); border-radius: var(--r-control); cursor: pointer; }
.theme-choice button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-tint); }

@media (max-width: 899px) {
  .shell { display: block; }
  .sidebar { position: fixed; z-index: 40; left: 0; top: 0; bottom: 0; height: auto; width: min(280px, 85vw);
             transform: translateX(-100%); visibility: hidden; transition: transform .15s ease-out, visibility .15s;
             box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0); }
  .sidebar.open { transform: none; visibility: visible; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: var(--s2) var(--s4); }
  .topbar-actions { flex: 1 1 100%; order: 3; }
  .topbar-actions .hsearch { flex: 1 1 auto; width: auto; }
  :root { --gutter: 16px; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

/* --- card ------------------------------------------------------------------------------------------------------ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); margin: 0 0 var(--s4);
        min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap;
             padding: var(--s4) var(--s4) 0; }
.card-head h2 { font-size: var(--t16); }
.card-actions { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.card-body { padding: var(--s4); }
.card-body.flush { padding: var(--s3) 0 0; }
a.card { display: block; color: inherit; text-decoration: none; transition: box-shadow .12s, border-color .12s; }
a.card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-hover); color: inherit; }
.card.tone-good { border-left: 3px solid var(--good); }
.card.tone-warn { border-left: 3px solid var(--warn); }
.card.tone-bad { border-left: 3px solid var(--bad); }
.card.tone-accent { border-left: 3px solid var(--accent); }
.card.narrow { max-width: 440px; margin-left: auto; margin-right: auto; }
.card-list { list-style: none; margin: 0; padding: 0; }
.card-list > li { display: flex; gap: var(--s3); align-items: flex-start; justify-content: space-between; flex-wrap: wrap;
                  padding: var(--s3) var(--s4); border-top: 1px solid var(--border); }
.card-list > li:first-child { border-top: 0; }
.card-list .title { font-weight: 600; }
.card-title-link { color: var(--text); text-decoration: none; }
.card-title-link:hover { color: var(--accent); text-decoration: underline; }
.card-list .detail { color: var(--muted); font-size: var(--t13); }
.card-foot { padding: var(--s3) var(--s4); border-top: 1px solid var(--border); font-size: var(--t13); }

/* --- metric ---------------------------------------------------------------------------------------------------- */
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s4); margin-bottom: var(--s4); }
.metric { display: flex; flex-direction: column; gap: 2px; background: var(--surface); border: 1px solid var(--border);
          border-radius: var(--r-card); padding: var(--s4); color: inherit; text-decoration: none; min-width: 0; }
a.metric:hover { border-color: var(--border-strong); box-shadow: var(--shadow-hover); color: inherit; }
.metric .label { color: var(--muted); font-size: var(--t13); }
.metric .value { font-size: var(--t24); font-weight: 600; line-height: 1.25; }
.metric .caption { font-size: var(--t13); color: var(--muted); }
.metric .caption.good { color: var(--good); } .metric .caption.warn { color: var(--warn); }
.metric .caption.bad { color: var(--bad); }
.metric .spark { width: 100%; height: 24px; margin-top: var(--s1); }
.metric .spark polyline { fill: none; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
@media (max-width: 1099px) { .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* --- status pill ----------------------------------------------------------------------------------------------- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: var(--t12); font-weight: 600; line-height: 1.5;
        padding: 1px 8px; border-radius: 999px; white-space: nowrap; vertical-align: middle; }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.pill-good { background: var(--good-tint); color: var(--good); }
.pill-warn { background: var(--warn-tint); color: var(--warn); }
.pill-bad { background: var(--bad-tint); color: var(--bad); }
.pill-neutral { background: var(--neutral-tint); color: var(--neutral); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: var(--neutral); }
.status-dot.good { background: var(--good); } .status-dot.warn { background: var(--warn); }
.status-dot.bad { background: var(--bad); }

/* --- table ----------------------------------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
.card > .table-wrap { border-top: 1px solid var(--border); margin-top: var(--s3); }
.card > .table-wrap:first-child { border-top: 0; margin-top: 0; }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--t14); }
table.table th, table.table td { text-align: left; padding: 10px var(--s4); border-bottom: 1px solid var(--border);
                                 vertical-align: top; }
table.table thead th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); color: var(--muted);
                       font-size: var(--t12); font-weight: 600; white-space: nowrap; }
table.table tbody tr:last-child > td { border-bottom: 0; }
table.table tbody tr:hover > td { background: var(--surface-2); }
table.table tr.dim td { color: var(--muted); }
table.table tr.flag td, table.table tr.urgent td { background: var(--bad-tint); }
table.table tr.detail > td { background: var(--surface-2); }
table.table td.actions, table.table th.actions { text-align: right; white-space: nowrap; width: 1%; }
table.table td.num, table.table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-title { font-weight: 600; }
.cell-sub { display: block; color: var(--muted); font-size: var(--t13); }
.row-actions { display: inline-flex; gap: 2px; align-items: center; }
.row-actions form { display: inline; margin: 0; }
/* Keeps the move buttons of the first and last rule in line with the others. */
.icon-spacer { display: inline-block; width: 32px; height: 32px; }
.source { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); white-space: nowrap; }
.source .icon { color: var(--muted); }
table.table td.empty-cell { padding: 0; }
table.table td.empty-cell:hover { background: none; }

/* --- empty state ----------------------------------------------------------------------------------------------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s2);
         padding: var(--s6) var(--s4); }
.empty .empty-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
                     background: var(--accent-tint); color: var(--accent-ink); margin-bottom: var(--s1); }
.empty h2, .empty h3 { font-size: var(--t16); }
.empty p { color: var(--muted); max-width: 46ch; margin: 0; }
.empty .button { margin-top: var(--s2); }
.empty.compact { padding: var(--s5) var(--s4); }

/* --- toasts ---------------------------------------------------------------------------------------------------- */
.toasts { position: fixed; right: var(--s4); bottom: var(--s4); z-index: 60; display: grid; gap: var(--s2);
          max-width: min(400px, calc(100vw - 32px)); }
.toast { display: flex; gap: var(--s2); align-items: flex-start; background: var(--surface); color: var(--text);
         border: 1px solid var(--border); border-left: 3px solid var(--good); border-radius: var(--r-control);
         padding: var(--s3) var(--s4); box-shadow: 0 8px 24px rgba(16, 24, 40, .16); }
.toast .icon { color: var(--good); }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity .3s, transform .3s; }

/* --- buttons --------------------------------------------------------------------------------------------------- */
.button, button { font: inherit; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 14px;
          border-radius: var(--r-control); border: 1px solid var(--border-strong); background: var(--surface);
          color: var(--text); font-weight: 600; text-decoration: none; cursor: pointer; line-height: 1.4;
          white-space: nowrap; }
.button:hover { background: var(--surface-2); color: var(--text); }
.button.primary { background: var(--button-primary); border-color: var(--button-primary); color: #fff; }
.button.primary:hover { background: var(--button-primary-hover); border-color: var(--button-primary-hover); color: #fff; }
.button.ghost { background: transparent; border-color: transparent; color: var(--accent); }
.button.ghost:hover { background: var(--accent-tint); color: var(--accent-ink); }
.button.danger { color: var(--bad); }
.button.small { padding: 3px 10px; font-size: var(--t13); }
.button:disabled, .button.disabled, .button[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.icon-button { position: relative; display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0;
               border-radius: var(--r-control); border: 1px solid transparent; background: transparent; color: var(--text-2);
               cursor: pointer; text-decoration: none; }
.icon-button:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.icon-button.danger:hover { color: var(--bad); }
.icon-button[aria-expanded="true"] .icon { transform: rotate(180deg); }
/* Tooltip from the accessible name: same words for mouse, keyboard and screen readers. */
[data-tip]::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); right: 0; z-index: 20;
                    background: var(--text); color: var(--surface); font-size: var(--t12); font-weight: 400;
                    padding: 3px 8px; border-radius: 6px; white-space: nowrap; pointer-events: none; opacity: 0;
                    transition: opacity .1s; }
[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; }
.link-button { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline;
               text-underline-offset: 2px; }

/* --- tabs and chips -------------------------------------------------------------------------------------------- */
.tabs { display: flex; gap: var(--s1); border-bottom: 1px solid var(--border); margin: 0 0 var(--s4); overflow-x: auto;
        scrollbar-width: thin; }
.tabs a { padding: var(--s2) var(--s3); color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent;
          margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--accent-ink); border-bottom-color: var(--accent); font-weight: 600; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; border: 0; margin: 0; padding: 0; }
.chips a, .chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px;
                  border: 1px solid var(--border-strong); color: var(--text-2); text-decoration: none;
                  font-size: var(--t13); cursor: pointer; background: var(--surface); }
.chips a:hover, .chip:hover { background: var(--surface-2); color: var(--text); }
.chips a[aria-current="true"], .chip:has(input:checked) { background: var(--accent-tint); border-color: var(--accent);
                                                          color: var(--accent-ink); font-weight: 600; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.chip:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.toolbar { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; padding: var(--s4) var(--s4) 0; }
.toolbar .search-field { flex: 1 1 220px; max-width: 360px; position: relative; }
.toolbar .search-field .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.toolbar .search-field input { padding-left: 34px; }
.toolbar select { width: auto; }

/* --- chart ----------------------------------------------------------------------------------------------------- */
.chart { margin: 0; }
.chart-plot { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s2); }
.chart-y { display: flex; flex-direction: column; justify-content: space-between; align-items: flex-end;
           font-size: var(--t12); color: var(--muted); font-variant-numeric: tabular-nums; height: 180px;
           margin-top: -7px; margin-bottom: -7px; }
.chart svg { display: block; width: 100%; height: 166px; }
.chart .grid line { stroke: var(--chart-grid); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .bar-allowed { fill: var(--chart-allowed); }
.chart .bar-blocked { fill: var(--chart-blocked); }
.chart-x { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); font-size: var(--t12); color: var(--muted);
           margin-top: var(--s1); grid-column: 2; }
.chart-x span { grid-column: span 6; white-space: nowrap; }
.chart-legend { display: flex; gap: var(--s4); flex-wrap: wrap; font-size: var(--t13); color: var(--text-2);
                margin-top: var(--s3); }
.chart-legend .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px;
                        vertical-align: -1px; }
.swatch.allowed { background: var(--chart-allowed); } .swatch.blocked { background: var(--chart-blocked); }
.chart figcaption { font-size: var(--t13); color: var(--text-2); margin-top: var(--s2); }
/* Other label counts (7 days: one per day; 30 days: one per 5 days; the health strip: one per 6 hours). */
.chart-x.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.chart-x.cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.chart-x.cols-7 { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.chart-x[class*="cols-"] span { grid-column: span 1; }

/* --- appliance health strip ------------------------------------------------------------------------------------ */
.strip { margin: 0; }
.strip svg { display: block; width: 100%; height: 20px; border-radius: 4px; }
.strip .chart-x { grid-column: auto; }
.strip .seg-up { fill: var(--good); }
.strip .seg-down { fill: var(--bad); }
.strip .seg-none { fill: var(--neutral-tint); }
.swatch.up { background: var(--good); } .swatch.down { background: var(--bad); }
.swatch.none { background: var(--neutral-tint); border: 1px solid var(--border-strong); }
.strip figcaption { font-size: var(--t13); color: var(--text-2); margin-top: var(--s2); }
.spark-lg { margin-top: var(--s3); }
.spark-lg .spark { display: block; width: 100%; height: 40px; }
.spark-lg .spark polyline { fill: none; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }

/* --- progress ring --------------------------------------------------------------------------------------------- */
.ring { flex: 0 0 auto; }
.ring circle { fill: none; stroke-width: 3; }
.ring .track { stroke: var(--border); }
.ring .done { stroke: var(--good); stroke-linecap: round; }
.ring-wrap { display: inline-flex; align-items: center; gap: var(--s3); }
.ring.big circle { stroke-width: 4; }

/* --- forms ----------------------------------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > .label { font-weight: 600; font-size: var(--t13); color: var(--text); }
.field > .label .optional { font-weight: 400; color: var(--muted); }
.help { font-size: var(--t13); color: var(--muted); }
.field-error { font-size: var(--t13); color: var(--bad); font-weight: 600; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--s4); align-items: start; }
:where(input:not([type="radio"]):not([type="checkbox"]):not([type="file"])), :where(select), :where(textarea) {
  font: inherit; width: 100%; padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: var(--r-control);
  background: var(--surface); color: var(--text); min-height: 36px; }
textarea { min-height: 96px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px;
                                                                    border-color: var(--focus); border-radius: var(--r-control); }
input[readonly] { background: var(--surface-2); }
input[type="file"] { font: inherit; max-width: 100%; color: var(--text-2); }
input[type="radio"], input[type="checkbox"] { accent-color: var(--button-primary); width: 16px; height: 16px; margin: 2px 0 0; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { font-weight: 600; font-size: var(--t13); margin-bottom: var(--s2); padding: 0; }
.choices { display: grid; gap: var(--s2); }
.choice { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3); border: 1px solid var(--border);
          border-radius: var(--r-control); cursor: pointer; background: var(--surface); }
.choice:hover { border-color: var(--border-strong); }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-tint); }
.choice .choice-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.choice select { width: auto; margin-top: var(--s1); }
.form-actions { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
form.inline { display: inline-flex; gap: var(--s2); align-items: center; flex-wrap: wrap; margin: 0; }

/* --- notices (inline callouts) --------------------------------------------------------------------------------- */
.notice { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border-radius: var(--r-control);
          border: 1px solid transparent; margin: 0 0 var(--s4); }
.notice > .icon { margin-top: 1px; }
.notice .notice-body { flex: 1 1 auto; min-width: 0; }
.notice .notice-actions { display: flex; gap: var(--s2); align-items: center; }
.notice.info { background: var(--accent-tint); color: var(--accent-ink); }
.notice.good { background: var(--good-tint); color: var(--good); }
.notice.warn { background: var(--warn-tint); color: var(--warn); }
.notice.bad { background: var(--bad-tint); color: var(--bad); }
.notice a, .notice .link-button { color: inherit; font-weight: 600; }

/* --- disclosure ("Details") ------------------------------------------------------------------------------------ */
details.more > summary { cursor: pointer; color: var(--muted); font-size: var(--t13); width: fit-content; }
details.more > summary:hover { color: var(--text); }
details.more[open] > summary { margin-bottom: var(--s2); }
details.more .mono { overflow-wrap: anywhere; }

/* --- one-click fix --------------------------------------------------------------------------------------------- */
details.fix, details.edit { display: inline-block; }
details.fix > summary, details.edit > summary { list-style: none; }
details.fix > summary::-webkit-details-marker, details.edit > summary::-webkit-details-marker { display: none; }
details.fix[open] > summary, details.edit[open] > summary { margin-bottom: var(--s2); }
.fixform, .editform { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: flex-end; padding: var(--s3);
                      background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-control); }
.fixform .field, .editform .field { flex: 1 1 160px; }
.fixnote { color: var(--text-2); font-size: var(--t13); }

/* --- pages ----------------------------------------------------------------------------------------------------- */
.greeting { display: flex; gap: var(--s4); align-items: flex-start; justify-content: space-between; flex-wrap: wrap;
            margin-bottom: var(--s4); }
.greeting h2 { font-size: var(--t20); }
.greeting p { color: var(--text-2); margin: 2px 0 0; }
.site-line { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.site-line a.title { color: var(--text); text-decoration: none; }
.site-line a.title:hover { color: var(--accent); text-decoration: underline; }
/* Device and site pages: status and actions above the cards. */
.detail-head { display: flex; gap: var(--s4); align-items: flex-start; justify-content: space-between; flex-wrap: wrap;
               margin-bottom: var(--s4); }
.detail-grid { margin-bottom: var(--s4); }
.detail-grid > .card { margin: 0; }
.rule-line { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-control);
             padding: var(--s2) var(--s3); font-weight: 600; }
.plain-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s1); font-size: var(--t13); }
a.cell-title { color: var(--text); text-decoration: none; }
a.cell-title:hover { color: var(--accent); text-decoration: underline; }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px var(--s5); margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.tenant-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--s4);
               margin-bottom: var(--s5); }
.tenant-grid .card { margin: 0; }
.tenant-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); margin-top: var(--s3); }
.tenant-stats .value { font-size: var(--t16); font-weight: 600; display: block; }
.tenant-stats .label { font-size: var(--t12); color: var(--muted); }
.code { font-family: var(--mono); font-size: 32px; letter-spacing: .1em; font-weight: 600; margin: var(--s1) 0 var(--s3); }
.center { text-align: center; }
.steps-list { display: grid; gap: var(--s2); list-style: none; padding: 0; margin: 0; }
.steps-list > li { display: flex; gap: var(--s4); align-items: center; padding: var(--s4); border: 1px solid var(--border);
                   border-radius: var(--r-card); background: var(--surface); flex-wrap: wrap; }
.steps-list > li.current { border-color: var(--accent); }
.steps-list .mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; flex: 0 0 auto;
                    background: var(--neutral-tint); color: var(--neutral); font-weight: 600; }
.steps-list li.done .mark { background: var(--good-tint); color: var(--good); }
.steps-list li.current .mark { background: var(--button-primary); color: #fff; }
.steps-list .step-text { flex: 1 1 240px; min-width: 0; }
.steps-list .step-text a { color: var(--text); font-weight: 600; text-decoration: none; }
.steps-list .step-text a:hover { color: var(--accent); }
.waiting { color: var(--warn); font-weight: 600; font-size: var(--t13); margin: 2px 0 0; }
.checks-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s2); }
.checks-list li { display: flex; gap: var(--s3); align-items: flex-start; }
.checks-list .icon { margin-top: 1px; }
.checks-list .pass .icon { color: var(--good); } .checks-list .warn .icon { color: var(--warn); }
.checks-list .fail .icon { color: var(--bad); } .checks-list .info .icon { color: var(--muted); }
.verdict { display: flex; gap: var(--s2); align-items: center; font-size: var(--t16); font-weight: 600; margin-bottom: var(--s3); }
.verdict.ok { color: var(--good); } .verdict.bad { color: var(--bad); }
.results { list-style: none; margin: 0; padding: 0; }
.results li { padding: var(--s2) var(--s4); border-top: 1px solid var(--border); }
.results li:first-child { border-top: 0; }
ol.plain-steps, ol.steps { padding-left: 20px; display: grid; gap: var(--s1); }
.download-list { display: flex; gap: var(--s2); flex-wrap: wrap; list-style: none; padding: 0; margin: 0 0 var(--s3); }

/* login and the signed-out pages */
.solo { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
        padding: var(--s5) var(--s4); }
.solo .card { width: 100%; max-width: 400px; }
.solo .brand { justify-content: center; margin-bottom: var(--s5); font-size: var(--t20); }
.login h1 { text-align: center; margin-bottom: var(--s4); }
.sso { display: grid; gap: var(--s2); }
.sso .button { justify-content: center; padding: 9px 14px; }
.sso img { width: 18px; height: 18px; }
details.password { margin-top: var(--s4); }
details.password > summary { cursor: pointer; text-align: center; color: var(--accent); list-style: none;
                             font-weight: 600; }
details.password > summary::-webkit-details-marker { display: none; }
details.password[open] > summary { margin-bottom: var(--s4); }
.form-error { background: var(--bad-tint); color: var(--bad); padding: var(--s2) var(--s3); border-radius: var(--r-control);
              margin-bottom: var(--s4); font-weight: 600; }

@media (max-width: 899px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 559px) {
  .metrics { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s2); }
  .metric { padding: var(--s3); }
  .metric .value { font-size: var(--t20); }
  .facts { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .facts dd { margin-bottom: var(--s2); }
  table.table th, table.table td { padding: 10px var(--s3); }
  .tenant-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .toolbar { padding: var(--s3) var(--s3) 0; }
}
.org .menu-panel { position: static; box-shadow: none; }
.login .button.primary { width: 100%; }
/* Home alerts: one thin row each; the severity pill carries the colour. */
.card-list.alert-list > li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center;
                            gap: var(--s3); padding: 6px var(--s4); }
.alert-list form { margin: 0; }
@media (max-width: 559px) { .card-list.alert-list > li { align-items: start; } .alert-list .pill { margin-top: 2px; } }

/* Live setup and MSP onboarding (docs/portal-design.md section 4, items 5 and 8). */
.celebrate { display: flex; gap: var(--s4); align-items: center; padding: var(--s3); border-radius: var(--r-control);
             background: var(--good-tint); }
.celebrate-mark { color: var(--good); display: inline-flex; }
@media (prefers-reduced-motion: no-preference) {
  .celebrate-mark { animation: celebrate-pop .6s ease-out 1; }
  @keyframes celebrate-pop { 0% { transform: scale(.4); opacity: 0; } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }
}
.code-block { display: grid; gap: var(--s1); min-width: 0; }
.code-block pre { max-height: 360px; }
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s3); }
.checklist .card-head h2 { display: flex; align-items: center; gap: var(--s2); }
.checklist .mark { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
                   border: 1px solid var(--border); font-size: var(--t12); flex: none; }
.checklist li.done .mark { background: var(--good-tint); color: var(--good); border-color: transparent; }
.checklist li.done .card { opacity: .85; }
.checklist .card-actions form { margin: 0; }
.pending { padding-top: var(--s3); border-top: 1px solid var(--border); }
.pending h3 { margin: 0; }
.filters { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); align-items: end; }
.detail-cell { overflow-wrap: anywhere; min-width: 200px; }
.pager { display: flex; gap: var(--s3); align-items: center; justify-content: center; margin-top: var(--s4); }
