/* Ulysses: the Hub back office look (server-hub/Backoffice, Angular Material), rebuilt
   without Angular. Same class names where possible: .page-header, .page-filters, .filters,
   .list-table, .status-badge, .empty-state. Shell from the Hub's app.ts (top bar, sidebar,
   content card on a light gray background). docs/plan.md, "Look".

   Themes: the defaults below are the Hub's neutral black and white, used by the admin
   space. A brand's user space overrides the base tokens with `brands.theme` (base.html):
   --bg, --surface, --text, --primary, --on-primary, and `scheme` (light or dark). Every
   other shade derives from them, so a dark brand (BetBreaker) works without extra rules. */

:root {
  color-scheme: light;
  /* base tokens */
  --bg: #f7f7f8;
  --surface: #fff;
  --text: #000;
  --primary: #000;
  --on-primary: #fff;
  --danger: #dc2626;
  --success: #2e7d32;
  --warning: #f57f17;
  /* derived shades of the text color (the Hub's rgba(0, 0, 0, x)) */
  --text-1: color-mix(in srgb, var(--text) 87%, transparent);
  --text-2: color-mix(in srgb, var(--text) 70%, transparent);
  --muted: color-mix(in srgb, var(--text) 50%, transparent);
  --faint: color-mix(in srgb, var(--text) 38%, transparent);
  --border: color-mix(in srgb, var(--text) 12%, transparent);
  --border-focus: color-mix(in srgb, var(--text) 30%, transparent);
  --line: color-mix(in srgb, var(--text) 8%, transparent);
  --line-soft: color-mix(in srgb, var(--text) 5%, transparent);
  --hover: color-mix(in srgb, var(--text) 5%, transparent);
  --active: color-mix(in srgb, var(--text) 8%, transparent);
  --tint: color-mix(in srgb, var(--text) 3%, transparent);
  --radius: 8px;
}

/* The admin's dark look (Preferences: dark, or system on a dark computer); every other shade
   derives from these. Brand spaces never set data-theme: their own theme applies. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111113;
  --surface: #1b1b1e;
  --text: #ececef;
  --primary: #ececef;
  --on-primary: #111113;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    color-scheme: dark;
    --bg: #111113;
    --surface: #1b1b1e;
    --text: #ececef;
    --primary: #ececef;
    --on-primary: #111113;
  }
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: Roboto, "Helvetica Neue", sans-serif;
  font-size: 14px;
  color: var(--text-1);
  background: var(--surface);
}

h1 { font-size: 24px; font-weight: 500; margin: 0; }
h2 { font-size: 18px; font-weight: 500; }
a { color: inherit; }

.material-icons { font-size: 20px; line-height: 1; }

/* ── Shell ── */
.shell { display: flex; flex-direction: column; height: 100vh; background: var(--bg); }

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 0 20px;
  flex-shrink: 0;
}
.topbar-logo { width: 28px; height: 28px; border-radius: 7px; }
.topbar-brand { font-size: 15px; font-weight: 600; white-space: nowrap; }
.topbar-spacer { flex: 1; }

.body { flex: 1; display: flex; min-height: 0; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar-main { flex: 1; overflow-y: auto; }

/* The signed-in member, at the bottom of the sidebar: a menu opening upwards */
.account-menu { position: relative; margin-top: 8px; }
.account-button {
  list-style: none; display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: var(--radius); cursor: pointer; color: var(--text-1);
}
.account-button::-webkit-details-marker { display: none; }
.account-button:hover, .account-menu[open] .account-button { background: var(--hover); }
.account-avatar {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--text-1); color: var(--surface); font-size: 13px; font-weight: 600;
}
.account-names { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.account-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-chevron { font-size: 18px; color: var(--muted); }
.account-menu-list {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 30;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); padding: 6px; min-width: 220px;
}
.account-menu-head { display: flex; flex-direction: column; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.account-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0;
  border-radius: 6px; background: none; color: var(--text-1); font: inherit; font-size: 14px;
  text-decoration: none; cursor: pointer; text-align: left;
}
.account-menu-item:hover { background: var(--hover); }
.account-menu-item .material-icons { color: var(--muted); }
.account-menu-hint { margin-left: auto; font-size: 12px; color: var(--muted); }
.account-menu-divider { height: 1px; background: var(--line); margin: 4px 0; }
.sidebar-section-label {
  padding: 16px 10px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s;
}
.sidebar-item:hover { background: var(--hover); }
.sidebar-item--active { background: var(--active); color: var(--text); }
.sidebar-item--disabled { cursor: default; color: var(--faint); }
.sidebar-item--disabled:hover { background: none; }
.sidebar-icon { color: var(--muted); }
.sidebar-item--active .sidebar-icon { color: var(--primary); }
.sidebar-item--disabled .sidebar-icon { color: var(--faint); }

.content-wrapper {
  flex: 1;
  min-width: 0;
  margin: 0 12px 8px 0;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
  display: flex;
  flex-direction: column;
}
.content { flex: 1; overflow-y: auto; padding: 16px 32px; }

/* ── Page header and filters, sticky (Hub styles.scss) ── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 40px;
  padding: 16px 32px 12px;
  margin: -16px -32px 16px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: -16px;
  background: var(--surface);
  z-index: 10;
}
/* not sticky: a sticky filter bar slid over the top of the table when the page scrolled */
.page-filters { margin: 0 0 16px; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

/* ── Buttons: primary filled, secondary tinted, text, danger red ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border: none;
  border-radius: var(--radius);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn .material-icons { font-size: 18px; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: color-mix(in srgb, var(--primary) 85%, var(--on-primary)); }
.btn-secondary { background: var(--active); color: var(--text); }
.btn-secondary:hover { background: color-mix(in srgb, var(--text) 12%, transparent); }
.btn-text { background: transparent; color: var(--text); }
.btn-text:hover { background: var(--hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 85%, #000); }
.btn:disabled, .btn[aria-disabled="true"] { cursor: default; opacity: 0.35; }
.btn[aria-disabled="true"] { cursor: help; }
.btn-icon { width: 18px; height: 18px; }

/* ── Form fields (native inputs in place of Material fields) ── */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.input, .field input, .field select, .field textarea {
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font: inherit;
  color: var(--text);
}
.field textarea { height: auto; padding: 8px 10px; }
/* a set of checkboxes in a field (e.g. a brand's blocked DNS categories) */
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 6px 0; }
.field .check { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; color: var(--text); }
.field .check input { width: 16px; height: 16px; padding: 0; margin: 0; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--border-focus);
}
.field .hint { font-size: 12px; color: var(--muted); }
.field .error { font-size: 12px; color: var(--danger); }

/* ── Filter bar (Hub _list-table.scss) ── */
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filter-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.filter-input-wrap:focus-within { border-color: var(--border-focus); }
.filter-input-icon { font-size: 18px; color: var(--faint); }
.filter-input {
  border: none;
  outline: none;
  font: inherit;
  color: var(--text);
  background: transparent;
  width: 240px;
  min-width: 0;
}
.filter-input::placeholder { color: var(--muted); }
.filter-select {
  height: 38px;
  padding: 0 32px 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  /* the system look (and its blue focus ring) replaced by the fields' own */
  appearance: none;
  background: var(--surface) no-repeat right 10px center / 16px
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23888'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  font: inherit;
  color: var(--text);
  cursor: pointer;
}
.filter-select:focus { outline: none; border-color: var(--border-focus); }

/* ── List table: grid rows, uppercase header (set grid-template-columns per page) ── */
.list-table {
  display: block;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow-x: auto;
}
/* every row exactly as wide as the table, so `fr` columns line up from row to row
   (with `width: max-content` each row sized its columns on its own content) */
.list-header, .list-row {
  display: grid;
  gap: 12px;
  align-items: center;
  padding: 10px 16px;
  width: 100%;
}
.list-header {
  background: var(--tint);
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  font-weight: 500;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.list-row { border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.list-row > * { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--tint); }
.row-actions { display: flex; justify-content: flex-end; gap: 2px; justify-self: stretch; }
.action-btn {
  display: flex;
  flex-shrink: 0;
  text-decoration: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
}
.action-btn:hover { background: var(--hover); color: var(--text); }
.action-btn--danger { color: var(--danger); }
.action-btn--danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
/* neutral like the other actions; the danger color only on hover */
.action-btn--remove:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }

.cell-date { color: var(--muted); font-size: 12px; white-space: nowrap; }
/* data at their own width on the left; the last column takes the rest and holds the
   actions against the right edge (as .accounts-grid) */
.devices-grid { grid-template-columns: minmax(140px, 260px) minmax(90px, 150px) 56px 110px 120px 96px minmax(36px, 1fr); }
.all-devices-grid { grid-template-columns: minmax(140px, 260px) minmax(90px, 140px) 78px minmax(100px, 180px) 84px minmax(120px, 240px) minmax(36px, 1fr); }
.device-account { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.admin-devices-grid { grid-template-columns: minmax(130px, 260px) minmax(80px, 140px) 78px 48px minmax(100px, 180px) 90px 120px 84px minmax(36px, 1fr); }
.device-name { display: flex; align-items: center; gap: 8px; }
.device-name > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-names { display: flex; flex-direction: column; min-width: 0; }
.device-names > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* the name SuperVise read on the device, under the user's own */
.device-label { font-size: 12px; color: var(--muted); }
.device-alert { color: var(--danger); }
.device-state { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
.device-name .device-kind { font-size: 18px; color: var(--muted); flex-shrink: 0; }
/* Generate a code: choices, then the code itself */
.choice-form { display: flex; flex-direction: column; gap: 10px; max-width: 560px; }
.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}
.choice:has(input:checked) { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 6%, var(--surface)); }
.choice input { accent-color: var(--primary); }
.choice > span:last-child { display: flex; flex-direction: column; gap: 2px; }
.choice .muted { font-size: 13px; }
.choice-icon { color: var(--primary); }
.choice-form .btn { align-self: flex-start; margin-top: 6px; }
.code-card { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 24px 0; text-align: center; }
.code-value {
  font-family: "Roboto Mono", ui-monospace, monospace;
  font-size: 44px;
  font-weight: 500;
  letter-spacing: 0.12em;
  padding: 12px 24px;
  border-radius: 12px;
  background: var(--tint);
  border: 1px solid var(--line);
  user-select: all;
}
.code-value.expired { text-decoration: line-through; opacity: 0.4; }
.code-value.flash { animation: code-flash 0.6s ease-out; }
@keyframes code-flash {
  from { border-color: var(--success); box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 25%, transparent); }
  to { border-color: var(--line); box-shadow: 0 0 0 0 transparent; }
}
.btn-done, .btn-done:hover { background: color-mix(in srgb, var(--success) 15%, var(--surface)); color: var(--success); }
.code-timer { margin: 0; color: var(--text-2); font-variant-numeric: tabular-nums; }
.code-timer.expired { color: var(--danger); }
.download-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 12px 0; max-width: 720px; }
.download-choice { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.download-choice > .material-icons { font-size: 28px; color: var(--primary); }
.download-choice h3 { margin: 0; font-size: 15px; }
.download-choice p { margin: 0 0 8px; }
.download-url { font-family: ui-monospace, monospace; font-size: 13px; word-break: break-all; padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px; max-width: 520px; }
.download-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.download-buttons { display: flex; flex-direction: column; gap: 8px; margin: 16px 0 8px; }
.download-buttons form { margin: 0; }
.code-step { margin-bottom: 24px; }
.account-section { margin-bottom: 8px; }
.account-section .facts { margin-bottom: 12px; }
.danger-zone { margin-top: 32px; padding: 4px 20px 20px; border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); border-radius: 12px; }
.danger-zone .section-title { margin-top: 16px; color: var(--danger); }
.blocked-summary { display: flex; align-items: center; gap: 14px; padding: 16px 20px; border: 1px solid var(--line); border-radius: 12px; max-width: 520px; }
.blocked-summary > .material-icons { font-size: 28px; color: var(--primary); }
.blocked-summary div { display: flex; flex-direction: column; gap: 2px; }
.history-grid { grid-template-columns: 130px minmax(110px, 160px) minmax(120px, 240px) minmax(140px, 1fr); }
.blocked-summary form { margin-left: auto; }
.blocked-sites-grid { grid-template-columns: minmax(160px, 320px) 110px 150px minmax(0, 1fr); }
.blocked-sites-grid .cell-site { font-family: var(--mono, ui-monospace, monospace); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-title-row { display: flex; align-items: center; gap: 12px; margin: 28px 0 8px; }
.section-title-row .section-title { margin-top: 0; margin-bottom: 0; }
.section-title-row form { margin-left: auto; }
.history-action { display: flex; align-items: center; gap: 6px; }
.history-action .material-icons { font-size: 17px; color: var(--muted); }
.history-state { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.welcome { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 16px; max-width: 620px; margin: 80px auto 64px; padding: 0 16px; }
.welcome-icon { font-size: 36px; width: 76px; height: 76px; margin-bottom: 4px; display: flex; align-items: center; justify-content: center; border-radius: 50%; color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, transparent); }
.welcome h2 { margin: 0; font-size: 22px; }
.welcome p { margin: 0; line-height: 1.6; }
.welcome .btn { margin-top: 8px; }
.welcome-steps { list-style: none; padding: 0; margin: 16px 0 8px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; width: 100%; }
.welcome-steps li { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 22px 16px; line-height: 1.4; border: 1px solid var(--line); border-radius: 12px; font-size: 13px; color: var(--text-2); }
.welcome-steps .material-icons { font-size: 22px; color: var(--primary); }
@media (max-width: 600px) { .welcome-steps { grid-template-columns: 1fr; } }
.code-step-title { display: flex; align-items: center; gap: 10px; font-size: 16px; margin: 0 0 8px; }
.code-step-number { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: var(--on-primary); font-size: 13px; }
.code-step-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.progress-panel { width: 100%; max-width: 520px; margin-top: 12px; padding: 16px 20px; border: 1px solid var(--line); border-radius: 12px; text-align: left; display: flex; flex-direction: column; gap: 10px; }
.progress-panel h2 { margin: 0; font-size: 15px; }
.progress-steps { display: flex; gap: 6px; padding: 0; margin: 0; list-style: none; flex-wrap: wrap; }
.progress-steps li { flex: 1; min-width: 90px; font-size: 12px; color: var(--muted); padding-top: 8px; border-top: 3px solid var(--line); }
.progress-steps li.done { color: var(--success); border-top-color: var(--success); }
.progress-steps li.current { color: var(--text); font-weight: 600; border-top-color: var(--primary); }
.progress-text { margin: 0; }
.progress-panel .btn { align-self: flex-start; }
/* .btn and .banner set their display: hidden must still hide them */
.progress-panel [hidden] { display: none; }
.code-steps { text-align: left; line-height: 1.6; color: var(--text-2); margin: 8px 0 0; }
.small { font-size: 12px; }
.next-code { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.next-code--start { align-items: flex-start; margin-top: 6px; }
.next-code .code-wait { margin: 0; }
.choice-form .next-code .btn { margin-top: 0; }
/* data columns at their own width on the left (e-mail keeps a comfortable width), the
   last column takes the rest and holds the actions against the right edge, as in the Hub */
.accounts-grid {
  grid-template-columns: minmax(180px, 280px) 150px 84px 64px 96px 96px 170px minmax(36px, 1fr);
}
.brands-grid { grid-template-columns: minmax(160px, 220px) minmax(160px, 300px) 200px 140px 80px minmax(36px, 1fr); }
/* brand settings: sections of fields in two columns */
.settings-section { margin-bottom: 8px; }
.brand-ids { font-size: 12px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 8px; overflow-x: auto; }
.tab { position: relative; background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; font: inherit; font-size: 14px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--primary); font-weight: 500; }
.tab-error { position: absolute; top: 8px; right: 4px; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); }
/* unsaved changes: a floating bar as wide as the settings, kept in view at the bottom */
.save-bar {
  position: sticky; bottom: 16px; z-index: 20; max-width: 880px; margin-top: 24px;
  display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 6px 24px rgb(0 0 0 / 12%);
}
.save-bar > span { margin-right: auto; display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.save-bar > span::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--warning); }
.save-bar[hidden] { display: none; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; max-width: 880px; }
.settings-grid .field textarea { font: inherit; resize: vertical; }
.field input[readonly], .field textarea[readonly] { background: var(--tint); color: var(--text-2); }
.field--error input, .field--error textarea, .field--error select { border-color: var(--danger); }
.color-field { display: flex; gap: 8px; }
.color-field input[type="color"] { width: 44px; height: 38px; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; }
.color-field input:not([type="color"]) { flex: 1; font-family: monospace; }
/* the preview uses its own copy of the theme tokens, set by the page's script */
.theme-preview {
  max-width: 880px;
  margin-bottom: 16px;
  padding: 12px;
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
}
.theme-preview-bar { font-weight: 600; margin-bottom: 10px; }
.theme-preview-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--surface);
}
.theme-preview-button { padding: 6px 12px; border-radius: var(--radius); background: var(--primary); color: var(--on-primary); }
.audit-log-grid { grid-template-columns: 130px 170px minmax(120px, 180px) minmax(160px, 260px) 140px minmax(0, 1fr) 110px; }
.audit-log-grid > :nth-child(6) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }  /* details: one line, all on hover */
/* target: one line, its stored form on hover */
.audit-log-grid > :nth-child(4), .audit-log-grid > :nth-child(4) a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.list-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.members-grid { grid-template-columns: minmax(200px, 300px) 80px 130px 140px 72px 96px 80px minmax(40px, 1fr); }
.inline-form { margin: 0; }
.account-head { display: flex; flex-direction: column; gap: 8px; margin: -4px 0 16px; }
.account-states { display: flex; flex-wrap: wrap; gap: 4px; }
.account-badges { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn-small-text { height: 26px; padding: 0 8px; font-size: 12px; }
.btn-small-text .material-icons { font-size: 16px; }
.account-meta { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 12px; align-items: center; }
.tab-count { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; font-size: 11px; background: var(--hover); color: var(--muted); }
.devices-limit { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 12px 0 16px; font-size: 13px; }
.devices-limit .devices-grant { margin-top: 0; }
.section-title--first { margin-top: 12px; }
.devices-grant { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.devices-grant input { width: 64px; height: 30px; }
.devices-grant .btn { height: 30px; padding: 0 10px; font-size: 12px; }
.devices-count { font-size: 13px; }
.compact-select { height: 30px; font-size: 13px; }
.compact-input { height: 32px; padding: 0 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text-1); font: inherit; min-width: 220px; }
.member-names { display: flex; flex-direction: column; }
.logins-grid { grid-template-columns: 140px 140px 130px minmax(0, 1fr); }
.logins-grid > :last-child { white-space: nowrap; }
.links-grid { grid-template-columns: 140px 140px 140px 90px 90px minmax(40px, 1fr); }
.codes-grid { grid-template-columns: 110px 80px 80px 140px 140px minmax(80px, 1fr); }
/* UDID: only its last 4 characters are known; the hidden part, faint */
.udid { font-family: ui-monospace, monospace; font-size: 13px; letter-spacing: 0.06em; white-space: nowrap; }
.udid-hidden { color: var(--faint); margin-right: 2px; }
.code-hint { font-size: 13px; letter-spacing: 0.06em; white-space: nowrap; }
.all-codes-grid { grid-template-columns: 110px minmax(160px, 260px) 140px 70px 70px 130px 130px 80px minmax(48px, 1fr); }
.code-finder { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.code-finder .filter-input { font-family: ui-monospace, monospace; letter-spacing: 0.08em; text-transform: uppercase; width: 160px; }
.found { padding: 16px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 20px; }
.found .facts { margin: 0; }
.operations-grid { grid-template-columns: 80px 140px 110px minmax(100px, 180px) minmax(140px, 1fr); }
.audit-grid { grid-template-columns: 140px minmax(140px, 220px) minmax(100px, 200px) minmax(0, 1fr); }
.cell-link { color: inherit; text-decoration: none; font-weight: 500; }
.cell-link:hover { text-decoration: underline; }
.row-actions form { margin: 0; }
.row-actions .material-icons { font-size: 20px; }
.list-note { font-size: 12px; margin-top: 8px; }
/* flex (not inline): the cell is then exactly the chip, centered like the other cells */
.brand-chip { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.brand-chip img { width: 18px; height: 18px; border-radius: 5px; flex-shrink: 0; }
.providers { display: flex; align-items: center; gap: 6px; }
.provider { display: inline-flex; width: 18px; height: 18px; align-items: center; justify-content: center; color: var(--text); }
.provider svg { width: 16px; height: 16px; }
.provider .material-icons { font-size: 17px; color: var(--muted); }
.provider-other { font-size: 10px; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; }
.status-neutral { background: var(--active); color: var(--text-2); }
.title-with-back { display: flex; align-items: center; gap: 8px; min-width: 0; }
.title-with-back h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-actions form { margin: 0; }
.section-title { margin-top: 28px; }
.facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px 24px;
  margin: 0 0 8px;
}
.facts dt { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; color: var(--faint); margin-bottom: 4px; }
.facts dd { margin: 0; font-size: 14px; }
.muted, .muted-cell { color: var(--muted); }

/* ── Badges ── */
/* inline-block: the cell (overflow hidden, for ellipses) grows to the badge's full height */
.status-badge {
  display: inline-block;
  line-height: 16px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
  white-space: nowrap;
}
.status-success { background: color-mix(in srgb, var(--success) 15%, transparent); color: var(--success); }
.status-pending { background: color-mix(in srgb, var(--warning) 15%, transparent); color: var(--warning); }
.status-error { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
code {
  background: var(--hover);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
}

/* ── Banners (the Hub's snackbars, inline) ── */
.banner { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; }
/* tinted with the theme's own colors, readable on light and dark brands alike */
.banner { border: 1px solid; color: var(--text); line-height: 1.4; }
.banner-success {
  background: color-mix(in srgb, var(--success) 14%, var(--surface));
  border-color: color-mix(in srgb, var(--success) 40%, transparent);
}
.banner-error {
  background: color-mix(in srgb, var(--danger) 14%, var(--surface));
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
}
.banner-info {
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--primary) 35%, transparent);
}
.banner-warning {
  background: color-mix(in srgb, var(--warning) 14%, var(--surface));
  border-color: color-mix(in srgb, var(--warning) 45%, transparent);
}
.list-row-note { display: flex; gap: 10px; align-items: flex-start; padding: 8px 16px 12px; font-size: 13px; line-height: 1.45; color: var(--muted); border-bottom: 1px solid var(--line-soft); margin-top: -1px; }
.list-row-note .material-icons { font-size: 18px; color: var(--warning); }
.list-row-note strong { display: block; color: var(--text); font-weight: 500; margin-top: 2px; }
.rescue-code { max-width: 520px; display: flex; flex-direction: column; gap: 12px; }
.rescue-code .code-value { margin: 4px 0; }

.prose { max-width: 640px; line-height: 1.5; margin: 0 0 12px; }
.narrow-form { max-width: 400px; }

/* ── Dialogs (native <dialog>) ── */
.dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 24px;
  border: none;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
.dialog h2 { margin: 0 0 8px; }
.dialog .muted { margin: 0 0 16px; line-height: 1.45; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.field select { appearance: auto; }

/* ── Empty state ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 40px;
  color: var(--faint);
  text-align: center;
}
.empty-state .material-icons { font-size: 36px; }
/* inside a page section: one line in a dashed box */
.empty-state--compact {
  flex-direction: row;
  justify-content: center;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  font-size: 13px;
}
.empty-state--compact .material-icons { font-size: 20px; }

/* ── Standalone pages (sign-in, not found) ── */
body.centered {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 16px;
}
.card {
  width: 100%;
  max-width: 400px;
  padding: 32px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line);
}
.card h1 { margin-bottom: 8px; }
.card > .muted { margin: 0 0 20px; }
.card h1 + form, .card h1 + .banner { margin-top: 20px; }
.card-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.card-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  margin: 8px -12px 0;
}
.btn-block { width: 100%; justify-content: center; }
.btn-block + .btn-block { margin-top: 8px; }
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--faint);
  font-size: 12px;
}
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.topbar form { margin: 0; }
.language-picker {
  height: 30px;
  padding: 0 26px 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  appearance: none;
  background: transparent no-repeat right 6px center / 14px
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23888'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.language-picker:focus { outline: none; border-color: var(--border-focus); }
.language-picker option { background: var(--surface); color: var(--text); }
.card-footer { display: flex; justify-content: center; margin-top: 20px; }
.qr { display: flex; justify-content: center; margin: 8px 0 12px; }
.qr svg { width: 220px; max-width: 100%; height: auto; border-radius: 8px; background: #fff; }
.secret { text-align: center; font-size: 12px; }
.secret code { font-size: 13px; letter-spacing: 0.08em; }
.code-input { font-size: 20px; letter-spacing: 0.3em; text-align: center; }
.topbar-user { font-size: 13px; }
.choice-group { border: 0; padding: 0; margin: 0 0 16px; display: flex; gap: 8px; flex-wrap: wrap; }
.choice-group legend { padding: 0; margin-bottom: 6px; font-weight: 500; }
.choice { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; }
.choice:has(input:checked) { border-color: var(--text-2); background: var(--active); }
.choice input { margin: 0; }

/* ── Medium widths: the least useful columns go first ── */
@media (max-width: 1100px) {
  .col-wide { display: none; }
  .list-header, .list-row { gap: 8px; }
  .accounts-grid { grid-template-columns: minmax(140px, 260px) 140px 76px 56px 90px 96px minmax(36px, 1fr); }
  .members-grid { grid-template-columns: minmax(160px, 1fr) 72px 120px 130px 64px 80px 40px; }
  .brands-grid { grid-template-columns: minmax(140px, 200px) minmax(120px, 260px) 180px 72px minmax(36px, 1fr); }
  .audit-log-grid { grid-template-columns: 110px 130px minmax(90px, 140px) minmax(110px, 200px) 100px minmax(0, 1fr); }
  /* "by" and "expires" hidden (col-wide) */
  .all-codes-grid { grid-template-columns: 100px minmax(130px, 220px) 120px 64px 120px 76px minmax(40px, 1fr); }
  .logins-grid { grid-template-columns: 130px 130px 120px; }
  /* "added" hidden (col-wide) */
  .admin-devices-grid { grid-template-columns: minmax(120px, 220px) minmax(70px, 120px) 78px 44px minmax(100px, 170px) 84px 110px minmax(36px, 1fr); }
}

/* ── Mobile ── */
@media (max-width: 767px) {
  h1 { font-size: 20px; }
  .topbar { padding: 0 12px; }
  .body { flex-direction: column; }
  .sidebar { width: auto; flex-direction: row; align-items: center; gap: 4px; padding: 4px 12px; }
  .sidebar-main { display: flex; gap: 4px; overflow-x: auto; overflow-y: visible; }
  /* the account menu: its avatar at the end of the row, the list under it */
  .account-menu { margin: 0 0 0 auto; }
  .account-names, .account-chevron { display: none; }
  .account-button { padding: 4px; }
  .account-menu-list { position: fixed; top: 100px; right: 12px; left: auto; bottom: auto; width: 240px; }
  .sidebar-section-label { display: none; }
  .content-wrapper { margin: 0; border-radius: 0; }
  .content { padding: 12px 16px; }
  .page-header {
    padding: 12px 16px 10px;
    margin: -12px -16px 12px;
    top: -12px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .page-filters { margin-bottom: 12px; }
  .filter-input-wrap { flex: 1; }
  .filter-input { width: 100%; }
  /* top bar: no e-mail, sign-out icon only */
  .topbar-user, .topbar .btn-label { display: none; }
  /* rows share the table's width so columns line up */
  .list-header, .list-row { padding: 8px 12px; gap: 8px; }
  .col-optional { display: none; }
  .devices-grid { grid-template-columns: minmax(0, 1fr) 48px 96px 40px; }
  .admin-devices-grid { grid-template-columns: minmax(0, 1fr) 48px 110px 40px; }
  .all-devices-grid { grid-template-columns: minmax(0, 1fr) 110px 40px; }
  .history-grid { grid-template-columns: 96px minmax(0, 1fr) minmax(0, 1fr); }
  .blocked-sites-grid { grid-template-columns: minmax(0, 1fr) 80px; }
  .code-value { font-size: 32px; }
  .accounts-grid { grid-template-columns: minmax(0, 1fr) 24px 64px 40px; }
  .members-grid { grid-template-columns: minmax(0, 1fr) 64px 110px 70px 40px; }
  .brands-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 40px; }
  .audit-log-grid { grid-template-columns: 110px minmax(0, 1fr) minmax(0, 1fr); }
  .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .logins-grid { grid-template-columns: 110px minmax(0, 1fr); }
  .accounts-grid > :first-child { min-width: 0; }
  .accounts-grid .brand-name { display: none; }
  .accounts-grid > :first-child { overflow-wrap: anywhere; text-overflow: clip; }
  .accounts-grid.list-header > :nth-child(2) { visibility: hidden; }
  .codes-grid { grid-template-columns: 96px 60px 60px minmax(0, 1fr) 80px; }
  .all-codes-grid { grid-template-columns: 96px minmax(0, 1fr) 70px 48px; }
  .operations-grid { grid-template-columns: 60px minmax(0, 1fr) 90px; }
  .audit-grid { grid-template-columns: 110px minmax(0, 1fr) minmax(0, 1fr); }
}

/* ⋮ menu of a list row (_macros.html, row_menu) */
.row-actions { justify-self: end; display: flex; align-items: center; gap: 4px; }
.row-menu { position: relative; }
.row-menu > summary { list-style: none; cursor: pointer; }
.row-menu > summary::-webkit-details-marker { display: none; }
.row-menu-list { position: fixed; z-index: 50; visibility: hidden; min-width: 200px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgb(0 0 0 / 14%); display: flex; flex-direction: column; }
.row-menu-list form { margin: 0; }
.row-menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 6px; background: none; color: var(--text); font: inherit; font-size: 13px; text-align: left; cursor: pointer; text-decoration: none; }
.row-menu-item:hover { background: var(--hover); }
.row-menu-item .material-icons { font-size: 18px; color: var(--muted); }
.row-menu-item--danger, .row-menu-item--danger .material-icons { color: var(--danger); }
