/* ============ GSC Reporter design system ============ */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eaf1ff;
  --good: #15803d; --good-soft: #dcfce7;
  --bad: #b91c1c;  --bad-soft: #fee2e2;
  --warn: #92400e; --warn-soft: #fef3c7;
  --info: #1e40af; --info-soft: #dbeafe;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .04);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  /* legacy names still used in a few places */
  --text-primary: var(--text); --text-secondary: var(--text-2); --accent-light: var(--accent-soft);
  --bg-top: var(--surface-2); --row-alt: var(--surface-2);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg); min-height: 100vh; }
a { color: var(--accent); }
code { background: var(--surface-2); border: 1px solid var(--border); padding: 0 4px; border-radius: 4px; font-size: 12px; }

/* ---------- app bar ---------- */
.appbar { position: sticky; top: 0; z-index: 50; background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.appbar-inner { max-width: 1320px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 28px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: var(--text); text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: #fff; font-weight: 800;
  background: linear-gradient(135deg, #2563eb, #7c3aed); }
.topnav { display: flex; gap: 4px; }
.topnav a { color: var(--text-2); text-decoration: none; font-weight: 600; padding: 7px 12px; border-radius: 8px; }
.topnav a:hover { background: var(--surface-2); color: var(--text); }
.topnav a.active { background: var(--accent-soft); color: var(--accent); }
.appbar-user { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* ---------- layout ---------- */
.app-shell { max-width: 1320px; margin: 20px auto; padding: 0 20px 48px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 18px; }
.panel-head { margin-bottom: 14px; }
.panel-head h2 { margin: 0; font-size: 18px; display: inline-flex; align-items: center; gap: 6px; }
.panel-head p { margin: 2px 0 0; color: var(--text-2); }
.subcard { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 14px; background: var(--surface); }
.subcard h3 { margin: 0 0 10px; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.section-title { margin: 22px 0 8px; font-size: 15px; display: inline-flex; align-items: center; gap: 6px; }
.muted { color: var(--text-2); font-size: 13px; }
.tiny { font-size: 11px; line-height: 1.2; }

/* ---------- controls ---------- */
.controls { padding-bottom: 14px; }
.control-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 14px 22px; }
.control > label { display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--text-2); margin-bottom: 5px; }
.inline { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.inline select { min-width: 0; flex: 1 1 160px; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 16px; margin-top: 14px; padding: 12px 14px; background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }
.filters .control select, .filters .control input { width: 100%; }
.action-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.field-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.field-row > label { color: var(--text-2); font-weight: 500; display: inline-flex; align-items: center; gap: 3px; }
.toolbar { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; margin-top: 4px; }
label.check { display: inline-flex; align-items: center; gap: 5px; color: var(--text); font-weight: 500; cursor: pointer; }
.w-num { width: 64px; }
.status-line { font-size: 13px; color: var(--text-2); margin: 8px 0 10px; min-height: 18px; }

input[type="text"], input[type="password"], input[type="email"], input[type="date"], select, textarea {
  font: inherit; font-size: 14px; padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: #fff; color: var(--text); transition: border-color .15s, box-shadow .15s; }
textarea { width: 100%; resize: vertical; font-size: 13px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
input[type="file"] { font-size: 13px; max-width: 240px; }

/* ---------- buttons ---------- */
button, .btn { font: inherit; font-weight: 600; font-size: 14px; padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; background: var(--accent); color: #fff; transition: background .15s, border-color .15s, color .15s; white-space: nowrap; }
button:hover, .btn:hover { background: var(--accent-hover); }
button:disabled { opacity: .55; cursor: progress; }
button.secondary { background: #fff; color: var(--accent); border-color: #c7d7fb; }
button.secondary:hover { background: var(--accent-soft); }
button.ghost, a.ghost { background: transparent; color: var(--text-2); border-color: transparent; font-weight: 600; text-decoration: none; padding: 6px 10px; border-radius: var(--radius-sm); font-size: 13px; }
button.ghost:hover, a.ghost:hover { background: var(--surface-2); color: var(--text); }
button.small, a.small { padding: 5px 10px; font-size: 13px; }
button.danger { background: var(--bad-soft); color: var(--bad); }
button.danger:hover { background: #fecaca; }
.danger-text { color: var(--bad) !important; }
.link-btn { background: none; border: none; color: var(--accent); font-weight: 600; padding: 4px; cursor: pointer; text-decoration: none; }
.link-btn:hover { background: none; text-decoration: underline; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: -4px 0 18px; flex-wrap: wrap; }
.tabs.grouped { gap: 18px; padding-bottom: 0; }
.tab-group { display: flex; align-items: flex-end; gap: 2px; position: relative; padding-top: 16px; }
.tab-group-label { position: absolute; top: 0; left: 10px; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.tab-btn { background: transparent; color: var(--text-2); border: none; border-radius: 0; padding: 9px 12px; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab-btn:hover { background: transparent; color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; animation: fade .15s ease; }
.tab-panel.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }

/* ---------- tables ---------- */
.table-scroll { max-height: 520px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }
.table-scroll.short { max-height: 320px; }
.table-scroll:has(table:empty) { display: none; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
thead th { position: sticky; top: 0; z-index: 1; background: #f1f5f9; color: var(--text-2); text-align: left; font-weight: 600; font-size: 12px;
  padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody td { padding: 7px 10px; border-bottom: 1px solid #eef2f7; vertical-align: top; }
tbody tr:hover td { background: #f8fbff; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
tr.clickable { cursor: pointer; }
caption { font-size: 12px; }
.pivot td, .pivot th { white-space: nowrap; }
.pivot td:first-child, .pivot th:first-child { position: sticky; left: 0; background: #fff; z-index: 1; }
.pivot th:first-child { background: #f1f5f9; z-index: 2; }
.cell-up { background: #e9f9ef; color: var(--good); }
.cell-down { background: #fdecec; color: var(--bad); }
.cell-base { box-shadow: inset 0 0 0 2px #93c5fd; }
tr.row-base td { background: #f0f6ff; }

/* row highlights (existing tabs) */
.row-High td { background: #ffe4e6; } .row-Medium td { background: #fff7d6; } .row-Low td { background: #e7f8ec; }
.row-unreliable td { background: #fef3c7; } .row-error td { background: #fee2e2; } .row-na td { background: #f1f5f9; color: var(--text-2); }
.row-notindexed td { background: #ffe4e6; } .row-excluded td { color: var(--text-3); }
.row-Up td { background: #ecfdf3; } .row-Down td { background: #fef2f2; } .row-New td { background: #eff6ff; } .row-Lost td { background: #fde8e8; }
.row-sev-High td { background: #ffe4e6; }

/* ---------- stats, pills, badges ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 6px 0 12px; }
.stat-row:empty { display: none; }
.stat { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--surface); }
.stat .k { font-size: 12px; color: var(--text-2); font-weight: 500; }
.stat .v { font-size: 22px; font-weight: 700; margin-top: 2px; letter-spacing: -.01em; }
.stat .d { font-size: 12px; font-weight: 600; }
.up { color: var(--good); } .down { color: var(--bad); } .flat { color: var(--text-2); }
.v.up { color: var(--good); } .v.down { color: var(--bad); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.pill.ok { background: var(--good-soft); color: var(--good); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; color: var(--text-2); }
.badge:not(:empty) { background: var(--surface-2); border: 1px solid var(--border); padding: 2px 9px; border-radius: 999px; }
.badge.ok { background: var(--good-soft); color: var(--good); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

/* ---------- progress, charts, detail ---------- */
.progress { height: 6px; background: var(--accent-soft); border-radius: 999px; overflow: hidden; margin: 4px 0 8px; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, #2563eb, #7c3aed); transition: width .3s ease; }
.chart-box { position: relative; height: 300px; margin: 8px 0 14px; }
.detail { border: 1px solid #c7d7fb; background: #fbfdff; border-radius: var(--radius-sm); padding: 12px 14px; margin-top: 14px; }
.detail-head { display: flex; justify-content: space-between; align-items: center; }
.detail-head h3 { margin: 0; font-size: 15px; }

/* ---------- info "i" popovers ---------- */
.help-i { display: inline-grid; place-items: center; width: 17px; height: 17px; padding: 0; margin-left: 4px; border-radius: 50%;
  border: 1px solid var(--border-strong); background: #fff; color: var(--text-3); font: italic 700 11px/1 Georgia, serif;
  cursor: help; vertical-align: middle; text-transform: none; letter-spacing: 0; flex: none; }
.help-i:hover, .help-i.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.help-anchor { display: inline-flex; margin-right: 6px; }
.help-pop { position: absolute; z-index: 1000; display: none; background: #0f172a; color: #e2e8f0; border-radius: 10px; padding: 12px 14px 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .28); font-size: 13px; line-height: 1.5; }
.help-pop .help-title { font-weight: 700; color: #fff; margin: 0 18px 4px 0; }
.help-pop .help-out { margin-top: 8px; padding-top: 8px; border-top: 1px solid #334155; color: #bfdbfe; }
.help-pop b { color: #fff; }
.help-pop code { background: #1e293b; border-color: #334155; color: #e2e8f0; }
.help-close { position: absolute; top: 6px; right: 8px; background: none; border: none; color: #94a3b8; font-size: 18px; padding: 0 4px; line-height: 1; }
.help-close:hover { background: none; color: #fff; }

/* ---------- settings ---------- */
.settings-grid { display: grid; grid-template-columns: 190px 1fr; gap: 10px 14px; align-items: center; max-width: 760px; }
.settings-grid > label { font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.settings-grid input[type="text"], .settings-grid input[type="email"], .settings-grid input[type="password"], .settings-grid select { width: 100%; }
.hint { font-size: 12px; color: var(--text-2); grid-column: 2; margin-top: -6px; }
.panel { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px 18px; margin-bottom: 14px; background: #fff; }
.panel h2 { margin: 0 0 12px; font-size: 16px; display: flex; align-items: center; gap: 4px; }
.share-box { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.share-box input { flex: 1; min-width: 260px; }

/* ---------- login ---------- */
.login-shell { max-width: 380px; margin: 14vh auto; padding: 0 16px; }
.login-shell .card { padding: 32px; }
.login-shell h1 { font-size: 20px; margin: 0 0 20px; text-align: center; }
.login-shell input { width: 100%; margin-bottom: 12px; }
.login-shell button { width: 100%; }
.error-text { color: var(--bad); font-size: 13px; margin: 8px 0; }

/* ---------- old header (share page) ---------- */
.header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .split, .two-col { grid-template-columns: 1fr; }
  .appbar-inner { gap: 12px; flex-wrap: wrap; }
  .appbar-user { margin-left: 0; }
}
@media (max-width: 640px) {
  .app-shell { padding: 0 12px 40px; margin-top: 12px; }
  .card { padding: 16px; }
  .settings-grid { grid-template-columns: 1fr; }
  .hint { grid-column: 1; }
  .tabs.grouped { gap: 6px; }
  .topnav a { padding: 6px 8px; }
}
