/*
  SpiderPanel · Admin Design System
  ──────────────────────────────────
  PerfectPanel-inspired clean admin UI.
  Two themes: [data-theme="light"] (default) / [data-theme="dark"]
*/

:root {
  /* Accent: PerfectPanel blue */
  --accent:       #337ab7;
  --accent-hov:   #286090;
  --accent-soft:  rgba(51,122,183,.12);

  /* Status colors */
  --ok:     #67c23a;
  --warn:   #e6a23c;
  --err:    #f56c6c;
  --info:   #409eff;

  /* Radii: minimal for PerfectPanel look */
  --r-sm: 3px;
  --r:    4px;
  --r-lg: 4px;
  --r-xl: 6px;
  --t:    150ms ease;
}

/* ---------- light theme (default) ---------- */
:root, [data-theme="light"] {
  --bg-0:      #ffffff;
  --bg:        #f5f5f5;
  --bg-2:      #ffffff;
  --surface:   #ffffff;
  --surface-2: #f5f5f5;
  --surface-3: #e8e8e8;
  --border:    #ddd;
  --border-2:  #ccc;

  --fg:        #333;
  --fg-dim:    #555;
  --fg-muted:  #999;
  --fg-faint:  #bbb;

  --scrim:     rgba(0,0,0,.4);
  --shadow-1:  0 1px 3px rgba(0,0,0,.08);
  --shadow-2:  0 4px 12px rgba(0,0,0,.1);
  --shadow-3:  0 8px 30px rgba(0,0,0,.12);

  color-scheme: light;
}

/* ---------- dark theme ---------- */
[data-theme="dark"] {
  --bg-0:      #1a1a2e;
  --bg:        #1e1e2d;
  --bg-2:      #27293d;
  --surface:   #27293d;
  --surface-2: #2e3148;
  --surface-3: #3a3d52;
  --border:    #3e4162;
  --border-2:  #4d5070;

  --fg:        #e0e0e0;
  --fg-dim:    #c0c0c0;
  --fg-muted:  #8a8a9a;
  --fg-faint:  #5e6078;

  --scrim:     rgba(0,0,0,.6);
  --shadow-1:  0 1px 3px rgba(0,0,0,.3);
  --shadow-2:  0 4px 12px rgba(0,0,0,.35);
  --shadow-3:  0 8px 30px rgba(0,0,0,.4);

  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family:
    "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI",
    system-ui, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background var(--t), color var(--t);
}
a { color: var(--fg-dim); text-decoration: none; transition: color var(--t); }
a:hover { color: var(--fg); }
code, kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: var(--r-sm);
  color: var(--fg-dim);
}
::selection { background: var(--accent-soft); color: var(--fg); }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 16px; }
h2 { font-size: 14px; }
h3 { font-size: 13px; }
p { margin: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }

/* scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-2); }

/* ========================================================================
   TOPBAR  (admin layout)
   ======================================================================== */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 2px;
  padding: 0 clamp(8px, 1.5vw, 16px);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  min-height: 36px;
}
.brand {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 700; font-size: 13px; color: var(--fg);
  text-decoration: none; white-space: nowrap;
  padding: 2px 6px 2px 0;
  margin-right: 4px;
}
.brand img { display: block; width: 20px; height: 20px; }

.topnav {
  display: flex; gap: 0; flex: 1;
  overflow-x: auto; scrollbar-width: none;
}
.topnav::-webkit-scrollbar { display: none; }
.topnav a {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 8px 8px; border-radius: 0;
  color: var(--fg-muted); font-weight: 400; font-size: 12px;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color var(--t), border-color var(--t);
}
.topnav a:hover { color: var(--fg); }
.topnav a.active { color: var(--fg); font-weight: 600; border-bottom-color: var(--accent); }
.topnav .badge {
  background: #f60; color: #fff; font-size: 9px;
  padding: 0 5px; border-radius: 8px; font-weight: 700;
  min-width: 16px; text-align: center; line-height: 16px;
}
.topright {
  display: flex; align-items: center; gap: 4px; margin-left: auto;
}

/* ---- theme toggle button ---- */
.theme-btn, .bell, .help-btn {
  background: transparent; border: 0;
  width: 30px; height: 30px; border-radius: 4px;
  color: var(--fg-muted); cursor: pointer;
  display: grid; place-items: center;
  transition: background var(--t), color var(--t);
}
.theme-btn:hover, .bell:hover, .help-btn:hover { background: var(--surface-2); color: var(--fg); }
/* Help ("i") button — lowercase i in a circle to read as "info". The font
   weight is bumped so the glyph stays legible at 36px despite being a
   single character. */
.help-btn {
  font: 600 15px/1 ui-sans-serif, system-ui, sans-serif;
  font-style: italic;
}
.help-btn::before { content: ""; position: absolute; }
.theme-btn svg.sun,
[data-theme="light"] .theme-btn svg.moon { display: none; }
[data-theme="light"] .theme-btn svg.sun { display: block; }
.bell { position: relative; }
.bell-dot {
  position: absolute; top: 7px; right: 7px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--bg);
}

/* ---- avatar menu ---- */
.avatar-menu { position: relative; }
.avatar-menu summary {
  list-style: none; cursor: pointer;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface-2); color: var(--fg);
  display: grid; place-items: center;
  font-weight: 600; font-size: 11px;
  transition: background var(--t);
}
.avatar-menu summary::-webkit-details-marker { display: none; }
.avatar-menu summary:hover { background: var(--surface-3); }
.avatar-menu[open] .menu { display: block; }
.avatar-menu .menu {
  display: none; position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 240px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-2); z-index: 50;
}
.avatar-menu .menu a, .avatar-menu .menu .menu-head {
  display: block; padding: 8px 12px; border-radius: var(--r-sm);
  color: var(--fg-dim); font-size: 13px;
}
.avatar-menu .menu-head {
  color: var(--fg-muted);
  border-bottom: 1px solid var(--border); margin-bottom: 4px;
}
.avatar-menu .menu a:hover { background: var(--surface-2); color: var(--fg); }

/* ========================================================================
   LAYOUT SHELL
   ======================================================================== */
.wrap {
  max-width: 100%; margin: 0 auto;
  padding: 6px clamp(10px, 1.5vw, 18px);
}
.pageheader {
  display: flex; justify-content: space-between; align-items: center;
  gap: 6px; flex-wrap: wrap; margin-bottom: 4px; min-height: 0;
}
.pageheader:empty { display: none; }
@media (max-width: 780px) {
  .pageheader { margin-bottom: 8px; gap: 8px; }
  .pageheader h1 { font-size: 18px; }
  .pageheader .actions .btn { padding: 4px 10px; font-size: 12px; }
  .filters { gap: 6px; margin: 6px 0; }
  .tabs { font-size: 12px; gap: 4px; }
  .tabs a { padding: 6px 8px; }
}
.pageheader .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pageheader .sub { color: var(--fg-muted); font-size: 13px; margin-top: 4px; }
.muted { color: var(--fg-muted); }
.small { font-size: 12px; }
.empty {
  padding: 28px; text-align: center; color: var(--fg-muted);
  font-size: 13px;
}

/* ========================================================================
   BUTTONS
   ======================================================================== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: var(--r);
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  font-size: 13px; font-weight: 400; font-family: inherit;
  cursor: pointer; user-select: none;
  text-decoration: none; white-space: nowrap;
  transition: background var(--t), border-color var(--t);
}
.btn:hover { background: var(--surface-2); border-color: var(--border-2); }
.btn:active { opacity: .9; }
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-soft);
  border-color: var(--accent);
}
.btn.small { padding: 4px 8px; font-size: 12px; border-radius: var(--r-sm); }
.btn.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.btn.primary:hover {
  background: var(--accent-hov); border-color: var(--accent-hov);
}
.btn.danger {
  background: #d9534f; border-color: #d43f3a; color: #fff;
}
.btn.danger:hover {
  background: #c9302c; border-color: #ac2925;
}
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface); }
.btn.icon-only { width: 36px; justify-content: center; padding: 0; }

/* ========================================================================
   CARDS / PANELS
   ======================================================================== */
.card, .panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 16px;
}
.card + .card, .panel + .panel { margin-top: 14px; }
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; flex-wrap: wrap; gap: 8px;
}
.panel-head h2 { font-size: 14px; font-weight: 600; }

/* ========================================================================
   TABLES
   ======================================================================== */
.admin-table {
  width: 100%; border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  overflow: hidden;
  margin-top: 4px;
}
.admin-table th, .admin-table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left; vertical-align: middle;
  font-size: 12px;
  line-height: 1.4;
}
.admin-table th {
  color: var(--fg); font-weight: 600; font-size: 12px;
  text-transform: none; letter-spacing: 0;
  background: var(--bg-2);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table tr:hover td { background: color-mix(in srgb, var(--info) 4%, var(--surface)); }
.admin-table .link {
  max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: ui-monospace, monospace; font-size: 11px; color: var(--fg-dim);
}
.table-scroll { overflow-x: auto; margin: 0; }

/* inline action cluster in the last column */
.row-actions {
  display: inline-flex; gap: 6px; flex-wrap: nowrap;
}

/* ========================================================================
   FORMS
   ======================================================================== */
.form { display: grid; gap: 14px; max-width: 520px; }
.form-wide { max-width: none; }
.form label {
  display: flex; flex-direction: column; gap: 6px;
  color: var(--fg-muted); font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
}
.form label.inline {
  flex-direction: row; align-items: center; gap: 10px;
  text-transform: none; font-size: 13px; color: var(--fg); font-weight: 500;
}
.form label.span2 { grid-column: span 2; }
.form input, .form select, .form textarea {
  padding: 10px 12px;
  border-radius: var(--r);
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--fg);
  font-size: 13px; font-family: inherit;
  transition: border-color var(--t), box-shadow var(--t);
}
[data-theme="light"] .form input,
[data-theme="light"] .form select,
[data-theme="light"] .form textarea { background: #fff; }
.form input:focus, .form select:focus, .form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form input:disabled, .form select:disabled {
  color: var(--fg-muted); background: var(--bg); cursor: not-allowed;
}
.form textarea { resize: vertical; min-height: 100px; }
.grid2 {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
@media (max-width: 640px) {
  .grid2 { grid-template-columns: 1fr; }
  .form label.span2 { grid-column: auto; }
}
.input-with-btn { display: flex; gap: 6px; align-items: stretch; }
.input-with-btn input { flex: 1; min-width: 0; }
.fs {
  border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 16px; margin: 8px 0; background: var(--bg-2);
}
.fs legend {
  padding: 0 8px; color: var(--fg-muted);
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
}
.row-end { display: flex; gap: 10px; justify-content: flex-start; align-items: center; flex-wrap: wrap; }

/* ========================================================================
   FILTERS / TOOLBARS
   ======================================================================== */
.filters {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-bottom: 8px; align-items: stretch;
}
.filters input, .filters select {
  padding: 4px 8px; border-radius: var(--r); font-size: 12px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--fg); font-size: 13px;
  transition: border-color var(--t), box-shadow var(--t);
}
.filters input:focus, .filters select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ========================================================================
   TABS
   ======================================================================== */
.tabs {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  padding: 6px 10px; font-size: 12px; color: var(--fg-muted);
  display: inline-flex; align-items: center; gap: 4px;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color var(--t), border-color var(--t);
}
.tabs a:hover { color: var(--accent); }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tabs .badge {
  background: transparent; color: inherit;
  font-size: 12px; padding: 0; font-weight: 400;
}
.tabs a.active .badge { color: inherit; }

/* ========================================================================
   BADGES
   ======================================================================== */
.bdg {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 6px; border-radius: 3px;
  font-size: 11px; font-weight: 400; text-transform: capitalize;
  background: var(--surface-2); color: var(--fg-muted);
  border: none;
  line-height: 1.4;
}
.bdg-pending, [class*="bdg-in"] {
  background: rgba(230,162,60,.12);
  color: var(--warn);
}
.bdg-partial, .bdg-completed, .bdg-done {
  background: rgba(103,194,58,.12);
  color: var(--ok);
}
.bdg-canceled, .bdg-failed {
  background: rgba(245,108,108,.12);
  color: var(--err);
}

/* ========================================================================
   PAGINATION
   ======================================================================== */
.pagination {
  display: flex; gap: 4px; margin-top: 8px;
  align-items: center; flex-wrap: wrap;
}
.pagination .btn[aria-current="page"] {
  background: var(--surface); border-color: var(--accent); color: var(--fg);
}

/* ========================================================================
   DASHBOARD HERO + STATS
   ======================================================================== */
.hero {
  display: grid; grid-template-columns: 1fr auto;
  align-items: center; gap: 24px;
  padding: clamp(16px, 3vw, 28px) clamp(16px, 3vw, 30px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-bottom: 18px;
  overflow: hidden; position: relative;
}
.hero .kicker {
  text-transform: uppercase; letter-spacing: .12em;
  font-size: 10px; color: var(--fg-muted);
  margin: 0 0 8px; font-weight: 700;
}
.hero h1 {
  margin: 0 0 6px;
  font-size: clamp(24px, 3vw, 34px); line-height: 1.05;
  font-weight: 700; letter-spacing: -0.025em;
}
.hero p.muted { font-size: 14px; }
.hero-big {
  display: flex; flex-direction: column; align-items: flex-end;
  gap: 6px; padding-left: 24px;
  border-left: 1px solid var(--border);
}
.hero-big .big-num {
  font-size: clamp(34px, 6vw, 56px); font-weight: 800;
  letter-spacing: -0.03em; line-height: 1; color: var(--fg);
}
.hero-big .big-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--fg-muted); font-weight: 600;
}
@media (max-width: 640px) {
  .hero { grid-template-columns: 1fr; }
  .hero-big {
    align-items: flex-start; padding-left: 0; padding-top: 16px;
    border-left: 0; border-top: 1px solid var(--border);
  }
}

.stat-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr));
  margin-bottom: 22px;
}
/* Two-column dashboard row — leaderboards sit side-by-side on wide
   screens and stack on narrow ones. No margin-bottom override: each
   child .panel already carries its own bottom margin. */
.two-col {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr));
  margin-bottom: 22px;
}
.stat {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 16px;
  transition: border-color var(--t);
}
.stat:hover {
  border-color: var(--border-2);
}
.stat-head {
  display: flex; align-items: center; gap: 12px; margin-bottom: 12px;
}
.stat-ico {
  width: 36px; height: 36px; border-radius: var(--r);
  background: var(--surface-2); display: grid; place-items: center;
  flex-shrink: 0;
}
.stat-ico svg { width: 18px; height: 18px; color: var(--fg-muted); }
.stat-head h2 {
  margin: 0; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--fg-muted);
}
.stat-value {
  font-size: clamp(28px, 3vw, 34px); font-weight: 800;
  letter-spacing: -0.025em; line-height: 1;
  margin: 4px 0 6px; color: var(--fg);
}
.stat-sub { font-size: 12px; color: var(--fg-muted); }

/* accent per stat card (first 4 pick a colored icon) */
.stat.stat-pending .stat-ico { background: rgba(230,162,60,.12); }
.stat.stat-pending .stat-ico svg { color: var(--warn); }
.stat.stat-today   .stat-ico { background: rgba(51,122,183,.12); }
.stat.stat-today   .stat-ico svg { color: var(--accent); }
.stat.stat-done    .stat-ico { background: rgba(103,194,58,.12); }
.stat.stat-done    .stat-ico svg { color: var(--ok); }
.stat.stat-failed  .stat-ico { background: rgba(245,108,108,.12); }
.stat.stat-failed  .stat-ico svg { color: var(--err); }
.stat.stat-revenue .stat-ico { background: rgba(64,158,255,.12); }
.stat.stat-revenue .stat-ico svg { color: var(--info); }

.trend-chart {
  width: 100%; min-height: 200px;
  padding: 8px; border-radius: var(--r);
  background: var(--bg-2);
}

.status-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}
.status-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: var(--bg-2);
  border: 1px solid var(--border); border-radius: var(--r);
}
.status-count { font-weight: 700; font-size: 18px; color: var(--fg); }

/* ========================================================================
   SERVICES GROUPED ROWS
   ======================================================================== */
.services-group { margin-top: 22px; }
.services-group h2.cat {
  padding: 8px 12px; background: var(--surface-2);
  border-radius: var(--r); margin: 0 0 4px;
  font-size: 13px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
  border-left: 3px solid var(--accent);
}
.services-group h2.cat::before { display: none; }

/* ========================================================================
   LOGIN PAGE
   ======================================================================== */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  padding: clamp(26px, 5vw, 40px); border-radius: var(--r);
  width: min(420px, 100%);
  box-shadow: var(--shadow-2);
}
.login-card h1 {
  margin: 0 0 24px; font-size: 22px; text-align: center;
  letter-spacing: -0.025em;
}
.error {
  color: var(--err); text-align: center; margin: 0 0 14px;
  padding: 8px 12px; background: rgba(245,108,108,.08);
  border: 1px solid rgba(245,108,108,.2);
  border-radius: var(--r); font-size: 13px;
}

/* ========================================================================
   DIALOGS — popup-based admin edits
   ======================================================================== */
dialog {
  background: var(--surface); color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 0;
  width: min(560px, calc(100% - 24px));
  max-height: min(90vh, 780px);
  box-shadow: var(--shadow-3);
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity .15s ease-out;
  margin: 0;
  overflow: hidden;
}
dialog[open] { opacity: 1; transform: translate(-50%, -50%); }
dialog::backdrop { background: var(--scrim); backdrop-filter: blur(4px); }
dialog[data-size="sm"] { width: min(420px, calc(100% - 24px)); }
dialog[data-size="lg"] { width: min(780px, calc(100% - 24px)); }
dialog h1 { font-size: 18px; margin: 0; letter-spacing: -0.015em; }
dialog h2 { font-size: 15px; margin: 0; }

.edit-dlg { position: relative; display: flex; flex-direction: column; }
.edit-dlg .dlg-body {
  padding: 20px 22px 0;
  max-height: inherit;
  overflow: auto;
  display: flex; flex-direction: column;
}
.edit-dlg .dlg-close {
  position: absolute; top: 8px; right: 10px;
  background: transparent; border: 0;
  font-size: 22px; line-height: 1; color: var(--fg-muted);
  cursor: pointer; padding: 4px 10px; border-radius: var(--r-sm);
  z-index: 3;
}
.edit-dlg .dlg-close:hover { background: var(--surface-2); color: var(--fg); }

/* breadcrumbs + page-sub are noise inside a modal */
.edit-dlg .crumbs, .edit-dlg .sub { display: none; }

/* -------- Page help dialog -------- */
/* Same chrome as edit-dlg but wider and tuned for reading long prose. */
.help-dlg {
  position: relative; display: flex; flex-direction: column;
  width: min(720px, calc(100% - 24px));
  max-height: min(85vh, 760px);
}
.help-dlg .dlg-body {
  padding: 22px 28px 26px;
  max-height: inherit; overflow: auto;
}
.help-dlg .dlg-close {
  position: absolute; top: 8px; right: 10px;
  background: transparent; border: 0;
  font-size: 22px; line-height: 1; color: var(--fg-muted);
  cursor: pointer; padding: 4px 10px; border-radius: var(--r-sm);
  z-index: 3;
}
.help-dlg .dlg-close:hover { background: var(--surface-2); color: var(--fg); }

.help-body h2 {
  font-size: 18px; margin: 0 0 10px;
  letter-spacing: -0.01em;
}
.help-body h4 {
  font-size: 13px; margin: 18px 0 6px;
  letter-spacing: .02em; text-transform: uppercase;
  color: var(--fg-muted);
}
.help-body p, .help-body li {
  font-size: 13.5px; line-height: 1.55;
  color: var(--fg);
}
.help-body p { margin: 6px 0; }
.help-body ul, .help-body ol { margin: 4px 0 6px; padding-left: 20px; }
.help-body li { margin: 3px 0; }
.help-body code {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
  padding: 1px 6px;
  background: var(--surface-2);
  border-radius: 5px;
}
.help-body strong { color: var(--fg); font-weight: 600; }
.help-body em { color: var(--fg-muted); font-style: normal; text-decoration: underline dotted; }

/* -------- Admin form: permission fieldsets -------- */
.perm-toolbar {
  display: flex; align-items: center; gap: 8px;
  margin: 6px 0 -4px;
}
.perm-toolbar .btn.small { padding: 3px 10px; font-size: 11.5px; }
.perm-group {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 14px 12px;
  margin: 0;
}
.perm-group legend {
  display: flex; align-items: center; gap: 8px;
  padding: 0 6px; font-size: 12px; font-weight: 600;
  color: var(--fg); text-transform: uppercase; letter-spacing: .04em;
}
.perm-group legend .btn.small {
  font-size: 10.5px; padding: 2px 8px; border-radius: 6px;
  font-weight: 500; text-transform: none; letter-spacing: 0;
}
.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 6px 18px;
  margin-top: 6px;
}
.perm-row {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 8px;
  align-items: baseline;
  font-size: 13px; font-weight: 400;
  letter-spacing: 0; text-transform: none;
  color: var(--fg);
  cursor: pointer;
  padding: 2px 0;
}
.perm-row input[type="checkbox"] { margin: 0; }
.perm-row .perm-label { grid-column: 2; }
.perm-row .perm-hint {
  grid-column: 2;
  font-size: 11.5px;
  line-height: 1.35;
  display: block;
  margin-top: 1px;
}
.perm-row input[data-self-lock] { opacity: .55; cursor: not-allowed; }
.perm-row input[data-self-lock] + .perm-label { color: var(--fg-muted); }

/* -------- Provider metrics page -------- */
.pm-table th.num, .pm-table td.num { text-align: right; white-space: nowrap; }
.pm-table td.num .small { margin-left: 4px; }
.pm-table .pm-bar-col { min-width: 220px; width: 40%; }
.pm-bar {
  display: flex; width: 100%; height: 10px;
  border-radius: 6px; overflow: hidden;
  background: var(--surface-2);
}
.pm-seg { display: block; height: 100%; }
.pm-seg.pm-ok     { background: #22c55e; }  /* green */
.pm-seg.pm-warn   { background: #f59e0b; }  /* amber */
.pm-seg.pm-cancel { background: #94a3b8; }  /* slate */
.pm-seg.pm-fail   { background: #ef4444; }  /* red */
.pm-seg.pm-open   { background: #3b82f6; }  /* blue */
/* Column accent dots — tint just the leading digit group */
.pm-table td.pm-ok > *:first-child     { color: #16a34a; }
.pm-table td.pm-warn > *:first-child   { color: #d97706; }
.pm-table td.pm-cancel > *:first-child { color: #64748b; }
.pm-table td.pm-fail > *:first-child   { color: #dc2626; }
.pm-table td.pm-open > *:first-child   { color: #2563eb; }

/* Modal head pattern: h1 + a small badge/id beside it */
.modal-head {
  display: flex; align-items: baseline; gap: 10px;
  padding-bottom: 10px; margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.modal-head h1 { font-size: 17px; font-weight: 600; }
.modal-head .muted, .modal-head .small { font-size: 12px; }

/* Inline error banner (replaces alert()) */
.modal-error {
  margin: 0 0 12px;
  padding: 9px 12px;
  background: rgba(245,108,108,.08);
  border: 1px solid rgba(245,108,108,.2);
  border-radius: 4px;
  color: var(--err);
  font-size: 12.5px; line-height: 1.4;
}
.modal-error[hidden] { display: none; }

/* Compact form variant used inside modals */
.form.compact { gap: 10px; }
.form.compact label {
  font-size: 10px; letter-spacing: .05em; text-transform: uppercase;
  color: var(--fg-muted); font-weight: 600; gap: 4px;
}
.form.compact input,
.form.compact select,
.form.compact textarea {
  padding: 8px 11px; font-size: 13px; border-radius: 8px;
}
.form.compact .grid2 { gap: 10px; }

/* Sticky footer inside modals: save/cancel always visible while body scrolls. */
.form.compact .row-end {
  position: sticky;
  bottom: 0;
  margin: 12px -22px 0;
  padding: 12px 22px 14px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 2;
}
.form .input-suffix {
  display: flex; align-items: center; gap: 10px;
}

/* Button spinner (replaces the "disabled" while posting) */
.btn.loading {
  position: relative; pointer-events: none; color: transparent !important;
}
.btn.loading::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 14px; height: 14px; margin: -7px 0 0 -7px;
  border: 2px solid color-mix(in srgb, currentColor 35%, transparent);
  border-top-color: #fff;
  border-radius: 50%;
  animation: fs-spin .6s linear infinite;
}
.btn.loading:not(.primary):not(.danger)::after { border-top-color: var(--fg); }
@keyframes fs-spin { to { transform: rotate(360deg); } }

/* Confirm dialog (delete / destructive) */
.confirm-dlg .dlg-body { padding: 22px 24px 20px; }
.confirm-dlg h2 { font-size: 15.5px; font-weight: 600; margin: 0; }

/* Toast (lightweight feedback after save) */
.toast {
  position: fixed; left: 50%; bottom: 32px;
  transform: translate(-50%, 16px);
  background: var(--surface); color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px 18px; font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-3);
  opacity: 0; pointer-events: none;
  transition: transform .18s, opacity .18s;
  z-index: 200;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.error {
  border-color: rgba(245,108,108,.4);
  color: var(--err);
}

/* Collapsible details (modals + forms) */
.fs-details {
  border: 1px solid var(--border); border-radius: var(--r);
  padding: 0; background: var(--bg-2);
  margin: 4px 0;
}
.fs-details > summary {
  padding: 10px 14px; cursor: pointer; user-select: none;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; font-weight: 500;
  list-style: none; gap: 8px;
}
.fs-details > summary::-webkit-details-marker { display: none; }
.fs-details > summary::after {
  content: '▸'; color: var(--fg-muted); font-size: 12px;
  transition: transform var(--t);
}
.fs-details[open] > summary::after { transform: rotate(90deg); }
.fs-details > *:not(summary) {
  padding: 0 14px 14px;
}
.fs-details .admin-table { margin-top: 6px; }

/* key/value mini grid for read-only context inside a form */
.mini-kv {
  display: grid; gap: 6px 14px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  padding: 10px 12px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px;
  margin: 2px 0;
}
.mini-kv > div { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.mini-kv dt {
  font-size: 10px; color: var(--fg-muted);
  text-transform: uppercase; letter-spacing: .05em; font-weight: 600;
}
.mini-kv dd {
  margin: 0; font-size: 13px; color: var(--fg);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mini-kv dd.mono { font-family: ui-monospace, monospace; font-size: 12px; color: var(--fg-dim); }

/* Compact table variant (dense rows, smaller font) */
.admin-table.compact th,
.admin-table.compact td {
  padding: 4px 8px; font-size: 11px;
}
.admin-table.compact th {
  font-size: 10px; padding: 4px 8px;
}

/* ---------- mobile dialog: near-fullscreen for more usable editing ---------- */
@media (max-width: 640px) {
  dialog,
  dialog[data-size="sm"],
  dialog[data-size="lg"] {
    width: 100%; height: 100%; max-width: 100%; max-height: 100%;
    border-radius: 0;
    top: 0; left: 0; transform: none;
    border: 0;
  }
  dialog[open] { transform: none; }
  .edit-dlg .dlg-body { padding: 16px 14px 0; }
  .modal-head { margin-bottom: 10px; }
  .form.compact .grid2 { grid-template-columns: 1fr; }
  .form.compact .row-end {
    margin: 12px -14px 0;
    padding: 12px 14px calc(14px + env(safe-area-inset-bottom, 0px));
  }
}

/* ========================================================================
   NOTIFICATIONS DROPDOWN
   ======================================================================== */
.notifications {
  position: fixed; right: clamp(8px, 2vw, 24px); top: 64px; z-index: 40;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg);
  width: min(380px, calc(100vw - 20px));
  max-height: 70vh; overflow-y: auto;
  box-shadow: var(--shadow-3);
}
.notif { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.notif:last-child { border-bottom: 0; }
.notif h4 { margin: 0 0 4px; font-size: 13px; font-weight: 600; }
.notif p { margin: 0; font-size: 12px; color: var(--fg-muted); }
.notif .acts { display: flex; gap: 6px; margin-top: 8px; }

/* ========================================================================
   BREADCRUMBS
   ======================================================================== */
.crumbs {
  display: flex; align-items: center; gap: 6px;
  color: var(--fg-muted); font-size: 12px; margin-bottom: 8px;
}
.crumbs a { color: var(--fg-muted); }
.crumbs a:hover { color: var(--fg); }
.crumbs .sep { color: var(--fg-faint); }

/* ========================================================================
   ICONS
   ======================================================================== */
.ico {
  display: inline-block; vertical-align: -2px;
  color: currentColor; flex-shrink: 0;
}

/* ========================================================================
   UTILITIES
   ======================================================================== */
.hidden { display: none !important; }
.flex-row { display: flex; align-items: center; gap: 8px; }
.flex-col { display: flex; flex-direction: column; gap: 8px; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.kv-list { list-style: none; padding: 0; margin: 0; }
.kv-list li {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 6px 0; color: var(--fg-dim); font-size: 13px;
}

/* ========================================================================
   RESPONSIVE TWEAKS
   ======================================================================== */

/* Hamburger button — hidden on desktop, shown on mobile. */
.nav-toggle {
  display: none;
  background: transparent; border: 0;
  width: 36px; height: 36px; border-radius: 10px;
  cursor: pointer; padding: 0;
  color: var(--fg-muted);
}
.nav-toggle:hover { background: var(--surface); color: var(--fg); }
.nav-toggle span {
  display: block; width: 18px; height: 2px; margin: 3px auto;
  background: currentColor; border-radius: 2px;
  transition: transform var(--t), opacity var(--t);
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(5px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-5px) rotate(-45deg); }

@media (max-width: 900px) {
  .topnav a span.label { display: none; } /* icon-only nav on tablet */
}
@media (max-width: 780px) {
  .nav-toggle { display: block; order: 2; margin-left: auto; }
  .topright { order: 3; }
  .topnav {
    order: 4;
    display: none;
    position: absolute; top: calc(100% - 4px); left: 12px; right: 12px;
    flex-direction: column; gap: 2px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r); box-shadow: var(--shadow-2);
    padding: 6px; z-index: 60;
    overflow: hidden;
  }
  .topnav.open { display: flex; }
  .topnav a {
    width: 100%; justify-content: flex-start; padding: 10px 12px;
    border-radius: var(--r-sm); font-size: 13px;
  }
  .topbar { position: relative; flex-wrap: wrap; }
  .admin-table th, .admin-table td { padding: 6px 8px; font-size: 12px; }
  .admin-table .link { max-width: 160px; font-size: 11px; }
  .wrap { padding: 10px 12px; }
}
@media (max-width: 540px) {
  .brand span { display: none; }
  .avatar-menu .menu { right: 0; min-width: 200px; }
}

/* ------------------------------------------------------------------
   Sub-line under a primary cell value — "MY / 16913584", "M / 3115".
   Kept tiny and dim so it visually reads as metadata, not data.
   ------------------------------------------------------------------ */
.meta-sub {
  display: block; font-size: 11px; color: var(--fg-muted);
  line-height: 1.2; margin-top: 2px; word-break: break-all;
}
.meta-sub .tag {
  display: inline-block; padding: 1px 5px; border-radius: 4px;
  background: var(--surface-2); color: var(--fg-dim);
  font-family: ui-monospace, monospace; font-size: 10px;
  margin-right: 4px;
}

/* ------------------------------------------------------------------
   Admin list compact mode — kicks in automatically on ≤780px for
   .admin-table.list-compact. Each row becomes a single visual line
   (no per-cell label wrapping, no multi-line cells) by hiding
   lower-priority columns and tightening padding.
   ------------------------------------------------------------------ */
.admin-table.list-compact th,
.admin-table.list-compact td { padding: 4px 6px; font-size: 12px; }
.admin-table.list-compact td .meta-sub { display: inline; margin-left: 6px; }

@media (max-width: 780px) {
  .admin-table.list-compact [data-col="secondary"] { display: none; }
  .admin-table.list-compact .link { max-width: 140px; }
  .admin-table.list-compact td,
  .admin-table.list-compact th { padding: 5px 6px; font-size: 11px; }
  .admin-table.list-compact .bdg { font-size: 10px; padding: 1px 5px; }
  .admin-table.list-compact .meta-sub { font-size: 10px; }
  .admin-table.list-compact .row-actions .btn.small { padding: 3px 8px; font-size: 10px; }
  .admin-table.list-compact .row-actions form { display: none; } /* hide delete on mobile row; still available on edit page */
}

/* ========================================================================
   PORTAL + DASHBOARD helpers that live in app.css
   (legacy account / wallet-pill / summary-card from old user-facing pages)
   ======================================================================== */
.wallet-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 13px; font-weight: 600; color: var(--fg);
}
.wallet-pill svg { color: var(--accent); }

.summary-card {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r);
}
.summary-card > div { display: flex; flex-direction: column; gap: 2px; }
.summary-card b { color: var(--fg); font-weight: 600; font-size: 14px; }

.cards {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
  margin: 8px 0 22px;
}
.card .count {
  font-size: clamp(24px, 3vw, 30px); font-weight: 800; letter-spacing: -0.025em;
  color: var(--fg); margin: 2px 0 2px;
}

/* --- animations --- */
@keyframes fade-up { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ========================================================================
   EXTRA: .tag, .pill, .actions-menu (used in templates)
   ======================================================================== */
.tag {
  display: inline-block; padding: 1px 6px; border-radius: 3px;
  background: var(--surface-2); color: var(--fg-dim);
  font-size: 12px; font-weight: 400;
}
.pill {
  display: inline-block; padding: 2px 8px; border-radius: 3px;
  font-size: 12px;
}
.pill.ok { background: rgba(103,194,58,.12); color: var(--ok); }
.pill.muted { background: var(--surface-2); color: var(--fg-muted); }

/* Actions dropdown menu (subscriptions, etc.) */
.actions-menu { position: relative; display: inline-block; }
.actions-menu summary { list-style: none; cursor: pointer; }
.actions-menu summary::-webkit-details-marker { display: none; }
.actions-menu .menu {
  display: none; position: absolute; right: 0; top: calc(100% + 4px);
  min-width: 180px; padding: 4px 0; z-index: 50;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-2);
}
.actions-menu[open] .menu { display: block; }
.actions-menu .menu a,
.actions-menu .menu button {
  display: block; width: 100%; padding: 6px 14px;
  background: none; border: 0; text-align: left;
  font: inherit; font-size: 13px; color: var(--fg);
  cursor: pointer; text-decoration: none;
}
.actions-menu .menu a:hover,
.actions-menu .menu button:hover { background: var(--surface-2); }

/* ========================================================================
   ADMIN COMPACT REDESIGN — settings shell, denser panels, mobile dropdowns
   ========================================================================
   Goal: PerfectPanel-tight density without losing legibility. Layered on
   top of the base rules above so the "compact" pass is auditable in one
   block instead of scattered across the file. */

/* ---- topbar polish — slightly tighter, sturdier separators ---- */
.topbar { min-height: 40px; gap: 4px; padding: 0 clamp(10px, 1.6vw, 18px); }
.topnav a { padding: 9px 10px; font-size: 12.5px; }
.topnav a:focus-visible {
  outline: none; color: var(--fg);
  box-shadow: inset 0 -2px 0 var(--accent);
}
.topright { gap: 6px; }
.theme-btn, .bell, .help-btn { width: 32px; height: 32px; }
.avatar-menu summary { width: 30px; height: 30px; font-size: 12px; }

/* ---- wrap: pull content closer to the topbar ---- */
.wrap { padding: 8px clamp(12px, 1.8vw, 22px) 32px; }
.pageheader { margin: 0 0 6px; gap: 8px; }
.pageheader h1 { font-size: 15px; font-weight: 600; }
.pageheader .actions .btn { padding: 5px 10px; font-size: 12px; }

/* ---- panels: tighter padding + better head treatment ---- */
.card, .panel { padding: 12px 14px; border-radius: var(--r); }
.card + .card, .panel + .panel { margin-top: 10px; }
.panel-head { margin-bottom: 10px; }
.panel-head h2 { font-size: 13px; }

/* ---- hero (dashboard intro) — half the previous vertical weight ---- */
.hero {
  padding: clamp(12px, 2vw, 20px) clamp(14px, 2vw, 22px);
  margin-bottom: 12px;
  gap: 18px;
}
.hero .kicker { font-size: 9px; margin-bottom: 4px; }
.hero h1 { font-size: clamp(18px, 2.4vw, 24px); margin-bottom: 2px; }
.hero p.muted { font-size: 12.5px; }
.hero-big { padding-left: 18px; gap: 4px; }
.hero-big .big-num { font-size: clamp(26px, 4.4vw, 40px); }
.hero-big .big-label { font-size: 10px; }

/* ---- stat cards — keep the colour cue, drop the bulk ---- */
.stat-grid { gap: 10px; margin-bottom: 14px; }
.stat { padding: 10px 12px; }
.stat-head { gap: 8px; margin-bottom: 6px; }
.stat-ico { width: 28px; height: 28px; border-radius: var(--r-sm); }
.stat-ico svg { width: 14px; height: 14px; }
.stat-head h2 { font-size: 10px; letter-spacing: .07em; }
.stat-value { font-size: clamp(20px, 2.4vw, 24px); margin: 2px 0 2px; }
.stat-sub { font-size: 11px; }
.two-col { gap: 12px; margin-bottom: 14px; }
.status-row { padding: 7px 10px; }
.status-count { font-size: 14px; }

/* ---- forms: tighter default for admin — keeps .compact for modals ---- */
.form { gap: 10px; }
.form label { gap: 4px; }
.form input, .form select, .form textarea {
  padding: 7px 10px; font-size: 12.5px;
}
.form textarea { min-height: 72px; }
.grid2 { gap: 10px; }
.row-end { gap: 8px; }
.fs { padding: 12px 14px; margin: 6px 0; }

/* Nice section heading inside a form (replaces inline `<h3 style=...>`s) */
.form-section {
  margin: 14px 0 6px;
  padding-top: 12px; border-top: 1px solid var(--border);
  font-size: 12px; font-weight: 600; color: var(--fg);
  text-transform: uppercase; letter-spacing: .05em;
}
.form-section:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.form-section + p.muted { margin-top: -2px; margin-bottom: 8px; font-size: 12px; }

/* Small "current value" hint under a file input */
.field-hint { font-size: 11px; color: var(--fg-muted); }
.field-hint code {
  font-size: 11px; padding: 0 4px; background: var(--surface-2);
  border-radius: 3px; color: var(--fg-dim);
}

/* Monospace textarea variant — JSON-LD, robots rules, code-ish payloads */
.form textarea.mono,
.form input.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; line-height: 1.45;
}

/* ---- tables: tighter padding, hover that feels intentional ---- */
.admin-table th, .admin-table td { padding: 6px 9px; font-size: 12.5px; }
.admin-table th { font-size: 11px; padding: 6px 9px; }
.admin-table tr:hover td {
  background: color-mix(in srgb, var(--accent) 5%, var(--surface));
}

/* ---- filters strip ---- */
.filters { gap: 6px; margin-bottom: 6px; }
.filters input, .filters select { padding: 5px 9px; font-size: 12.5px; }
.filters .btn { padding: 5px 10px; font-size: 12px; }

/* ---- tabs — slightly shorter, clearer active state ---- */
.tabs { margin-bottom: 8px; }
.tabs a { padding: 6px 10px; font-size: 12px; }
.tabs .badge {
  background: var(--surface-2); color: var(--fg-muted);
  padding: 0 5px; border-radius: 8px; font-size: 10px; font-weight: 600;
  min-width: 14px; text-align: center; line-height: 16px;
  margin-left: 4px;
}
.tabs a.active .badge { background: var(--accent-soft); color: var(--accent); }

/* ---- settings shell — left rail + content pane ----
   The settings template uses these classes already; previously they had
   no styles, so the page rendered as stacked blocks. */
.settings-shell {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.settings-side {
  position: sticky; top: 48px;
  display: flex; flex-direction: column; gap: 1px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
}
.settings-side-link {
  display: block; padding: 6px 10px;
  font-size: 12.5px; color: var(--fg-dim);
  border-radius: var(--r-sm);
  border-left: 2px solid transparent;
  transition: background var(--t), color var(--t), border-color var(--t);
}
.settings-side-link:hover { background: var(--surface-2); color: var(--fg); }
.settings-side-link.active {
  background: var(--accent-soft); color: var(--accent);
  border-left-color: var(--accent); font-weight: 600;
}
.settings-pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 16px;
  min-width: 0;
}
.settings-pane > h2:first-child,
.settings-pane > .form-section:first-child {
  margin-top: 0;
}

/* On mobile the rail collapses into a horizontal scroller above the pane.
   sticky disabled so it doesn't fight the topbar dropdown. */
@media (max-width: 780px) {
  .settings-shell { grid-template-columns: 1fr; gap: 10px; }
  .settings-side {
    position: static;
    flex-direction: row; overflow-x: auto;
    gap: 4px; padding: 4px;
    scrollbar-width: none;
  }
  .settings-side::-webkit-scrollbar { display: none; }
  .settings-side-link {
    border-left: 0; border-bottom: 2px solid transparent;
    padding: 6px 10px; white-space: nowrap;
  }
  .settings-side-link.active {
    border-bottom-color: var(--accent);
    background: transparent;
  }
  .settings-pane { padding: 12px; }
}

/* ---- mobile dropdowns: topnav + avatar — match the user-portal polish ---- */
@media (max-width: 780px) {
  .topbar { min-height: 44px; padding: 0 12px; }
  .nav-toggle { width: 34px; height: 34px; }
  .nav-toggle:focus-visible {
    outline: none; box-shadow: 0 0 0 2px var(--accent-soft);
  }
  .topnav {
    top: calc(100% + 2px); left: 8px; right: 8px;
    padding: 6px;
    border-radius: var(--r);
    box-shadow: var(--shadow-3);
    gap: 0;
    animation: dropdown-in .14s ease-out;
  }
  .topnav a {
    padding: 9px 12px;
    border-radius: var(--r-sm);
    border-bottom: 0;
    font-size: 13px;
    color: var(--fg-dim);
  }
  .topnav a:hover { background: var(--surface-2); color: var(--fg); }
  .topnav a.active {
    background: var(--accent-soft); color: var(--accent);
  }
  .topnav a .badge { margin-left: auto; }

  /* Avatar menu — full-width-ish dropdown on the right edge */
  .avatar-menu .menu {
    right: 0; min-width: 220px;
    border-radius: var(--r);
    box-shadow: var(--shadow-3);
    animation: dropdown-in .14s ease-out;
  }
  .avatar-menu .menu .menu-item,
  .avatar-menu .menu a,
  .avatar-menu .menu button { padding: 9px 12px; font-size: 13px; }
}

@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- input-suffix uses smaller gap ---- */
.form .input-suffix { gap: 6px; }
.form .input-suffix .muted.small { font-size: 11px; }

/* ---- Per-page SEO row (settings → seo tab) ---- */
.seo-page-row {
  border: 1px solid var(--border) !important;
  border-radius: var(--r) !important;
  padding: 8px 12px !important;
  background: var(--bg-2);
  margin-bottom: 6px !important;
}
.seo-page-row[open] { background: var(--surface); }
.seo-page-row > summary {
  font-weight: 500; font-size: 12.5px; cursor: pointer;
  list-style: none; padding: 2px 0;
  display: flex; align-items: center; gap: 8px;
}
.seo-page-row > summary::-webkit-details-marker { display: none; }
.seo-page-row > summary::before {
  content: '▸'; color: var(--fg-muted); font-size: 11px;
  transition: transform var(--t); flex-shrink: 0;
}
.seo-page-row[open] > summary::before { transform: rotate(90deg); }
.seo-page-row > summary code {
  font-size: 11px; padding: 1px 6px; background: var(--surface-2);
}
.seo-page-row .form { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }

/* ---- TG link types catalog (telegram-filters tab → link-types sub) ----
   Lifted out of an inline <style> block when the three Telegram-specific
   tabs got merged. Same selectors so the existing markup keeps working. */
.ltx-head { display:flex; justify-content:space-between; align-items:flex-start; gap:16px; margin-bottom:14px; }
.ltx-tester { background:var(--surface-2); border:1px solid var(--border); border-radius:var(--r); padding:12px 14px; margin:8px 0 14px; }
.ltx-tester-label { display:flex; flex-direction:column; gap:6px; margin:0; }
.ltx-tester-label > span { color:var(--fg); font-weight:500; }
.ltx-tester input { width:100%; padding:8px 10px; border:1px solid var(--border); border-radius:var(--r-sm); background:var(--bg-2); font-family:inherit; }
.ltx-tester-results { margin-top:8px; min-height:18px; }
.ltx-tester-results .ltx-hit { display:inline-block; background:var(--accent-soft); color:var(--accent); border:1px solid var(--accent); border-radius:var(--r-sm); padding:1px 6px; margin:2px 4px 2px 0; font-size:12px; }
.ltx-tester-results .ltx-no { color:var(--fg-muted); }
.ltx-filter { display:flex; align-items:center; gap:10px; margin:0 0 8px; }
.ltx-filter input { flex:1; max-width:340px; padding:6px 10px; border:1px solid var(--border); border-radius:var(--r-sm); background:var(--surface); }
.ltx-rows { display:flex; flex-direction:column; border:1px solid var(--border); border-radius:var(--r); overflow:hidden; background:var(--surface); }
.ltx-row { display:grid; grid-template-columns: minmax(220px, 1.3fr) minmax(200px, 1.5fr) minmax(220px, 1.4fr) 110px; gap:10px; align-items:center; padding:10px 14px; border-top:1px solid var(--border); }
.ltx-row:first-child { border-top:0; }
.ltx-row.is-disabled { background: repeating-linear-gradient(45deg, transparent 0 6px, var(--surface-2) 6px 12px); opacity:0.65; }
.ltx-row.is-disabled .ltx-status { background: var(--fg-muted); }
.ltx-cell { min-width:0; }
.ltx-cell code { font-size:12px; background:var(--surface-2); border:1px solid var(--border); border-radius:var(--r-sm); padding:2px 6px; word-break:break-all; display:inline-block; max-width:100%; }
.ltx-cell-name { display:flex; align-items:center; gap:8px; }
.ltx-status { width:8px; height:8px; border-radius:50%; background: var(--ok); flex:0 0 auto; }
.ltx-name-link { color: var(--fg); font-weight:600; text-decoration:none; }
.ltx-name-link:hover { color: var(--accent); text-decoration:underline; }
.ltx-sort { font-size:11px; }
.ltx-cell-actions { display:flex; gap:4px; justify-content:flex-end; }
.ltx-row.hidden-by-filter { display:none; }
@media (max-width: 920px) {
  .ltx-row { grid-template-columns: 1fr; }
  .ltx-cell-actions { justify-content:flex-start; }
}

/* ---- inline checkbox row (used heavily in SEO + integrations forms) ---- */
.row-check {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 400; color: var(--fg);
  text-transform: none; letter-spacing: 0;
  padding: 4px 0;
}
.row-check input[type="checkbox"] {
  width: 16px; height: 16px; margin: 0;
  accent-color: var(--accent);
  flex-shrink: 0;
}
