/* AyPanel — dark sidebar admin styles (QPanel-inspired) */
:root {
  --bg:        #0E0E10;
  --surface:   #18181B;
  --surface-2: #1F1F23;
  --border:    #2A2A2E;
  --text:      #E4E4E7;
  --muted:     #A1A1AA;   /* 6.91:1 on --surface — was #71717A at 3.67:1 */
  --dim:       #8A8A94;   /* 5.18:1 on --surface — was #52525B at 2.29:1 */
  --gold:      #D4920A;
  --gold-2:    #F0B23A;
  --green:     #22C55E;
  --red:       #EF4444;
  --blue:      #3B82F6;
  --sidebar-w: 240px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Cairo", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-2); }

/* ── Layout ──────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 20px 20px; border-bottom: 1px solid var(--border);
}
.sidebar .brand .logo {
  width: 36px; height: 36px; border-radius: 9px;
  background: linear-gradient(135deg, #1A3575, #0A1C41);
  display: flex; align-items: center; justify-content: center;
  color: var(--gold); font-weight: 900; font-size: 13px;
  border: 1px solid rgba(212,146,10,.4);
}
.sidebar .brand .name { font-size: 15px; font-weight: 800; letter-spacing: 0.5px; }
.sidebar .brand .name span { color: var(--gold); }
.sidebar nav { padding: 12px 8px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; margin: 2px 0;
  color: var(--muted); border-radius: 8px;
  font-size: 13px; font-weight: 500;
}
.sidebar nav a:hover { color: var(--text); background: var(--surface-2); }
.sidebar nav a.active {
  background: rgba(212,146,10,.12);
  color: var(--gold);
  border: 1px solid rgba(212,146,10,.25);
}
.sidebar nav .label {
  padding: 14px 12px 4px; color: var(--muted);
  font-size: 10px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase;
}
/* Live count badges in the sidebar (T5). Pushed to the trailing edge. */
.sidebar nav a .nav-counts {
  margin-inline-start: auto; display: inline-flex; gap: 5px; align-items: center;
}
.sidebar nav a .nav-count {
  background: var(--surface-2); color: var(--muted);
  font-size: 10px; font-weight: 700; line-height: 1;
  padding: 3px 7px; border-radius: 9px; min-width: 16px; text-align: center;
}
.sidebar nav a .nav-count.online {
  background: rgba(34,197,94,.14); color: var(--green);
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.topbar h1 { font-size: 16px; font-weight: 700; margin: 0; }
.topbar .user { display: flex; align-items: center; gap: 8px; color: var(--muted); }
/* Every topbar control (pills, lang, logout, brand picker) shares one 28px
   height so the row reads as a single line of chips — the pills used to be
   free-height spans that could wrap their emoji onto a second line. */
.topbar .user .pill {
  display: inline-flex; align-items: center; gap: 5px;
  white-space: nowrap; height: 28px; padding: 0 11px;
  background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px;
  font-size: 11px; font-weight: 600; line-height: 1;
}
.content { padding: 24px; }

/* Panel vendor footer — pinned to the bottom of the main column via
   margin-top:auto (the flex column on .main + the 100vh .layout give it the
   free space to push into on short pages). The brand word links to the site. */
.app-footer {
  margin-top: auto;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  color: var(--muted); font-size: 12px; text-align: center;
}
.app-footer a { color: var(--gold); text-decoration: none; font-weight: 700; }
.app-footer a:hover { text-decoration: underline; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px; margin-bottom: 20px;
  /* Scroll a too-wide table INSIDE the card rather than dragging the page.
     This used to exist only below 900px, so laptop and tablet widths — where
     an 11-column table with a 5-control action rail still does not fit — had
     no scroll container and clipped the action column off the right edge. */
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.card h2 { margin: 0 0 12px; font-size: 14px; color: var(--gold);
           letter-spacing: 1px; text-transform: uppercase; }
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 200px; }

/* ── Stat tiles ──────────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px;
}
.stat .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.2px; }
.stat .value { font-size: 24px; font-weight: 800; color: var(--gold); margin-top: 6px; }
.stat .delta { font-size: 11px; color: var(--green); margin-top: 4px; }

/* ── Tables ──────────────────────────────────────────────────── */
.table {
  width: 100%; border-collapse: collapse;
  background: var(--surface); border-radius: 12px; overflow: hidden;
  border: 1px solid var(--border);
}
.table th, .table td { padding: 12px 14px; text-align: start; border-bottom: 1px solid var(--border); font-size: 13px; }
.table th { background: var(--surface-2); color: var(--muted);
            text-transform: uppercase; font-size: 11px; letter-spacing: 1.2px; font-weight: 700; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--surface-2); }

.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase;
}
.badge.active   { background: rgba(34,197,94,.12);  color: var(--green); border: 1px solid rgba(34,197,94,.3); }
.badge.expired  { background: rgba(239,68,68,.12);  color: var(--red);   border: 1px solid rgba(239,68,68,.3); }
.badge.banned   { background: rgba(239,68,68,.18);  color: var(--red);   border: 1px solid rgba(239,68,68,.4); }
.badge.unused   { background: rgba(59,130,246,.12); color: var(--blue);  border: 1px solid rgba(59,130,246,.3); }
.badge.used     { background: rgba(212,146,10,.12); color: var(--gold);  border: 1px solid rgba(212,146,10,.3); }
.badge.disabled { background: rgba(113,113,122,.18);color: var(--muted); border: 1px solid var(--border); }
.badge.trial    { background: rgba(212,146,10,.12); color: var(--gold);  border: 1px solid rgba(212,146,10,.3); }

/* ── Buttons & forms ─────────────────────────────────────────── */
.btn {
  display: inline-block; padding: 9px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 700; cursor: pointer; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); transition: all .15s;
}
.btn:hover { background: var(--border); }
.btn.primary { background: var(--gold); color: #000; border-color: var(--gold); }
.btn.primary:hover { background: var(--gold-2); border-color: var(--gold-2); }
.btn.danger  { color: var(--red); border-color: rgba(239,68,68,.4); }
.btn.danger:hover { background: rgba(239,68,68,.14); }
.btn.sm { padding: 7px 11px; font-size: 11px; min-height: 32px; }
.btn-group { display: flex; gap: 8px; }

/* Amber "reversible but consequential" tier, between plain and .danger.
   Ban stops a paying customer streaming, so it should not read as routine —
   but it is undoable, so it should not read as delete either. */
.btn.warn {
  border-color: #7A5A12; background: #2A2008; color: var(--gold-2);
}
.btn.warn:hover { border-color: var(--gold); background: #3A2C0C; }

/* ── Table row action rail ───────────────────────────────────────
   Routine controls, a gap, then the irreversible ones. Delete used to sit
   ~4px from ban with both at 24px tall, which on a trackpad or any touch
   screen made a mis-click between them a coin flip. */
.row-actions { align-items: center; flex-wrap: wrap; gap: 6px; }
.row-actions-split {
  width: 1px; align-self: stretch; min-height: 24px;
  margin-inline: 8px; background: var(--border); flex: 0 0 auto;
}
.row-actions select.sm,
select.sm {
  width: auto; height: 32px; padding: 0 6px;
  font-size: 11px; border-radius: 6px;
}
@media (max-width: 640px) {
  /* Stacked cards give the rail room, so let it breathe rather than wrap
     into an unreadable clump. */
  .row-actions { gap: 8px; }
  .row-actions-split { margin-inline: 4px; }
}

input[type="text"], input[type="password"], input[type="email"],
input[type="number"], input[type="url"], input[type="datetime-local"],
input[type="date"], input[type="search"], input[type="tel"], select, textarea {
  width: 100%; padding: 10px 12px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 13px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); }
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 4px;
}
label { display: block; font-size: 12px; color: var(--muted);
        text-transform: uppercase; letter-spacing: 1px; font-weight: 700;
        margin: 12px 0 6px; }

/* ── Toolbar (search + filters above tables) ────────────────── */
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.toolbar .grow { flex: 1; min-width: 200px; }
.toolbar input, .toolbar select { margin: 0; }

/* ── Pagination ─────────────────────────────────────────────── */
.pager { display: flex; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.pager a, .pager span {
  padding: 6px 11px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); font-size: 12px; font-weight: 600;
}
.pager a:hover { color: var(--gold); border-color: var(--gold); }
.pager .active { background: var(--gold); color: #000; border-color: var(--gold); }

/* ── Login screen ───────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 20%, #1A2540 0%, #0E0E10 60%);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px; text-align: center;
}
.login-card .logo {
  width: 64px; height: 64px; border-radius: 16px; margin: 0 auto 12px;
  background: linear-gradient(135deg, #1A3575, #0A1C41);
  display: flex; align-items: center; justify-content: center;
  color: var(--gold); font-weight: 900; font-size: 18px;
  box-shadow: 0 0 30px rgba(212,146,10,.25);
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
/* ── Reseller portal logos (migration 044) ───────────────────
   A portal may supply an image instead of the initials tile.
   object-fit:contain keeps a wide wordmark or a square mark both intact.
   On the sign-in card the image is 1.5x the initials tile (96 vs 64, owner's
   request 2026-12-01): a brand's icon is the page's whole identity there,
   while the stock tile only carries two letters. The sidebar keeps its size. */
.sidebar .brand .logo-img {
  width: 36px; height: 36px; border-radius: 9px;
  object-fit: contain; background: #0A1C41; border: 1px solid var(--border);
}
.login-card .logo-img {
  width: 96px; height: 96px; border-radius: 24px; margin: 0 auto 14px;
  display: block; object-fit: contain; background: #0A1C41;
}

.login-card .sub { color: var(--muted); font-size: 12px; margin-bottom: 24px; }
.login-card .btn { width: 100%; margin-top: 16px; padding: 12px; }
.login-card label { text-align: start; }

/* ── Password field + show/hide eye (login card) ──────────────
   The button sits INSIDE the field on the inline-end side, so the
   logical property keeps it correct in both LTR (en) and RTL (ar)
   without a dir-specific rule. type="button" keeps Enter submitting
   the form and the toggle out of the POST. */
.login-card .pw-wrap { position: relative; }
.login-card .pw-wrap input { width: 100%; padding-inline-end: 38px; }
.login-card .pw-eye {
  position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0;
  background: transparent; border: 0; border-radius: 6px;
  color: var(--muted); cursor: pointer;
}
.login-card .pw-eye:hover { color: var(--text); }
.login-card .pw-eye:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.login-card .pw-eye svg { fill: currentColor; }
.login-card .pw-eye .eye-shut { display: none; }
.login-card .pw-eye[aria-pressed="true"] .eye-open { display: none; }
.login-card .pw-eye[aria-pressed="true"] .eye-shut { display: block; }

/* ── Flash messages ─────────────────────────────────────────── */
.flash {
  padding: 11px 14px; border-radius: 8px; margin-bottom: 16px;
  font-size: 12px; font-weight: 600;
}
.flash.ok    { background: rgba(34,197,94,.10);  color: var(--green); border: 1px solid rgba(34,197,94,.3); }
.flash.error { background: rgba(239,68,68,.10);  color: var(--red);   border: 1px solid rgba(239,68,68,.3); }

/* ── Mobile menu (hamburger) ────────────────────────────────── */
.menu-btn {
  display: none;
  align-items: center; justify-content: center;
  width: 38px; height: 38px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  padding: 0;
  margin-inline-end: 12px;
  flex: 0 0 38px;
}
.menu-btn:hover { background: var(--border); color: var(--gold); }
.menu-btn svg { width: 18px; height: 18px; display: block; }
.menu-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.sidebar-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}
.sidebar-overlay.show { opacity: 1; pointer-events: auto; }

/* ── Mobile / tablet ────────────────────────────────────────── */
@media (max-width: 900px) {
  /* Off-canvas sidebar — slides in from the leading edge */
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0;
    width: 260px; flex-basis: 260px;
    z-index: 90;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 6px 0 18px rgba(0,0,0,.5);
  }
  html[dir="rtl"] .sidebar {
    transform: translateX(100%);
    box-shadow: -6px 0 18px rgba(0,0,0,.5);
  }
  .sidebar.open,
  html[dir="rtl"] .sidebar.open { transform: translateX(0); }
  /* Restore full labels inside the drawer (older rule hid them) */
  .sidebar .brand .name,
  .sidebar nav .text,
  .sidebar nav .label { display: revert; }
  .sidebar nav a { justify-content: flex-start; }

  /* Topbar gets the hamburger; right side shows only the lang toggle */
  .menu-btn { display: inline-flex; }
  .topbar { padding: 0 14px; gap: 8px; }
  .topbar h1 { font-size: 14px; flex: 1; min-width: 0;
               overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar .user .pill { display: none; }

  /* Content / cards tighter */
  .content { padding: 16px 14px; }
  .card { padding: 14px; border-radius: 10px; margin-bottom: 14px; }
  .card h2 { font-size: 13px; }

  /* Stats — 2-up on phones */
  .stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 16px; }
  .stat { padding: 14px; }
  .stat .value { font-size: 20px; }

  /* Tables keep their native cell layout, scroll horizontally inside the card */
  .table { min-width: 560px; }
  .table th, .table td { padding: 9px 10px; font-size: 12px; }

  /* Forms — let row children collapse cleanly to a single column */
  .row > * { min-width: 0; }
  .toolbar { gap: 8px; }
  .toolbar .grow { min-width: 160px; }

  /* iOS — 16px input font prevents the auto-zoom on focus */
  input[type="text"], input[type="password"], input[type="email"],
  input[type="number"], input[type="url"], input[type="datetime-local"],
  input[type="date"], input[type="search"], input[type="tel"], select, textarea { font-size: 16px; }

  /* Login screen — compact card */
  .login-card { padding: 24px; border-radius: 14px; }
}

@media (max-width: 480px) {
  .content { padding: 14px 10px; }
  .card { padding: 12px; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat { padding: 12px; }
  .stat .value { font-size: 18px; }
  .stat .label { font-size: 10px; }
  /* Drop the lang/logout labels, keep the icons — saves the topbar from wrapping */
  .lang-toggle .lang-toggle-label,
  .logout-btn .logout-btn-label { display: none; }
  .lang-toggle, .logout-btn { padding: 5px 8px; }
  /* Tighter table cells for the smallest screens */
  .table th, .table td { padding: 7px 8px; font-size: 11.5px; }
}

/* Phones: stack every form .row to a single column. Without this the wider
   media rule (.row > * { min-width:0 }) lets flex children shrink instead of
   wrap, so multi-field rows (DNS add-server, MAC-Users add-user) crush to
   unreadable widths and the Settings two-column never stacks. .row is the
   shared form-row primitive across all admin pages, so this fixes them all. */
@media (max-width: 640px) {
  .row { flex-direction: column; gap: 0; }
  .row > * { width: 100%; flex: none; }
}

/* ── Language toggle (single corner icon) ───────────────────── */
.lang-toggle {
  display: inline-flex; align-items: center; gap: 5px;
  height: 28px; padding: 0 11px; white-space: nowrap;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11px; line-height: 1;
  font-weight: 700;
  text-decoration: none;
  transition: all .15s;
}
.lang-toggle:hover {
  color: var(--gold);
  border-color: var(--gold);
  background: rgba(212,146,10,.10);
}
.lang-toggle-label { font-size: 11px; letter-spacing: .3px; }

/* Top-bar logout — sits next to the language toggle so the
   user can sign out from any page (essential on mobile, where
   the sidebar is collapsed behind the hamburger). Picks up the
   red accent so it reads as a leaving/destructive action. */
.logout-btn {
  display: inline-flex; align-items: center; gap: 5px;
  height: 28px; padding: 0 11px; white-space: nowrap;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11px; line-height: 1;
  font-weight: 700;
  text-decoration: none;
  transition: all .15s;
}
.logout-btn:hover {
  color: var(--red);
  border-color: rgba(239,68,68,.4);
  background: rgba(239,68,68,.10);
}
.logout-btn-label { font-size: 11px; letter-spacing: .3px; }

/* Fixed-position variant for the login screen — sits in the
   viewport's trailing corner so a fresh visitor can switch
   language without scrolling or interacting with the card. */
.lang-toggle-fixed {
  position: fixed;
  top: 16px;
  inset-inline-end: 16px;
  z-index: 10;
  background: var(--surface);
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
}

/* ── 2026-07-03 UX batch ────────────────────────────────────── */
/* Clickable dashboard stat tiles */
a.stat { display: block; color: inherit; text-decoration: none; transition: border-color .15s; }
a.stat:hover { border-color: var(--gold); }
a.stat:hover .label { color: var(--gold-2); }

/* Shared muted paragraph (change_host/trial/login_themes de-skin) */
.muted { color: var(--muted); font-size: 12.5px; }

/* Copy-to-clipboard affordance + toast */
[data-copy] { cursor: pointer; }
[data-copy]:hover { text-decoration: underline; }
#copy-toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--gold); color: var(--gold);
  padding: 8px 16px; border-radius: 999px; font-size: 12px; font-weight: 700;
  z-index: 200; opacity: 0; transition: opacity .2s; pointer-events: none;
}
#copy-toast.show { opacity: 1; }

/* Text hex field + native color picker pair */
.color-pair { display: flex; gap: 6px; align-items: center; }
.color-pair input[type="text"] { flex: 1; }
.color-pair input[type="color"] {
  width: 42px; height: 38px; padding: 2px; flex: 0 0 42px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer;
}

/* Dashboard 14-day activations chart (pure CSS bars) */
.chart-bars { display: flex; align-items: flex-end; gap: 6px; height: 110px; }
.chart-bars .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; text-align: center; min-width: 0; }
.chart-bars .bar i { display: block; background: var(--gold); border-radius: 3px 3px 0 0; min-height: 2px; }
.chart-bars .bar i.trial { background: var(--blue); border-radius: 0; }
.chart-bars .bar small { color: var(--muted); font-size: 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-legend { display: flex; gap: 14px; margin-top: 10px; font-size: 11px; color: var(--muted); }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: -1px; margin-inline-end: 4px; }

/* Super-admin working-brand picker (topbar) — same 28px chip metrics as the
   pills/lang/logout so the topbar stays one even row. */
/* The control that decides whose customers you are about to edit is the most
   consequential one in the header, so it is sized like it (audit P-10). It
   stays visible on phones — hiding it there left a super admin unable to see
   or change which tenant they were acting on. */
.brand-picker {
  width: auto; max-width: 200px; height: 34px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 999px; padding: 0 12px;
  font-size: 13px; font-weight: 700; line-height: 1;
}
.brand-picker:hover { border-color: var(--gold); }
@media (max-width: 640px) { .brand-picker { max-width: 132px; font-size: 12px; padding: 0 8px; } }

/* ── Active-brand context strip ──────────────────────────────────
   Sits at the top of every page's content and names the tenant whose
   records are on screen, in that brand's accent. */
.brand-ctx {
  --brand-accent: var(--gold);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 14px; margin: 0 0 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-inline-start: 3px solid var(--brand-accent);
  border-radius: 8px; font-size: 12.5px;
}
.brand-ctx.all { --brand-accent: var(--muted); }
.brand-ctx-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--brand-accent); flex: 0 0 auto;
}
.brand-ctx-name {
  font-weight: 800; font-size: 14px; color: var(--text);
  letter-spacing: .2px;
}
.brand-ctx-note { color: var(--muted); }
@media (max-width: 640px) {
  .brand-ctx { padding: 8px 11px; font-size: 12px; }
  .brand-ctx-note { flex-basis: 100%; }
}

/* ── RTL overrides ──────────────────────────────────────────────
   Most layout uses logical properties (flex + start/end) which auto-
   flip. These rules cover the few physical leftovers and add Cairo
   as the primary font for Arabic so the script renders properly. */
html[dir="rtl"] body {
  font-family: "Cairo", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
html[dir="rtl"] .sidebar {
  border-right: none;
  border-left: 1px solid var(--border);
}
html[dir="rtl"] .stat .delta,
html[dir="rtl"] .pager,
html[dir="rtl"] .toolbar {
  direction: rtl;
}
/* The audit-log timestamps in settings.php float right by default;
   in RTL they should hug the left edge instead so they still sit on
   the trailing side of the row. */
html[dir="rtl"] .content small[style*="float:right"] {
  float: left !important;
}


/* ── Broadcast actions ───────────────────────────────────────────
   Adding one ad and forcing an update onto every installed device used to
   wear the same amber button. Broadcast submits now read as their own tier,
   and each states its reach before it is clicked (audit H-02). */
.btn.primary.broadcast {
  background: linear-gradient(180deg, #B4400E, #8E2F08);
  border-color: #C2551F; color: #FFF1E8;
}
.btn.primary.broadcast:hover { background: linear-gradient(180deg, #C74A12, #A3380A); }
.btn.primary.broadcast[disabled] {
  background: var(--surface-2); border-color: var(--border);
  color: var(--muted); cursor: not-allowed;
}

.blast {
  margin: 12px 0 0; padding: 8px 12px; font-size: 12.5px;
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-inline-start: 3px solid var(--muted);
  border-radius: 6px;
}
.blast.wide { border-inline-start-color: #C2551F; }

.promote-state { display: grid; gap: 6px; margin: 0 0 10px; }
.promote-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; }
.promote-pf {
  min-width: 74px; font-weight: 700; text-transform: uppercase;
  font-size: 10.5px; letter-spacing: 1px; color: var(--dim);
}
.promote-warn {
  margin: 10px 0 0; font-size: 12px; color: var(--muted);
  padding-inline-start: 10px; border-inline-start: 2px solid var(--border);
}


/* ── Stacked table cards on phones ───────────────────────────────
   Below 640px a wide table stops being a table: each row becomes a card with
   its cells labelled, so the actions an operator most wants from a phone —
   extend an expiring customer, check a MAC — are reachable without a
   sideways scroll. Cell captions come from the matching <th>, copied into
   data-label by the script in _layout.php, so no page markup changes.
   Opt in per table with `class="table stack"`. */
@media (max-width: 640px) {
  .table.stack { min-width: 0; border: none; background: none; }
  .table.stack thead { display: none; }
  .table.stack tbody, .table.stack tr, .table.stack td { display: block; width: 100%; }
  .table.stack tr {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; padding: 10px 12px; margin-bottom: 10px;
  }
  .table.stack tr:hover td { background: none; }
  .table.stack td {
    border-bottom: none; padding: 4px 0;
    display: flex; gap: 10px; align-items: baseline; justify-content: space-between;
  }
  .table.stack td::before {
    content: attr(data-label);
    flex: 0 0 40%;
    font-size: 10px; font-weight: 700; letter-spacing: 1px;
    text-transform: uppercase; color: var(--muted);
  }
  /* A cell whose header is blank (the actions column) spans the full width
     and drops the caption, so the buttons get the whole row. */
  .table.stack td[data-label=""]::before { content: none; }
  .table.stack td[data-label=""] { display: block; padding-top: 10px; margin-top: 6px;
                                   border-top: 1px solid var(--border); }
  .table.stack td[data-label=""] .btn { min-height: 36px; }
  .table.stack td[data-label=""] .btn-group { flex-wrap: wrap; gap: 8px; }
  /* Empty-state row keeps its own centred treatment. */
  .table.stack td[colspan]::before { content: none; }
  .table.stack td[colspan] { display: block; text-align: center; }
}


/* ── Inbox message cell ──────────────────────────────────────────
   Clamp to three lines so one long message cannot set the column width for
   the whole table; click or Enter expands it in place. */
.msg-cell { max-width: 420px; }
.msg-clamp {
  white-space: pre-wrap; word-break: break-word; cursor: pointer;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}
.msg-clamp.open { -webkit-line-clamp: unset; overflow: visible; }
.msg-clamp:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }


/* Consequence line under a select whose choice has real-world effect. */
.role-desc {
  margin: 6px 0 0; font-size: 12px; line-height: 1.45; color: var(--muted);
}
.role-desc:empty { display: none; }
/* A field whose value is fixed by another choice — shown, not editable. */
.static-field {
  padding: 10px 12px; background: var(--surface-2);
  border: 1px dashed var(--border); border-radius: 8px;
  color: var(--text); font-size: 13px;
}


/* Field-level notes on the DNS form. .feat-off marks a control whose value is
   overridden at brand level, so the operator is told why it will not take
   effect instead of watching the app ignore it. */
.field-hint { margin-top: 4px; font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.feat-off {
  margin-top: 6px; padding: 7px 9px; font-size: 11.5px; line-height: 1.5;
  color: var(--gold-2); background: rgba(212,146,10,.08);
  border: 1px solid rgba(212,146,10,.28); border-radius: 6px;
}
.feat-off a { text-decoration: underline; white-space: nowrap; }

/* Read-only mirror of a setting whose real home is another page. */
.mirror { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.mirror-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; margin-bottom: 8px;
  font-size: 11px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--muted);
}
.mirror-body { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; }


/* ── Collapsible create panel ────────────────────────────────────
   The create form used to sit above the list on every list page, so reading
   the list — the constant action — cost a scroll past the rare one. The
   heading is now the toggle, and the list starts one row below it. */
.create-panel { padding: 0; }
.create-panel > summary {
  padding: 14px 20px; cursor: pointer; list-style: none;
  display: flex; align-items: center; gap: 10px;
  font-family: inherit; font-size: 14px; font-weight: 700; color: var(--gold);
}
.create-panel > summary::-webkit-details-marker { display: none; }
.create-panel > summary:hover { color: var(--gold-2); }
.create-panel > summary:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.create-toggle {
  flex: 0 0 auto; width: 20px; height: 20px; border-radius: 5px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--gold); font-weight: 700; line-height: 1;
  transition: transform .15s ease;
}
.create-panel[open] > summary { border-bottom: 1px solid var(--border); }
.create-panel[open] .create-toggle { transform: rotate(45deg); }
.create-panel > *:not(summary) { padding-inline: 20px; }
.create-panel > form:last-child,
.create-panel > *:last-child { padding-bottom: 20px; }
@media (max-width: 900px) {
  .create-panel > summary { padding: 12px 14px; font-size: 13px; }
  .create-panel > *:not(summary) { padding-inline: 14px; }
}


/* Audit details: a readable sentence, with the raw JSON one click away. */
.audit-details { max-width: 380px; font-size: 12px; color: var(--muted); }
.audit-details > span { word-break: break-word; }
.audit-details details { margin-top: 3px; }
.audit-details summary {
  cursor: pointer; font-size: 10px; letter-spacing: .8px;
  text-transform: uppercase; color: var(--dim);
}
.audit-details code {
  display: block; margin-top: 4px; padding: 6px 8px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px;
  font-size: 11px; word-break: break-all; color: var(--muted);
}


/* A page whose feature is intentionally switched off at the client end. Says
   so plainly rather than letting an operator configure something inert. */
.notice-dormant {
  padding: 14px 18px; margin-bottom: 18px;
  background: rgba(59,130,246,.08);
  border: 1px solid rgba(59,130,246,.32);
  border-inline-start: 3px solid var(--blue);
  border-radius: 10px;
}
.notice-dormant strong { display: block; margin-bottom: 5px; font-size: 13.5px; color: var(--text); }
.notice-dormant p { margin: 0; font-size: 12.5px; line-height: 1.55; color: var(--muted); max-width: 76ch; }


/* ── Dashboard hierarchy ─────────────────────────────────────────
   The counters that imply an action are given size and their own row; the
   standing counts sit quieter beneath. */
.stats-head {
  font-size: 10.5px; font-weight: 700; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--muted); margin: 0 0 8px;
}
.stats-head + .stats { margin-bottom: 18px; }
.stats-attention { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.stat.urgent { padding: 20px; border-color: #33333A; }
.stat.urgent .value { font-size: 32px; }
.stat.urgent .label { font-size: 11.5px; }
.stats-standing .stat { padding: 14px 16px; }
.stats-standing .value { font-size: 20px; }
.delta { margin-top: 5px; font-size: 11px; color: var(--dim); }
.delta.up   { color: var(--green); }
.delta.down { color: var(--gold-2); }
@media (max-width: 640px) {
  .stats-attention { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .stat.urgent { padding: 14px; }
  .stat.urgent .value { font-size: 24px; }
}


/* Advisory length counter — amber past the point a device truncates. */
.char-counter { margin-top: 4px; font-size: 11px; color: var(--dim); text-align: end; }
.char-counter.over { color: var(--gold-2); font-weight: 700; }

/* Shared empty-state cell, modelled on the Trial page's wording. */
.empty-state {
  text-align: center; padding: 26px 18px !important;
  color: var(--muted); font-size: 13px; line-height: 1.6;
}
