:root {
  --color-primary: #1e40af;
  --color-primary-strong: #17358f;
  --color-accent: #b45309;
  --color-bg: #f8fafc;
  --color-card: #ffffff;
  --color-text: #172554;
  --color-muted: #475569;
  --color-border: #dbeafe;
  --color-success: #047857;
  --color-warning: #b45309;
  --color-danger: #b91c1c;
  --shadow: 0 8px 22px rgba(30, 64, 175, 0.08);
  --radius: 12px;
  font-family: "Fira Sans", "Avenir Next", "Noto Sans SC", system-ui, sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
a:focus-visible { outline: 3px solid #93c5fd; outline-offset: 3px; }
.sidebar-foot a { color: #bfdbfe; }
body { margin: 0; min-width: 320px; background: var(--color-bg); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }
.skip-link { position: fixed; z-index: 10; top: 8px; left: 8px; padding: 9px 12px; color: #fff; background: var(--color-primary); border-radius: 8px; transform: translateY(-160%); transition: transform .2s ease; }
.skip-link:focus { transform: translateY(0); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { display: flex; flex-direction: column; gap: 28px; padding: 24px 16px; color: #dbeafe; background: #102766; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .01em; color: #fff; }
.brand-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 1px solid #93c5fd; border-radius: 8px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: rgba(59,130,246,.18); }
.nav-list { display: grid; gap: 4px; }
.nav-item { width: 100%; min-height: 44px; border: 0; border-radius: 8px; padding: 11px 12px; color: #cbd5e1; text-align: left; background: transparent; transition: background .2s ease, color .2s ease; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.10); }
.nav-item.is-active { color: #fff; background: #1e40af; box-shadow: inset 3px 0 0 #fbbf24; }
.sidebar-foot { margin-top: auto; font-size: 12px; line-height: 1.5; color: #bfdbfe; }
.sidebar-foot p { margin: 10px 2px 0; }
.local-badge { display: inline-block; padding: 3px 7px; border: 1px solid rgba(191,219,254,.45); border-radius: 999px; }

.main-content { min-width: 0; padding: 32px clamp(20px, 4vw, 56px) 48px; }
.topbar { display: flex; justify-content: space-between; gap: 24px; align-items: center; padding-bottom: 26px; border-bottom: 1px solid var(--color-border); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(28px, 3vw, 36px); letter-spacing: -.035em; }
h2 { margin-bottom: 6px; font-size: 22px; letter-spacing: -.02em; }
h3 { margin-bottom: 14px; font-size: 16px; }
.eyebrow { margin-bottom: 6px; color: var(--color-primary); font-size: 12px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.topbar-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.button { min-height: 44px; padding: 9px 14px; border-radius: 8px; border: 1px solid transparent; font-weight: 650; transition: transform .2s ease, background .2s ease, border-color .2s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .6; transform: none; }
.button-primary { color: #fff; background: var(--color-primary); }
.button-primary:hover { background: var(--color-primary-strong); }
.button-secondary { color: var(--color-primary); background: #fff; border-color: #bfdbfe; }
.button-secondary:hover { background: #eff6ff; }
.text-button { padding: 4px 0; border: 0; color: var(--color-primary); font-weight: 650; background: transparent; }

.view { padding-top: 26px; }
.notice { margin-top: 20px; padding: 13px 15px; border-radius: 8px; color: #7c2d12; border: 1px solid #fdba74; background: #fff7ed; }
.notice.is-error { color: #991b1b; border-color: #fca5a5; background: #fef2f2; }
.notice.is-success { color: #065f46; border-color: #6ee7b7; background: #ecfdf5; }
.source-panel { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 18px; padding: 16px 18px; border: 1px solid #fcd34d; border-left: 4px solid var(--color-accent); border-radius: var(--radius); background: #fffbeb; }
.source-panel p { margin: 2px 0 0; color: #713f12; line-height: 1.5; }
.source-panel strong { color: #78350f; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.metric { min-height: 118px; padding: 18px; border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-card); box-shadow: var(--shadow); }
.metric-label { margin-bottom: 10px; color: var(--color-muted); font-size: 13px; }
.metric-value { font-family: "Fira Code", ui-monospace, monospace; font-size: 27px; font-weight: 700; letter-spacing: -.06em; }
.metric-sub { margin: 9px 0 0; color: var(--color-muted); font-size: 12px; line-height: 1.35; }
.panel-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, .8fr); gap: 16px; }
.panel { padding: 20px; border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-card); box-shadow: var(--shadow); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.panel-heading h2, .panel-heading h3 { margin-bottom: 0; }
.section-heading { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 18px; }
.section-heading > div > p:last-child { max-width: 720px; margin-bottom: 0; color: var(--color-muted); line-height: 1.55; }
.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 620px; border-collapse: collapse; font-size: 13px; }
th { padding: 0 10px 10px; color: var(--color-muted); font-size: 11px; letter-spacing: .06em; text-align: left; text-transform: uppercase; }
td { padding: 12px 10px; border-top: 1px solid #e8effc; vertical-align: middle; }
.product-name { font-weight: 650; }
.muted { color: var(--color-muted); }
.mono { font-family: "Fira Code", ui-monospace, monospace; font-size: 12px; }
.compact-button { min-height: 32px; padding: 5px 9px; font-size: 12px; }
.status-chip { display: inline-flex; align-items: center; min-height: 28px; max-width: 260px; padding: 5px 9px; border-radius: 999px; font-size: 12px; font-weight: 650; }
.status-muted { color: #334155; background: #e2e8f0; }
.status-ready, .status-completed { color: #065f46; background: #d1fae5; }
.status-warning, .status-needs_configuration, .status-no_products { color: #92400e; background: #fef3c7; }
.status-error, .status-failed { color: #991b1b; background: #fee2e2; }
.change-list { display: grid; gap: 1px; }
.change-item { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 13px 0; border-bottom: 1px solid #e8effc; }
.change-item:last-child { border-bottom: 0; }
.change-title { margin-bottom: 4px; font-size: 13px; font-weight: 650; }
.change-detail { color: var(--color-muted); font-size: 12px; line-height: 1.45; }
.rank-chart-panel { margin-bottom: 18px; padding: 18px; border: 1px solid #bfdbfe; border-radius: 10px; background: #f8fbff; }
.chart-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.chart-heading h3 { margin-bottom: 5px; }
.chart-heading p:not(.eyebrow) { margin: 0; color: var(--color-muted); font-size: 13px; line-height: 1.5; }
.chart-note { flex: 0 0 auto; padding: 5px 9px; border: 1px solid #bfdbfe; border-radius: 999px; color: #1e3a8a; font-size: 12px; font-weight: 650; background: #eff6ff; }
.rank-chart-wrap { overflow-x: auto; margin-top: 14px; }
.rank-chart { display: block; width: 100%; min-width: 600px; height: auto; }
.rank-chart-grid { stroke: #dbeafe; stroke-width: 1; }
.rank-chart-axis-line { stroke: #94a3b8; stroke-width: 1; }
.rank-chart-axis { fill: #475569; font-family: "Fira Code", ui-monospace, monospace; font-size: 11px; }
.rank-chart-line { fill: none; stroke: #2563eb; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.rank-chart-point { fill: #fff; stroke: #1d4ed8; stroke-width: 2.5; }
.rank-chart-point:hover { fill: #f59e0b; stroke: #92400e; }
.chart-a11y-note, .chart-empty { margin: 10px 0 0; color: var(--color-muted); font-size: 12px; line-height: 1.5; }
.empty-state { padding: 30px 12px; color: var(--color-muted); text-align: center; }
.form-panel { margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: 1.1fr 1.25fr .85fr auto; gap: 12px; align-items: end; }
label { display: grid; gap: 7px; color: #334155; font-size: 13px; font-weight: 650; }
input, select { width: 100%; min-height: 44px; padding: 8px 10px; color: var(--color-text); border: 1px solid #bfdbfe; border-radius: 8px; background: #fff; }
input::placeholder { color: #94a3b8; }
.form-submit { white-space: nowrap; }
.settings-grid { display: grid; grid-template-columns: minmax(320px, 1fr) minmax(300px, .85fr); gap: 16px; }
.settings-form { display: grid; gap: 16px; max-width: 440px; }
.switch-row { display: flex; align-items: flex-start; gap: 10px; }
.switch-row input { width: 18px; min-height: 18px; margin-top: 2px; accent-color: var(--color-primary); }
.switch-row small { display: block; margin-top: 3px; color: var(--color-muted); font-weight: 400; line-height: 1.45; }
.provider-detail { display: grid; gap: 10px; padding: 15px; border-radius: 8px; background: #f8fafc; }
.provider-detail p { margin: 0; color: var(--color-muted); line-height: 1.5; }
.muted-copy { margin: 16px 0 0; color: var(--color-muted); font-size: 13px; line-height: 1.6; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 2; flex-direction: row; align-items: center; gap: 16px; padding: 12px 18px; }
  .nav-list { display: flex; gap: 4px; overflow-x: auto; }
  .nav-item { width: auto; white-space: nowrap; }
  .sidebar-foot { display: none; }
  .panel-grid, .settings-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .main-content { padding: 22px 16px 36px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar-actions { width: 100%; justify-content: space-between; }
  .form-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: 1fr; }
  .sidebar { align-items: flex-start; flex-direction: column; }
  .brand { padding-left: 4px; }
  .nav-list { width: 100%; }
  .chart-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; } }
