:root {
  color-scheme: light;
  --ink: #07131f;
  --muted: #667381;
  --line: #dfe5e8;
  --paper: #f4f6f5;
  --panel: #ffffff;
  --navy: #07131f;
  --mint: #38e0ad;
  --mint-dark: #087a5b;
  --amber: #ffb24a;
  --blue: #3978ff;
  --danger: #b33a3a;
  --shadow: 0 18px 55px rgba(7, 19, 31, 0.08);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); }
button, input, select { font: inherit; }
button, select { cursor: pointer; }

.eyebrow {
  margin: 0 0 7px;
  color: var(--mint-dark);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .16em;
}

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 230px;
  display: flex;
  flex-direction: column;
  padding: 28px 20px;
  color: white;
  background:
    radial-gradient(circle at 30% 12%, rgba(56,224,173,.18), transparent 26%),
    var(--navy);
  z-index: 5;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 36px; }
.sidebar-brand strong { display: block; letter-spacing: .18em; }
.sidebar-brand span { display: block; margin-top: 3px; color: #8fa1ad; font-size: 9px; letter-spacing: .15em; }
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: var(--navy);
  background: var(--mint);
  font-family: Georgia, serif;
  font-size: 24px;
  font-weight: 800;
  box-shadow: 0 9px 28px rgba(56,224,173,.2);
}
.brand-mark svg { width: 23px; height: 23px; fill: currentColor; }
.sidebar nav { display: grid; gap: 8px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  color: #aebbc4;
  border-radius: 12px;
  text-decoration: none;
  font-size: 14px;
}
.nav-item span { width: 18px; color: var(--mint); font-size: 18px; text-align: center; }
.nav-item:hover, .nav-item.active { color: white; background: rgba(255,255,255,.08); }
.sidebar-foot { margin-top: auto; display: grid; gap: 16px; padding: 20px 10px 4px; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-foot a { color: #8798a3; font-size: 12px; text-decoration: none; }
.sync-dot { display: flex; align-items: center; gap: 8px; color: #b8c5cc; font-size: 11px; }
.sync-dot i { width: 8px; height: 8px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 5px rgba(56,224,173,.12); }

.content { margin-left: 230px; padding: 34px 42px 24px; max-width: 1720px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.topbar h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(31px, 3vw, 47px); font-weight: 500; letter-spacing: -.035em; }
.freshness { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.freshness span { width: 9px; height: 9px; border-radius: 50%; background: var(--mint); }

.control-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 15px 17px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.78);
  box-shadow: 0 10px 35px rgba(7,19,31,.04);
  backdrop-filter: blur(14px);
}
.store-filter { display: flex; flex-wrap: wrap; gap: 7px; }
.store-chip { padding: 9px 12px; border: 1px solid var(--line); border-radius: 11px; color: var(--muted); background: white; font-size: 12px; font-weight: 700; }
.store-chip[aria-pressed="true"] { color: var(--navy); border-color: var(--mint); background: rgba(56,224,173,.15); }
.date-controls { display: flex; align-items: end; gap: 8px; }
.date-controls label { display: grid; gap: 4px; color: var(--muted); font-size: 10px; }
.date-controls input, .date-controls select, .date-controls button, #preset {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--ink);
  padding: 0 10px;
  font-size: 12px;
}
.primary-button { border-color: var(--navy) !important; color: white !important; background: var(--navy) !important; font-weight: 800; }
.ghost-button { padding: 9px 13px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: white; font-size: 12px; font-weight: 700; }
.primary-button:hover, .ghost-button:hover { transform: translateY(-1px); }

.status-banner { margin: 16px 0; padding: 12px 15px; border: 1px solid #f0d193; border-radius: 12px; color: #7c5513; background: #fff9e9; font-size: 12px; }
.sync-alert { margin: 0 0 18px; padding: 14px 17px; border: 1px solid #efaaaa; border-radius: 13px; color: #8e2020; background: #fff0f0; box-shadow: 0 9px 26px rgba(179,58,58,.08); font-size: 12px; font-weight: 750; line-height: 1.5; }
.sync-alert::before { content: "!"; display: inline-grid; width: 20px; height: 20px; margin-right: 9px; place-items: center; border-radius: 50%; color: white; background: var(--danger); font-size: 11px; font-weight: 900; }
.section-block { margin-top: 31px; }
.section-head, .panel-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.section-head { margin-bottom: 14px; }
.section-head h2, .panel-head h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 24px; font-weight: 500; letter-spacing: -.02em; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 12px; }
.metric-card {
  position: relative;
  min-height: 150px;
  padding: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--panel);
  box-shadow: 0 9px 28px rgba(7,19,31,.04);
}
.metric-card::after { content: ""; position: absolute; right: -30px; bottom: -45px; width: 100px; height: 100px; border: 17px solid rgba(56,224,173,.08); border-radius: 50%; }
.metric-card.featured { color: white; border-color: var(--navy); background: var(--navy); }
.metric-card.featured::after { border-color: rgba(56,224,173,.18); }
.metric-label { min-height: 32px; color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .03em; }
.featured .metric-label { color: #a6b6c0; }
.metric-value { position: relative; z-index: 1; margin: 12px 0 9px; font-family: Georgia, serif; font-size: clamp(24px, 2.25vw, 36px); line-height: 1; letter-spacing: -.035em; }
.metric-note { position: relative; z-index: 1; color: #84919a; font-size: 10px; line-height: 1.4; }
.metric-note strong.good { color: var(--mint-dark); }
.metric-note strong.bad { color: #c24c4c; }
.featured .metric-note strong { color: var(--mint); }
.featured .metric-note strong.bad { color: #ff9c9c; }

.chart-grid { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(290px, .75fr); gap: 14px; margin-top: 14px; }
.overview-grid { grid-template-columns: 1fr; }
.wide-panel { min-width: 0; }
.lower-grid { grid-template-columns: minmax(0, 1.45fr) minmax(320px, .7fr); }
.panel { padding: 21px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); box-shadow: var(--shadow); }
.panel-head { margin-bottom: 18px; }
.legend { display: flex; gap: 15px; color: var(--muted); font-size: 11px; }
.legend span::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 6px; border-radius: 50%; }
.legend .seo::before { background: var(--mint); }
.legend .ai::before { background: var(--blue); }
.chart-wrap { position: relative; width: 100%; height: 290px; }
.chart-wrap canvas { width: 100%; height: 100%; }
.rank-list { display: grid; gap: 13px; }
.rank-item { display: grid; gap: 7px; }
.rank-title { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 11px; }
.rank-title strong { color: var(--ink); font-size: 12px; }
.rank-bar { height: 7px; overflow: hidden; border-radius: 999px; background: #edf1f2; }
.rank-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--mint-dark), var(--mint)); }

.table-wrap { overflow: auto; }
.tall-table { max-height: 520px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { position: sticky; top: 0; z-index: 2; padding: 0 11px 11px; color: #7b8790; background: var(--panel); font-size: 10px; text-align: right; text-transform: uppercase; letter-spacing: .06em; }
th:first-child, td:first-child { text-align: left; }
td { padding: 13px 11px; border-top: 1px solid #edf0f2; text-align: right; white-space: nowrap; }
td:first-child { font-weight: 800; }
.text-cell { text-align: left; }
.wrap-cell { min-width: 210px; white-space: normal; line-height: 1.35; }
.url-cell { max-width: 360px; overflow: hidden; text-overflow: ellipsis; }
.empty-cell { padding: 34px 12px; color: var(--muted); text-align: center !important; font-weight: 500 !important; }
.section-note, .data-note { margin: 0; color: var(--muted); font-size: 10px; }
.definition-note { margin: 10px 3px 0; color: #7d8992; font-size: 10px; line-height: 1.5; }
.source-badge, .type-chip { display: inline-flex; align-items: center; justify-content: center; min-width: 39px; padding: 4px 8px; border-radius: 999px; font-size: 9px; font-weight: 850; letter-spacing: .05em; }
.source-badge.seo { color: #086449; background: #dff9ef; }
.source-badge.ai { color: #2455c6; background: #e5edff; }
.type-chip { min-width: 0; color: #55636d; background: #eef2f2; letter-spacing: 0; }
.quality-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.quality-item { padding: 16px; border-radius: 14px; background: #f3f6f5; }
.quality-item span { display: block; color: var(--muted); font-size: 10px; }
.quality-item strong { display: block; margin-top: 7px; font-family: Georgia, serif; font-size: 25px; font-weight: 500; }
.quality-item small { display: block; margin-top: 8px; color: #84919a; font-size: 9px; line-height: 1.4; }
.metric-pair small { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }
.change-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 52px; padding: 3px 6px; border-radius: 999px; font-size: 9px; font-style: normal; font-weight: 800; }
.change-badge.good { color: #087a5b; background: #dff9ef; }
.change-badge.bad { color: #b33a3a; background: #ffebeb; }
.change-badge.neutral { color: #75828b; background: #eef2f2; }
.comparison-stack { display: grid; gap: 4px; min-width: 108px; }
.comparison-stack > span { display: flex; align-items: center; justify-content: space-between; gap: 7px; }
.comparison-stack i { color: var(--muted); font-size: 8px; font-style: normal; font-weight: 700; }
.value-with-change { display: grid; justify-items: end; gap: 4px; }

footer { display: flex; justify-content: space-between; gap: 16px; padding: 24px 2px 6px; color: #82909a; font-size: 10px; }
.skeleton { position: relative; overflow: hidden; color: transparent !important; background: #eef2f1; border-radius: 6px; }
.skeleton::before { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.75), transparent); animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }

.login-page { min-height: 100vh; background: #eef2f1; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 28px; }
.login-card { width: min(100%, 560px); padding: clamp(36px, 7vw, 72px); border: 1px solid var(--line); border-radius: 24px; background: #f9faf9; box-shadow: var(--shadow); }
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 48px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .14em; }
.login-card h2 { margin: 7px 0 10px; font-family: Georgia, serif; font-size: 35px; font-weight: 500; }
.login-card > p:not(.eyebrow) { color: var(--muted); }
.login-card form { display: grid; gap: 10px; margin-top: 28px; }
.login-card label { color: var(--ink); font-size: 12px; font-weight: 800; }
.login-card input { height: 52px; padding: 0 15px; border: 1px solid #cfd7da; border-radius: 12px; background: white; }
.login-card input:focus { outline: 3px solid rgba(56,224,173,.24); border-color: var(--mint-dark); }
.login-card button { height: 52px; margin-top: 5px; border: 0; border-radius: 12px; color: white; background: var(--navy); font-weight: 800; }
.login-card button span { margin-left: 8px; color: var(--mint); }
.form-error { margin: 0; color: var(--danger) !important; font-size: 12px; }
.session-note { margin-top: 22px; font-size: 10px; }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .control-panel { align-items: stretch; flex-direction: column; }
  .date-controls { flex-wrap: wrap; }
}
@media (max-width: 820px) {
  .sidebar { position: static; width: 100%; min-height: auto; padding: 16px 18px; flex-direction: row; align-items: center; justify-content: space-between; }
  .sidebar-brand { padding: 0; }
  .sidebar nav { display: none; }
  .sidebar-foot { margin: 0; padding: 0; border: 0; }
  .sync-dot { display: none; }
  .content { margin-left: 0; padding: 23px 18px; }
  .chart-grid, .lower-grid { grid-template-columns: 1fr; }
  .login-shell { padding: 18px; }
  .login-card { padding: 42px 28px; }
}
@media (max-width: 620px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .metric-card { min-height: 138px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .date-controls label { flex: 1 1 42%; }
  .date-controls input { width: 100%; }
  #preset { flex: 1 1 100%; }
  footer { flex-direction: column; }
}
