:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #17212b;
  --muted: #687482;
  --line: #dce2e7;
  --google: #2675e8;
  --google-soft: #e9f2ff;
  --yandex: #ef4438;
  --yandex-soft: #fff0ee;
  --local: #0b7d62;
  --radius: 14px;
  --shadow: 0 7px 24px rgba(25, 37, 49, 0.06);
  --content: 1440px;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; color: var(--ink); background: var(--bg); font: 16px/1.45 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(38, 117, 232, .25); outline-offset: 2px; }
.shell { width: min(100% - 24px, var(--content)); margin-inline: auto; padding-block: 24px 48px; min-width: 0; }
.topbar { display: grid; gap: 16px; align-items: end; margin-bottom: 20px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: clamp(28px, 4.2vw, 48px); line-height: 1.03; letter-spacing: -.04em; }
h2 { margin-bottom: 0; font-size: clamp(19px, 2.2vw, 25px); line-height: 1.15; letter-spacing: -.02em; }
.subtitle, .result-count { color: var(--muted); margin-bottom: 0; }
.eyebrow { margin-bottom: 7px; color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .1em; }
.source-note { display: flex; flex-wrap: wrap; gap: 8px; color: var(--muted); }
.source-note span { padding: 8px 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.header-controls { display: grid; gap: 8px; min-width: 0; }
.refresh-button { min-height: 44px; padding: 0 16px; border: 1px solid #175ab2; border-radius: 9px; color: #fff; background: var(--google); font-weight: 800; }
.refresh-button:hover { background: #175fbe; }
.refresh-button:disabled { cursor: wait; opacity: .62; }
.refresh-details { max-width: 430px; color: var(--muted); font-size: 12px; text-align: left; overflow-wrap: anywhere; }
.period-control, .direction-scope { display: grid; gap: 5px; min-width: 0; color: var(--muted); font-size: 12px; font-weight: 700; }
.period-control select, .direction-scope select { min-height: 44px; padding-inline: 12px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: var(--surface); font-size: 16px; }
.sync-badge { display: inline-flex; align-items: center; width: fit-content; min-height: 32px; padding-inline: 11px; border: 1px solid #e8c982; border-radius: 999px; color: #805d0b; background: #fff9e9; font-size: 12px; font-weight: 800; }
.tabs { display: flex; gap: 5px; width: max-content; max-width: 100%; padding: 4px; margin-bottom: 14px; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.tab { display: inline-flex; gap: 7px; align-items: center; min-height: 44px; padding: 0 18px; border: 0; border-radius: 9px; color: var(--muted); background: transparent; font-weight: 700; white-space: nowrap; }
.tab.is-active { color: var(--ink); background: #edf0f3; }
.tab.is-unavailable { color: #9b6f0c; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.dot-google { background: var(--google); }
.dot-yandex { background: var(--yandex); }
.summary-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 14px; }
.metric-card, .panel { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.metric-card { padding: 17px; }
.metric-card p { margin-bottom: 9px; color: var(--muted); }
.metric-card strong { display: block; font-size: clamp(30px, 4vw, 44px); line-height: 1; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.metric-card span { display: block; margin-top: 9px; color: var(--muted); }
.metric-local { border-color: #b8ddd3; background: #f3fbf8; }
.metric-local strong { color: var(--local); }
.metric-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.info { width: 44px; height: 44px; border: 1px solid #abd5ca; border-radius: 50%; color: var(--local); background: white; font-weight: 800; }
.chart-panel, .table-panel, .method-card, .local-card, .regional-panel { padding: 18px; }
.directions-panel { padding: 18px; margin-bottom: 14px; }
.direction-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr)); gap: 10px; }
.direction-grid > * { min-width: 0; }
.direction-card { min-height: 132px; padding: 15px; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: #fbfcfd; text-align: left; }
.direction-card:hover { border-color: #aeb9c3; background: #f7f9fb; }
.direction-card.is-active { border-color: var(--google); box-shadow: 0 0 0 2px rgba(38, 117, 232, .13); }
.direction-card strong { display: block; margin-bottom: 10px; font-size: 16px; }
.direction-demand { display: block; margin-bottom: 8px; font-size: 22px; font-weight: 850; letter-spacing: -.03em; }
.direction-demand small { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0; }
.direction-systems { display: grid; gap: 3px; color: var(--muted); font-size: 12px; }
.period-notice { min-height: 18px; margin: 12px 0 0; color: #805d0b; font-size: 13px; }
.section-heading { display: flex; flex-direction: column; gap: 12px; margin-bottom: 22px; }
.section-heading > * { min-width: 0; }
.directions-panel .direction-scope select { width: 100%; max-width: 100%; }
.legend { display: flex; gap: 18px; color: var(--muted); }
.legend span { display: inline-flex; gap: 7px; align-items: center; }
.chart-scroll, .table-scroll { overflow-x: auto; overscroll-behavior-inline: contain; }
.chart { min-width: 760px; height: 320px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart-grid { stroke: #edf0f3; stroke-width: 1; }
.chart-axis { fill: var(--muted); font-size: 12px; font-weight: 700; }
.chart-value { fill: var(--ink); font-size: 12px; font-weight: 800; text-anchor: middle; pointer-events: none; }
.bar { cursor: pointer; transition: opacity .15s ease; }
.bar:hover { opacity: .78; }
.bar-google { fill: var(--google); }
.bar-yandex { fill: var(--yandex); }
.chart-hint { margin: 13px 0 0; color: var(--muted); font-size: 13px; }
.method-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin-block: 14px; }
.method-card p:last-child, .local-card p:last-child { margin: 14px 0 0; color: var(--muted); }
.method-card .fine-print { padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; }
.local-card { border-color: #b8ddd3; }
.regional-panel { margin-bottom: 14px; }
.regional-heading { align-items: stretch; }
.regional-scope { min-width: 0; }
.regional-note { max-width: 82ch; margin: 0 0 16px; color: var(--muted); }
.regional-table { min-width: 980px; }
.regional-table td:first-child { max-width: none; font-weight: 400; }
.regional-table td:nth-child(2) { font-weight: 650; }
.regional-empty { color: var(--muted); text-align: center; }
.regional-footnote { margin: 14px 0 0; color: var(--muted); font-size: 13px; }
.table-title { margin-bottom: 18px; }
.quick-filter-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 8px; }
.quick-filter-grid > * { min-width: 0; }
.quick-filter-group { min-width: 0; padding: 0; border: 0; }
.quick-filter-group legend, .sort-control > span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12px; font-weight: 800; }
.segmented { display: flex; min-width: 0; padding: 3px; overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: #f3f5f7; overscroll-behavior-inline: contain; }
.segmented button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: max-content; min-height: 44px; padding-inline: 8px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; font-size: 14px; font-weight: 750; white-space: nowrap; }
.segmented button.is-active { color: var(--ink); background: var(--surface); box-shadow: 0 1px 4px rgba(25, 37, 49, .1); }
.sort-control { display: grid; min-width: 0; }
.sort-control select { width: 100%; min-width: 0; min-height: 50px; padding-inline: 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--surface); font-size: 16px; }
.demand-definition { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.wordstat-summary { display: grid; gap: 10px; margin: 0 0 18px; padding: 14px; border: 1px solid #b8ddd3; border-radius: 11px; background: #f3fbf8; }
.wordstat-summary > div { min-width: 0; }
.wordstat-summary strong, .wordstat-summary span { display: block; }
.wordstat-summary strong { color: var(--local); }
.wordstat-summary span { margin-top: 3px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.filters { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 18px; }
.filters label { display: grid; gap: 5px; min-width: 0; color: var(--muted); font-size: 12px; font-weight: 700; }
.filters input, .filters select { width: 100%; min-width: 0; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: white; }
.secondary-button { min-height: 44px; padding-inline: 15px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: white; font-weight: 700; }
table { width: 100%; min-width: 1320px; border-collapse: collapse; }
th, td { padding: 12px 10px; border-bottom: 1px solid #e8ecef; text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 12px; letter-spacing: .03em; text-transform: uppercase; }
th button { display: inline-flex; align-items: center; min-height: 44px; padding: 0; border: 0; color: inherit; background: transparent; font-weight: 800; text-transform: inherit; }
td { font-variant-numeric: tabular-nums; }
td:first-child { max-width: 420px; font-weight: 650; }
.numeric { text-align: right; }
.demand-link { display: inline-flex; align-items: center; justify-content: flex-end; min-width: 44px; min-height: 44px; color: #175ab2; font-weight: 800; text-underline-offset: 3px; }
.demand-link-local { color: var(--local); }
.demand-missing { display: inline-block; max-width: 92px; color: var(--muted); font-size: 12px; line-height: 1.2; text-align: right; }
.system-badge, .intent-badge { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.system-google { color: #175ab2; background: var(--google-soft); }
.system-yandex { color: #b52a22; background: var(--yandex-soft); }
.intent-local { color: var(--local); background: #e8f6f2; }
.intent-commercial { color: #805d0b; background: #fff4d7; }
.intent-informational { color: #175ab2; background: var(--google-soft); }
.intent-navigational { color: #6d42a8; background: #f1eaff; }
.intent-uncertain { color: #8a4f15; background: #fff0df; }
.intent-general { color: var(--muted); background: #eef1f3; }
.intent-stack { display: flex; flex-wrap: wrap; gap: 5px; }
.page-type { display: inline-flex; align-items: center; min-height: 28px; padding-inline: 9px; border-radius: 999px; color: var(--muted); background: #eef1f3; font-size: 12px; font-weight: 800; white-space: nowrap; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 16px; color: var(--muted); }
.pagination button:disabled { opacity: .45; cursor: default; }
footer { display: grid; gap: 4px; padding: 18px 2px 0; color: var(--muted); font-size: 12px; }
footer p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (min-width: 640px) {
  .shell { width: min(100% - 40px, var(--content)); padding-top: 34px; }
  .topbar { grid-template-columns: 1fr auto; }
  .header-controls { justify-items: end; }
  .refresh-details { text-align: right; }
  .period-control { width: 190px; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-heading { flex-direction: row; align-items: flex-end; justify-content: space-between; }
  .regional-heading { align-items: flex-end; }
  .regional-scope { flex: 0 1 580px; }
  .directions-panel .section-heading > div { flex: 1 1 auto; }
  .directions-panel .direction-scope { flex: 0 1 340px; max-width: 100%; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; }
  .search-field { grid-column: span 2; }
  .quick-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wordstat-summary { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
}

@media (min-width: 980px) {
  .summary-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .method-grid { grid-template-columns: 1fr 1fr; }
  .chart-panel, .table-panel, .regional-panel { padding: 24px; }
  .directions-panel { padding: 24px; }
  .filters { grid-template-columns: minmax(220px, 2fr) repeat(4, minmax(120px, 1fr)) auto; }
  .search-field { grid-column: auto; }
  .quick-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

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