/* shell.css — generic layout: sidebar + topbar + main column.
   Page-specific styles live in pages/pages.css.
   Module CSS is namespaced (chat-, tt-, etc.) and loaded by each module. */

:root {
  /* Dark palette — mirrors legacy core/styles-base.css */
  --bg:           #0a0b0f;
  --bg2:          #111318;
  --bg3:          #181c24;
  --bg4:          #1e2330;
  --border:       #232733;
  --text:         #e8eef7;
  --text2:        #b6c0d0;
  --text3:        #7a8493;

  --accent:       #00e5a0;
  --accent2:      #00b87a;
  --accent-dim:   rgba(0, 229, 160, 0.10);
  --accent-glow:  rgba(0, 229, 160, 0.32);

  --green:        #2dd36f;
  --red:          #ff5560;
  --yellow:       #f5b94d;
  --blue:         #5aa9ff;

  --radius:       12px;
  --shadow:       0 4px 18px rgba(0, 0, 0, 0.30);

  --sidebar-w:    232px;
  --sidebar-w-collapsed: 0px;
  --topbar-h:     56px;
  --ticker-h:     38px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font: 14px/1.4 'DM Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  height: 100%; min-height: 100dvh;
  -webkit-text-size-adjust: 100%;
}
body { overflow: hidden; } /* shell scrolls #page only */

/* ─── Common form/button defaults ─── */
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: var(--bg3); border: 1px solid var(--border); color: var(--text); padding: 6px 12px; border-radius: 6px; transition: background .15s, border-color .15s, color .15s; }
button:hover { background: var(--bg4); border-color: var(--text3); }
button.primary { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 600; }
button.primary:hover { background: var(--accent2); border-color: var(--accent2); }
button.danger  { background: #3a1a1d; border-color: var(--red); color: #ffd5d5; }
button:disabled, button[disabled] { opacity: 0.55; cursor: not-allowed; }
input, textarea, select {
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px;
  outline: none; transition: border-color .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
.muted { color: var(--text3); font-size: 12px; }
.err   { color: var(--red);   font-size: 13px; margin-top: 8px; }

/* ─── Shell skeleton ─── */
#shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh; height: 100dvh;
  width: 100%;
}
#shell.shell-collapsed-mobile { /* default off-canvas on mobile */ }

/* The browser default for [hidden] is display:none WITHOUT !important, which
   loses to .sidebar/.main display rules below. Force it. */
.sidebar[hidden], .main[hidden], #tt-ticker[hidden], .topbar[hidden] {
  display: none !important;
}

/* ─── Sidebar ─── */
.sidebar {
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
  overflow: hidden;
  z-index: 200;
}
.sidebar-logo {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.logo-block { min-width: 0; flex: 1; }
.logo-mark  {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 16px; font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.logo-role  { color: var(--text3); font-size: 11px; margin-top: 2px; text-transform: capitalize; }
.sidebar-close {
  display: none; /* shown on mobile */
  background: none; border: none; color: var(--text3);
  font-size: 20px; padding: 4px; cursor: pointer;
  margin-left: auto;
}
.sidebar-pin-btn {
  margin-left: auto;
  background: none; border: 1px solid transparent;
  color: var(--text3); font-size: 18px; line-height: 1;
  width: 32px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0; border-radius: 6px; cursor: pointer;
}
.sidebar-pin-btn:hover { color: var(--accent); border-color: var(--accent); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px 0 12px;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 3px; }

.sidebar-section {
  padding: 14px 14px 6px;
  font-size: 10px;
  color: var(--text3);
  font-family: 'DM Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  margin: 1px 8px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text2);
  transition: background .15s, color .15s;
  text-decoration: none;
  user-select: none;
}
.nav-item:hover  { background: var(--bg3); color: var(--text); }
.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  box-shadow: inset 2px 0 0 var(--accent);
}
.nav-item .icon { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }
.nav-item .label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-badge {
  margin-left: auto;
  background: var(--bg4);
  color: var(--text2);
  font-size: 10px; font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
}
.nav-badge.green { background: var(--accent); color: #000; }
.nav-badge.red   { background: var(--red);    color: #fff; }

/* Collapsible group (Super Admin) */
.nav-group { margin: 4px 0; }
.nav-group .nav-children { margin: 2px 0 4px 12px; padding-left: 8px; border-left: 1px dashed var(--border); }
.nav-group.collapsed .nav-children { display: none; }
.nav-group .nav-toggle { display: inline-block; margin-left: auto; font-size: 11px; color: var(--text3); transition: transform .15s; }
.nav-group.collapsed .nav-toggle { transform: rotate(-90deg); }

/* Sidebar bottom: user card + logout */
.sidebar-bottom {
  padding: 12px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
}
.user-card {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 10px;
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}
.user-meta { min-width: 0; flex: 1; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }
.logout-btn { background: none; border: none; color: var(--text3); padding: 6px; border-radius: 6px; }
.logout-btn:hover { background: var(--bg4); color: var(--red); }

/* Round 7 task #25: ensure sidebar bottom stays FIXED at the bottom (not in
   scrollable nav area). The flexbox "scrolling child" needs min-height:0 on the
   flex:1 sibling, plus flex-shrink:0 on the bottom strip. Without both, on
   tall nav lists (super_admin sees ~12 nav rows) the bottom gets pushed off. */
.sidebar-nav { min-height: 0; }
.sidebar-bottom { flex-shrink: 0; }

/* Round 7 task #18: Troubleshooting button — only renders inside Capacitor shell. */
.nx-native-only { display: none; }
body.nx-native .nx-native-only { display: inline-flex; }
.troubleshoot-btn {
  display: none;
  align-items: center; gap: 8px;
  width: 100%; box-sizing: border-box;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 12px;
  color: var(--text); font-size: 12px; font-weight: 600;
  margin-bottom: 8px; cursor: pointer;
}
body.nx-native .troubleshoot-btn { display: inline-flex; }
.troubleshoot-btn:hover { background: var(--bg4); color: var(--accent); }
.troubleshoot-btn svg { flex-shrink: 0; }
.tb-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.65); z-index: 9999;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  /* Android nav-bar floor — last-row buttons must clear the system nav. */
  padding-bottom: max(16px, env(safe-area-inset-bottom, 0px), 80px); }
.tb-modal-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 14px;
  max-width: 540px; width: 100%; max-height: 90vh; overflow: auto; padding: 16px; }
.tb-modal-card h3 { margin: 0 0 12px; font-size: 16px; color: var(--text); }
.tb-row { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0;
  border-bottom: 1px dashed var(--border); font-size: 13px; }
.tb-row:last-child { border-bottom: none; }
.tb-row .lbl { color: var(--text3); flex: 1; }
.tb-row .val { color: var(--text); font-family: monospace; word-break: break-word; text-align: right; flex-shrink: 0; }
.tb-row .val.ok { color: #34d399; font-weight: 600; }
.tb-row .val.bad { color: #ef4444; font-weight: 600; }
/* Round 7 task #29: channels-registered status row needs to be obviously a
   STATUS line, not blend in with the rest. Color the whole row when bad. */
.tb-row.tb-row-status { padding: 12px 10px; margin: 8px -10px; border-radius: 8px;
  border: 1px solid transparent; font-size: 14px; font-weight: 600; }
.tb-row.tb-row-status.tb-ok  { background: rgba(52,211,153,0.10); border-color: rgba(52,211,153,0.4); }
.tb-row.tb-row-status.tb-bad { background: rgba(239,68,68,0.10);  border-color: rgba(239,68,68,0.4); }
/* Round 7 task #30: action buttons — text was spilling out of boxes on
   narrow phone widths. Use grid 2-cols on phone so each button has predictable
   width, allow text wrap inside, smaller font, hyphenation as a safety net. */
.tb-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.tb-actions button { background: var(--bg3); border: 1px solid var(--border); color: var(--text);
  padding: 10px 8px; border-radius: 8px; font-size: 11.5px; line-height: 1.25;
  cursor: pointer; min-width: 0; word-break: break-word; hyphens: auto;
  white-space: normal; text-align: center; }
.tb-actions button:hover { background: var(--bg4); color: var(--accent); }
.tb-actions .tb-close { grid-column: 1 / -1; background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 600; }
/* Round 7 #1: actions row at TOP of panel + versions row + lock-screen callout */
.tb-actions-top { margin-top: 4px; margin-bottom: 12px; }
.tb-version-row { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 6px 10px;
  font-size: 12px; padding: 8px 10px; background: var(--bg3); border-radius: 8px;
  margin-bottom: 12px; align-items: center; }
.tb-version-row .lbl { color: var(--text3); }
.tb-version-row .val { color: var(--text); font-family: monospace; }
.tb-callout { padding: 12px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; line-height: 1.4; }
.tb-callout-warn { background: rgba(245,158,11,0.12); border: 1px solid rgba(245,158,11,0.5); color: var(--text); }
.tb-callout-warn strong { display: block; font-size: 14px; color: #f59e0b; margin-bottom: 6px; }

/* ─── Sidebar overlay (mobile) ─── */
.sidebar-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 199;
  -webkit-tap-highlight-color: transparent;
}

/* ─── Main column ─── */
.main {
  display: flex; flex-direction: column;
  min-width: 0;
  height: 100vh; height: 100dvh;
  overflow: hidden;
}

/* Topbar — wraps its own buttons on narrow screens (does NOT spill into the
   ticker / page-actions rows). Height grows when wrapping.
   Top padding clears the notch / punch-hole / status bar via safe-area-inset
   (iOS) AND a mobile floor (Android often reports 0 for env()). */
.topbar {
  min-height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
  padding: env(safe-area-inset-top, 0px) calc(16px + env(safe-area-inset-right, 0px)) 0 calc(16px + env(safe-area-inset-left, 0px));
  flex-shrink: 0;
}
.topbar-right { flex-wrap: wrap; row-gap: 6px; }

/* Mobile: force a hard top padding so the topbar children never sit under the
   camera punch / status bar even when env(safe-area-inset-top) reports 0
   (typical on Android Capacitor WebView with fitsSystemWindows=true).
   The hamburger button MUST stay tappable. */
@media (max-width: 768px) {
  .topbar {
    padding-top: max(env(safe-area-inset-top, 0px), 38px);
    min-height: calc(var(--topbar-h) + max(env(safe-area-inset-top, 0px), 38px));
  }
}
.menu-btn {
  display: none; /* desktop: hidden — sidebar pin button (≡) lives inside sidebar */
  background: none; border: 1px solid var(--border); color: var(--text2);
  font-size: 18px; padding: 0; width: 36px; height: 30px;
  border-radius: 6px;
  align-items: center; justify-content: center;
  line-height: 1;
}
.menu-btn:hover { background: var(--bg3); color: var(--accent); border-color: var(--accent); }
.page-title {
  margin: 0;
  font-size: 16px; font-weight: 600;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 60vw;
}
.topbar-spacer { flex: 1; }

/* Topbar right group — mirrors v1 layout exactly */
.topbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* DIRECT / RELAY pill — green dot + small caps text (v1 spec) */
.conn-pill {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--bg3); border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 10px; font-weight: 700; letter-spacing: 0.5px;
  padding: 4px 10px; border-radius: 999px;
  cursor: pointer; height: 26px;
  white-space: nowrap;
}
.conn-pill .conn-dot { width: 6px; height: 6px; background: var(--accent); border-radius: 50%; }
.conn-pill.relay { color: var(--yellow); border-color: var(--yellow); }
.conn-pill.relay .conn-dot { background: var(--yellow); }

/* MAIN / VM dual-indicator (replaces single DIRECT pill 2026-05-11) ---------- */
.conn-status { display: inline-flex; align-items: center; gap: 4px; }
.conn-ind {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--bg3); border: 1px solid transparent;
  color: var(--text2);
  font-size: 10px; font-weight: 700; letter-spacing: 0.5px;
  padding: 4px 10px; border-radius: 999px;
  height: 26px; white-space: nowrap;
  transition: border-color 0.2s, color 0.2s;
}
.conn-ind.active { border-color: var(--accent); color: var(--accent); }
.conn-ind .conn-dot {
  width: 6px; height: 6px; background: var(--text3);
  border-radius: 50%; transition: background 0.2s;
}
.conn-ind .conn-dot.up   { background: var(--accent); }
.conn-ind .conn-dot.down { background: var(--red);    }

/* Generic topbar pill (USD/EUR rate, etc.) */
.topbar-pill {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 12px;
  font-size: 11px; color: var(--text2);
  font-family: 'DM Mono', monospace;
  white-space: nowrap; height: 26px;
  display: inline-flex; align-items: center;
}

/* Language dropdown 🌐 EN with menu */
.lang-dropdown { position: relative; }
.lang-btn {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 10px; height: 26px;
  font-size: 12px; color: var(--text2);
  display: inline-flex; align-items: center; gap: 4px;
}
.lang-btn:hover { background: var(--bg4); color: var(--text); }
.lang-dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 4px);
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 8px; padding: 4px;
  min-width: 140px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 300;
}
.lang-option { padding: 6px 10px; font-size: 12px; cursor: pointer; border-radius: 4px; color: var(--text); }
.lang-option:hover { background: var(--bg3); }
.lang-option.active { background: var(--accent-dim); color: var(--accent); }

/* Notification bell */
.notif-btn {
  background: none; border: 1px solid var(--border);
  color: var(--text2); padding: 4px 10px; height: 26px;
  border-radius: 6px;
  position: relative;
  font-size: 14px;
}
.notif-btn:hover { color: var(--text); border-color: var(--text3); }
.notif-badge {
  position: absolute; top: -3px; right: -3px;
  background: var(--red); color: #fff;
  font-size: 9px; font-weight: 700;
  padding: 1px 5px; border-radius: 999px;
  border: 2px solid var(--bg2);
  min-width: 14px; text-align: center;
}

.theme-toggle { background: none; border: 1px solid var(--border); padding: 4px 10px; height: 26px; font-size: 14px; color: var(--text2); }
.theme-toggle:hover { color: var(--text); border-color: var(--text3); }
.reload-btn { background: none; border: 1px solid var(--border); padding: 4px 10px; height: 26px; font-size: 16px; line-height: 1; color: var(--text2); }
.reload-btn:hover { color: var(--accent); border-color: var(--accent); }
.legacy-link  { background: var(--bg3); border: 1px solid var(--border); padding: 4px 10px; height: 26px; font-size: 12px; color: var(--text2); border-radius: 6px; }
.legacy-link:hover { background: var(--bg4); color: var(--text); }

/* Page title — natural case (was lowercase like v1; user requested 2026-05-02) */
.page-title { font-weight: 600; }

/* ─── Row 2: Global ticker bar (site-wide, populated by TT module) ─── */
/* Wraps its own buttons on narrow screens. Stays a single row at desktop widths. */
.tt-ticker {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 16px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  min-height: 42px;
  flex-shrink: 0;
  flex-wrap: wrap;
  row-gap: 6px;
}
.tt-ticker .tt-tk-add {
  background: var(--accent); color: #000; font-weight: 700;
  border-color: var(--accent);
  padding: 5px 12px; font-size: 12.5px;
  flex-shrink: 0;
}
.tt-ticker .tt-tk-add:hover { background: var(--accent2); border-color: var(--accent2); }
.tt-ticker .tt-tk-dot {
  width: 8px; height: 8px; background: var(--accent); border-radius: 50%;
  animation: tt-pulse 1.6s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes tt-pulse { 0%,100% { opacity: 0.4; transform: scale(0.85); } 50% { opacity: 1; transform: scale(1.15); } }
.tt-ticker .tt-tk-label {
  flex: 1;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.tt-ticker .tt-tk-label em { color: var(--text3); font-style: normal; }
.tt-ticker .tt-tk-time {
  font-family: 'DM Mono', monospace; color: var(--accent); font-size: 14px;
  flex-shrink: 0;
}
.tt-ticker .tt-tk-actions {
  display: flex; gap: 6px; flex-shrink: 0;
}
.tt-ticker .tt-tk-actions button {
  padding: 4px 12px; font-size: 12px; height: 28px;
}
.tt-ticker .tt-tk-actions .tt-tk-start { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 600; }
.tt-ticker .tt-tk-actions .tt-tk-stop  { background: #3a1a1d; border-color: var(--red); color: #ffd5d5; }

/* Per-page action bar */
.page-actions {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  flex-shrink: 0;
}
.page-actions:empty { display: none; }

/* Page content */
.page-host {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 24px 32px;
  scroll-behavior: smooth;
}
.page-host:focus { outline: none; }
.page-host::-webkit-scrollbar { width: 10px; height: 10px; }
.page-host::-webkit-scrollbar-track { background: var(--bg2); }
.page-host::-webkit-scrollbar-thumb { background: var(--accent2); border-radius: 5px; }

/* ─── Light theme overrides ─── */
html[data-theme="light"] {
  --bg:        #f4f6fa;
  --bg2:       #ffffff;
  --bg3:       #eef1f6;
  --bg4:       #e1e5ec;
  --border:    #d4d8e0;
  --text:      #18222e;
  --text2:     #43526a;
  --text3:     #6f7c92;
  --accent:    #00a374;
  --accent2:   #007e5a;
  --accent-dim: rgba(0,163,116,0.12);
}

/* ─── Login card (used pre-auth) ─── */
.login-card {
  max-width: 420px; margin: 80px auto;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px;
  box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 20px; font-size: 18px; color: var(--accent); }
.login-card label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; font-size: 12px; color: var(--text3); }
.login-card button[type="submit"] { width: 100%; padding: 12px; background: var(--accent); color: #000; border: 0; border-radius: 8px; font-weight: 700; }
.login-card button[type="submit"]:hover { background: var(--accent2); }
.login-remember { flex-direction: row !important; align-items: center; gap: 8px; color: var(--text); margin-top: 4px; }
.login-remember input { width: auto !important; margin: 0; }
.login-langs { display: flex; gap: 4px; justify-content: center; margin-top: 16px; }
.login-langs button { background: var(--bg3); border: 1px solid var(--border); padding: 4px 10px; font-size: 11px; color: var(--text3); border-radius: 4px; }
.login-langs button.active { background: var(--accent); color: #000; font-weight: 700; border-color: var(--accent); }

/* ─── Desktop sidebar collapsed (icons only) ─── */
#shell.sidebar-collapsed-desktop {
  grid-template-columns: 56px 1fr;
}
#shell.sidebar-collapsed-desktop .logo-mark,
#shell.sidebar-collapsed-desktop .logo-role,
#shell.sidebar-collapsed-desktop .nav-item .label,
#shell.sidebar-collapsed-desktop .nav-badge,
#shell.sidebar-collapsed-desktop .nav-toggle,
#shell.sidebar-collapsed-desktop .sidebar-section,
#shell.sidebar-collapsed-desktop .user-meta,
#shell.sidebar-collapsed-desktop .nav-children { display: none !important; }
#shell.sidebar-collapsed-desktop .nav-item { justify-content: center; padding: 9px 4px; margin: 1px 4px; }
#shell.sidebar-collapsed-desktop .sidebar-logo { padding: 14px 0; justify-content: center; }
#shell.sidebar-collapsed-desktop .user-card { padding: 4px; justify-content: center; }
#shell.sidebar-collapsed-desktop .sidebar-bottom { padding: 6px; }

/* ─── Mobile (≤ 768px) ─── */
@media (max-width: 768px) {
  #shell { grid-template-columns: 1fr; } /* sidebar floats over content */
  #shell.sidebar-collapsed-desktop { grid-template-columns: 1fr; } /* desktop collapse irrelevant on mobile */
  .sidebar {
    position: fixed; inset: 0 auto 0 0;
    width: min(86vw, 320px);
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.4);
  }
  #shell.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-close { display: inline-flex; align-items: center; justify-content: center; }
  .menu-btn      { display: inline-flex; }
  .sidebar-pin-btn { display: none; } /* mobile uses sidebar-close (✕) instead */
  .page-title { font-size: 15px; max-width: 50vw; }
  .legacy-link { display: none; }
  .page-host { padding: 14px 14px 24px; }
  .ticker-row .t-title { max-width: 28vw; }
}

/* ≤ 480px stacking — DO NOT use shorthand `padding` here, it would wipe the
   notch-clearing padding-top set by the @media(≤768px) rule above. Set sides
   only. */
@media (max-width: 480px) {
  .topbar { padding-left: calc(10px + env(safe-area-inset-left, 0px)); padding-right: calc(10px + env(safe-area-inset-right, 0px)); gap: 6px; }
  .lang-picker button { padding: 4px 6px; }
  .theme-toggle { padding: 4px 8px; }
  .page-host { padding: 12px 10px 24px; }
}

/* ─── Shared modal primitives (NEXUS.modals.openBackdrop) ─── */
.nx-modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  z-index: 1999; display: none; align-items: center; justify-content: center;
  /* padding-bottom floor for Android nav bar so the modal's last-row buttons
     (Save / Cancel / Delete) stay above the system nav. 2026-05-04 fix. */
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0px), 80px);
}
.nx-modal-backdrop.open { display: flex; }
.nx-modal {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 14px; padding: 20px; max-width: 92vw; width: 480px;
  max-height: 90vh; overflow-y: auto; box-sizing: border-box;
  color: var(--text);
}
.nx-modal h3 { margin: 0 0 12px 0; }

/* ─── Shared emoji renderer (Twemoji-style) ─── */
.nx-emoji {
  height: 1em; width: 1em;
  vertical-align: -0.15em;
  display: inline-block;
  margin: 0 0.05em;
}

/* iOS safe-area inset + Android nav-bar floor.
   env(safe-area-inset-bottom) returns 0 on most Android phones even when
   there's a software 3-button nav bar / gesture pill that covers the last
   ~48-64px of every page. max() pins a 80px floor so any button on the last
   visible row stays above the nav bar. Bug fix 2026-05-04. */
@supports (padding: env(safe-area-inset-bottom)) {
  .page-host { padding-bottom: max(env(safe-area-inset-bottom, 0px), 80px); }
  /* Sidebar drawer also needs to clear the notch on Android phones — when the
     drawer slides over the topbar, its top must sit below the system status bar. */
  .sidebar   { padding-top: env(safe-area-inset-top); padding-bottom: max(env(safe-area-inset-bottom, 0px), 80px); }
}

/* Toast — single shared bottom-center popup. NEXUS.toast(msg, type) controls. */
.nx-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  min-width: 180px; max-width: 70vw; padding: 12px 18px;
  background: var(--bg2, #1d1f23); color: var(--text1, #f1f1f1);
  border: 1px solid var(--border1, #2c2f36); border-radius: 8px;
  font-size: 14px; line-height: 1.4; box-shadow: 0 8px 24px rgba(0,0,0,.35);
  opacity: 0; pointer-events: none; transition: opacity .25s ease, transform .25s ease;
  z-index: 99999;
}
.nx-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.nx-toast.warning { border-color: #d39e00; }
.nx-toast.error   { border-color: #c0392b; }
.nx-toast.success { border-color: #2ecc71; }
.nx-toast.info    { border-color: #3498db; }

/* Apps page — 3 latest-version cards (extension/android/ios) + history list */
.apps-grid { display:grid; grid-template-columns:repeat(3, 1fr); gap:16px; margin-bottom:32px; }
@media (max-width:780px) { .apps-grid { grid-template-columns:1fr; } }
.app-card {
  background:var(--bg2,#161820); border:1px solid var(--border1,#232730);
  border-radius:8px; padding:18px; display:flex; flex-direction:column; gap:12px;
}
.app-card-placeholder { opacity:.55; border-style:dashed; }
.app-head { display:flex; gap:12px; align-items:center; }
.app-icon { font-size:32px; line-height:1; width:44px; text-align:center; }
.app-name { font-size:16px; font-weight:600; }
.app-version { display:inline-block; margin-left:8px; padding:2px 8px; background:#2a3; color:#0b1a0b; font-size:11px; font-weight:700; border-radius:3px; vertical-align:middle; }
.app-meta { font-size:12px; color:var(--text3,#888); margin-top:2px; }
.app-steps { font-size:13px; color:var(--text2,#aaa); line-height:1.45; }
.app-actions { display:flex; gap:8px; align-items:center; flex-wrap:wrap; margin-top:auto; }
.dl-btn { background:#2a3; color:#0b1a0b; font-weight:600; padding:9px 16px; border-radius:6px; font-size:13px; text-decoration:none; }
.dl-btn:hover { background:#3b4; }
.dl-btn-old { background:#3a3d48; color:#ccc; padding:5px 12px; font-size:12px; }
.dl-btn-old:hover { background:#4a4d58; }
.edit-btn { background:#2c2f36; color:#eee; border:1px solid #3a3d48; border-radius:6px; padding:8px 14px; font-size:13px; cursor:pointer; }
.edit-btn:hover { background:#3a3d48; }
.edit-btn-sm { padding:4px 10px; font-size:12px; }

/* Build history (super-admin only) */
.apps-history-h { font-size:14px; color:var(--text3,#666); letter-spacing:.5px; text-transform:uppercase; margin:24px 0 6px; }
.apps-history { display:flex; flex-direction:column; gap:6px; }
.app-history-row {
  display:grid; grid-template-columns:24px 80px 80px 1fr 130px auto auto;
  gap:10px; align-items:center;
  padding:8px 12px; background:var(--bg2,#161820); border:1px solid var(--border1,#232730); border-radius:6px;
  font-size:13px;
}
.app-history-icon { text-align:center; font-size:18px; }
.app-history-kind { color:#8ab; font-size:11px; letter-spacing:.4px; text-transform:uppercase; }
.app-history-ver { font-weight:600; color:#aaa; }
.app-history-name, .app-history-date { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.app-history-date { font-size:11px; }
@media (max-width:680px) {
  .app-history-row { grid-template-columns:24px 1fr auto; row-gap:4px; }
  .app-history-kind, .app-history-name, .app-history-date { display:none; }
}

