@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600&family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg-dark: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.7);
  --bg-card-border: rgba(255, 255, 255, 0.08);
  --accent-cyan: #06b6d4;
  --accent-indigo: #6366f1;
  --accent-purple: #8b5cf6;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Fira Code', monospace;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --glass-bg: rgba(15, 23, 42, 0.85);
  --glass-blur: blur(12px);
}

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

body {
  background: var(--bg-dark);
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(6, 182, 212, 0.12) 0px, transparent 50%);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  line-height: 1.5;
  padding-bottom: 60px;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Header */
header {
  border-bottom: 1px solid var(--bg-card-border);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 16px 0;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.header-content > *,
.settings-card > *,
.cam-card,
.cam-title-group,
.url-box,
.url-input,
.tab-content {
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-indigo));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 20px;
  color: #fff;
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

.brand-text h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-text p {
  font-size: 12px;
  color: var(--text-muted);
}

.ip-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.badge {
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid var(--bg-card-border);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

.badge-val {
  font-family: var(--font-mono);
  color: var(--accent-cyan);
  font-weight: 500;
}

/* Action Buttons */
.btn {
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-purple));
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
  background: rgba(51, 65, 85, 0.8);
  border: 1px solid var(--bg-card-border);
  color: var(--text-main);
  box-shadow: none;
}

.btn-secondary:hover {
  background: rgba(71, 85, 105, 0.9);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-success {
  background: linear-gradient(135deg, #059669, #10b981);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-danger {
  background: linear-gradient(135deg, #e11d48, #f43f5e);
  box-shadow: 0 4px 12px rgba(244, 63, 94, 0.3);
}

/* Sections */
.section-header {
  margin: 32px 0 16px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-title {
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.notice {
  margin-top: 24px;
  padding: 14px 18px;
  color: #cbd5e1;
  background: rgba(14, 116, 144, 0.14);
  border: 1px solid rgba(34, 211, 238, 0.22);
  border-radius: var(--radius-md);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.settings-card {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  margin-top: 18px;
  padding: 18px 20px;
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
}
.service-switches { display: flex; gap: 24px; flex-wrap: wrap; }
.public-card, .noalbs-settings { margin-top: 12px; padding: 18px 20px; background: rgba(14,116,144,.10); border: 1px solid rgba(34,211,238,.22); border-radius: var(--radius-lg); }
.public-card { display:flex; justify-content:space-between; gap:24px; align-items:center; }
.public-card p { color:var(--text-muted); font-size:12px; max-width:820px; margin-top:5px; }
.forwarding-list { font-family:var(--font-mono); color:var(--accent-cyan); font-size:12px; white-space:nowrap; }
.public-host-control { min-width:310px; }
.public-host-control label { display:block; color:var(--text-muted); font-size:11px; margin-bottom:5px; }
.port-pool-card { margin-top:12px; padding:18px 20px; display:flex; align-items:center; justify-content:space-between; gap:24px; background:rgba(99,102,241,.10); border:1px solid rgba(99,102,241,.28); border-radius:var(--radius-lg); }
.port-pool-card p { color:var(--text-muted); font-size:12px; margin-top:5px; }
.pool-meter { min-width:210px; text-align:right; }
.pool-track { height:8px; margin-top:8px; overflow:hidden; background:#090d16; border-radius:999px; }
.pool-track span { display:block; width:0; height:100%; background:linear-gradient(90deg,var(--accent-cyan),var(--accent-indigo)); transition:width .2s ease; }
.noalbs-settings { display:grid; grid-template-columns: 1.4fr 1.4fr .7fr 1.4fr; gap:12px; align-items:end; }
.noalbs-settings .form-group { margin:0; }
.noalbs-settings .noalbs-wide { grid-column:span 2; }
.noalbs-settings small { display:block; color:var(--text-muted); font-size:10px; margin-top:4px; }
.noalbs-options { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px 14px; padding:10px 12px; border:1px solid rgba(148,163,184,.18); border-radius:8px; }
.noalbs-options label { color:var(--text-muted); font-size:11px; display:flex; align-items:center; gap:7px; }
.form-control.compact { width:auto; min-width:140px; padding:6px 10px; }
.logs-block { min-height:340px; max-height:620px; overflow:auto; }
.source-bridges { margin-top:32px; }
.bridge-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:18px; margin-top:14px; }
.bridge-card { padding:20px; background:var(--bg-card); border:1px solid var(--bg-card-border); border-radius:var(--radius-lg); }
.bridge-card h3 { margin-top:12px; }
.bridge-card p, .bridge-note { color:var(--text-muted); font-size:12px; margin:7px 0 14px; }
.bridge-note { padding:10px 14px; border-left:3px solid var(--accent-amber); background:rgba(245,158,11,.08); }
.setup-modal { max-width:760px; }
.setup-progress { display:flex; gap:8px; margin-bottom:18px; }
.setup-progress span { flex:1; padding:7px 10px; text-align:center; font-size:11px; color:var(--text-muted); background:#0f172a; border-radius:999px; }
.setup-progress span.active { color:#fff; background:var(--accent-indigo); }
.setup-step { padding:14px; margin-bottom:12px; background:rgba(15,23,42,.65); border:1px solid var(--bg-card-border); border-radius:var(--radius-md); }
.setup-step h3 { font-size:14px; margin-bottom:4px; }
.setup-step p { color:var(--text-muted); font-size:12px; margin-bottom:8px; }
.noalbs-editor { margin-top:12px; padding:18px 20px; background:var(--bg-card); border:1px solid var(--bg-card-border); border-radius:var(--radius-lg); }
.noalbs-editor p, .editor-status { color:var(--text-muted); font-size:12px; margin-top:4px; }
.editor-actions { display:flex; flex-wrap:wrap; gap:8px; }
.json-editor { width:100%; min-height:420px; resize:vertical; background:#090d16; color:#c4f1f9; border:1px solid var(--bg-card-border); border-radius:var(--radius-md); padding:16px; font:12px/1.55 var(--font-mono); outline:none; tab-size:2; }
.json-editor:focus { border-color:var(--accent-cyan); }
.editor-status.error { color:var(--accent-rose); }

.developer-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-top: 12px;
  padding: 18px 20px;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-lg);
}

.developer-card p {
  max-width: 780px;
  margin-top: 5px;
  color: var(--text-muted);
  font-size: 12px;
}

.developer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.status-pill {
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.stable {
  color: #6ee7b7;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.eyebrow,
.settings-card small,
.cam-title-group small,
.status-row small {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
}

.switch-row,
.mini-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.switch-row input,
.mini-switch input {
  accent-color: var(--accent-indigo);
  width: 18px;
  height: 18px;
}

/* Camera Grid */
.camera-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(550px, 1fr));
  gap: 24px;
}

@media (max-width: 768px) {
  .camera-grid {
    grid-template-columns: 1fr;
  }
}

.cam-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-lg);
  transition: border-color 0.2s ease;
  position: relative;
}

.cam-card:hover {
  border-color: rgba(99, 102, 241, 0.4);
}

.cam-card.disabled {
  opacity: 0.58;
}

.cam-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--bg-card-border);
}

.cam-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cam-name {
  font-size: 18px;
  font-weight: 700;
}

.cam-type-badge {
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.cam-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.telemetry-panel {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.08), rgba(99, 102, 241, 0.08));
  border: 1px solid rgba(6, 182, 212, 0.22);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  padding: 14px;
}

.telemetry-heading { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:12px; font-size:13px; font-weight:700; text-transform:uppercase; letter-spacing:.04em; }
.telemetry-state { border-radius:999px; padding:3px 9px; font-size:11px; }
.telemetry-state.waiting { color:var(--text-muted); background:rgba(148,163,184,.12); }
.telemetry-state.online { color:#34d399; background:rgba(16,185,129,.14); }
.telemetry-state.ready { color:var(--accent-amber); background:rgba(245,158,11,.14); }
.telemetry-state.offline { color:#fb7185; background:rgba(244,63,94,.14); }
.telemetry-state.health-degraded { color:var(--accent-amber); background:rgba(245,158,11,.14); }
.telemetry-state.health-critical { color:#fb7185; background:rgba(244,63,94,.14); }
.telemetry-grid { display:grid; grid-template-columns:repeat(4, minmax(0, 1fr)); gap:8px; }
.telemetry-metric { min-width:0; background:rgba(15,23,42,.66); border:1px solid rgba(255,255,255,.05); border-radius:8px; padding:9px; }
.telemetry-metric span, .telemetry-metric small { display:block; color:var(--text-muted); font-size:10px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.telemetry-metric strong { display:block; color:var(--text-main); font-family:var(--font-mono); font-size:14px; margin:3px 0; }
.telemetry-empty { color:var(--text-muted); font-size:13px; padding:10px 2px; }
.telemetry-sparkline { width:100%; height:48px; margin-top:10px; background:rgba(15,23,42,.5); border-radius:8px; }
.telemetry-sparkline polyline { fill:none; stroke:var(--accent-cyan); stroke-width:2; vector-effect:non-scaling-stroke; }
.sparkline-placeholder { color:var(--text-muted); font-size:11px; margin-top:10px; }
.telemetry-formula { margin-top:10px; color:var(--text-muted); font-size:11px; }
.telemetry-formula summary { cursor:pointer; color:var(--accent-cyan); }
.telemetry-formula code { display:block; margin-top:8px; color:var(--text-main); white-space:normal; }
.telemetry-formula p { margin:6px 0 0; }

/* URL List */
.url-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.url-item {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  padding: 10px 14px;
}

.url-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
}

.url-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.url-input {
  background: transparent;
  border: none;
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  font-size: 13px;
  width: 100%;
  outline: none;
  text-overflow: ellipsis;
}

.btn-copy {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-copy:hover {
  background: var(--accent-indigo);
  color: #fff;
}

/* Container Control Card */
.control-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-top: 32px;
}

.tabs {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--bg-card-border);
  padding-bottom: 12px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 16px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

.tab-btn.active {
  background: rgba(99, 102, 241, 0.2);
  color: var(--accent-indigo);
}

.code-block {
  background: #090d16;
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: #e2e8f0;
  overflow-x: auto;
  white-space: pre-wrap;
  position: relative;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--text-muted);
  font-size: 13px;
}

.toolbar.actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.status-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--bg-card-border);
}

.warning { color: var(--accent-amber); }

/* Modal */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: #1e293b;
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  background: #0f172a;
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-main);
  font-size: 14px;
  outline: none;
  font-family: inherit;
}

.form-control:focus {
  border-color: var(--accent-cyan);
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--accent-indigo);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-weight: 500;
  font-size: 14px;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 2000;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.error { background: var(--accent-rose); }

[hidden] { display: none !important; }

@media (max-width: 700px) {
  .container { padding: 0 14px; }
  .settings-card, .developer-card, .public-card, .port-pool-card, .section-header, .cam-card-header, .toolbar { align-items: stretch; flex-direction: column; }
  .pool-meter { min-width:0; text-align:left; }
  .noalbs-settings { grid-template-columns:1fr; }
  .noalbs-settings .noalbs-wide { grid-column:auto; }
  .noalbs-options { grid-template-columns:1fr; }
  .bridge-grid { grid-template-columns:1fr; }
  .camera-grid { grid-template-columns: minmax(0, 1fr); }
  .cam-card { padding: 16px; }
  .cam-actions, .tabs { flex-wrap: wrap; }
  .url-box { align-items: stretch; flex-direction: column; }
  .url-input { min-height: 34px; }
  .form-row { flex-direction: column; gap: 0; }
  .telemetry-grid { grid-template-columns:repeat(2, minmax(0, 1fr)); }
}
