:root {
  --bg: #f3f6fa;
  --panel: #ffffff;
  --text: #172033;
  --muted: #68748a;
  --line: #dfe5ee;
  --brand: #2563eb;
  --brand-dark: #1749b5;
  --brand-soft: #eaf1ff;
  --green: #18a66b;
  --green-soft: #e8f8f1;
  --red: #db4455;
  --red-soft: #fff0f2;
  --amber: #d58a16;
  --amber-soft: #fff7e8;
  --yandex: #e53935;
  --google: #2563eb;
  --shadow: 0 14px 40px rgba(29, 45, 77, 0.08);
  --radius: 16px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 92% 0%, rgba(37, 99, 235, 0.08), transparent 28rem),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 32px;
  min-height: 68px;
  padding: 0 4vw;
  border-bottom: 1px solid rgba(223, 229, 238, 0.9);
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(16px);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); letter-spacing: .035em; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-flex;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  color: #fff;
  background: linear-gradient(145deg, #2f7bf1, #1749b5);
  box-shadow: 0 8px 18px rgba(37, 99, 235, .25);
  font-size: 13px;
  font-weight: 900;
}
.brand-mark-large { width: 54px; height: 54px; border-radius: 16px; font-size: 17px; }
.topnav { display: flex; gap: 22px; flex: 1; }
.topnav a { color: #48556d; font-weight: 600; }
.account { display: flex; align-items: center; gap: 14px; }
.account-email { color: var(--muted); font-size: 13px; }
.account-balance { display: grid; grid-template-columns: auto auto; column-gap: 10px; align-items: center; padding: 6px 12px; border: 1px solid #dbe5ce; border-radius: 6px; color: #58624d; background: linear-gradient(#fff, #f4f8ef); font-size: 11px; line-height: 1.15; }
.account-balance:hover { border-color: #aaca78; text-decoration: none; }
.account-balance strong { color: #79a92d; font-size: 17px; }
.account-balance small { grid-column: 2; color: #347cad; text-align: right; text-decoration: underline; }
.billing-card { max-width: 760px; margin: 0 auto; }
.billing-amount { margin: 12px 0 22px; color: #79a92d; font-size: 38px; font-weight: 800; }
.billing-note { padding: 14px 16px; border: 1px solid #dce6ef; border-radius: 8px; background: #f7fafc; color: var(--muted); }

.page-shell { width: min(1500px, 94vw); margin: 28px auto 64px; }
.auth-shell { display: grid; min-height: 100vh; width: 100%; margin: 0; place-items: center; padding: 24px; }

.auth-card {
  width: min(460px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.auth-brand { display: flex; align-items: center; gap: 16px; margin-bottom: 28px; }
.auth-brand h1 { margin: 0 0 3px; font-size: 27px; }
.auth-brand p { margin: 0; color: var(--muted); font-size: 14px; }
.auth-switch { margin: 20px 0 4px; text-align: center; color: var(--muted); }
.demo-link { display: block; margin-top: 16px; text-align: center; font-weight: 700; }

h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(28px, 3vw, 42px); line-height: 1.12; letter-spacing: -.03em; }
h2 { margin-bottom: 5px; font-size: 20px; letter-spacing: -.015em; }
h3 { font-size: 16px; }

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  padding: 34px 38px;
  margin-bottom: 24px;
  overflow: hidden;
  border-radius: 22px;
  color: #fff;
  background:
    linear-gradient(112deg, rgba(17, 65, 154, .98), rgba(37, 99, 235, .9)),
    #1d4ed8;
  box-shadow: 0 20px 50px rgba(29, 78, 216, .2);
}
.hero h1 { max-width: 790px; margin-bottom: 10px; }
.hero p { max-width: 780px; margin: 0; color: rgba(255,255,255,.82); }
.eyebrow { display: block; margin-bottom: 9px; color: #bcd4ff; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .13em; }
.hero-status { display: flex; min-width: 235px; align-items: center; gap: 12px; padding: 14px 16px; border: 1px solid rgba(255,255,255,.2); border-radius: 14px; background: rgba(255,255,255,.1); }
.hero-status b, .hero-status small { display: block; }
.hero-status small { color: rgba(255,255,255,.7); }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: #5ee2a8; box-shadow: 0 0 0 6px rgba(94,226,168,.14); }

.dashboard-grid, .content-grid, .forms-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, .85fr); gap: 22px; }
.forms-grid { grid-template-columns: 1fr 1fr; margin-top: 22px; }
.panel {
  min-width: 0;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 8px 28px rgba(25, 39, 68, .045);
}
.panel-large { min-width: 0; }
.compact-panel { padding: 16px 20px; }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.panel-header p { margin: 0; color: var(--muted); font-size: 13px; }
.counter { display: inline-flex; min-width: 34px; height: 34px; align-items: center; justify-content: center; border-radius: 10px; color: var(--brand); background: var(--brand-soft); font-weight: 800; }
.loading-block { color: var(--muted); }

.project-list { display: grid; gap: 12px; }
.project-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  background: #fbfcfe;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.project-card:hover { transform: translateY(-2px); border-color: #b8c9e9; box-shadow: 0 12px 30px rgba(31, 52, 87, .08); text-decoration: none; }
.project-card h3 { margin: 0 0 4px; font-size: 17px; }
.project-domain { color: var(--muted); font-size: 13px; }
.project-meta { display: flex; gap: 18px; color: var(--muted); font-size: 12px; }
.project-meta b { color: var(--text); font-size: 15px; }
.empty-state { padding: 30px; border: 1px dashed #cbd5e1; border-radius: 14px; text-align: center; color: var(--muted); }

.stack { display: grid; gap: 16px; }
label { display: grid; gap: 7px; color: #435069; font-size: 13px; font-weight: 700; }
label small { color: var(--muted); font-weight: 400; }
input, select, textarea {
  width: 100%;
  min-height: 43px;
  padding: 10px 12px;
  border: 1px solid #ccd5e2;
  border-radius: 10px;
  outline: none;
  color: var(--text);
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #6e9cf0; box-shadow: 0 0 0 3px rgba(37,99,235,.1); }

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 750;
  transition: transform .12s ease, background .15s ease, border-color .15s ease;
}
.button:hover { transform: translateY(-1px); text-decoration: none; }
.button:disabled { cursor: wait; opacity: .62; transform: none; }
.button-primary { color: #fff; background: var(--brand); box-shadow: 0 8px 16px rgba(37,99,235,.2); }
.button-primary:hover { background: var(--brand-dark); }
.button-secondary { color: var(--brand); border-color: #b9cdf1; background: var(--brand-soft); }
.button-ghost { color: #4c5870; border-color: var(--line); background: #fff; }
.button-small { min-height: 34px; padding: 6px 11px; font-size: 12px; }
.button-wide { width: 100%; }

.alert { padding: 12px 14px; margin-bottom: 16px; border-radius: 10px; font-size: 14px; }
.alert-error { color: #a32738; border: 1px solid #f4c4cb; background: var(--red-soft); }

.project-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.project-heading h1 { margin: 7px 0 3px; font-size: clamp(27px, 3vw, 38px); }
.back-link { color: var(--muted); font-size: 13px; }
.domain-line { margin: 0; color: var(--muted); font-size: 15px; }
.heading-actions { display: flex; gap: 10px; }

.filter-bar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.filter-label { margin-right: 10px; color: var(--muted); font-size: 13px; font-weight: 700; }
.segmented { display: inline-flex; padding: 4px; border: 1px solid var(--line); border-radius: 11px; background: #f7f9fc; }
.segmented button { padding: 7px 12px; border: 0; border-radius: 8px; color: #59667d; background: transparent; font-weight: 700; }
.segmented button.active { color: #fff; background: var(--brand); box-shadow: 0 5px 12px rgba(37,99,235,.18); }
.last-check { color: var(--muted); font-size: 13px; }

.project-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); align-items: start; gap: 22px; }
.project-main { min-width: 0; }
.competitors-panel { position: sticky; top: 84px; padding: 18px; }
.competitors-panel .panel-header { margin-bottom: 14px; }
.competitor-form { display: grid; gap: 7px; margin-bottom: 14px; }
.competitor-form-row { display: grid; grid-template-columns: minmax(0, 1fr) 38px; gap: 7px; }
.competitor-form-row .button { min-height: 38px; padding: 6px; font-size: 20px; }
.competitors-list { display: grid; gap: 7px; max-height: calc(100vh - 285px); overflow: auto; }
.competitor-item { display: grid; grid-template-columns: minmax(0, 1fr) 26px; align-items: center; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: 9px; background: #f8fafc; }
.competitor-item.selected { border-color: var(--brand); background: var(--brand-soft); }
.competitor-select { overflow: hidden; padding: 0; border: 0; color: var(--text); background: transparent; font-size: 12px; font-weight: 700; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.competitor-delete { width: 26px; height: 26px; padding: 0; border: 0; border-radius: 7px; color: #9b3a49; background: transparent; font-size: 18px; line-height: 1; }
.competitor-delete:hover { background: var(--red-soft); }
.competitor-position { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 8px; margin-top: 8px; border-radius: 8px; background: #f3f6fb; }
.competitor-position span { max-width: 150px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.competitor-position b { color: var(--brand-dark); font-size: 12px; }

.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.metric-card { padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: 0 6px 20px rgba(25,39,68,.035); }
.metric-card .metric-label { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; color: var(--muted); font-size: 12px; font-weight: 750; }
.metric-value { margin-bottom: 7px; font-size: 30px; font-weight: 850; letter-spacing: -.04em; }
.metric-sub { display: flex; gap: 11px; color: var(--muted); font-size: 12px; }
.metric-sub b { color: var(--text); }
.engine-badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.engine-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; }
.engine-yandex { color: #b62429; background: #fff0f1; }
.engine-yandex::before { background: var(--yandex); }
.engine-google { color: #174eaa; background: #eaf1ff; }
.engine-google::before { background: var(--google); }

.content-grid { margin-bottom: 22px; }
.check-progress-panel { display: grid; grid-template-columns: 190px minmax(180px, 280px) 42px; align-items: center; gap: 10px; width: min(100%, 560px); margin: 8px 0 12px auto; padding: 8px 11px; border-color: #c7d5e9; border-radius: 3px; background: #f7faff; box-shadow: none; }
.check-progress-panel[hidden] { display: none; }
.check-progress-copy { display: grid; gap: 1px; }
.check-progress-copy strong { color: #153d7a; font-size: 12px; }
.check-progress-copy span { color: var(--muted); font-size: 10px; }
.check-progress-meter { height: 7px; overflow: hidden; border: 1px solid #cbd8ea; border-radius: 2px; background: #e5ebf3; box-shadow: inset 0 1px 2px rgba(30, 60, 100, .08); }
.check-progress-meter > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #87bd24, #a8d63e); transition: width .3s ease; }
.check-progress-panel.is-running .check-progress-meter > span { background-image: linear-gradient(90deg, #78ad19 0%, #b5dc52 50%, #78ad19 100%); background-size: 200% 100%; animation: progress-shimmer 1.2s linear infinite; }
.check-progress-panel.is-failed { border-color: #efc7cd; background: #fff7f8; }
.check-progress-panel.is-failed .check-progress-copy strong,
.check-progress-panel.is-failed > b { color: #a62c3d; }
.check-progress-panel.is-failed .check-progress-meter > span { background: #d45b6b; }
.check-progress-panel > b { color: #315c13; font-size: 13px; text-align: right; }
@keyframes progress-shimmer { to { background-position: -200% 0; } }
@media (max-width: 760px) {
  .check-progress-panel { grid-template-columns: 1fr 42px; width: 100%; margin-left: 0; }
  .check-progress-copy { grid-column: 1 / -1; }
}

/* Project report follows the classic AllPositions layout: one working sidebar only. */
body[data-page="project"] { padding-left: 0; padding-bottom: 0; }
body[data-page="project"] .app-sidebar { display: none; }
body[data-page="project"] .topbar { left: 0; }
body[data-page="project"] .page-shell { width: min(100% - 28px, 1500px); max-width: 1500px; padding-right: 0; padding-left: 0; }

body[data-page="billing"] { padding-left: 0; }
.billing-card { max-width: 820px; margin: 30px auto; }
.billing-amount { margin: 18px 0; color: #5f981a; font-size: 36px; font-weight: 800; }
.billing-note { padding: 12px 14px; border-left: 4px solid #d7a928; background: #fff8dc; }
.billing-note.billing-ready { border-color: #78b82a; background: #f1f8e8; }
.topup-form { margin: 22px 0; padding: 18px; border: 1px solid #d9dde0; background: #f8f9f9; }
.topup-form label { display: block; margin-bottom: 7px; font-weight: 700; }
.topup-row { display: flex; gap: 8px; }
.topup-row input { width: 220px; }
.topup-form small, .form-status, .empty-note { color: #788397; }
.billing-history { margin-top: 25px; }
.billing-history table { width: 100%; border-collapse: collapse; }
.billing-history th, .billing-history td { padding: 10px; border-bottom: 1px solid #e1e6ec; text-align: left; }
.amount-positive { color: #268451; font-weight: 700; }

.keyword-entry-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: -5px; color: #66727c; font-size: 12px; }
.keyword-entry-tools b { flex: 0 0 auto; color: #347cad; }
.keyword-line-button { width: max-content; min-height: 32px; padding: 6px 12px; color: #347cad; border: 1px solid #b9c9d4; background: #f7fafc; }
.keyword-line-button:hover { background: #edf5fa; }
.segmented .engine-unavailable { opacity: .58; cursor: help; border-style: dashed; }
.segmented .engine-unavailable:hover { color: #6a7480; background: #f1f3f4; }
@media (max-width: 600px) {
  .keyword-entry-tools { align-items: flex-start; flex-direction: column; gap: 4px; }
}
.chart-box { min-height: 286px; overflow: hidden; border-radius: 12px; background: linear-gradient(180deg, #fbfdff, #f7f9fc); }
.chart-box svg { display: block; width: 100%; height: 286px; }
.chart-grid-line { stroke: #e6ebf2; stroke-width: 1; }
.chart-label { fill: #8390a4; font-size: 11px; }
.chart-line { fill: none; stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.chart-point { stroke: #fff; stroke-width: 2; }
.chart-line-yandex, .chart-point-yandex { stroke: var(--yandex); }
.chart-point-yandex { fill: var(--yandex); }
.chart-line-google, .chart-point-google { stroke: var(--google); }
.chart-point-google { fill: var(--google); }
.chart-legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 12px; }
.legend-item { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; }
.legend-yandex { background: var(--yandex); }
.legend-google { background: var(--google); }

.run-status { display: grid; gap: 10px; }
.run-status-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.run-progress { height: 7px; overflow: hidden; border-radius: 999px; background: #edf1f6; }
.run-progress > span { display: block; height: 100%; border-radius: inherit; background: var(--brand); }
.status-pill { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.status-completed { color: #13714c; background: var(--green-soft); }
.status-partial { color: #8a5a12; background: var(--amber-soft); }
.status-running, .status-pending { color: #1e56ae; background: var(--brand-soft); }
.status-failed { color: #a62c3d; background: var(--red-soft); }
.divider { height: 1px; margin: 20px 0; background: var(--line); }
.section-title { margin-bottom: 12px; }
.alerts-list { display: grid; gap: 10px; max-height: 230px; overflow: auto; }
.alert-item { padding: 10px 11px; border-left: 3px solid #afbdd2; border-radius: 7px; background: #f8fafc; }
.alert-item b { display: block; margin-bottom: 2px; font-size: 12px; }
.alert-item span { color: var(--muted); font-size: 11px; }

.table-panel { padding: 0; overflow: hidden; }
.table-panel .panel-header { padding: 22px 24px 0; }
.table-toolbar { align-items: center; }
.table-tools { display: flex; gap: 10px; }
.table-tools input { min-width: 220px; }
.table-scroll { overflow: auto; border-top: 1px solid var(--line); }
.rankings-table { width: 100%; min-width: 820px; border-collapse: collapse; font-size: 13px; }
.rankings-table th, .rankings-table td { padding: 12px 14px; border-bottom: 1px solid #e8edf3; text-align: left; vertical-align: top; }
.rankings-table th { position: sticky; top: 0; z-index: 2; color: #566278; background: #f8fafc; font-size: 11px; text-transform: uppercase; letter-spacing: .045em; }
.rankings-table tbody tr:hover { background: #fbfdff; }
.keyword-cell { min-width: 270px; max-width: 380px; }
.keyword-cell b { display: block; margin-bottom: 3px; font-size: 13px; }
.keyword-group { color: var(--muted); font-size: 11px; }
.profile-head { min-width: 210px; }
.profile-head-main { display: flex; align-items: center; justify-content: flex-start; gap: 8px; }
.profile-head-main .engine-badge { justify-self: start; }
.position-sort-toggle { min-width: 30px; margin: 0; padding: 2px 6px; border: 1px solid #cbd4df; border-radius: 5px; color: #697587; background: #fff; cursor: pointer; font: inherit; }
.position-sort-toggle:hover, .position-sort-toggle.active { border-color: #91b839; color: #315c13; background: #f3f9e8; }
.profile-head small { display: block; margin-top: 3px; color: var(--muted); font-weight: 500; text-transform: none; letter-spacing: 0; }
.engine-header-row th { border-bottom: 0; }
.engine-group-head { padding-bottom: 4px !important; }
.regions-header-row th { padding-top: 5px !important; padding-bottom: 7px !important; border-top: 1px solid #dce2e6; background: #e9edef; text-align: center; }
.region-column-head b { display: block; color: #465461; font-size: 11px; }
.region-column-head small { display: block; margin-top: 2px; color: #87919a; font-size: 9px; font-weight: 500; text-transform: none; letter-spacing: 0; }
.dates-header-row .region-column-head { min-width: 68px; }
.history-position-cell { padding: 7px !important; text-align: center; }
.history-position { display: inline-flex; min-width: 34px; height: 28px; align-items: center; justify-content: center; border-radius: 2px; color: #52606a; background: #eef1f2; font-weight: 700; }
.history-position.top3 { color: #17623f; background: #bfeacb; }
.history-position.top10 { color: #286077; background: #d9edf2; }
.history-position.top30 { color: #755f32; background: #f2ead0; }
.history-position-empty { color: #a2a9ae; }
.position-cell { min-width: 210px; }
.position-row { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.position-number { display: inline-flex; min-width: 34px; height: 30px; align-items: center; justify-content: center; border-radius: 8px; color: var(--text); background: #edf2f8; font-weight: 850; }
.position-number.top3 { color: #0d6f49; background: var(--green-soft); }
.position-number.top10 { color: #1e56ae; background: var(--brand-soft); }
.delta { font-size: 12px; font-weight: 800; }
.delta-up { color: var(--green); }
.delta-down { color: var(--red); }
.result-url { display: block; max-width: 240px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.result-empty { color: #9aa5b5; }
.result-error { color: var(--red); font-size: 11px; }

.two-column-form { grid-template-columns: 1fr 1fr; }
.form-span { grid-column: 1 / -1; }

.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 9px; width: min(390px, calc(100vw - 40px)); }
.toast { padding: 13px 15px; border: 1px solid var(--line); border-radius: 11px; background: #fff; box-shadow: var(--shadow); animation: toast-in .18s ease; }
.toast.error { color: #9d2637; border-color: #f0b8c1; background: #fff7f8; }
.toast.success { color: #126b49; border-color: #bce9d5; background: #f4fcf8; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 1040px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid, .content-grid { grid-template-columns: 1fr; }
  .forms-grid { grid-template-columns: 1fr; }
  .hero { align-items: flex-start; flex-direction: column; }
  .project-layout { grid-template-columns: 210px minmax(0, 1fr); }
}

@media (max-width: 720px) {
  .topbar { gap: 14px; padding: 0 16px; }
  .topnav, .account-email { display: none; }
  .account { margin-left: auto; }
  .page-shell { width: min(100% - 24px, 1500px); margin-top: 16px; }
  .hero { padding: 24px; }
  .hero-status { width: 100%; }
  .project-heading { align-items: flex-start; flex-direction: column; }
  .heading-actions { width: 100%; }
  .heading-actions .button { flex: 1; }
  .filter-bar { align-items: flex-start; flex-direction: column; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; padding-inline: 7px; font-size: 11px; }
  .metrics-grid { grid-template-columns: 1fr; }
  .project-layout { grid-template-columns: 1fr; }
  .competitors-panel { position: static; }
  .competitors-list { max-height: 260px; }
  .panel { padding: 18px; }
  .table-panel { padding: 0; }
  .table-panel .panel-header { padding: 18px 18px 0; }
  .table-toolbar { align-items: stretch; flex-direction: column; }
  .table-tools { flex-direction: column; }
  .table-tools input { min-width: 0; }
  .two-column-form { grid-template-columns: 1fr; }
  .form-span { grid-column: auto; }
  .auth-card { padding: 25px; }
}

/* Classic report layout based on the supplied reference screens. */
:root {
  --bg: #f0f1f2;
  --text: #3f4b55;
  --muted: #77818a;
  --line: #d9dde0;
  --brand: #78b82a;
  --brand-dark: #5f981a;
  --brand-soft: #f1f8e6;
  --sidebar-width: 255px;
}
body { color: var(--text); background: #eef0f1; font-family: Arial, Helvetica, sans-serif; }
.app-sidebar { color: var(--text); background: #f6f6f6; border-right: 1px solid #d5d8da; box-shadow: none; }
.app-sidebar .brand { min-height: 70px; color: #505861; background: #fff; border-bottom: 3px solid var(--brand); }
.app-sidebar .brand small { color: #8a939a; }
.brand-mark { color: #fff; background: var(--brand); }
.side-nav { padding: 14px 10px 10px; }
.side-nav a { color: #52606b; border: 1px solid #dfe2e4; background: #fff; }
.side-nav a:hover { color: #335b78; background: #f8fafb; }
.side-nav a.active { color: #fff; border-color: #2e77aa; background: #347cad; }
.sidebar-help { display: grid; gap: 7px; margin: auto 12px 12px; padding: 14px; border: 1px solid #d9dddf; background: #fff; font-size: 11px; }
.sidebar-help b { padding-bottom: 8px; border-bottom: 1px solid #e2e4e6; font-size: 14px; }
.sidebar-help a { color: #4d738d; text-decoration: underline; }
.sidebar-foot { margin-top: 0; color: #76818a; border-top: 1px solid #dadde0; }
.topbar { border-bottom: 1px solid #d8dbdd; background: linear-gradient(#fff,#f4f5f5); }
.page-shell { padding: 19px 22px 45px; }
.project-heading { margin: 0 0 10px; padding: 12px 15px; border: 1px solid var(--line); background: #fff; }
.project-heading h1 { font-size: 20px; text-transform: uppercase; }
.project-heading h1::before { content: ":: "; color: #7a8790; }
.domain-line { font-size: 12px; }
.project-tabs { gap: 0; margin: 0; padding: 0 10px; border: 1px solid var(--line); border-bottom: 3px solid var(--brand); background: #fff; }
.project-tabs a { padding: 9px 16px; border-right: 1px solid #e0e3e5; }
.project-tabs a.active { color: #fff; background: #347cad; }
.tab-count { display: inline-flex; min-width: 20px; height: 20px; margin-left: 5px; padding: 0 6px; align-items: center; justify-content: center; border-radius: 10px; color: #315c13; background: #e7f2cf; font-size: 11px; line-height: 1; }
.project-tabs a.active .tab-count { color: #245778; background: #fff; }
.project-tabs a.active::after { display: none; }
.filter-bar { margin: 0 0 12px; border-top: 0; border-radius: 0; box-shadow: none; }
.panel { border-radius: 3px; box-shadow: 0 1px 3px rgba(20,30,40,.08); }
.project-layout { grid-template-columns: 255px minmax(0,1fr); gap: 12px; }
.competitors-panel { top: 74px; border-radius: 3px; }
.competitors-panel::before { content: "ТЕКУЩИЙ ПРОЕКТ"; display: block; margin: -16px -16px 14px; padding: 11px 14px; color: #56636d; border-bottom: 1px solid var(--line); background: #f6f7f7; font-weight: 700; }
.competitor-item { background: #fff; }
.competitor-item.selected { border-color: #9bc464; background: #f2f8e9; }
.content-grid { display: grid; grid-template-columns: minmax(0,1fr) 245px; gap: 12px; margin-bottom: 0; }
.content-grid .panel-large { padding-bottom: 8px; }
.chart-box { min-height: 300px; border: 1px solid #e1e3e5; background: #fff; }
.chart-box svg { height: 300px; }
.metrics-grid { grid-template-columns: repeat(4,minmax(0,1fr)); gap: 0; margin: 0 0 12px; border: 1px solid var(--line); background: #fff; }
.metric-card { min-height: 105px; border: 0; border-right: 1px solid var(--line); border-radius: 0; box-shadow: none; }
.metric-card:last-child { border-right: 0; }
.metric-value { color: var(--brand-dark); font-size: 29px; font-weight: 700; }
.engine-badge { background: #f3f5f6; }
.table-panel { border-radius: 3px; }
.table-panel .panel-header { background: linear-gradient(#fafafa,#f0f1f2); }
.rankings-table th { color: #4c565f; background: #eef0f1; text-transform: none; }
.rankings-table td { border-right: 1px solid #e5e7e8; }
.rankings-table tbody tr:nth-child(even) { background: #f3f8fb; }
.position-number { border: 1px solid #dce2e4; background: #f4f5f5; }
.position-number.top3 { color: #2f6720; background: #b9ebad; }
.position-number.top10 { color: #42623b; background: #d8ead4; }
.forms-grid { grid-template-columns: 1fr 1fr; }

@media (max-width: 1040px) {
  .sidebar-help { display: none; }
  .content-grid { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 720px) {
  .project-heading { align-items: stretch; }
  .project-tabs { overflow-x: auto; }
  .project-tabs a { white-space: nowrap; }
  .project-layout { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .forms-grid { grid-template-columns: 1fr; }
}

/* Workspace interface: dense SEO cabinet with original Rank Monitor styling. */
:root {
  --bg: #f4f6f8;
  --panel: #fff;
  --text: #263143;
  --muted: #788397;
  --line: #e1e6ec;
  --brand: #37a56c;
  --brand-dark: #268451;
  --brand-soft: #eaf7f0;
  --shadow: 0 2px 9px rgba(29, 42, 58, .055);
  --radius: 5px;
  --sidebar-width: 210px;
}
body { background: var(--bg); font-size: 14px; }
body[data-page="dashboard"], body[data-page="project"] { padding-left: var(--sidebar-width); }
.app-sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 30; display: flex; width: var(--sidebar-width);
  flex-direction: column; color: #cbd4dc; background: #27323d; box-shadow: 2px 0 12px rgba(18,27,36,.12);
}
.app-sidebar .brand { min-height: 62px; padding: 0 20px; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); }
.app-sidebar .brand > span:last-child { display: flex; flex-direction: column; line-height: 1.05; text-transform: uppercase; letter-spacing: .08em; }
.app-sidebar .brand small { margin-top: 3px; color: #8da0af; font-size: 8px; letter-spacing: .24em; }
.brand-mark { width: 32px; height: 32px; border-radius: 4px; background: var(--brand); box-shadow: none; }
.side-nav { display: grid; gap: 3px; padding: 18px 10px; }
.side-nav a { display: flex; align-items: center; gap: 12px; min-height: 42px; padding: 0 12px; border-radius: 4px; color: #bac6d0; font-weight: 600; }
.side-nav a:hover { color: #fff; background: rgba(255,255,255,.06); text-decoration: none; }
.side-nav a.active { color: #fff; background: var(--brand); }
.nav-icon { width: 20px; text-align: center; font-size: 18px; }
.sidebar-foot { display: flex; align-items: center; gap: 9px; margin-top: auto; padding: 17px 20px; border-top: 1px solid rgba(255,255,255,.08); color: #8fa0ad; font-size: 11px; }
.sidebar-foot .status-dot { width: 7px; height: 7px; box-shadow: none; }
.topbar { left: var(--sidebar-width); min-height: 62px; padding: 0 28px; border-color: var(--line); background: #fff; backdrop-filter: none; }
.topbar-title { flex: 1; color: #3e4b5e; font-weight: 700; }
.topbar-title span { color: #a0a8b4; font-weight: 400; }
.account-avatar { display: inline-flex; width: 30px; height: 30px; align-items: center; justify-content: center; border-radius: 50%; color: #fff; background: #92a0ae; font-size: 12px; font-weight: 800; }
.page-shell { width: auto; max-width: 1640px; margin: 0 auto 55px; padding: 27px 30px; }
.auth-shell { width: 100%; padding: 24px; }
.workspace-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 22px; margin: 3px 0 22px; }
.workspace-heading h1, .project-heading h1 { margin: 4px 0; font-size: 26px; letter-spacing: -.02em; }
.workspace-heading p { margin: 0; color: var(--muted); }
.eyebrow { margin-bottom: 3px; color: var(--brand-dark); font-size: 10px; }
.panel { padding: 20px; border-radius: var(--radius); box-shadow: var(--shadow); }
.panel.check-progress-panel { padding: 8px 11px; border-radius: 3px; box-shadow: none; }
.panel-header { margin-bottom: 16px; }
h2 { font-size: 17px; }
.dashboard-grid { grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; }
.project-list { gap: 0; border: 1px solid var(--line); border-radius: 4px; }
.project-card { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: #fff; }
.project-card:last-child { border-bottom: 0; }
.project-card:hover { transform: none; border-color: var(--line); background: #f9fbfa; box-shadow: inset 3px 0 var(--brand); }
.button { min-height: 37px; border-radius: 4px; padding: 7px 14px; font-size: 13px; }
.button-primary { background: var(--brand); box-shadow: none; }
.button-primary:hover { background: var(--brand-dark); }
.button-secondary { color: var(--brand-dark); border-color: #b8ddca; background: var(--brand-soft); }
input, select, textarea { min-height: 38px; border-radius: 4px; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(55,165,108,.12); }
.region-autocomplete { position: relative; display: block; }
.region-autocomplete > input { width: 100%; }
.region-suggestions { position: absolute; z-index: 20; top: calc(100% + 3px); right: 0; left: 0; overflow: hidden; border: 1px solid #bcc8d5; border-radius: 3px; background: #fff; box-shadow: 0 5px 14px rgba(30,45,60,.16); }
.region-suggestions[hidden] { display: none; }
.region-suggestions button { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px; border: 0; border-bottom: 1px solid #edf0f2; color: #334052; background: #fff; cursor: pointer; text-align: left; }
.region-suggestions button:last-child { border-bottom: 0; }
.region-suggestions button:hover { background: #f2f7e9; }
.region-suggestions button small { color: #7e8997; }
.saved-keywords { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.saved-keywords-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.saved-keywords-head h3 { margin: 0; font-size: 14px; }
.saved-keywords-head > b { display: inline-flex; min-width: 25px; height: 22px; padding: 0 7px; align-items: center; justify-content: center; border-radius: 11px; color: #245778; background: #e6f0f6; font-size: 12px; }
.saved-keywords-list { display: grid; max-height: 330px; overflow-y: auto; border: 1px solid #dfe4e8; background: #fff; }
.saved-keyword-item { display: flex; min-height: 31px; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 6px 4px 9px; border-bottom: 1px solid #edf0f2; color: #344152; font-size: 12px; }
.saved-keyword-item:last-child { border-bottom: 0; }
.saved-keyword-delete { display: inline-flex; width: 24px; height: 24px; flex: 0 0 24px; align-items: center; justify-content: center; padding: 0; border: 0; border-radius: 3px; color: #b54b52; background: transparent; font-size: 18px; line-height: 1; cursor: pointer; }
.saved-keyword-delete:hover { color: #fff; background: #c94f58; }
.table-keyword-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.table-keyword-line .saved-keyword-delete { margin-left: auto; }
.competitor-page-label { display: block; margin-top: 4px; color: #7b8792; font-size: 10px; }
body[data-page="project"] .rankings-table .position-cell .result-url { display: block; max-width: none; overflow: visible; margin-top: 2px; color: #347cad; white-space: normal; overflow-wrap: anywhere; text-overflow: clip; }
@media (max-width: 720px) {
}
.project-heading { align-items: center; margin-bottom: 14px; }
.back-link { color: var(--brand-dark); }
.project-tabs { display: flex; gap: 26px; margin-bottom: 18px; padding: 0 2px; border-bottom: 1px solid #d7dde4; }
.project-tabs a { position: relative; padding: 10px 2px 12px; color: #667286; font-size: 13px; font-weight: 700; }
.project-tabs a:hover { color: var(--brand-dark); text-decoration: none; }
.project-tabs a.active { color: var(--brand-dark); }
.project-tabs a.active::after { content: ""; position: absolute; right: 0; bottom: -1px; left: 0; height: 3px; background: var(--brand); }
.filter-bar { margin-bottom: 16px; }
.segmented { border-radius: 4px; }
.segmented button { border-radius: 3px; font-size: 12px; }
.segmented button.active { background: var(--brand); box-shadow: none; }
.project-layout { grid-template-columns: 230px minmax(0, 1fr); gap: 16px; }
.competitors-panel { top: 78px; padding: 16px; }
.competitor-item { border-radius: 3px; background: #fafbfc; }
.competitor-item.selected { border-color: #87c9a5; background: var(--brand-soft); }
.competitor-form { gap: 3px; margin-bottom: 8px; }
.competitor-form-row { grid-template-columns: minmax(0, 1fr) 30px; gap: 4px; }
.competitor-form-row input { height: 30px; min-height: 30px; padding: 4px 8px; font-size: 12px; }
.competitor-form-row .button { height: 30px; min-height: 30px; padding: 2px; font-size: 16px; }
.competitors-list { gap: 3px; }
.competitor-item { min-height: 29px; grid-template-columns: 15px minmax(0, 1fr) 21px; gap: 3px; padding: 3px 5px; }
.competitor-item.dragging { opacity: .45; border-style: dashed; }
.competitor-drag { color: #9aa4ae; cursor: grab; font-size: 12px; letter-spacing: -3px; user-select: none; }
.competitor-drag:active { cursor: grabbing; }
.competitor-select { font-size: 11px; }
.competitor-delete { width: 21px; height: 21px; border-radius: 3px; font-size: 14px; }
.selected-site-card { margin: -20px -20px 13px; padding: 10px 14px 12px; border-bottom: 1px solid #d9dde0; background: #f8f9f9; text-align: center; }
.selected-site-label { display: block; margin-bottom: 7px; color: #5d6974; font-size: 10px; font-weight: 700; text-align: left; }
.selected-site-preview { display: grid; min-height: 62px; margin-bottom: 7px; place-items: center; overflow: hidden; border: 1px solid #d6dadd; background: linear-gradient(#fff,#eef1f2); color: #7a8791; }
.preview-browser-bar { align-self: start; display: flex; width: 100%; gap: 3px; padding: 4px 5px; border-bottom: 1px solid #dfe3e5; background: #eceff0; }
.preview-browser-bar i { width: 4px; height: 4px; border-radius: 50%; background: #aab2b8; }
.selected-site-preview strong { align-self: start; max-width: 190px; overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.selected-site-card > a { display: block; overflow: hidden; color: #376b8e; font-size: 12px; font-weight: 700; text-decoration: underline; text-overflow: ellipsis; white-space: nowrap; }
.selected-site-card > small { display: block; margin-top: 2px; color: #8a949c; font-size: 9px; }
.metrics-grid { gap: 10px; margin-bottom: 16px; }
.metric-card { padding: 14px 15px; border-radius: 4px; box-shadow: var(--shadow); }
.metric-value { font-size: 25px; }
.engine-badge { border-radius: 3px; }
.content-grid { gap: 16px; margin-bottom: 16px; }
.chart-box { min-height: 250px; border-radius: 3px; }
.chart-box svg { height: 250px; }
.table-panel { border-radius: 5px; }
.table-panel .panel-header { padding: 17px 18px 0; }
.table-tools input { min-width: 180px; }
.rankings-table { font-size: 12px; }
.rankings-table th, .rankings-table td { padding: 9px 11px; }
.rankings-table th { background: #f2f4f6; color: #5e6878; }
.rankings-table tbody tr:nth-child(even) { background: #fbfcfd; }
.rankings-table tbody tr:hover { background: #f0f8f4; }
.position-number { min-width: 30px; height: 26px; border-radius: 3px; }
.position-number.top3 { color: #146841; background: #dff4e9; }
.position-number.top10 { color: #2a657f; background: #e7f3f7; }
.forms-grid { gap: 16px; margin-top: 16px; }
.counter { border-radius: 3px; color: var(--brand-dark); background: var(--brand-soft); }

@media (max-width: 1040px) {
  :root { --sidebar-width: 68px; }
  .app-sidebar .brand { justify-content: center; padding: 0; }
  .app-sidebar .brand > span:last-child, .side-nav a span:last-child, .sidebar-foot span:last-child { display: none; }
  .side-nav a { justify-content: center; padding: 0; }
  .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  body[data-page="dashboard"], body[data-page="project"] { padding-left: 0; padding-bottom: 58px; }
  .app-sidebar { inset: auto 0 0; width: 100%; height: 58px; flex-direction: row; }
  .app-sidebar .brand, .sidebar-foot { display: none; }
  .side-nav { width: 100%; grid-template-columns: repeat(3, 1fr); padding: 6px; }
  .side-nav a { min-height: 46px; }
  .side-nav a span:last-child { display: inline; font-size: 11px; }
  .topbar { left: 0; min-height: 54px; padding: 0 13px; }
  .topbar-title span, .account-email { display: none; }
  .page-shell { padding: 17px 12px; }
  .workspace-heading { align-items: flex-start; flex-direction: column; }
  .project-tabs { gap: 16px; overflow-x: auto; }
  .project-layout { grid-template-columns: 1fr; }
}

/* Final reference alignment (must remain after the workspace rules). */
body[data-page="dashboard"], body[data-page="project"] { --sidebar-width: 255px; }
.app-sidebar { color: #3f4b55; background: #f5f6f6; border-right: 1px solid #d5d8da; box-shadow: none; }
.app-sidebar .brand { min-height: 70px; color: #505861; background: #fff; border-bottom: 3px solid #78b82a; }
.app-sidebar .brand small { color: #8a939a; }
.brand-mark { background: #78b82a; }
.side-nav a { color: #52606b; border: 1px solid #dfe2e4; background: #fff; }
.side-nav a.active { color: #fff; border-color: #2e77aa; background: #347cad; }
.sidebar-help { display: grid; gap: 7px; margin: auto 12px 12px; padding: 14px; border: 1px solid #d9dddf; background: #fff; font-size: 11px; }
.sidebar-help b { padding-bottom: 8px; border-bottom: 1px solid #e2e4e6; font-size: 14px; }
.sidebar-help a { color: #4d738d; text-decoration: underline; }
.sidebar-foot { margin-top: 0; color: #76818a; border-top: 1px solid #dadde0; }
.project-heading { margin: 0 0 10px; padding: 12px 15px; border: 1px solid #d9dde0; background: #fff; }
.project-heading h1 { font-size: 20px; text-transform: uppercase; }
.project-tabs { gap: 0; margin: 0; padding: 0 10px; border: 1px solid #d9dde0; border-bottom: 3px solid #78b82a; background: #fff; }
.project-tabs a { padding: 9px 16px; border-right: 1px solid #e0e3e5; }
.project-tabs a.active { color: #fff; background: #347cad; }
.filter-bar { margin: 0 0 12px; border-radius: 0; box-shadow: none; }
.project-layout { grid-template-columns: 255px minmax(0,1fr); gap: 12px; }
.competitors-panel { top: 74px; border-radius: 3px; }
.content-grid { grid-template-columns: minmax(0,1fr) 245px; gap: 12px; margin-bottom: 0; }
.chart-box { min-height: 300px; border: 1px solid #e1e3e5; background: #fff; }
.chart-box svg { height: 300px; }
.metrics-grid { grid-template-columns: repeat(4,minmax(0,1fr)); gap: 0; margin: 0 0 12px; border: 1px solid #d9dde0; background: #fff; }
.metric-card { min-height: 70px; padding: 8px 10px; border-radius: 0; box-shadow: none; }
.metric-card .metric-label { gap: 6px; margin-bottom: 4px; font-size: 10px; }
.metric-card .engine-badge { gap: 4px; padding: 2px 5px; font-size: 9px; }
.metric-card .engine-badge::before { width: 5px; height: 5px; }
.metric-value { margin-bottom: 3px; color: #5f981a; font-size: 20px; line-height: 1.05; }
.metric-sub { gap: 6px; font-size: 10px; line-height: 1.15; }

@media (max-width: 1040px) {
  body[data-page="dashboard"], body[data-page="project"] { --sidebar-width: 68px; }
  .sidebar-help { display: none; }
  .content-grid { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 720px) {
  body[data-page="dashboard"], body[data-page="project"] { --sidebar-width: 0px; }
  .project-layout { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
}

body[data-page="project"] { padding-left: 0; padding-bottom: 0; }
body[data-page="project"] .app-sidebar { display: none; }
body[data-page="project"] .topbar { left: 0; }
body[data-page="project"] .page-shell { width: min(100% - 28px, 1500px); max-width: 1500px; padding-right: 0; padding-left: 0; }
