* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #00ff00;
  --secondary: #00aa00;
  --bg-dark: #000;
  --bg-card: rgba(0,0,0,0.5);
  --text-color: #00ff00;
  --border: #00ff00;
  --terminal-height: 200px;
  --danger: #ff4444;
  --warning: #ffaa00;
}

body.light-mode {
  --bg-dark: #f0f2f5;
  --bg-card: rgba(255,255,255,0.9);
  --text-color: #1a1a2e;
  --border: #c0c0c0;
  --primary: #2563eb;
  --secondary: #1d4ed8;
}

body.dark-mode {
  --bg-dark: #0f1117;
  --bg-card: rgba(255,255,255,0.05);
  --text-color: #e2e8f0;
  --border: #334155;
  --primary: #38bdf8;
  --secondary: #0ea5e9;
}

body {
  font-family: 'Courier New', monospace;
  background: var(--bg-dark);
  color: var(--text-color);
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
  display: flex;
  flex-direction: column;
}

#matrix-canvas {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: -1; opacity: 0.15;
  pointer-events: none;
}
body.matrix-mode #matrix-canvas { opacity: 0.3; }
body.light-mode #matrix-canvas, body.dark-mode #matrix-canvas { display: none; }

/* ===== LAYOUT ===== */
.main-content {
  flex: 1;
  padding: 20px;
  padding-top: calc(20px + env(safe-area-inset-top, 0px));
  padding-left: calc(20px + env(safe-area-inset-left, 0px));
  padding-right: calc(20px + env(safe-area-inset-right, 0px));
  padding-bottom: calc(var(--terminal-height) + 20px);
  overflow-y: auto;
}
.container { max-width: 1400px; margin: 0 auto; position: relative; z-index: 1; }

/* ===== HEADER ===== */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 16px;
  gap: 12px;
}
.title { font-size: 22px; font-weight: bold; text-shadow: 0 0 10px var(--primary); white-space: nowrap; }
.header-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.header-user { font-size: 12px; opacity: 0.8; }

/* ===== HAMBURGER (mobile) ===== */
.hamburger {
  display: none;
  flex-direction: column; gap: 5px;
  cursor: pointer; padding: 6px;
  background: transparent; border: 1px solid var(--border); border-radius: 4px;
}
.hamburger span { display: block; width: 20px; height: 2px; background: var(--text-color); transition: 0.3s; }

.mobile-overlay {
  display: none; position: fixed;
  inset: 0; background: rgba(0,0,0,0.7);
  z-index: 200;
}
.mobile-overlay.active { display: block; }

.mobile-nav {
  position: fixed; top: 0; left: -280px;
  width: 280px; height: 100%;
  background: var(--bg-dark);
  border-right: 2px solid var(--border);
  z-index: 300;
  padding: 20px;
  padding-top: calc(20px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  transition: left 0.3s;
  display: flex; flex-direction: column; gap: 8px;
  overflow-y: auto;
}
.mobile-nav.open { left: 0; }
.mobile-nav-title { font-size: 18px; font-weight: bold; margin-bottom: 16px; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.mobile-nav-item {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}
.mobile-nav-item:hover, .mobile-nav-item.active { background: var(--primary); color: #000; }

/* ===== TABS ===== */
.tabs {
  display: flex; gap: 6px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
  flex-wrap: wrap;
  overflow-x: auto;
}
.tab {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--border);
  border-bottom: none;
  color: var(--text-color);
  cursor: pointer;
  font-family: 'Courier New', monospace;
  font-weight: bold;
  font-size: 13px;
  transition: background 0.2s;
  border-radius: 4px 4px 0 0;
  white-space: nowrap;
}
.tab:hover { background: rgba(0,255,0,0.08); }
.tab.active { background: var(--primary); color: #000; }
body.light-mode .tab.active { color: #fff; }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== CARDS / SECTIONS ===== */
.section {
  border: 1px solid var(--border);
  padding: 20px;
  margin-bottom: 20px;
  background: var(--bg-card);
  border-radius: 4px;
}
.section h2 { margin-bottom: 14px; border-bottom: 1px solid var(--border); padding-bottom: 10px; font-size: 15px; }

/* ===== SEARCH + SORT BAR ===== */
.list-controls {
  display: flex; gap: 8px; align-items: center;
  margin-bottom: 12px; flex-wrap: wrap;
}
.search-input {
  flex: 1; min-width: 160px;
  padding: 6px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-color);
  font-family: 'Courier New', monospace;
  font-size: 12px;
  border-radius: 3px;
}
.search-input::placeholder { opacity: 0.5; }
.sort-btn {
  padding: 6px 10px; font-size: 11px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-color);
  cursor: pointer;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
}
.sort-btn.active { background: var(--primary); color: #000; }

/* ===== SERVER ITEMS ===== */
.server-item {
  background: var(--bg-card);
  padding: 14px;
  margin-bottom: 8px;
  border-left: 3px solid var(--primary);
  border-radius: 0 4px 4px 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 10px;
  transition: border-color 0.2s;
}
.server-item:hover { border-left-color: var(--secondary); }
.server-info { flex: 1; min-width: 180px; }
.server-name { font-weight: bold; margin-bottom: 3px; font-size: 15px; }
.server-host { font-size: 11px; opacity: 0.7; margin-bottom: 4px; }

/* ===== UPTIME DOTS ===== */
.uptime-dots { display: flex; gap: 2px; flex-wrap: wrap; margin-top: 5px; }
.uptime-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  cursor: default;
  transition: transform 0.1s;
}
.uptime-dot:hover { transform: scale(1.4); }
.uptime-dot.online { background: #00cc44; box-shadow: 0 0 3px #00cc44; }
.uptime-dot.offline { background: #ff4444; box-shadow: 0 0 3px #ff4444; }
.uptime-dot.unknown { background: #666; }

/* ===== STATUS BADGES ===== */
.status { padding: 4px 10px; border-radius: 3px; font-weight: bold; font-size: 12px; white-space: nowrap; }
.status.online { background: #00cc44; color: #000; }
.status.offline { background: #ff4444; color: #fff; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-dot.online { background: #00cc44; box-shadow: 0 0 5px #00cc44; animation: pulse 2s infinite; }
.status-dot.offline { background: #ff4444; box-shadow: 0 0 5px #ff4444; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ===== ACTIONS ===== */
.actions { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }

/* ===== BUTTONS ===== */
button {
  padding: 6px 12px;
  background: var(--primary);
  color: #000;
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  font-weight: bold;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  transition: background 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
button:hover { background: var(--secondary); box-shadow: 0 0 10px var(--primary); }
body.light-mode button { color: #fff; }
button.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.btn-danger:hover { box-shadow: 0 0 10px var(--danger); }
button.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
button.btn-outline:hover { background: rgba(0,255,0,0.1); }
button.btn-sm { padding: 4px 8px; font-size: 11px; }
button.btn-warning { background: #ffaa00; border-color: #ffaa00; color: #000; }
button.btn-warning:hover { box-shadow: 0 0 10px #ffaa00; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 12px; }
label { display: block; margin-bottom: 4px; font-weight: bold; font-size: 12px; }
input, textarea, select {
  width: 100%; padding: 7px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-color);
  font-family: 'Courier New', monospace;
  font-size: 13px;
  border-radius: 3px;
  transition: border-color 0.2s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 5px rgba(0,255,0,0.3); }
body.light-mode input, body.light-mode textarea, body.light-mode select { background: #fff; }
textarea { resize: vertical; min-height: 80px; }
input[type="color"] { width: 50px; height: 32px; padding: 2px; cursor: pointer; }
select { cursor: pointer; }

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.inline-form .form-group { flex: 1; min-width: 110px; margin-bottom: 0; }

/* ===== DASHBOARD STATS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 24px;
  text-align: center;
  border-radius: 6px;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 4px 20px rgba(0,255,0,0.2); }
.stat-card.clickable { cursor: pointer; }
.stat-icon { font-size: 20px; margin-bottom: 12px; font-weight: bold; letter-spacing: 2px; }
.stat-title { font-size: 12px; opacity: 0.7; margin-bottom: 8px; }
.stat-value { font-size: 40px; font-weight: bold; line-height: 1; }
.stat-details { display: flex; justify-content: center; gap: 16px; margin-top: 12px; font-size: 13px; }
.stat-online { color: #00cc44; }
.stat-offline { color: #ff4444; }
.stat-subtitle { font-size: 11px; margin-top: 8px; opacity: 0.6; }

/* ===== LOGIN ===== */
.login-box {
  border: 2px solid var(--border);
  padding: 40px;
  background: rgba(0,0,0,0.92);
  max-width: 400px;
  margin: 0 auto;
  border-radius: 6px;
}
body.light-mode .login-box { background: rgba(255,255,255,0.98); }
body.dark-mode .login-box { background: rgba(15,17,23,0.98); }
.login-box h1 { margin-bottom: 28px; font-size: 22px; text-shadow: 0 0 20px var(--primary); text-align: center; }
.login-box input { margin-bottom: 12px; }

/* ===== TERMINAL FOOTER ===== */
.terminal-footer {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--terminal-height);
  background: #000;
  border-top: 2px solid var(--primary);
  z-index: 100;
  display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
body.light-mode .terminal-footer, body.dark-mode .terminal-footer { background: #0a0a0a; }
.resize-handle { height: 5px; background: var(--primary); cursor: ns-resize; opacity: 0.4; flex-shrink: 0; }
.resize-handle:hover { opacity: 1; }
.terminal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 12px;
  background: rgba(0,255,0,0.08);
  border-bottom: 1px solid var(--primary);
  flex-shrink: 0;
}
.terminal-title { font-weight: bold; font-size: 11px; display: flex; align-items: center; gap: 12px; }
.terminal-status { display: flex; gap: 12px; font-size: 10px; }
.terminal-status-item { display: flex; align-items: center; gap: 4px; }
.terminal-controls { display: flex; gap: 4px; }
.terminal-controls button { padding: 2px 8px; font-size: 10px; }
.terminal-body {
  flex: 1; overflow-y: auto; padding: 8px 12px;
  font-size: 11px; font-family: 'Courier New', monospace;
  color: var(--primary);
}
.terminal-body::-webkit-scrollbar { width: 6px; }
.terminal-body::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 3px; }
.terminal-line { margin-bottom: 1px; white-space: pre-wrap; word-wrap: break-word; }
.terminal-line.error { color: #ff6666; }
.terminal-line.success { color: #00cc44; }
.terminal-line.warning { color: #ffaa00; }
.terminal-line.info { color: #66ccff; }

/* ===== SSH MODAL ===== */
.modal {
  display: none; position: fixed; z-index: 1000;
  inset: 0; background: rgba(0,0,0,0.85);
}
.modal.active { display: flex; justify-content: center; align-items: center; }
.modal-content {
  background: #000; border: 2px solid var(--primary);
  width: 96%; max-width: 1400px; height: 88vh;
  display: flex; flex-direction: column;
  border-radius: 4px; overflow: hidden;
}
body.light-mode .modal-content { background: #111; }
body.dark-mode .modal-content { background: #0a0a0a; }

/* ===== SSH TABS ===== */
.ssh-tab-bar {
  display: flex; align-items: center;
  background: rgba(0,255,0,0.05);
  border-bottom: 1px solid var(--primary);
  padding: 0 8px;
  gap: 4px;
  overflow-x: auto;
  flex-shrink: 0;
}
.ssh-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 12px; font-weight: bold;
  border-right: 1px solid rgba(0,255,0,0.2);
  white-space: nowrap;
  color: rgba(0,255,0,0.6);
  transition: color 0.15s, background 0.15s;
}
.ssh-tab:hover { color: var(--primary); background: rgba(0,255,0,0.1); }
.ssh-tab.active { color: var(--primary); background: rgba(0,255,0,0.12); }
.ssh-tab .ssh-tab-status { width: 7px; height: 7px; border-radius: 50%; background: #666; flex-shrink: 0; }
.ssh-tab .ssh-tab-status.connected { background: #00cc44; animation: pulse 2s infinite; }
.ssh-tab .ssh-tab-status.error { background: #ff4444; }
.ssh-tab-close {
  font-size: 13px; opacity: 0.5;
  padding: 0 2px;
  background: transparent; border: none; cursor: pointer;
  color: var(--primary); font-family: inherit;
  line-height: 1;
}
.ssh-tab-close:hover { opacity: 1; box-shadow: none; background: transparent; }
.ssh-tab-new {
  padding: 6px 10px; margin-left: 4px;
  background: transparent; border: 1px dashed var(--border);
  color: var(--primary); font-size: 16px; cursor: pointer;
  border-radius: 3px; flex-shrink: 0;
}
.ssh-tab-new:hover { background: rgba(0,255,0,0.1); box-shadow: none; }

.modal-header {
  padding: 10px 14px; border-bottom: 1px solid var(--primary);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-close { background: var(--danger); color: #fff; border-color: var(--danger); }

.ssh-sessions-wrapper { flex: 1; position: relative; overflow: hidden; }
.ssh-session-pane {
  position: absolute; inset: 0;
  display: none; flex-direction: column;
}
.ssh-session-pane.active { display: flex; }

.ssh-auth-form {
  padding: 20px;
  background: rgba(0,255,0,0.06);
  border-bottom: 1px solid var(--primary);
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
}
.ssh-auth-form input, .ssh-auth-form textarea { font-size: 13px; }
.ssh-auth-input { flex: 1; min-width: 140px; }
.ssh-auth-key { width: 100%; }

#ssh-terminal-container, .ssh-terminal-pane {
  flex: 1; overflow: hidden; cursor: text; background: #000;
}

/* ===== 2FA MODAL ===== */
#fa2-modal-content { max-width: 500px; height: auto; }
.qr-container { text-align: center; padding: 16px; background: #fff; border-radius: 8px; margin: 16px 0; }
.qr-container img { max-width: 180px; }
.secret-code {
  font-size: 16px; letter-spacing: 3px;
  padding: 10px; background: rgba(0,255,0,0.08);
  border: 1px dashed var(--primary); margin: 10px 0;
  border-radius: 3px;
}

/* ===== TABLES ===== */
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th { padding: 8px; text-align: left; border: 1px solid var(--border); background: rgba(0,255,0,0.12); font-size: 11px; }
.data-table td { padding: 6px 8px; border: 1px solid var(--border); }
.data-table tr:hover td { background: rgba(0,255,0,0.04); }

/* ===== FRITZ SCAN MODAL ===== */
.fritz-scan-modal-content { max-width: 900px; height: 85vh; }
.fritz-scan-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 0; }
.fritz-section { margin-bottom: 20px; }
.fritz-section-title {
  font-size: 10px; font-weight: bold; letter-spacing: 2px;
  color: var(--primary); margin-bottom: 8px; padding: 5px 10px;
  background: rgba(0,255,0,0.08); border-left: 3px solid var(--primary);
}
.fritz-source { font-size: 11px; opacity: 0.55; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.fritz-loading {
  padding: 60px 20px; text-align: center; color: var(--primary); font-size: 13px;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
}
.fritz-connecting-anim {
  display: flex; align-items: center; gap: 0; height: 32px;
}
.fritz-connecting-anim span {
  display: inline-block; width: 4px; height: 10px;
  background: var(--primary); border-radius: 2px; margin: 0 3px;
  animation: fritz-bar 1.1s ease-in-out infinite;
  opacity: 0.3;
}
.fritz-connecting-anim span:nth-child(1) { animation-delay: 0s;    height: 10px; }
.fritz-connecting-anim span:nth-child(2) { animation-delay: 0.15s; height: 18px; }
.fritz-connecting-anim span:nth-child(3) { animation-delay: 0.3s;  height: 26px; }
.fritz-connecting-anim span:nth-child(4) { animation-delay: 0.45s; height: 18px; }
.fritz-connecting-anim span:nth-child(5) { animation-delay: 0.6s;  height: 10px; }
@keyframes fritz-bar {
  0%, 100% { opacity: 0.2; transform: scaleY(0.7); }
  50%       { opacity: 1;   transform: scaleY(1.2); }
}
.fritz-connecting-label { font-size: 12px; letter-spacing: 2px; opacity: 0.8; text-transform: uppercase; }
.fritz-connecting-ip {
  font-size: 14px; font-family: monospace; color: var(--primary);
  background: rgba(0,255,0,0.07); border: 1px solid rgba(0,255,0,0.2);
  padding: 4px 14px; border-radius: 4px; letter-spacing: 1px;
  animation: fritz-ip-blink 1.6s ease-in-out infinite;
}
@keyframes fritz-ip-blink {
  0%, 100% { opacity: 0.6; }
  50%       { opacity: 1; }
}
.fritz-error { padding: 20px; color: #ff4444; font-size: 13px; }
.fritz-ok { color: #00cc44; }
.fritz-nok { color: #ff4444; }
.fritz-warn { color: #ffaa00; }
.fritz-empty { padding: 8px 0; opacity: 0.55; font-size: 12px; }
.fritz-td-label { opacity: 0.7; min-width: 160px; max-width: 200px; font-size: 11px; white-space: nowrap; }

/* ===== MISC ===== */
.group-badge {
  display: inline-block; padding: 2px 7px;
  border-radius: 10px; font-size: 10px; font-weight: bold;
}
.sub-tabs { display: flex; gap: 4px; margin-bottom: 14px; flex-wrap: wrap; }
.sub-tab {
  padding: 6px 14px; background: transparent;
  border: 1px solid var(--border); color: var(--text-color);
  cursor: pointer; font-size: 12px; border-radius: 3px;
  font-family: 'Courier New', monospace;
}
.sub-tab.active { background: var(--primary); color: #000; }
.sub-content { display: none; }
.sub-content.active { display: block; }

.empty-state { text-align: center; padding: 40px 20px; opacity: 0.6; }
.empty-state h3 { margin-bottom: 8px; }

hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ===== TOAST ===== */
.toast-container { position: fixed; top: calc(16px + env(safe-area-inset-top, 0px)); right: calc(16px + env(safe-area-inset-right, 0px)); z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 18px; border-radius: 4px; font-size: 13px;
  font-family: 'Courier New', monospace; font-weight: bold;
  animation: slideIn 0.3s ease; max-width: 300px;
  border-left: 4px solid;
  background: #111; color: #fff;
}
.toast.success { border-color: #00cc44; }
.toast.error { border-color: #ff4444; }
.toast.warning { border-color: #ffaa00; }
@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== RESPONSIVE MOBILE ===== */
@media (max-width: 768px) {
  .hamburger { display: flex; }
  .tabs { display: none; }
  .header-user { display: none; }
  .title { font-size: 18px; }
  .main-content {
    /* explicit sides so safe-area-insets are not lost by a shorthand */
    padding-top:    calc(env(safe-area-inset-top,    0px) + 12px);
    padding-left:   calc(env(safe-area-inset-left,   0px) + 12px);
    padding-right:  calc(env(safe-area-inset-right,  0px) + 12px);
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 58px + 16px);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
  }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 16px 12px; }
  .stat-value { font-size: 28px; }
  .server-item { flex-direction: column; align-items: flex-start; }
  .actions { width: 100%; }
  .inline-form { flex-direction: column; }
  .inline-form .form-group { width: 100%; }
  .modal-content { width: 100%; height: 100%; border-radius: 0; border: none; }
  .terminal-footer { display: none !important; }
  .ssh-auth-form { flex-direction: column; }
  .data-table { font-size: 11px; }
  .data-table th:nth-child(n+5),
  .data-table td:nth-child(n+5) { display: none; }
  /* touch-friendly buttons */
  button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
  /* subfinder stacks on mobile */
  .sf-layout { grid-template-columns: 1fr !important; }
  .sf-layout-left {
    border-right: none !important;
    border-bottom: 1px solid var(--border);
    padding-bottom: 16px;
  }
  /* btn-sm big enough for touch */
  .btn-sm { padding: 7px 12px !important; font-size: 12px !important; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-icon { font-size: 14px; }
  .tab { font-size: 12px; padding: 6px 10px; }
}

/* ===== PWA BOTTOM NAV ===== */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(58px + env(safe-area-inset-bottom, 0px));
  background: var(--bg-dark);
  border-top: 1px solid var(--border);
  z-index: 150;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
.bottom-nav-inner {
  display: flex;
  width: 100%;
  height: 58px;
  align-items: stretch;
}
.bnav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: transparent;
  color: var(--text-color);
  opacity: 0.42;
  cursor: pointer;
  padding: 4px 2px;
  font-family: 'Courier New', monospace;
  transition: opacity 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-width: 0;
  outline: none;
}
.bnav-item.active {
  opacity: 1;
  color: var(--primary);
  background: rgba(0, 255, 0, 0.07);
}
.bnav-item:active { background: rgba(0, 255, 0, 0.15); opacity: 1; }
.bnav-icon { font-size: 17px; line-height: 1.2; }
.bnav-label { font-size: 8px; text-transform: uppercase; letter-spacing: 0.4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

@media (max-width: 768px) { .bottom-nav { display: flex; } }

/* ===== PWA STANDALONE ADJUSTMENTS ===== */
@media (display-mode: standalone) {
  /* prevent pull-to-refresh gesture interfering with app */
  body { overscroll-behavior: none; }
}

/* ===== SETTINGS GRID ===== */
.settings-grid {
  display: flex; flex-direction: column; gap: 16px;
}
.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 20px;
}
.settings-card-title {
  font-size: 13px; font-weight: bold; letter-spacing: 1px;
  text-transform: uppercase; opacity: 0.7;
  margin-bottom: 16px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.form-row { display: flex; gap: 10px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 120px; }

/* ===== NOTIFICATION SERVICES ===== */
.notif-service {
  border: 1px solid var(--border);
  border-radius: 5px; margin-bottom: 12px;
  overflow: hidden; transition: border-color 0.2s;
}
.notif-service--active { border-color: var(--primary); }
.notif-service-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  background: rgba(0,0,0,0.2);
  border-bottom: 1px solid var(--border);
}
body.light-mode .notif-service-header { background: rgba(0,0,0,0.04); }
.notif-service-body { padding: 14px 16px; }
.notif-logo {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-style: normal;
}
.notif-logo--tg   { background: #2AABEE22; }
.notif-logo--ntfy { background: rgba(0,255,0,0.1); }
.badge-set {
  font-size: 10px; background: rgba(0,204,68,0.2);
  color: #00cc44; padding: 2px 6px; border-radius: 10px;
  margin-left: 6px; font-weight: bold;
}

/* ===== TOGGLE SWITCH ===== */
.toggle-switch { position: relative; display: inline-block; width: 42px; height: 22px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: #444; border-radius: 22px; cursor: pointer;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: ''; position: absolute;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; bottom: 3px; left: 3px;
  transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }
body.dark-mode .toggle-slider { background: #334; }

/* ===== ROLE EXPLANATION ===== */
.role-explanation {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px; padding: 20px;
  margin-bottom: 4px;
}
.role-explanation-title {
  font-size: 13px; font-weight: bold; letter-spacing: 1px;
  text-transform: uppercase; opacity: 0.7;
  margin-bottom: 14px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.role-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.role-card {
  border: 1px solid var(--border); border-radius: 5px;
  padding: 14px; background: rgba(0,0,0,0.15);
}
body.light-mode .role-card { background: rgba(0,0,0,0.03); }
.role-card--admin { border-left: 3px solid #ff4444; }
.role-card--user  { border-left: 3px solid #38bdf8; }
.role-card-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.role-badge {
  font-size: 11px; font-weight: bold; padding: 3px 9px;
  border-radius: 10px; letter-spacing: 0.5px;
}
.role-badge--admin { background: rgba(255,68,68,0.2); color: #ff6666; }
.role-badge--user  { background: rgba(56,189,248,0.2); color: #38bdf8; }
.role-badge-desc { font-size: 11px; opacity: 0.6; }
.role-perms { list-style: none; font-size: 12px; line-height: 1.7; opacity: 0.85; }
.groups-explanation {
  background: rgba(0,0,0,0.1); border-radius: 4px;
  padding: 12px 14px; font-size: 12px; line-height: 1.6; opacity: 0.85;
  border-left: 3px solid var(--primary);
}
body.light-mode .groups-explanation { background: rgba(0,0,0,0.04); }
.groups-explanation-title { font-weight: bold; margin-bottom: 6px; font-size: 12px; }

@media (max-width: 600px) {
  .role-cards { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; }
}
