/* Newsroom PWA - mobile first, 360-430 px. No framework, no build step.
   Utility-ish class names only where they earn their keep; components are
   semantic so the markup stays readable. */

:root {
  --bg: #080d16;
  --bg-elev: #0f1725;
  --card: #131d2e;
  --card-2: #182338;
  --line: #22304a;
  --text: #e8eef7;
  --muted: #8fa0b8;
  --faint: #7c8ca6;
  --accent: #f0b429;
  --accent-ink: #1a1200;
  --green: #34d399;
  --red: #f87171;
  --blue: #60a5fa;
  --amber: #fbbf24;
  --radius: 16px;
  --tap: 48px;
  --nav-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  text-size-adjust: 100%;
}

body { min-height: 100dvh; }

a { color: var(--accent); text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { display: block; }

.shell {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 14px calc(var(--nav-h) + var(--safe-bottom) + 28px);
}
@media (min-width: 768px) {
  .shell {
    max-width: 1280px;
    padding: 26px 32px 56px;
  }
}

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: calc(var(--safe-top) + 10px) 14px 10px;
  background: rgba(8, 13, 22, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(34, 48, 74, 0.6);
}
.topbar-inner {
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
@media (min-width: 768px) {
  .topbar-inner { max-width: 1280px; }
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.01em;
  min-width: 0;
}
.brand span.name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand .dot {
  width: 10px; height: 10px; border-radius: 3px;
  background: var(--accent);
  box-shadow: 0 0 14px rgba(240, 180, 41, 0.55);
  flex: none;
}
.topbar .meta { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* ---------------------------------------------------------------- type */
h1 { font-size: 21px; line-height: 1.2; margin: 6px 0 2px; letter-spacing: -0.02em; }
h2 { font-size: 15px; margin: 0 0 10px; letter-spacing: 0.01em; }
h3 { font-size: 14px; margin: 0; }
.sub { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.section { margin-top: 20px; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 8px;
}
.section-head .count { color: var(--faint); font-size: 12px; }

/* ---------------------------------------------------------------- cards */
.card {
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.card + .card { margin-top: 10px; }
.card.flat { background: var(--bg-elev); }
.card-tight { padding: 12px; }

/* ---------------------------------------------------------------- stats */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.stat {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 10px 9px;
  min-width: 0;
}
.stat .n { font-size: 22px; font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; }
.stat .l { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; margin-top: 2px; }
.stat.accent .n { color: var(--accent); }
.stat.green .n { color: var(--green); }
.stat.red .n { color: var(--red); }

.quota { margin-top: 10px; }
.quota-bar {
  height: 8px; border-radius: 99px; background: #1c2940; overflow: hidden;
}
.quota-bar > i {
  display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), #ffd166);
  transition: width 0.35s ease;
}
.quota-bar.full > i { background: linear-gradient(90deg, #f87171, #fb923c); }
.quota .caption {
  display: flex; justify-content: space-between; gap: 8px;
  color: var(--muted); font-size: 12px; margin-top: 6px;
}

/* ---------------------------------------------------------------- badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  border: 1px solid transparent; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.amber { color: var(--amber); background: rgba(251, 191, 36, 0.10); border-color: rgba(251, 191, 36, 0.25); }
.badge.green { color: var(--green); background: rgba(52, 211, 153, 0.10); border-color: rgba(52, 211, 153, 0.25); }
.badge.red { color: var(--red); background: rgba(248, 113, 113, 0.10); border-color: rgba(248, 113, 113, 0.25); }
.badge.blue { color: var(--blue); background: rgba(96, 165, 250, 0.10); border-color: rgba(96, 165, 250, 0.25); }
.badge.slate { color: var(--muted); background: rgba(143, 160, 184, 0.10); border-color: rgba(143, 160, 184, 0.22); }

/* ---------------------------------------------------------------- article rows */
.item { display: block; }
.item + .item { margin-top: 10px; }
.item .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.item .title {
  font-size: 15px; font-weight: 650; line-height: 1.3; margin: 6px 0 4px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  word-break: break-word;
}
.item .orig {
  color: var(--faint); font-size: 12px; margin: 0 0 8px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.item .foot {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  color: var(--muted); font-size: 12px;
}
.item .foot .sep { color: var(--faint); }
.item .actions { display: flex; gap: 8px; margin-top: 10px; }
.item .actions .btn { flex: 1; }

.conf { display: inline-flex; align-items: center; gap: 4px; }
.conf b { color: var(--text); font-weight: 600; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: var(--tap); padding: 0 16px;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--card-2); color: var(--text);
  font-size: 15px; font-weight: 600; letter-spacing: 0.01em;
  cursor: pointer; text-align: center; user-select: none;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.975); background: #1d2b44; }
.btn.primary {
  background: var(--accent); color: var(--accent-ink); border-color: transparent;
  box-shadow: 0 6px 18px rgba(240, 180, 41, 0.18);
}
.btn.primary:active { background: #ffc94d; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: rgba(248, 113, 113, 0.35); background: rgba(248, 113, 113, 0.08); }
.btn.block { width: 100%; }
.btn.sm { min-height: 40px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.btn .ico { width: 18px; height: 18px; flex: none; }

/* ---------------------------------------------------------------- forms */
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field label, .label {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 6px;
}
.field .hint { color: var(--faint); font-size: 12px; text-transform: none; letter-spacing: 0; font-weight: 400; }
.input, .select, .textarea {
  width: 100%; min-height: var(--tap);
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font-size: 16px; /* 16px stops iOS zooming on focus */
  outline: none; transition: border-color 0.15s ease, box-shadow 0.15s ease;
  -webkit-appearance: none; appearance: none;
}
.textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus {
  border-color: rgba(240, 180, 41, 0.65);
  box-shadow: 0 0 0 3px rgba(240, 180, 41, 0.12);
}
.input::placeholder, .textarea::placeholder { color: #4b5b73; }
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238fa0b8' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 40px;
}
.segmented {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 5px;
}
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: flex; align-items: center; justify-content: center;
  min-height: 42px; border-radius: 10px; font-size: 14px; font-weight: 600; color: var(--muted);
}
.segmented input:checked + span { background: var(--card-2); color: var(--text); box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset; }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* switch */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.switch-row .txt { min-width: 0; }
.switch-row .txt b { display: block; font-size: 15px; font-weight: 650; }
.switch-row .txt small { color: var(--muted); font-size: 12px; }
.switch { position: relative; flex: none; width: 64px; height: 48px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 2; }
.switch i {
  position: absolute; inset: 8px 4px; border-radius: 999px; background: #243349;
  border: 1px solid var(--line); transition: background 0.2s ease, border-color 0.2s ease;
}
.switch i::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px;
  border-radius: 50%; background: #7b8ba3; transition: transform 0.2s ease, background 0.2s ease;
}
.switch input:checked + i { background: rgba(52, 211, 153, 0.25); border-color: rgba(52, 211, 153, 0.5); }
.switch input:checked + i::after { transform: translateX(24px); background: var(--green); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }

/* range */
input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 32px; background: transparent;
}
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 99px; background: #243349; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); margin-top: -10px; border: 3px solid var(--bg);
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 99px; background: #243349; }
input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; border: 3px solid var(--bg); border-radius: 50%; background: var(--accent); }
.range-row { display: flex; align-items: center; gap: 12px; }
.range-row output {
  flex: none; min-width: 58px; text-align: center;
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 6px;
}

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 10px; font-size: 13px;
}
.chip button {
  border: 0; background: transparent; color: var(--faint); cursor: pointer;
  font-size: 16px; line-height: 1; padding: 2px; min-width: 24px; min-height: 24px;
}
.chip button:hover { color: var(--red); }

/* filters */
.filters {
  display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 0 10px;
}
.chip-link {
  flex: none; padding: 9px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg-elev); color: var(--muted); font-size: 13px; font-weight: 600;
  min-height: 40px; display: inline-flex; align-items: center;
}
.chip-link.active { background: rgba(240, 180, 41, 0.14); border-color: rgba(240, 180, 41, 0.45); color: var(--accent); }
.date-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; }
.date-row .field { margin: 0; }
.date-row .btn { min-height: var(--tap); }

/* ---------------------------------------------------------------- nav */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 6px 8px calc(6px + var(--safe-bottom));
  background: rgba(11, 17, 28, 0.94);
  backdrop-filter: blur(16px);
  border-top: 1px solid rgba(34, 48, 74, 0.8);
}
.tabbar-inner {
  max-width: 520px; margin: 0 auto;
  display: flex; gap: 2px;
}
.tab {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 54px; border-radius: 12px;
  color: var(--faint); font-size: 10.5px; font-weight: 600; letter-spacing: 0.01em;
  text-align: center; -webkit-tap-highlight-color: transparent;
  transition: color 0.15s ease, background 0.15s ease;
}
.tab svg { width: 22px; height: 22px; }
.tab:active { background: rgba(255,255,255,0.04); }
.tab.is-active { color: var(--accent); background: rgba(240, 180, 41, 0.08); }
.tab.is-active svg { filter: drop-shadow(0 0 8px rgba(240, 180, 41, 0.35)); }

/* ---------------------------------------------------------------- misc */
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.note {
  display: flex; gap: 8px; padding: 10px 12px; border-radius: 12px;
  background: rgba(96, 165, 250, 0.08); border: 1px solid rgba(96, 165, 250, 0.2);
  color: #cfe1ff; font-size: 12.5px; line-height: 1.45;
}
.note.warn { background: rgba(251, 191, 36, 0.08); border-color: rgba(251, 191, 36, 0.22); color: #ffe6ae; }
.note.bad { background: rgba(248, 113, 113, 0.08); border-color: rgba(248, 113, 113, 0.22); color: #ffd0d0; }
.empty { text-align: center; padding: 28px 16px; color: var(--muted); }
.empty .big { font-size: 34px; margin-bottom: 8px; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.tiny { font-size: 12px; }
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.15); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* stream */
.stream {
  background: #070c14; border: 1px solid var(--line); border-radius: 14px;
  padding: 12px; min-height: 84px; font-size: 13.5px; line-height: 1.5;
}
.stream .line { display: flex; gap: 8px; padding: 3px 0; color: var(--muted); }
.stream .line .k { color: var(--accent); flex: none; font-weight: 700; }
.stream .line.ok { color: var(--green); }
.stream .line.err { color: var(--red); }
.stream .caret::after { content: "▍"; color: var(--accent); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* modal */
.modal {
  position: fixed; inset: 0; z-index: 60; display: none;
  align-items: flex-end; justify-content: center;
  background: rgba(3, 6, 12, 0.7); backdrop-filter: blur(3px);
  padding: 0 0 calc(var(--safe-bottom) + 0px);
}
.modal.open { display: flex; }
.modal .sheet {
  width: 100%; max-width: 520px; background: var(--card);
  border: 1px solid var(--line); border-bottom: 0;
  border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + var(--safe-bottom));
  animation: rise 0.22s ease;
}
@keyframes rise { from { transform: translateY(18px); opacity: 0.6; } }
.modal h3 { font-size: 17px; margin-bottom: 6px; }
.modal p { color: var(--muted); font-size: 13.5px; margin: 0 0 14px; }
.modal .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #1c2a40; color: var(--text); border: 1px solid var(--line);
  padding: 11px 16px; border-radius: 12px; font-size: 13.5px; z-index: 70;
  max-width: min(92vw, 420px); text-align: center;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* login */
.auth {
  min-height: 100dvh; display: flex; flex-direction: column;
  justify-content: center; padding: 28px 20px calc(var(--safe-bottom) + 28px);
  max-width: 420px; margin: 0 auto;
}
.auth .logo { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.auth .logo .dot { width: 12px; height: 12px; border-radius: 4px; background: var(--accent); }
.auth h1 { font-size: 26px; margin: 0 0 6px; }
.auth .sub { margin-bottom: 22px; }

.help { color: var(--faint); font-size: 12px; margin-top: 6px; line-height: 1.5; }
details summary {
  cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 600;
  padding: 10px 0; list-style: none; min-height: var(--tap); display: flex; align-items: center;
}
details summary::-webkit-details-marker { display: none; }
details summary::after { content: "+"; margin-left: auto; color: var(--faint); font-size: 18px; }
details[open] summary::after { content: "−"; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ====================================================================
   Phase 3: notifications, push, superadmin, desktop layout
   ==================================================================== */

.topnav { display: none; align-items: center; gap: 2px; flex: 1; justify-content: center; }
.topnav a {
  position: relative; color: var(--muted); font-size: 13px; font-weight: 600;
  padding: 9px 12px; border-radius: 10px; min-height: 40px;
  display: inline-flex; align-items: center; gap: 6px;
}
.topnav a:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.topnav a.is-active { color: var(--accent); background: rgba(240, 180, 41, 0.10); }
.top-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 12px; color: var(--muted);
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.brand-tag {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent);
  background: rgba(240, 180, 41, 0.12); border: 1px solid rgba(240, 180, 41, 0.28);
  padding: 2px 6px; border-radius: 6px;
}
.bell {
  position: relative; width: 44px; height: 44px; display: inline-flex;
  align-items: center; justify-content: center; border-radius: 12px; color: var(--muted);
}
.bell svg { width: 21px; height: 21px; }
.bell:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.bell-badge {
  position: absolute; top: 1px; right: -1px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--accent); color: var(--accent-ink);
  font-size: 10.5px; font-weight: 800; display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg);
}
.dot-badge {
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 9.5px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center;
}
.tab { position: relative; }
.tab-dot {
  position: absolute; top: 8px; right: calc(50% - 17px); width: 7px; height: 7px;
  border-radius: 50%; background: var(--accent); box-shadow: 0 0 6px rgba(240, 180, 41, 0.6);
}

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 8px;
}
.page-head h1 { margin: 0; }
.page-head .sub { margin: 2px 0 0; }

/* notifications */
.notif { position: relative; }
.notif.is-unread { border-color: rgba(240, 180, 41, 0.32); }
.notif.is-unread::before {
  content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent);
}
.notif .title { margin: 6px 0 4px; }
.notif-body { color: var(--muted); font-size: 13px; margin: 0 0 8px; line-height: 1.5; }
.notif-open { font-size: 13px; font-weight: 600; color: var(--accent); }
.push-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.push-card .btn { flex: none; }

/* editorial diff: stacked on phones, side by side on desktop */
.item-body { display: block; }
.diff-col.source { display: none; }
.diff-label { display: none; }
.diff-snippet {
  color: var(--faint); font-size: 12.5px; line-height: 1.45; margin: 6px 0 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.diff-title { color: var(--muted); font-size: 13px; line-height: 1.4; }

/* superadmin */
.impersonation-bar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 14px; padding-top: calc(8px + var(--safe-top));
  background: rgba(240, 180, 41, 0.16);
  border-bottom: 1px solid rgba(240, 180, 41, 0.45);
  font-size: 13px; color: var(--text);
}
.impersonation-bar form { margin: 0; }
.add-client summary {
  cursor: pointer; font-weight: 600; font-size: 14px; padding: 2px 0;
}
.tenant-actions {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  justify-content: space-between; margin-top: 14px;
  padding-top: 12px; border-top: 1px solid var(--line);
}
.tenant-actions form { margin: 0; }
.key-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.key-row:last-child { border-bottom: 0; }
.key-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.tenant-card { margin-top: 12px; }
.tenant-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.tenant-title .title { font-size: 17px; margin: 0 0 2px; }
.tenant-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.pill {
  font-size: 11px; padding: 3px 9px; border-radius: 999px;
  background: var(--bg-elev); border: 1px solid var(--line); color: var(--muted);
}
.pill.ok { color: var(--green); border-color: rgba(52, 211, 153, 0.3); }
.pill.warn { color: var(--amber); border-color: rgba(251, 191, 36, 0.3); }
.tenant-grid { display: grid; grid-template-columns: 1fr; gap: 14px; margin-top: 12px; }
.tenant-form { background: var(--bg-elev); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.tenant-form h3 {
  margin: 0 0 10px; font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted);
}
.two-up { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.inline-form { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

@media (min-width: 768px) {
  .topnav { display: flex; }
  .tabbar { display: none; }
  .stat-grid { gap: 12px; }
  .card { padding: 18px; }
  .item .title { font-size: 16px; }
  .item .actions .btn { flex: 0 0 auto; min-width: 120px; }
  .item .actions form { flex: 0 0 auto; }
  .filters { padding-bottom: 14px; }
}

@media (min-width: 1024px) {
  .item-body { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
  .diff-col.source { display: block; padding-right: 20px; border-right: 1px solid var(--line); }
  .diff-label {
    display: block; font-size: 10px; letter-spacing: 0.09em; text-transform: uppercase;
    color: var(--faint); margin-bottom: 6px;
  }
  .diff-snippet { -webkit-line-clamp: 4; }
  .tenant-grid { grid-template-columns: 1fr 1fr; }
}

/* Superadmin Platform & Drawer Enhancements */
.subnav-tabs {
  display: flex; gap: 8px; margin: 16px 0 20px; border-bottom: 1px solid var(--line);
  padding-bottom: 10px; flex-wrap: wrap;
}
.subnav-tab {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 16px;
  border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--muted);
  background: var(--bg-elev); border: 1px solid var(--line); text-decoration: none;
  transition: all 0.15s ease;
}
.subnav-tab:hover { color: var(--text); border-color: var(--line-strong, #334155); }
.subnav-tab.active {
  color: #fff; background: var(--primary, #3b82f6); border-color: transparent;
}
.tenant-drawer { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.tenant-drawer summary {
  cursor: pointer; font-size: 13px; font-weight: 500; color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px; user-select: none;
  padding: 6px 12px; border-radius: 8px; background: var(--bg-elev);
  border: 1px solid var(--line);
}
.tenant-drawer summary:hover { color: var(--text); }
.tenant-drawer[open] summary { margin-bottom: 12px; color: var(--text); border-color: var(--primary, #3b82f6); }
details.add-client summary {
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text);
  user-select: none; padding: 8px 14px; border-radius: 8px;
  background: var(--bg-elev); border: 1px solid var(--line); display: inline-flex;
  align-items: center; gap: 6px; margin-bottom: 8px;
}
details.add-client[open] summary { margin-bottom: 14px; border-color: var(--primary, #3b82f6); }
.help-box {
  font-size: 12px; color: var(--muted); margin: 4px 0 8px; line-height: 1.4;
}
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-block; }
.htmx-request.htmx-indicator { display: inline-block; }

/* User Menu & Profile Dropdown */
.user-menu-wrapper {
  position: relative;
  display: inline-block;
}
.user-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s ease;
  user-select: none;
}
.user-menu-btn:hover, .user-menu-btn.active {
  background: var(--card-2);
  border-color: var(--muted);
}
.user-avatar-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.user-btn-name {
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chevron-icon {
  width: 14px;
  height: 14px;
  color: var(--muted);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}
.user-menu-btn.active .chevron-icon {
  transform: rotate(180deg);
}

.user-dropdown-panel {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 280px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
  padding: 12px;
  z-index: 1000;
  animation: dropdownFadeIn 0.15s ease;
}
.user-dropdown-panel.show {
  display: block;
}

@keyframes dropdownFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.user-dropdown-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 8px;
}
.user-dropdown-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
}
.user-dropdown-details {
  min-width: 0;
  flex: 1;
}
.user-dropdown-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-dropdown-email {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.user-dropdown-badges {
  display: flex;
  gap: 4px;
}

.user-dropdown-contact {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}
.user-dropdown-contact .text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-divider {
  height: 1px;
  background: var(--line);
  margin: 10px 0;
}

.user-dropdown-tenant {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.3;
}
.user-dropdown-tenant small {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--faint);
}
.user-dropdown-tenant b {
  color: var(--text);
}

.user-dropdown-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  text-decoration: none;
  transition: all 0.12s ease;
}
.dropdown-item svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
  flex-shrink: 0;
}
.dropdown-item:hover {
  background: var(--bg-elev);
  color: var(--accent);
}
.dropdown-item:hover svg {
  color: var(--accent);
}
.dropdown-item.logout {
  color: var(--red);
}
.dropdown-item.logout svg {
  color: var(--red);
}
.dropdown-item.logout:hover {
  background: rgba(248, 113, 113, 0.12);
  color: #fca5a5;
}
.dropdown-item.logout:hover svg {
  color: #fca5a5;
}

/* Platform Console Clean & Modern Layout */
.console-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}
.console-title-wrap h1 {
  font-size: 22px;
  line-height: 1.2;
  margin: 0 0 4px;
}
.console-stat-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.stat-pill b {
  color: var(--text);
}
.stat-pill.ok {
  color: var(--green);
  border-color: rgba(52, 211, 153, 0.3);
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 14px;
}
@media (min-width: 900px) {
  .settings-grid {
    grid-template-columns: 1.15fr 0.85fr;
    gap: 20px;
    align-items: start;
  }
}
.settings-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.console-card {
  padding: 20px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.card-title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.key-pool-list {
  display: flex;
  flex-direction: column;
}
.vapid-box {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
}
.vapid-code {
  font-size: 11px;
  color: var(--accent);
  word-break: break-all;
}

.add-client-drawer {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 14px 18px;
  background: var(--bg-elev);
  margin-bottom: 16px;
}
.add-client-summary {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  user-select: none;
}
.tenant-niche-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(240, 180, 41, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}



