/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d1117;
  --bg2: #161b22;
  --bg3: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text2: #8b949e;
  --green: #3fb950;
  --red: #f85149;
  --yellow: #d29922;
  --blue: #58a6ff;
  --purple: #bc8cff;
  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: contain;
}

/* ===== Top Bar ===== */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(13, 17, 23, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}
.last-updated {
  font-size: 0.72rem;
  color: var(--text2);
  flex-shrink: 0;
}
.refresh-btn {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.refresh-btn:hover { color: var(--text); background: var(--bg3); }
.refresh-btn.spinning svg { animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Main ===== */
.main {
  padding: 12px 12px 32px;
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ===== Section ===== */
.section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-icon { font-size: 1.2rem; line-height: 1; flex-shrink: 0; }
.section-title {
  font-size: 1rem;
  font-weight: 600;
  flex: 1;
}
.status-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.status-badge.ok     { background: rgba(63,185,80,0.15);   color: var(--green);  border: 1px solid rgba(63,185,80,0.3); }
.status-badge.warn   { background: rgba(210,153,34,0.15);  color: var(--yellow); border: 1px solid rgba(210,153,34,0.3); }
.status-badge.error  { background: rgba(248,81,73,0.15);   color: var(--red);    border: 1px solid rgba(248,81,73,0.3); }
.status-badge.loading{ background: var(--bg3);             color: var(--text2);  border: 1px solid var(--border); }

/* ===== Alert Banner ===== */
.alert-banner {
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 600;
}
.alert-banner.ok    { background: rgba(63,185,80,0.1);  color: var(--green); border: 1px solid rgba(63,185,80,0.25); }
.alert-banner.error { background: rgba(248,81,73,0.1);  color: var(--red);   border: 1px solid rgba(248,81,73,0.3); }

/* ===== Net Monitor view mode ===== */
.net-view-switch {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.net-view-btn {
  border: 0;
  background: transparent;
  color: var(--text2);
  border-radius: 6px;
  padding: 7px 10px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.net-view-btn.active {
  background: var(--bg);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border);
}
.net-view-hint {
  margin-left: auto;
  color: var(--text2);
  font-family: 'SF Mono','Consolas',monospace;
  font-size: 0.68rem;
  white-space: nowrap;
}

/* ===== Shimmer ===== */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}
.loading-shimmer {
  background: linear-gradient(90deg, var(--bg3) 25%, #2d333b 50%, var(--bg3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
  min-height: 60px;
  border: 1px solid var(--border);
}

/* ===== Summary Grid ===== */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.summary-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 70px;
}
.summary-card .card-label {
  font-size: 0.68rem;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}
.summary-card .card-value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}
.summary-card .card-sub {
  font-size: 0.72rem;
  color: var(--text2);
  margin-top: 2px;
}
.summary-card.has-offline .card-value { color: var(--red); }
.summary-card.all-online  .card-value { color: var(--green); }

/* ===== Per-VPS mini tiles ===== */
.vps-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.vps-mini-tile {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  border-left: 3px solid var(--green);
}
.vps-mini-tile.offline { border-left-color: var(--red); }
.vps-mini-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.vps-mini-name {
  font-size: 0.85rem;
  font-weight: 600;
  flex: 1;
}
.vps-mini-ip {
  font-size: 0.68rem;
  color: var(--text2);
  font-family: 'SF Mono','Consolas',monospace;
}
.vps-mini-stats { padding-top: 2px; }
.vps-offline-label { font-size: 0.75rem; color: var(--red); }

/* ===== Online dot (shared) ===== */
.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.online-dot.green  { background: var(--green);  box-shadow: 0 0 5px var(--green); }
.online-dot.red    { background: var(--red);    box-shadow: 0 0 5px var(--red); }
.online-dot.yellow { background: var(--yellow); box-shadow: 0 0 5px var(--yellow); }

/* ===== Router list (collapsible) ===== */
.router-details {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.router-summary {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text2);
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  -webkit-tap-highlight-color: transparent;
}
.router-summary::-webkit-details-marker { display: none; }
.router-summary::before { content: '▶'; font-size: 0.65rem; transition: transform 0.2s; }
details[open] .router-summary::before { transform: rotate(90deg); }
.router-list {
  border-top: 1px solid var(--border);
  padding: 6px 0;
}
.router-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  font-size: 0.8rem;
}
.router-name  { flex: 1; color: var(--text); font-weight: 500; }
.router-dtype { font-size: 0.68rem; color: var(--text2); }
.router-ping  { font-size: 0.72rem; color: var(--blue); min-width: 36px; text-align: right; }
.offline-text { color: var(--text2); }

/* ===== GPU/Ollama tile ===== */
.gpu-tile {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.gpu-tile.gpu-error {
  display: flex;
  align-items: center;
  min-height: 44px;
}
.gpu-tile-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.gpu-tile-label { font-size: 0.78rem; font-weight: 600; color: var(--text2); text-transform: uppercase; }
.gpu-model      { font-size: 0.75rem; color: var(--blue); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gpu-tile-status { font-size: 0.68rem; padding: 1px 6px; border-radius: 10px; }
.gpu-tile-status.loaded   { background: rgba(63,185,80,0.15); color: var(--green); }
.gpu-tile-status.unloaded { background: var(--bg); color: var(--text2); }
.gpu-list { display: flex; flex-direction: column; gap: 4px; }
.gpu-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.74rem;
}
.gpu-name { flex: 1; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gpu-temp { color: var(--green); font-weight: 600; min-width: 36px; }
.gpu-temp.yellow { color: var(--yellow); }
.gpu-temp.red    { color: var(--red); }
.gpu-mem  { color: var(--text2); font-size: 0.68rem; min-width: 90px; text-align: right; }

/* ===== Offline List ===== */
.offline-list {
  background: rgba(248,81,73,0.06);
  border: 1px solid rgba(248,81,73,0.25);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.offline-list .offline-title {
  font-size: 0.72rem;
  color: var(--red);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.offline-item {
  font-size: 0.82rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}
.offline-item::before { content: "🔴"; font-size: 0.65rem; }

/* ===== Servers Grid ===== */
.servers-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.server-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
}
.server-card.online  { border-left: 3px solid var(--green); }
.server-card.offline { border-left: 3px solid var(--red); }
.server-card.warn    { border-left: 3px solid var(--yellow); }

.server-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.server-dot.green  { background: var(--green);  box-shadow: 0 0 6px var(--green); }
.server-dot.red    { background: var(--red);    box-shadow: 0 0 6px var(--red); }
.server-dot.yellow { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }

.server-info { flex: 1; min-width: 0; }
.server-name {
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.server-flag { font-size: 1rem; flex-shrink: 0; }
.server-host {
  font-size: 0.7rem;
  color: var(--text2);
  font-family: 'SF Mono','Consolas',monospace;
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.server-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  flex-shrink: 0;
}
.stat-row {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--text2);
}
.stat-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-bar {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.stat-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}
.stat-bar-fill.green  { background: var(--green); }
.stat-bar-fill.yellow { background: var(--yellow); }
.stat-bar-fill.red    { background: var(--red); }

.server-peers { font-size: 0.7rem; color: var(--blue); font-weight: 600; }

/* ===== Bundle Cards (Mukha VPN — связки РФ-вход → выход) ===== */
.bundle-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bundle-card.online  { border-left: 3px solid var(--green); }
.bundle-card.offline { border-left: 3px solid var(--red); }
.bundle-card.warn    { border-left: 3px solid var(--yellow); }

.bundle-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.bundle-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* The pair: [entry] -> [exit] side by side */
.bundle-pair {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.bundle-side {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.bundle-side-header {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  overflow: hidden;
}
.bundle-side-flag { font-size: 1rem; flex-shrink: 0; }
.bundle-side-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
}
.bundle-side-ip {
  font-size: 0.66rem;
  color: var(--text2);
  font-family: 'SF Mono', 'Consolas', monospace;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bundle-side-bars { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.bundle-side-nodata { font-size: 0.72rem; color: var(--text2); margin-top: 2px; }

.bundle-arrow {
  flex-shrink: 0;
  align-self: center;
  font-size: 1.1rem;
  color: var(--text2);
  line-height: 1;
  padding: 0 2px;
}

/* On very narrow screens, stack entry/exit vertically */
@media (max-width: 340px) {
  .bundle-pair { flex-direction: column; }
  .bundle-arrow { align-self: auto; transform: rotate(90deg); }
}

/* grey dot for unknown/no-data status */
.server-dot.grey  { background: var(--text2); }
.online-dot.grey  { background: var(--text2); }

/* ===== Clients Tile ===== */
.clients-tile {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
}
.clients-icon    { font-size: 1.4rem; flex-shrink: 0; }
.clients-info    { flex: 1; }
.clients-number  { font-size: 1.8rem; font-weight: 700; color: var(--text); line-height: 1; }
.clients-label   { font-size: 0.75rem; color: var(--text2); margin-top: 2px; }
.clients-sub     { font-size: 0.72rem; color: var(--text2); }

/* ===== Devices Tile ===== */
.devices-tile {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.devices-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.devices-icon   { font-size: 1.3rem; flex-shrink: 0; }
.devices-info   { flex: 1; }
.devices-number { font-size: 1.6rem; font-weight: 700; line-height: 1; color: var(--text); }
.devices-label  { font-size: 0.72rem; color: var(--text2); margin-top: 2px; }
.devices-online {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}
.devices-stat { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.devices-stat-val { font-size: 1rem; font-weight: 700; color: var(--text); line-height: 1; }
.devices-stat-lbl { font-size: 0.62rem; color: var(--text2); text-transform: uppercase; letter-spacing: 0.04em; }

/* ===== Health Tile ===== */
.health-tile {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.health-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.health-label { font-size: 0.72rem; color: var(--text2); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.health-count { font-size: 0.78rem; font-weight: 700; }
.health-count.ok    { color: var(--green); }
.health-count.error { color: var(--red); }
.health-nodes { display: flex; flex-direction: column; gap: 5px; }
.health-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.76rem;
}
.health-node      { font-weight: 600; min-width: 48px; }
.health-transport { color: var(--text2); flex: 1; }
.health-rtt       { color: var(--blue); font-size: 0.7rem; min-width: 36px; text-align: right; }

/* ===== Alerts ===== */
.alerts {
  background: rgba(210,153,34,0.08);
  border: 1px solid rgba(210,153,34,0.3);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.alert-title {
  font-size: 0.72rem;
  color: var(--yellow);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}
.alert-item { font-size: 0.82rem; color: var(--text); }

/* ===== Section error ===== */
.section-error {
  font-size: 0.8rem;
  color: var(--text2);
  padding: 8px 0;
  text-align: center;
}

/* ===== Big Buttons ===== */
.big-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--blue);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
.big-btn:hover { background: #2d333b; border-color: var(--blue); }
.big-btn:active { background: #363d45; }
.big-btn.muha-btn { color: var(--purple); }
.big-btn.muha-btn:hover { border-color: var(--purple); }

/* ===== Deploys ===== */
.deploys {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.deploys-title {
  font-size: 0.7rem;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-bottom: 6px;
}
.deploy-item {
  font-size: 0.78rem;
  color: var(--text);
  padding: 2px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.deploy-dot { color: var(--green); font-size: 0.6rem; }

/* ===== Error Toast ===== */
.error-toast {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 16px;
  right: 16px;
  background: rgba(248,81,73,0.15);
  border: 1px solid rgba(248,81,73,0.4);
  border-radius: var(--radius-sm);
  color: var(--red);
  font-size: 0.82rem;
  padding: 12px 16px;
  backdrop-filter: blur(8px);
  z-index: 200;
  animation: slideUp 0.25s ease;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Utilities ===== */
.hidden { display: none !important; }

/* ===== Safe areas ===== */
.main    { padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
.top-bar { padding-top: calc(12px + env(safe-area-inset-top)); }

/* ===== Large screens ===== */
@media (min-width: 480px) {
  .main { padding: 16px 16px calc(48px + env(safe-area-inset-bottom)); }
  .summary-grid { gap: 10px; }
  .summary-card .card-value { font-size: 2rem; }
  .vps-grid { display: grid; grid-template-columns: repeat(2, 1fr); }
}

/* Explicit Net Monitor modes. Phone keeps the current narrow overview; desktop
   deliberately becomes wide/dense even when opened from a phone. */
body.net-view-phone .main {
  max-width: 640px;
}
body.net-view-phone .vps-grid,
body.net-view-phone .router-list,
body.net-view-phone .gpu-list {
  display: flex;
  flex-direction: column;
}
body.net-view-desktop {
  overflow-x: auto;
}
body.net-view-desktop .main {
  max-width: 1180px;
}
body.net-view-desktop #section-net {
  gap: 14px;
}
body.net-view-desktop #net-summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
body.net-view-desktop #net-vps-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
body.net-view-desktop #net-router-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 10px;
}
body.net-view-desktop #net-gpu-tile .gpu-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
body.net-view-desktop #net-deploys {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
}

@media (max-width: 760px) {
  body.net-view-desktop .main {
    width: 1120px;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
  }
  body.net-view-desktop .top-bar,
  body.net-view-desktop .tab-bar {
    width: 1120px;
  }
  .net-view-switch {
    flex-wrap: wrap;
  }
  .net-view-hint {
    width: 100%;
    margin-left: 0;
  }
}

/* ── Logout link (session auth) ── */
.logout-link {
  font-size: 0.8rem;
  color: var(--text2);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s, background 0.15s;
}
.logout-link:hover, .logout-link:active { color: var(--text); background: var(--bg3); }

/* ===== Forced permanent-password modal ===== */
.pw-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-top: calc(20px + env(safe-area-inset-top));
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  background: rgba(1, 4, 9, 0.82);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  overflow-y: auto;
  -webkit-tap-highlight-color: transparent;
}
.pw-modal.hidden { display: none; }
.pw-modal-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 22px 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
.pw-modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin-bottom: 10px;
}
.pw-modal-hint {
  font-size: 0.9rem;
  color: var(--text2);
  text-align: center;
  line-height: 1.45;
  margin-bottom: 20px;
}
.pw-modal-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text2);
  margin: 14px 0 6px;
}
.pw-modal-input {
  width: 100%;
  font-size: 1.05rem;
  padding: 14px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
}
.pw-modal-input:focus { outline: none; border-color: var(--blue); }
.pw-modal-error {
  margin-top: 14px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  background: rgba(248, 81, 73, 0.12);
  border: 1px solid rgba(248, 81, 73, 0.4);
  color: var(--red);
  font-size: 0.86rem;
  text-align: center;
}
.pw-modal-error.hidden { display: none; }
.pw-modal-btn {
  width: 100%;
  margin-top: 22px;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 15px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--blue);
  color: #04121f;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pw-modal-btn:active { opacity: 0.85; }
.pw-modal-btn:disabled { opacity: 0.55; cursor: default; }
.pw-modal-min {
  margin-top: 14px;
  font-size: 0.76rem;
  color: var(--text2);
  text-align: center;
}

/* ===== Tab Bar ===== */
.tab-bar {
  position: sticky;
  top: calc(52px + env(safe-area-inset-top));  /* below .top-bar */
  z-index: 90;
  display: flex;
  background: rgba(13, 17, 23, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0;
}
.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 8px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text2);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  position: relative;
  min-height: 48px;  /* big tap target */
}
.tab-btn:hover   { color: var(--text); background: rgba(255,255,255,0.04); }
.tab-btn.active  { color: var(--blue); border-bottom-color: var(--blue); }
.tab-icon  { font-size: 1.05rem; line-height: 1; flex-shrink: 0; }
.tab-label { font-weight: 600; }

/* Status badge mirrored inside the tab (small dot) */
.tab-badge {
  position: absolute;
  top: 8px;
  right: 14px;
  min-width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
}
.tab-badge.ok     { background: var(--green); }
.tab-badge.warn   { background: var(--yellow); }
.tab-badge.error  { background: var(--red); }
.tab-badge.hidden { display: none; }
