/* ---------------------------------------------------------------------------
   Portal console + guest pages
   Visual language: light canvas, white surfaces, blue primary, 12px radius.
   --------------------------------------------------------------------------- */

@font-face {
  font-family: 'Material Symbols Rounded';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/MaterialSymbolsRounded.ttf') format('truetype');
}
@font-face {
  font-family: 'Overlock';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/Overlock-400.ttf') format('truetype');
}
@font-face {
  font-family: 'Overlock';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/assets/fonts/Overlock-700.ttf') format('truetype');
}

:root {
  color-scheme: light;
  --canvas: #f3f5f9;
  --surface: #ffffff;
  --text: #172b4d;
  --muted: #52627a;
  --primary: #2457d6;
  --primary-hover: #1944b3;
  --primary-tint: #eaf0ff;
  --line: #dce2ec;
  --control: #8796ad;
  --danger: #a32230;
  --danger-tint: #fff0f1;
  --success: #176344;
  --success-tint: #eaf6ef;
  --warning: #765113;
  --warning-tint: #fff4dc;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(23, 43, 77, .06), 0 6px 18px rgba(23, 43, 77, .05);

  /* aliases kept for the guest pages / older markup */
  --bg: var(--canvas);
  --bg-soft: #eef1f6;
  --bg-elev: var(--surface);
  --fg: var(--text);
  --fg-muted: var(--muted);
  --accent: var(--primary);
  --accent-soft: var(--primary-tint);
  --accent-fg: #fff;
  --ok: var(--success);
  --ok-soft: var(--success-tint);
  --warn: var(--warning);
  --warn-soft: var(--warning-tint);
  --bad: var(--danger);
  --bad-soft: var(--danger-tint);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 24px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--text);
  font: 400 15px/1.5 'Overlock', Roboto, "Segoe UI", -apple-system, BlinkMacSystemFont, Arial, sans-serif;
}
h1, h2, h3, p, dl, dd { margin: 0; }
h1 { font-size: 26px; line-height: 1.2; font-weight: 650; letter-spacing: -.3px; }
h2 { font-size: 18px; line-height: 1.35; font-weight: 650; }
h3 { font-size: 15px; line-height: 1.4; font-weight: 650; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
strong { font-weight: 650; }
code, .mono { font-family: var(--mono); font-size: .92em; }
.icon {
  font-family: 'Material Symbols Rounded';
  font-weight: 400;
  font-style: normal;
  font-size: 18px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  vertical-align: -3px;
  margin-right: 6px;
  -webkit-font-smoothing: antialiased;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.hint { color: var(--muted); font-size: .8rem; line-height: 1.45; }

input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--control);
  border-radius: var(--radius-sm);
  transition: border-color .12s, box-shadow .12s;
}
textarea { min-height: 84px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); }
input:hover, select:hover, textarea:hover { border-color: var(--text); }
input:focus, select:focus, textarea:focus {
  outline: 0;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
}
input:disabled, select:disabled, textarea:disabled { opacity: .6; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; accent-color: var(--primary); }

/* ------------------------------------------------------------------ layout */
.layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; align-items:start; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.side-brand { display: flex; align-items: center; gap: 10px; }
.side-brand strong { display: block; font-size: .95rem; letter-spacing: -.2px; }
.side-brand span { font-size: .72rem; color: var(--muted); }
.side-logo { height: 34px; width: auto; flex: none; }
.brand-logo { display: block; height: 58px; width: auto; margin: 0 auto 10px; }
.brand-logo.logo-sm { height: 44px; margin-bottom: 8px; }
.sidebar nav { display: grid; gap: 2px; }
.sidebar nav a {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 600;
}
.sidebar nav a:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }
.sidebar nav a.is-active { background: var(--primary-tint); color: var(--primary); }
.side-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: .78rem;
  color: var(--muted);
  display: grid;
  gap: 4px;
}

.content { padding: 0 28px 64px; max-width: 1200px; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 0 18px;
  margin-bottom: 4px;
}
.topbar h1 { font-size: 26px; }
.page-heading p { margin-top: 4px; color: var(--muted); font-size: .88rem; }
.top-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ------------------------------------------------------------------ cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 14px;
}
.card > h2:first-child, .card > .row:first-child h2 { margin-top: 0; }
.card > h2 { margin-bottom: 10px; font-size: 1.05rem; }
.card > h3 { margin: 14px 0 8px; font-size: .98rem; }
.card.center { text-align: center; }

.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.row.spread { justify-content: space-between; }
.row > h2 { margin: 0; }
.searchbar { display: flex; gap: 8px; align-items: stretch; flex: 1 1 260px; max-width: 380px; }
.searchbar input { flex: 1; min-width: 0; min-height: 38px; padding: 8px 12px; }
.searchbar .btn { min-height: 38px; padding: 7px 12px; }
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.stack { display: grid; gap: 14px; }
.stack.tight { gap: 8px; }
.plan-fields { min-width: 0; margin: 0; padding: 0; border: 0; }
.grid2 { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid3 { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.inline { display: flex; gap: 8px; align-items: stretch; }
.inline > input { flex: 1; min-width: 0; }

/* ------------------------------------------------------------------ summary */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
}
.stat { padding: 10px 12px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat span {
  display: block;
  font-size: .72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
}
.stat strong { display: block; font-size: 1.2rem; margin-top: 2px; letter-spacing: -.3px; }

/* ------------------------------------------------------------------ forms */
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: .8rem; font-weight: 600; color: var(--muted); }
.field > small, .field .hint { color: var(--muted); font-size: .78rem; }
.field .mono { font-size: .86rem; }

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: .86rem;
  color: var(--muted);
}
.check input { margin-top: 2px; flex: none; }

.code-input {
  font-family: var(--mono);
  font-size: 1.1rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  text-align: center;
}

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: .88rem;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { text-decoration: none; border-color: var(--control); background: #f8f9fc; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-quiet { background: transparent; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #8d1d29; border-color: #8d1d29; }
.btn-block { width: 100%; }
.btn-sm { min-height: 32px; padding: 5px 10px; font-size: .78rem; border-radius: 6px; }
.link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--primary);
  font: inherit;
  cursor: pointer;
}
.link:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ tabs */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-soft);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 16px;
}
.tabs a {
  flex: 1;
  text-align: center;
  padding: 9px 10px;
  border-radius: 7px;
  color: var(--muted);
  text-decoration: none;
  font-size: .88rem;
  font-weight: 600;
  white-space: nowrap;
}
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.is-active { background: var(--surface); color: var(--primary); box-shadow: 0 1px 3px rgba(23, 43, 77, .12); }

/* ------------------------------------------------------------------ badges */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 650;
  letter-spacing: .01em;
  text-transform: capitalize;
  white-space: nowrap;
}
.badge-ok { background: var(--success-tint); color: var(--success); }
.badge-warn { background: var(--warning-tint); color: var(--warning); }
.badge-idle { background: var(--bg-soft); color: var(--muted); }
.badge-bad { background: var(--danger-tint); color: var(--danger); }

.chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: .7rem;
  font-weight: 650;
  background: var(--bg-soft);
  color: var(--muted);
}
.chip-ok { background: var(--success-tint); color: var(--success); }
.chip-warn { background: var(--warning-tint); color: var(--warning); }
.chip-bad { background: var(--danger-tint); color: var(--danger); }

.tag-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: .8rem;
}

/* ------------------------------------------------------------------ notices */
.notice {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: .88rem;
  border: 1px solid transparent;
}
.notice-success { background: var(--success-tint); color: var(--success); border-color: #cfe9db; }
.notice-error { background: var(--danger-tint); color: var(--danger); border-color: #f3d2d6; }
.notice-warn { background: var(--warning-tint); color: var(--warning); border-color: #f0dfb6; }
.notice-info { background: var(--primary-tint); color: #1b3f9e; border-color: #d5e1ff; }

/* ------------------------------------------------------------------ tables */
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th, .table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: .84rem;
}
.table th {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 650;
  white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table td { overflow-wrap: anywhere; }
.table tbody tr:hover { background: #f8f9fc; }
.table td .mono, .table td .small { display: block; }
.table td .muted { display: block; }
.row-blocked { opacity: .62; }
.table .actions { white-space: nowrap; }
.table .actions form { display: inline; }
.table .actions .menu-body .stack { display: grid; }
.table .actions .btn { margin-right: 4px; margin-bottom: 4px; }

/* inline rename: appears only when the Rename summary is opened */
.rename { display: flex; gap: 6px; align-items: stretch; max-width: 340px; }
.rename input { flex: 1; min-width: 0; min-height: 36px; padding: 7px 10px; font-size: .84rem; }
.rename .btn { min-height: 36px; padding: 7px 12px; font-size: .8rem; }

/* device details disclosure inside a table cell */
.row-details { margin-top: 6px; }
.row-details > summary { cursor: pointer; color: var(--primary); font-size: .78rem; font-weight: 600; }
.detail-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; margin-top: 8px; }
.detail-list dt { font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.detail-list dd { margin: 0; font-size: .82rem; word-break: break-word; }

/* ------------------------------------------------------------------ menu */
.menu { position: relative; display: inline-block; }
.menu > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: .82rem;
  font-weight: 600;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary:hover { border-color: var(--control); background: #f8f9fc; }
.menu-body {
  position: absolute;
  right: 0;
  z-index: 50;
  width: 280px;
  max-width: calc(100vw - 24px);
  margin-top: 6px;
  padding: 10px;
  display: grid;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(23, 43, 77, .16);
  white-space: normal;
}
.menu-body form + form { border-top: 1px solid var(--line); padding-top: 10px; }
.menu-title {
  margin: 0;
  font-size: .68rem;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.menu-body .row { gap: 6px; }
.menu-body .row .btn { flex: 1 1 auto; min-height: 32px; padding: 5px 8px; font-size: .78rem; }

/* ------------------------------------------------------------------ guest portal */
.shell { width: min(100% - 32px, 440px); margin: 0 auto; padding: 28px 0 40px; }
.shell.narrow { max-width: 380px; }
.guest-shell { padding-top: 34px; }
.brand { text-align: center; margin-bottom: 18px; }
.brand h1 { font-size: 24px; }
.brand p { color: var(--muted); font-size: .84rem; margin-top: 2px; }
.guest-shell .card { padding: 22px; }
.guest-shell .card h2 { margin-bottom: 6px; }
.guest-shell .card > .muted { margin-bottom: 14px; }

.plan-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.plan-head h2 { margin: 0; }
.plan-head > :first-child { min-width: 0; overflow-wrap: anywhere; }
.plan-head .muted { font-size: .82rem; margin-top: 2px; }
.price { font-size: 1.15rem; font-weight: 700; color: var(--primary); white-space: nowrap; }

.plan-list { display: grid; gap: 10px; }
.plan-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.plan-row strong { display: block; }
.plan-row .muted { font-size: .78rem; }

.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 16px 0; }
.facts > div { background: var(--bg-soft); border-radius: var(--radius-sm); padding: 10px 12px; }
.facts dt { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.facts dd { margin: 2px 0 0; font-weight: 650; }
.tick {
  width: 54px;
  height: 54px;
  margin: 2px auto 12px;
  border-radius: 50%;
  background: var(--success-tint);
  color: var(--success);
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  font-weight: 700;
}
.lang-switch {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  font-size: .8rem;
  color: var(--muted);
}
.lang-switch a { color: var(--muted); text-decoration: none; padding: 4px 6px; border-radius: 6px; }
.lang-switch a.is-active { color: var(--primary); font-weight: 650; background: var(--primary-tint); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--danger);
  font-size: .85rem;
  cursor: pointer;
  padding: 0;
  margin: 0 2px;
}
.icon-btn:hover { background: var(--danger-tint); }

.name-edit { display: inline-block; position: relative; }
.name-edit > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--muted);
  font-size: .85rem;
}
.name-edit > summary::-webkit-details-marker { display: none; }
.name-edit[open] > summary { background: var(--primary); color: #fff; border-color: var(--primary); }
.name-edit > form {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 60;
  margin-top: 4px;
  padding: 8px;
  min-width: 160px;
  max-width: calc(100vw - 24px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.name-edit:not([open]) > form { display: none; }
.menu:not([open]) > .menu-body { display: none; }
.access-limits > summary { width: auto; min-width: 26px; padding: 0 8px; }
.access-limits[open] { display: block; }
.access-limits > form { position: static; width: 100%; min-width: 0; max-width: 100%; white-space: normal; }

/* ------------------------------------------------------------------ misc */
.qr { display: block; width: 180px; height: 180px; image-rendering: pixelated; margin: 10px 0; background: #fff; padding: 6px; border-radius: 8px; }
.plan-head h2 .chip { vertical-align: middle; margin-left: 6px; }
.break { flex-basis: 100%; height: 0; }
.note { color: var(--muted); font-size: .84rem; margin: 6px 0 0; }
.row-blocked { background: var(--danger-tint); }
.row-blocked:hover { background: #ffe7ea !important; }
.table .actions .name-edit { margin-right: 4px; }

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar nav a .icon { margin-right: 0; }
.desktop-nav { display: block; }
.mobile-nav { display: none !important; }

/* ------------------------------------------------------------------ responsive */


@media (max-width: 760px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    padding: 6px 10px;
    background: var(--surface);
  }
  .table td { border: 0; padding: 4px 0; }
  .table td::before {
    content: attr(data-label);
    display: block;
    font-size: .66rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    margin-bottom: 3px;
    font-weight: 600;
  }
  .table td.actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 10px; }
  .table td.actions::before { flex-basis: 100%; }
  .menu { display: block; }
  .table td.actions > .menu { width: 100%; min-width: 0; }
  .menu-body { position: static; width: 100%; margin-top: 8px; box-shadow: none; }
  .name-edit[open] { display: block; width: 100%; }
  .name-edit > form { position: static; width: 100%; min-width: 0; max-width: 100%; }
  .rename { max-width: 100%; }
  .detail-list { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .row > .field { flex: 1 1 100%; }
  .row.spread { align-items: flex-start; }
  .searchbar { flex: 1 1 100%; max-width: none; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: 12px 14px; }
  .stat:nth-child(2n) { border-right: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
  .stat strong { font-size: 1.2rem; }
  .card { padding: 15px; margin-bottom: 14px; }
  .tabs { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { flex: 0 0 auto; padding: 9px 14px; }
  .plan-row { grid-template-columns: 1fr auto; }
  .plan-row .btn { grid-column: 1 / -1; width: 100%; }
  .shell { width: min(100% - 24px, 440px); padding-top: 18px; }
  .brand-logo { height: 48px; }
  h1 { font-size: 22px; }
}


@media print {
  .sidebar, .topbar, .notice, .stats, .actions, .menu { display: none !important; }
  .layout { display: block; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
}

/* Compact plan and device controls; local icons share existing tokens. */
.plan-summary { display:flex; align-items:center; gap:12px; cursor:pointer; list-style:none; min-height:42px; }
.plan-summary::-webkit-details-marker { display:none; }
.plan-summary-title { display:grid; gap:3px; min-width:0; flex:1; overflow-wrap:anywhere; }
.plan-summary-title strong { font-size:1rem; }
.plan-summary-actions { display:flex; align-items:center; gap:12px; flex:none; }
.plan-edit-form { margin-top:14px; padding-top:14px; border-top:1px solid var(--line); }
.plan-editor:not([open]) > form, .plan-create:not([open]) > form { display:none; }
.device-heading { display:flex; flex-wrap:wrap; align-items:center; gap:6px 12px; margin-bottom:10px; }
.device-heading h2 { margin:0; font-size:1rem; }
.brand-logo { max-width:100%; object-fit:contain; min-height:44px; }
.topbar { gap:10px; padding-top:16px; padding-bottom:12px; }
@media (max-width:760px) {
 .plan-summary { align-items:flex-start; }
 .plan-summary-actions { flex-direction:column; align-items:flex-end; gap:6px; }
 .plan-summary-title .small { font-size:.78rem; }
 .device-heading { align-items:flex-start; }
}

/* Shared stable navigation; reserved icon metrics prevent font-loading shifts. */
.icon { width:18px; height:18px; min-width:18px; overflow:hidden; flex:0 0 18px; margin:0; }
.btn { gap:6px; }
.device-browser { min-width:0; }
.device-tools { display:flex; align-items:center; gap:8px; margin:8px 0; }
.device-search { display:flex; align-items:center; gap:6px; min-width:0; flex:1; }
.device-search input { min-height:36px; padding:6px 8px; }
.device-tools > select { width:140px; min-height:36px; padding:6px 8px; }
.device-count { flex:none; color:var(--muted); font-size:12px; }
.device-list { display:grid; gap:0; }
.device-item { display:grid; grid-template-columns:minmax(0,1fr) minmax(220px,1fr) auto; gap:4px 16px; padding:var(--record-padding,10px) 0; border-bottom:1px solid var(--line); align-items:center; min-width:0; }
.device-item:last-child { border-bottom:0; }
.device-item[hidden] { display:none; }
.device-name { display:flex; align-items:center; min-width:0; gap:6px; }
.device-name strong { display:block; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; font-size:14px; line-height:20px; }
.device-address { display:flex; gap:6px; font-size:12px; line-height:17px; color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.device-address .mono { font-size:11px; }
.device-address [data-device-ip]::before { content:'· '; }
.device-access { display:flex; align-items:center; gap:4px; flex-wrap:wrap; margin-top:3px; }
.device-access .badge,.device-access .chip { margin:0; font-size:11px; line-height:16px; padding:1px 5px; }
.device-traffic { display:grid; gap:2px; font-size:13px; line-height:18px; min-width:0; font-variant-numeric:tabular-nums; }
.device-down,.device-up { display:flex; align-items:baseline; gap:5px; white-space:nowrap; }
.device-down { color:var(--success); }
.device-up { color:var(--primary); }
.traffic-speed { color:var(--muted); font-size:12px; }
.traffic-speed:not(:empty)::before { content:'('; }
.traffic-speed:not(:empty)::after { content:')'; }
.device-policy { font-size:11px; color:var(--muted); overflow-wrap:anywhere; }
.device-actions { display:flex; align-items:center; justify-content:flex-end; gap:2px; }
.device-actions > form { display:inline-flex; margin:0; }
.device-actions .menu,.device-actions .name-edit,.device-actions .row-details { display:inline-flex; margin:0; }
.device-actions summary,.device-actions .icon-btn { display:flex; align-items:center; justify-content:center; width:40px; height:40px; min-height:40px; padding:0; background:transparent; border:0; border-radius:8px; color:var(--primary); cursor:pointer; list-style:none; }
.device-actions summary::-webkit-details-marker { display:none; }
.device-actions summary:hover,.device-actions .icon-btn:hover { background:var(--primary-tint); }
.device-actions .icon-btn { color:var(--danger); }
.device-actions details > :not(summary) { display:none; }
.device-session { grid-column:1 / -1; display:flex; gap:8px; color:var(--muted); font-size:11px; line-height:15px; flex-wrap:wrap; }
.device-session > span + span::before { content:'· '; }
.device-offline { opacity:.55; }
.device-live-footer { display:flex; gap:6px; align-items:center; color:var(--muted); font-size:11px; margin-top:8px; }
.live-dot { width:6px; height:6px; border-radius:50%; background:var(--success); flex:none; }
.device-empty { margin:14px 0; color:var(--muted); }
/* All edit surfaces are native top-layer dialogs; no table/disclosure reflow. */
.editor-dialog { padding:0; width:min(480px,calc(100vw - 24px)); max-height:calc(100dvh - 32px); border:1px solid var(--line); border-radius:12px; background:var(--surface); color:var(--text); box-shadow:0 16px 60px rgba(0,0,0,.2); }
.editor-dialog::backdrop { background:rgba(12,24,40,.35); }
.editor-head { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:12px 16px; border-bottom:1px solid var(--line); }
.editor-head h2 { font-size:16px; overflow-wrap:anywhere; }
.editor-close { width:44px; height:44px; display:flex; align-items:center; justify-content:center; border:0; background:transparent; border-radius:8px; cursor:pointer; }
.editor-body { padding:14px 16px; overflow-y:auto; max-height:calc(100dvh - 122px); }
.editor-body > form,.editor-body > .menu-body,.editor-body > .detail-list { display:grid; position:static; margin:0; padding:0; width:100%; min-width:0; max-width:100%; border:0; box-shadow:none; }
.editor-body .rename { display:flex; gap:8px; }
.editor-body .plan-edit-form { margin:0; border:0; }
.editor-body .menu-body { gap:12px; }
.editor-body .detail-list { gap:10px; }
.editor-body .grid2,.editor-body .grid3 { gap:10px; }
.editor-body form + form { padding-top:10px; border-top:1px solid var(--line); }
.editor-body input,.editor-body select { min-height:40px; }
.name-edit > summary,.access-limits > summary { display:inline-flex; align-items:center; justify-content:center; min-width:40px; min-height:40px; width:auto; padding:4px 8px; vertical-align:middle; }
.name-edit > form,.menu > .menu-body { display:none; }
.plan-editor > form,.plan-create > form { display:none; }
@media (max-width:900px) {
 .layout { grid-template-columns:minmax(0,1fr); grid-template-rows:48px minmax(0,1fr); align-items:start; align-content:start; }
 .sidebar { position:sticky; top:0; z-index:30; height:48px; flex-direction:row; flex-wrap:wrap; align-items:center; gap:8px; padding:6px 10px; border-right:0; border-bottom:1px solid var(--line); background:var(--surface); display:grid; grid-template-columns:minmax(0,1fr) auto auto; min-height:48px; }
 .side-brand { flex:1 1 auto; min-width:0; gap:8px; height:34px; overflow:hidden; }
 .side-brand span { display:none; }
 .side-logo { height:28px; display:block; width:40px; min-width:40px; object-fit:contain; }
 .side-foot { margin:0; padding:0; border:0; display:flex; gap:8px; align-items:center; font-size:.76rem; height:34px; min-width:34px; }
 .side-foot > span { display:none; }
 .desktop-nav { display:none !important; }
 .mobile-nav { display:block !important; flex-basis:auto; order:initial; position:static; margin:0; }
 .mobile-nav > summary { display:flex; align-items:center; gap:5px; list-style:none; cursor:pointer; padding:5px 8px; border:1px solid var(--line); border-radius:8px; background:var(--bg); font-weight:600; font-size:13px; height:34px; min-height:34px; line-height:20px; white-space:nowrap; }
 .mobile-nav > summary::-webkit-details-marker { display:none; }
 .mobile-nav > nav { display:none; flex-direction:column; gap:2px; margin-top:4px; padding:6px; background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); box-shadow:var(--shadow); position:absolute; left:10px; right:10px; top:calc(100% + 4px); margin:0; max-height:calc(100dvh - 64px); overflow-y:auto; }
 .mobile-nav[open] > nav { display:flex; }
 .mobile-nav > nav a { padding:8px 10px; border-radius:8px; }
 .content { padding:0 12px 32px; align-self:start; }
 .topbar { padding:6px 0; flex-wrap:nowrap; min-height:44px; gap:8px; margin-bottom:0; align-items:center; }
 .topbar h1 { font-size:21px; }
 .page-heading p { font-size:.82rem; display:none; }
 .side-brand > div { min-width:0; }
 .side-brand strong { font-size:14px; line-height:20px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
 .side-foot form { margin:0; }
 .side-foot .link { display:flex; align-items:center; justify-content:center; width:34px; height:34px; padding:0; border:0; }
 .logout-label { display:none; }
 .page-heading { flex:1; min-width:0; }
 .page-heading h1 { font-size:20px; line-height:26px; }
 .top-actions .btn { min-height:34px; padding:5px 10px; }
}

@media (max-width:760px) {
 .device-tools { gap:6px; flex-wrap:wrap; }
 .device-tools > select { width:112px; font-size:12px; }
 .device-count { flex-basis:100%; font-size:11px; }
 .device-item { grid-template-columns:minmax(0,1fr) auto; gap:5px 4px; padding:9px 0; }
 .device-identity { grid-column:1 / -1; }
 .device-name { padding-right:0; }
 .device-name strong { max-width:100%; }
 .device-address { line-height:16px; }
 .device-traffic { grid-column:1; grid-row:2; font-size:12px; line-height:17px; }
 .traffic-speed { font-size:11px; }
 .device-actions { grid-column:1 / -1; grid-row:3; display:flex; justify-content:flex-end; gap:2px; max-width:none; margin-top:-4px; }
 .device-traffic { grid-column:1 / -1; grid-row:2; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:2px 10px; }
 .device-policy { grid-column:1 / -1; }
 .device-session { display:none; }
 .device-access { position:absolute; right:0; top:0; max-width:145px; margin:0; justify-content:flex-end; }
 .device-access .chip { display:none; }
 .device-identity { position:relative; padding-right:106px; }
 .device-name strong { font-size:14px; line-height:20px; }
 .device-address { flex-direction:column; gap:0; }
 .device-address [data-device-ip]::before { content:none; }
 .device-item { padding:8px 0; gap:4px; }
 .device-actions summary,.device-actions .icon-btn { width:44px; height:44px; min-height:44px; }
 .device-session { grid-column:1 / -1; font-size:11px; }
 .device-policy { max-width:100%; line-height:15px; }
 .device-heading .hint { display:none; }
 .device-heading { margin-bottom:6px; }
 .editor-dialog { width:calc(100vw - 20px); }
 .editor-body .grid2 { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media print { .device-tools,.device-actions,.device-live-footer,.editor-dialog { display:none!important; } }

/* Shared compact records: guests, saved MACs and related management lists. */
:root { --record-gap:8px; --record-padding:10px; --action-size:40px; }
.records-card { padding:var(--record-padding) 14px; }
.record-header { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:var(--record-gap); margin-bottom:8px; min-height:36px; }
.record-header h2 { font-size:16px; margin:0; }
.record-list { display:grid; }
.record-row { display:grid; grid-template-columns:minmax(0,1.1fr) minmax(0,1.6fr) minmax(110px,.7fr) auto; align-items:center; gap:6px 12px; padding:var(--record-padding) 0; border-bottom:1px solid var(--line); min-width:0; }
.record-row:last-child { border-bottom:0; }
.record-identity,.record-content,.record-meta { min-width:0; }
.record-identity strong { display:block; font-size:14px; line-height:20px; overflow-wrap:anywhere; }
.record-identity .small,.record-content .small,.record-meta .small { display:block; font-size:12px; line-height:17px; color:var(--muted); overflow-wrap:anywhere; }
.record-identity .mono,.record-content .mono { font-size:12px; }
.record-meta { font-size:12px; line-height:17px; color:var(--muted); }
.record-state { font-size:12px; }
.guest-records .record-row { grid-template-columns:minmax(0,1.1fr) minmax(0,1.2fr) minmax(110px,.8fr) auto auto; }
.record-actions { display:flex; align-items:center; justify-content:flex-end; gap:2px; }
.record-actions form { display:inline-flex; margin:0; }
.record-actions .name-edit { display:inline-flex; margin:0; }
.record-icon,.record-actions summary { display:inline-flex; align-items:center; justify-content:center; width:var(--action-size); height:var(--action-size); min-height:var(--action-size); margin:0; padding:0; background:transparent; border:0; border-radius:8px; color:var(--primary); cursor:pointer; }
.record-icon:hover,.record-actions summary:hover { background:var(--primary-tint); }
.record-icon.danger { color:var(--danger); }
.record-icon:focus-visible,.record-actions summary:focus-visible { outline:2px solid var(--primary); outline-offset:2px; }
.record-settings { display:block; }
.record-settings > .record-header { display:flex; width:100%; padding:0; margin:0; border:0; background:none; min-height:36px; }
.record-settings > .record-header .muted { margin-left:auto; }
.record-settings > .menu-body { display:none; }
.record-add { display:inline-flex; margin:8px 0; }
.record-add > .menu-body { display:none; }
.record-content .chip { margin:0; }
.record-row .record-content > .small { font-size:12px; line-height:18px; }
.editor-dialog { overscroll-behavior:contain; }
button,summary { touch-action:manipulation; }
@media (max-width:760px) {
 :root { --record-padding:8px; --action-size:44px; }
 .record-row,.guest-records .record-row { grid-template-columns:minmax(0,1fr) auto; gap:4px 8px; padding:8px 0; }
 .record-identity { grid-column:1; }
 .record-content { grid-column:1; grid-row:2; }
 .record-meta { grid-column:1; font-size:11px; line-height:15px; }
 .record-state { grid-column:2; grid-row:1; justify-self:end; }
 .record-actions { grid-column:2; grid-row:2 / span 2; align-self:center; }
 .record-identity strong { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
 .record-content .small { font-size:11px; line-height:16px; }
 .record-header .searchbar { flex-basis:100%; }
 .record-header .searchbar input { min-height:36px; }
 .record-settings .record-header { flex-wrap:nowrap; gap:6px; font-size:14px; }
 .record-settings .record-header .small { max-width:42%; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
 .record-actions { max-width:132px; }
 .records-card { padding:10px 12px; }
}
@media print { .record-actions,.record-add,.record-settings { display:none!important; } }

/* Shared plan catalog and complete, grouped editor. */
.plan-catalog-list { display:grid; }
.plan-catalog .plan-editor { min-width:0; border-bottom:1px solid var(--line); padding:10px 0; }
.plan-catalog .plan-editor:last-child { border-bottom:0; }
.plan-summary-badges { display:flex; flex-wrap:wrap; align-items:center; gap:6px; }
.plan-summary-badges .chip { margin:0; font-size:10px; }
.plan-catalog .plan-summary-title strong { font-size:14px; }
.plan-catalog .plan-summary-title .small { font-size:12px; }
.plan-create { display:inline-block; margin-top:8px; }
.plan-editor > .plan-view { display:none; }
.plan-dialog { width:min(680px,calc(100vw - 24px)); }
.plan-dialog .editor-head h2 { margin:0; line-height:1.4; }
.plan-edit-form { gap:18px; }
.plan-section legend { padding:0; margin-bottom:10px; font-size:13px; font-weight:700; color:var(--muted); }
.plan-form-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px 14px; }
.plan-wide { grid-column:1 / -1; }
.plan-duration { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:8px; }
.plan-edit-form .hint { font-size:11px; line-height:1.4; }
.plan-section > .hint { margin:6px 0 10px; }
.plan-form-actions { display:flex; flex-wrap:wrap; justify-content:flex-end; gap:8px; position:sticky; bottom:-14px; padding:12px 0; background:var(--surface); border-top:1px solid var(--line); }
.plan-form-actions .btn-danger { margin-right:auto; }
.plan-view > div { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:10px; padding:8px 0; border-bottom:1px solid var(--line); }
.plan-view dt { font-size:12px; color:var(--muted); }
.plan-view dd { margin:0; font-size:14px; overflow-wrap:anywhere; }
.device-live-footer { flex-wrap:wrap; }
.device-refresh-control { display:flex; align-items:center; gap:6px; white-space:nowrap; }
.device-refresh-control select { width:auto; min-height:36px; padding:4px 8px; font-size:12px; }
.device-live-footer [data-device-live-status] { flex:1 1 180px; }
@media (max-width:600px) {
 .plan-dialog { width:calc(100vw - 20px); }
 .plan-form-grid { grid-template-columns:minmax(0,1fr); }
 .plan-catalog .plan-summary { align-items:center; gap:8px; }
 .plan-catalog .plan-summary-actions { gap:4px; }
 .plan-catalog .plan-summary-actions .btn { min-height:40px; padding:6px 8px; }
 .plan-view > div { grid-template-columns:minmax(0,1fr) minmax(0,1fr); }
}

.plan-advanced > summary { min-height:40px; display:flex; align-items:center; cursor:pointer; font-size:12px; font-weight:600; color:var(--muted); padding:6px 0; }
.plan-advanced[open] > summary { margin-bottom:8px; }
.record-actions { flex-wrap:wrap; }
@media (max-width:760px) { .allowed-records .record-actions { grid-column:1 / -1; grid-row:4; display:flex; flex-wrap:nowrap; max-width:none; justify-content:flex-end; gap:2px; } .allowed-records .record-content,.allowed-records .record-meta { grid-column:1 / -1; } }
