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

:root {
  --bg:          #0a0e27;
  --surface:     #141b36;
  --surface2:    #1e2847;
  --border:      #2c3e6f;
  --text:        #e8eaf6;
  --muted:       #9fa8da;
  --green:       #00e676;
  --green-dim:   #004d25;
  --red:         #ef4444;
  --red-dim:     #7f1d1d;
  --orange:      #f97316;
  --orange-dim:  #7c2d12;
  --blue:        #6366f1;
  --blue-dim:    #1e1b4b;
  --yellow:      #fbbf24;
  --yellow-dim:  #713f12;
  --purple:      #a855f7;
  --purple-dim:  #4c1d95;
  --accent:      #00e676;
  --accent-hover:#00c853;
  --radius:      8px;
  --font:        'Outfit', 'DM Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Layout ─────────────────────────────────────────────── */
.app { display: flex; flex-direction: column; min-height: 100vh; max-width: 1200px; margin: 0 auto; padding: 0 16px 40px; }

/* ── Header ─────────────────────────────────────────────── */
header { display: flex; align-items: center; justify-content: space-between; padding: 20px 0 16px; border-bottom: 1px solid var(--border); }
.header-left { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 28px; }
h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.subtitle { font-size: 12px; color: var(--muted); }
.header-right { display: flex; align-items: center; gap: 8px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); transition: background 0.3s; }
.status-dot.running { background: var(--green); box-shadow: 0 0 8px var(--green); animation: pulse 1.2s infinite; }
.status-dot.done { background: var(--green); }
.status-dot.error { background: var(--red); }
.status-text { font-size: 13px; color: var(--muted); }
@keyframes pulse { 0%,100% { opacity:1 } 50% { opacity:0.4 } }

/* ── Tabs ───────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; padding: 12px 0 0; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab { background: none; border: none; color: var(--muted); padding: 8px 16px; cursor: pointer; font-size: 14px; border-radius: var(--radius) var(--radius) 0 0; transition: color 0.2s, background 0.2s; position: relative; bottom: -1px; border-bottom: 2px solid transparent; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Cards ──────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; font-weight: 600; font-size: 14px; }

/* ── Controls ───────────────────────────────────────────── */
.controls-card { }
.controls-row { display: flex; flex-wrap: wrap; gap: 20px; margin-bottom: 16px; }
.control-group { display: flex; flex-direction: column; gap: 6px; }
.control-group > label { font-size: 12px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.toggle-row { display: flex; gap: 12px; flex-wrap: wrap; }
.toggle { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; }
.toggle input { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; }
.hint { font-size: 11px; color: var(--muted); }

/* ── Buttons ────────────────────────────────────────────── */
.btn-row { display: flex; gap: 10px; align-items: center; }
.btn { padding: 9px 20px; border-radius: 6px; border: none; cursor: pointer; font-family: var(--font); font-size: 14px; font-weight: 600; transition: opacity 0.15s, transform 0.1s; }
.btn:hover:not(:disabled) { opacity: 0.9; transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-primary { background: var(--accent);  color: #0a0e27; }
.btn-deep    { background: var(--orange);  color: #fff; }
.btn-danger  { background: var(--red);     color: #fff; }
.btn-sm      { padding: 5px 12px; font-size: 12px; background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-sm:hover{ border-color: var(--accent); }

/* ── Inputs ─────────────────────────────────────────────── */
.input-sm    { width: 90px; background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; color: var(--text); padding: 6px 10px; font-size: 13px; }
.input-search{ flex: 1; min-width: 200px; background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; color: var(--text); padding: 7px 12px; font-size: 13px; }
.select-sm   { background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; color: var(--text); padding: 6px 10px; font-size: 13px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ── Progress ───────────────────────────────────────────── */
.progress-card {}
.progress-header { display: flex; justify-content: space-between; margin-bottom: 10px; font-weight: 600; }
.progress-bar-wrap { background: var(--surface2); border-radius: 99px; height: 10px; overflow: hidden; margin-bottom: 12px; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--blue)); border-radius: 99px; transition: width 0.4s ease; }
.progress-stats { display: flex; gap: 24px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.progress-stats strong { color: var(--text); }

/* ── Scan mode hint ─────────────────────────────────────── */
.scan-mode-row { margin-bottom: 12px; }
.scan-mode-explain { font-size: 12px; color: var(--muted); line-height: 1.6; }
.scan-mode-explain strong { color: var(--text); }

/* ── Stat cards ─────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; text-align: center; }
.stat-card.online   { border-color: var(--green-dim); }
.stat-card.offline  { border-color: var(--red-dim); }
.stat-card.skipped  { border-color: var(--orange-dim); }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; margin-bottom: 4px; }
.stat-card.online   .stat-value { color: var(--green); }
.stat-card.offline  .stat-value { color: var(--red); }
.stat-card.skipped  .stat-value { color: var(--orange); }
.stat-label { font-size: 12px; color: var(--muted); }

/* ── Live feed ──────────────────────────────────────────── */
.feed-filters { display: flex; gap: 6px; }
.chip { background: var(--surface2); border: 1px solid var(--border); border-radius: 99px; padding: 3px 12px; font-size: 12px; color: var(--muted); cursor: pointer; transition: all 0.15s; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.feed { max-height: 360px; overflow-y: auto; }
.feed-empty { color: var(--muted); font-size: 13px; padding: 20px; text-align: center; }
.feed-row { display: flex; align-items: baseline; gap: 8px; padding: 5px 4px; border-bottom: 1px solid var(--border); font-size: 12px; font-family: monospace; animation: fadeIn 0.2s; }
.feed-row:last-child { border-bottom: none; }
.feed-row.online  .feed-name { color: var(--text); }
.feed-row.offline .feed-name { color: var(--muted); }
.feed-icon { font-size: 12px; width: 16px; flex-shrink: 0; }
.feed-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-country { color: var(--muted); width: 80px; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-error { color: var(--red); font-size: 11px; flex-shrink: 0; }
.feed-time { color: var(--muted); font-size: 11px; flex-shrink: 0; }
@keyframes fadeIn { from { opacity:0; transform: translateY(-4px); } to { opacity:1; transform: none; } }

/* ── Station table ──────────────────────────────────────── */
.search-row { display: flex; gap: 8px; align-items: center; }
.table-wrap { overflow-x: auto; }
.station-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.station-table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.station-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.station-table tr:last-child td { border-bottom: none; }
.station-table tr:hover td { background: var(--surface2); }
.status-pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.status-pill.online    { background: #14532d;             color: var(--green);  }
.status-pill.transient { background: var(--yellow-dim);   color: var(--yellow); }
.status-pill.dead      { background: var(--orange-dim);   color: var(--orange); }
.status-pill.unscanned { background: var(--surface2);     color: var(--muted);  }

.btn-quick-scan {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-quick-scan:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-quick-scan:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Feed error colour by category */
.feed-error.err-ssl     { color: var(--purple); }
.feed-error.err-content { color: var(--yellow); }
.feed-error.err-http    { color: var(--orange); }
.feed-error.err-net     { color: var(--red);    }
.empty-row { color: var(--muted); text-align: center; padding: 32px; }
.badge { background: var(--surface2); border: 1px solid var(--border); border-radius: 99px; padding: 1px 8px; font-size: 11px; color: var(--muted); font-weight: normal; margin-left: 6px; }

/* ── Logs ───────────────────────────────────────────────── */
.log-card { }
.log-actions { display: flex; align-items: center; gap: 10px; }
.log-output { background: #0a0c14; border: 1px solid var(--border); border-radius: 6px; padding: 14px; font-size: 12px; font-family: 'Fira Mono', 'Cascadia Code', monospace; max-height: 560px; overflow-y: auto; line-height: 1.6; white-space: pre-wrap; word-break: break-all; color: #c9d1d9; }
.log-empty { color: var(--muted); font-style: italic; }
.log-line-err  { color: #f87171; }
.log-line-ok   { color: #4ade80; }
.log-line-warn { color: #facc15; }
.log-line-info { color: #93c5fd; }

/* ── Settings ───────────────────────────────────────────── */
h2 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.hint-text { font-size: 12px; color: var(--muted); margin-bottom: 16px; }
.hint-text code { background: var(--surface2); padding: 1px 5px; border-radius: 3px; font-family: monospace; }
.settings-form { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: flex; align-items: center; gap: 10px; }
.form-row > label { width: 160px; flex-shrink: 0; font-size: 13px; color: var(--muted); }
.form-row input { flex: 1; background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; color: var(--text); padding: 7px 12px; font-size: 13px; }
.save-msg { font-size: 13px; color: var(--green); }

/* ── Report tab ─────────────────────────────────────────── */
.report-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.report-updated { font-size: 12px; color: var(--muted); flex: 1; }
.report-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.report-summary {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.rstat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; text-align: center; }
.rstat-card.active   { border-color: var(--green-dim); }
.rstat-card.inactive { border-color: var(--yellow-dim); }
.rstat-card.dead     { border-color: var(--orange-dim); }
.rstat-card.avail    { border-color: var(--blue-dim); }
.rstat-value { font-size: 26px; font-weight: 700; line-height: 1; margin-bottom: 4px; }
.rstat-card.active   .rstat-value { color: var(--green); }
.rstat-card.inactive .rstat-value { color: var(--yellow); }
.rstat-card.dead     .rstat-value { color: var(--orange); }
.rstat-card.avail    .rstat-value { color: var(--blue); }
.rstat-label { font-size: 11px; color: var(--muted); }

.report-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }

.breakdown-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.breakdown-table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; padding: 6px 10px; border-bottom: 1px solid var(--border); }
.breakdown-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.breakdown-table tr:last-child td { border-bottom: none; }
.breakdown-table tr:hover td { background: var(--surface2); }

@media (max-width: 900px) {
  .report-summary { grid-template-columns: repeat(3, 1fr); }
  .report-two-col { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .report-summary { grid-template-columns: repeat(2, 1fr); }
}

/* ── Commands ───────────────────────────────────────────── */
.cmd-list { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; }
.cmd-item { display: flex; align-items: center; gap: 16px; padding: 10px 12px; border-radius: 6px; }
.cmd-item:hover { background: var(--surface2); }
.cmd-item code { font-family: monospace; font-size: 13px; color: var(--accent); flex-shrink: 0; }
.cmd-item span  { font-size: 13px; color: var(--muted); }

/* ── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

@media (max-width: 700px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .controls-row { gap: 12px; }
  .form-row { flex-direction: column; align-items: flex-start; }
  .form-row > label { width: auto; }
}

/* ── User 360 Modal & Components ────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  border-radius: var(--radius) var(--radius) 0 0;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

.user-avatar-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, #34A853 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
  font-weight: 700;
  font-size: 16px;
  overflow: hidden;
  flex-shrink: 0;
}

.user-avatar-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.badge-google {
  background: rgba(66, 133, 244, 0.15);
  color: #4285F4;
  border: 1px solid rgba(66, 133, 244, 0.4);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.badge-anon {
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
}

