/* ============================================================
   GSC Plus Dashboard – stylesheet (matches websitereactor dark)
   ============================================================ */
:root {
  --bg-base:       #09090f;
  --bg-surface:    #0f1018;
  --bg-elevated:   #141520;
  --bg-card:       #161824;
  --border:        #1e2235;
  --border-accent: #2a3060;

  --text-primary:  #e8eaf0;
  --text-secondary:#a7afcc;   /* +5.1:1 on bg-base */
  --text-muted:    #7a83a3;   /* +4.5:1 on bg-base (was 5a6280, ~3:1 — failed AA) */

  --accent:        #4285f4;
  --accent-bright: #5b9af6;
  --accent-dim:    #1d3a6e;
  --accent-glow:   rgba(66,133,244,0.15);

  --green:         #34a853;
  --green-dim:     rgba(52,168,83,0.12);
  --red:           #ea4335;
  --red-dim:       rgba(234,67,53,0.12);
  --yellow:        #fbbc05;
  --yellow-dim:    rgba(251,188,5,0.12);

  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Courier New', monospace;

  --radius-sm:  4px;
  --radius:     8px;
  --radius-lg:  12px;

  --shadow-card: 0 1px 3px rgba(0,0,0,0.4), 0 0 0 1px var(--border);

  --nav-height: 60px;
  --content-max: 1500px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--accent-bright); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font: inherit; border: 0; }
input, textarea, select { font: inherit; }

/* Universal focus-visible ring (a11y; replaces removed default outlines) */
:focus { outline: 0; }
:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Reduced-motion respect */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}

/* Inline SVG icon system (Lucide-style, stroke 1.75, currentColor) */
.icon { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 22px; height: 22px; }

/* ── Login redirect ───────────────────────────────────────── */
.full-screen-msg {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  flex-direction: column; padding: 2rem; gap: 1rem;
}
.full-screen-msg p { color: var(--text-secondary); }

/* ── Top nav ─────────────────────────────────────────────── */
.site-nav {
  height: var(--nav-height); background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.nav-inner {
  max-width: var(--content-max); height: 100%; margin: 0 auto;
  padding: 0 1.5rem; display: flex; align-items: center; gap: 1.5rem;
}
.nav-brand { display: flex; align-items: center; gap: 0.5rem; color: var(--text-primary); font-weight: 700; }
.nav-brand-icon { width: 28px; height: 28px; background: var(--accent-glow); border: 1px solid var(--accent-dim); border-radius: var(--radius-sm); display: grid; place-items: center; color: var(--accent-bright); }
.nav-brand-text { letter-spacing: -0.01em; }
.nav-brand-badge { font-size: 0.625rem; font-weight: 600; background: var(--accent-dim); color: var(--accent-bright); padding: 2px 6px; border-radius: 3px; font-family: var(--font-mono); margin-left: 4px; }

.property-switcher {
  margin-left: 1rem; flex: 1; max-width: 480px;
}
.property-switcher select {
  width: 100%; background: var(--bg-elevated); border: 1px solid var(--border);
  color: var(--text-primary); padding: 6px 10px; border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: 0.85rem;
}
.property-switcher select:hover { border-color: var(--border-accent); }

.nav-right { display: flex; align-items: center; gap: 1rem; margin-left: auto; }
.nav-user { color: var(--text-secondary); font-size: 0.875rem; font-family: var(--font-mono); }

/* ── Layout ──────────────────────────────────────────────── */
.app-body { display: flex; max-width: var(--content-max); margin: 0 auto; min-height: calc(100vh - var(--nav-height)); }
.sidebar { width: 220px; padding: 1.5rem 0.75rem; border-right: 1px solid var(--border); flex-shrink: 0; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-link {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm); color: var(--text-secondary); font-size: 0.875rem;
  cursor: pointer; transition: background .15s ease-out, color .15s ease-out;
  min-height: 36px;
}
.sidebar-link:hover { background: var(--bg-elevated); color: var(--text-primary); text-decoration: none; }
.sidebar-link.active { background: var(--accent-glow); color: var(--accent-bright); box-shadow: inset 0 0 0 1px var(--accent-dim); }
.sidebar-link .icon { color: currentColor; opacity: 0.95; }

.main-content { flex: 1; padding: 1.5rem 2rem; min-width: 0; }

.page-header { margin-bottom: 1.5rem; }
.page-eyebrow { font-size: 0.75rem; color: var(--accent-bright); font-family: var(--font-mono); margin-bottom: 0.25rem; }
.page-title { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.page-sub { color: var(--text-secondary); font-size: 0.9rem; margin-top: 0.25rem; }

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; margin-bottom: 1rem;
}
.card-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; gap: 1rem; }
.card-title { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); }
.card-sub { font-size: 0.75rem; color: var(--text-muted); font-family: var(--font-mono); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.stat-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-family: var(--font-mono); }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-delta { font-size: 0.75rem; margin-top: 4px; font-family: var(--font-mono); }
.stat-delta.up { color: var(--green); }
.stat-delta.down { color: var(--red); }

/* ── Buttons ────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; padding: 0.5rem 0.9rem; border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 500; transition: background .15s ease-out, color .15s ease-out, border-color .15s ease-out, transform .08s ease-out; min-height: 36px; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled, .btn[aria-busy="true"] { opacity: 0.55; cursor: not-allowed; }
.btn[aria-busy="true"]::before { content: ''; display: inline-block; width: 12px; height: 12px; margin-right: 6px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--accent-bright); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { color: var(--text-primary); border-color: var(--border-accent); background: var(--bg-elevated); }
.btn-danger { background: var(--red); color: white; }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.78rem; min-height: 28px; }

/* ── Forms ──────────────────────────────────────────────── */
.form-row { display: flex; gap: 0.75rem; align-items: end; flex-wrap: wrap; margin-bottom: 1rem; }
.form-group { display: flex; flex-direction: column; gap: 0.3rem; }
.form-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-family: var(--font-mono); }
.form-input, .form-select, .form-textarea {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-primary); padding: 0.5rem 0.7rem; font-size: 0.85rem; min-width: 180px;
}
.form-textarea { width: 100%; min-height: 120px; font-family: var(--font-mono); }
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: 0; border-color: var(--accent); }

/* ── Tables ─────────────────────────────────────────────── */
.tbl-wrap { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.tbl { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.tbl th, .tbl td { padding: 0.6rem 0.85rem; text-align: left; border-bottom: 1px solid var(--border); }
.tbl th { background: var(--bg-elevated); color: var(--text-secondary); font-weight: 600; font-family: var(--font-mono); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; cursor: pointer; user-select: none; }
.tbl tr:hover td { background: var(--bg-elevated); }
.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.tbl td.url { word-break: break-all; max-width: 480px; font-family: var(--font-mono); font-size: 0.78rem; }
.tbl td.muted { color: var(--text-muted); }

.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 0.7rem; font-family: var(--font-mono); border: 1px solid; }
.pill-green  { background: var(--green-dim);  color: var(--green);  border-color: var(--green); }
.pill-red    { background: var(--red-dim);    color: var(--red);    border-color: var(--red); }
.pill-yellow { background: var(--yellow-dim); color: var(--yellow); border-color: var(--yellow); }
.pill-grey   { background: rgba(167,175,204,0.08); color: var(--text-secondary); border-color: var(--border-accent); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 99px; margin-right: 5px; vertical-align: middle; }
.dot-green { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot-red { background: var(--red); }
.dot-yellow { background: var(--yellow); }
.dot-grey { background: var(--text-muted); }

.pager { display: flex; gap: 0.5rem; align-items: center; padding: 0.75rem; justify-content: end; border-top: 1px solid var(--border); }

/* ── Chart wrappers (fixed height — prevents Chart.js + flex resize loop) ── */
.chart-wrap   { position: relative; width: 100%; height: 280px; }
.chart-wrap canvas { display: block !important; width: 100% !important; height: 100% !important; }
.chart-wrap.short { height: 200px; }
.chart-wrap.tall  { height: 360px; }

/* ── Toast ──────────────────────────────────────────────── */
#toast { position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 200; display: flex; flex-direction: column; gap: 0.5rem; max-width: 360px; }
.toast { background: var(--bg-elevated); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--radius); padding: 0.75rem 1rem; font-size: 0.85rem; box-shadow: var(--shadow-card); }
.toast.error { border-left-color: var(--red); }
.toast.ok    { border-left-color: var(--green); }

/* ── Misc ──────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }
.muted { color: var(--text-muted); }
.mono { font-family: var(--font-mono); font-size: 0.78rem; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } .sidebar { width: 60px; } .sidebar-label { display: none; } .property-switcher { max-width: 220px; } }

.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.5rem 1rem; font-size: 0.85rem; }
.kv dt { color: var(--text-muted); font-family: var(--font-mono); font-size: 0.78rem; }
.kv dd { color: var(--text-primary); word-break: break-all; }

pre.json { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.75rem; font-family: var(--font-mono); font-size: 0.75rem; max-height: 320px; overflow: auto; white-space: pre-wrap; word-break: break-all; }
