/* Stripe-like dashboard theme for local SEO rank tracker. */

:root {
  color-scheme: light;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", "Roboto", "Helvetica Neue", "Ubuntu", sans-serif;
  --font-mono: "Menlo", "Consolas", monospace;

  --bg: #ffffff;
  --bg-offset: #f4f6f8;
  --canvas: #d8dee6;
  --panel: #ffffff;
  --line: #dfe5ec;
  --line-strong: #b8c2cc;
  --text: #354052;
  --text-strong: #111827;
  --muted: #637083;
  --muted-soft: #99a3b3;
  --accent: #256f6b;
  --accent-strong: #174f4d;
  --accent-soft: #eaf5f3;
  --info: #2f6690;
  --success: #1f7a4d;
  --success-soft: #eaf7ef;
  --warning: #9a5b13;
  --warning-soft: #fff7e6;
  --danger: #b42342;
  --danger-soft: #fff1f3;
  --sidebar-bg: #121821;
  --sidebar-muted: #8b98aa;
  --sidebar-line: rgba(255, 255, 255, 0.08);
  --sidebar-active: rgba(255, 255, 255, 0.08);
  --shadow-keyline: 0 0 0 1px rgba(17, 24, 39, 0.07);
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.06);
  --shadow-md: 0 8px 18px rgba(17, 24, 39, 0.08);
  --focus: 0 0 0 4px rgba(37, 111, 107, 0.18);
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-offset);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 19px;
  letter-spacing: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--text-strong);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 12px;
  background: var(--sidebar-bg);
  border-right: 1px solid #0d121a;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 32px;
  padding: 4px 8px;
  color: #f8fafc;
  font-size: 14px;
  font-weight: 650;
}

.brand-mark {
  display: inline-grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: var(--radius-sm);
  background: #2b8a84;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}

.side-nav {
  display: grid;
  gap: 2px;
}

.side-nav__item,
.side-subnav__item {
  min-height: 32px;
  display: flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-muted);
  font-weight: 500;
}

.side-nav__item:hover,
.side-subnav__item:hover {
  background: var(--sidebar-active);
  color: #f8fafc;
}

.side-nav__item.is-active,
.side-subnav__item.is-active {
  background: var(--sidebar-active);
  color: #fff;
  box-shadow: inset 3px 0 0 #35b7ad;
}

.project-context {
  display: grid;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--sidebar-line);
}

.side-label {
  padding: 0 10px;
  color: var(--sidebar-muted);
  font-size: 11px;
  font-weight: 650;
}

.project-switch {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--sidebar-line);
  border-radius: 8px;
  color: #d8dee6;
  background: rgba(255, 255, 255, 0.035);
}

.project-switch strong {
  color: #fff;
  font-size: 13px;
  font-weight: 650;
}

.project-switch span {
  color: var(--sidebar-muted);
  font-size: 12px;
}

.side-subnav {
  display: grid;
  gap: 2px;
}

.side-subnav__item {
  padding-left: 18px;
}

.main-shell {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  background: rgba(250, 251, 252, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.search-box {
  width: min(520px, 50vw);
  height: 32px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--muted-soft);
  box-shadow: var(--shadow-keyline);
}

.search-box::before {
  content: "⌕";
  margin-right: 8px;
  color: var(--muted-soft);
}

.topbar-note,
.muted,
.small {
  color: var(--muted);
}

.topbar-note {
  font-size: 12px;
  font-weight: 500;
}

.breadcrumb {
  min-width: 0;
  color: var(--text-strong);
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.user-menu a {
  color: var(--text);
  font-weight: 600;
}

.env-badge,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 20px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.content {
  display: grid;
  gap: 14px;
  max-width: 1480px;
  margin: 0 auto;
  padding: 18px 24px 36px;
}

.page-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: end;
}

.page-header p {
  margin-top: 4px;
  color: var(--muted);
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.hero,
.split {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 16px;
  align-items: start;
}

.hero-compact {
  grid-template-columns: 1fr;
}

.form-stack {
  display: grid;
  gap: 12px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
}

.main-column,
.right-rail {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.main-column {
  overflow: hidden;
}

.right-rail {
  position: sticky;
  top: 72px;
}

.panel,
.project-card,
.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-keyline);
}

.panel {
  padding: 16px;
}

.project-card {
  display: grid;
  gap: 12px;
  padding: 14px 16px;
  color: inherit;
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.project-card:hover {
  background: var(--bg);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}

.project-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3 {
  color: var(--text-strong);
  letter-spacing: 0;
}

h1 {
  font-size: 24px;
  line-height: 30px;
  font-weight: 650;
}

h2 {
  margin-bottom: 12px;
  font-size: 14px;
  line-height: 20px;
  font-weight: 650;
}

h3 {
  font-size: 14px;
  line-height: 20px;
  font-weight: 650;
}

.hero > div > p {
  max-width: 760px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 20px;
}

.project-card__meta {
  color: var(--muted);
  font-size: 12px;
}

.projects-grid {
  grid-template-columns: minmax(0, 1fr) 360px;
}

.projects-panel {
  min-height: 360px;
}

.project-list {
  display: grid;
  gap: 8px;
}

.project-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(390px, 0.9fr);
  gap: 16px;
  align-items: center;
  min-height: 82px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: inherit;
}

.project-row:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}

.project-row__main {
  min-width: 0;
}

.project-row__stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.project-row__stats span,
.project-row__stats small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}

.project-row__stats strong {
  display: inline-block;
  color: var(--text-strong);
  font-size: 18px;
  line-height: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.empty-state {
  min-height: 180px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
}

.cards,
.stats-grid {
  display: grid;
  gap: 12px;
}

.cards {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.stats-grid--wide {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.hero-stats {
  margin-top: 18px;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow-keyline);
  overflow: hidden;
}

.metric-card {
  min-height: 78px;
  display: grid;
  align-content: space-between;
  gap: 6px;
  padding: 12px 14px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.metric-card:last-child {
  border-right: 0;
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
}

.metric-card strong {
  color: var(--text-strong);
  font-size: 22px;
  line-height: 26px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.metric-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}

.stat-card,
.stats-grid > div {
  padding: 13px 14px;
}

.stat-card span,
.stats-grid span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.stat-card strong,
.stats-grid strong {
  color: var(--text-strong);
  font-size: 22px;
  line-height: 28px;
  font-weight: 600;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.form-grid {
  display: grid;
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

input,
textarea,
select,
button {
  font: inherit;
}

.button-secondary {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--panel);
  color: var(--text-strong);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-keyline);
}

.button-secondary:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

input,
textarea,
select {
  width: 100%;
  min-height: 32px;
  padding: 6px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--panel);
  color: var(--text);
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted-soft);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--info);
  box-shadow: var(--focus);
}

textarea {
  resize: vertical;
  min-height: 132px;
}

button {
  min-height: 32px;
  padding: 6px 12px;
  border: 1px solid var(--accent);
  border-radius: 5px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  box-shadow: none;
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

button:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

button:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
}

.checkbox input {
  width: 16px;
  height: 16px;
}

.notice {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(37, 111, 107, 0.2);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 500;
}

.tabs,
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tabs {
  margin-top: 12px;
}

.filter-chips {
  margin-top: 12px;
}

.sort-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: -2px 0 12px;
}

.sort-toolbar > span {
  margin-right: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
}

.tab,
.filter-chip,
.sort-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
}

.tab:hover,
.filter-chip:hover,
.sort-chip:hover {
  background: var(--bg-offset);
}

.tab.is-active,
.filter-chip.is-active,
.sort-chip.is-active {
  border-color: rgba(37, 111, 107, 0.28);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.filters {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(120px, 160px) auto;
  gap: 10px;
  align-items: end;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.table-wrap {
  overflow: auto;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.keyword-table-wrap {
  max-height: 620px;
}

.keyword-table-wrap table {
  min-width: 720px;
}

.compact-table {
  max-height: 240px;
}

.compact-table table {
  min-width: 0;
}

.compact-table th,
.compact-table td {
  padding: 8px 9px;
  font-size: 12px;
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-offset);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

td {
  font-size: 13px;
}

tbody tr {
  transition: background 120ms ease;
}

tbody tr:hover {
  background: var(--bg-offset);
}

tr:last-child td {
  border-bottom: 0;
}

.sort-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  color: inherit;
}

.num {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.delta-up,
.delta-down,
.delta-flat,
.job-badge,
.cell-delta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.delta-up,
.delta-down,
.delta-flat {
  min-width: 44px;
  padding: 2px 8px;
}

.delta-up {
  color: #0e6245;
  background: #efffed;
}

.delta-down {
  color: #a41c4e;
  background: #fff8f5;
}

.delta-flat {
  color: var(--muted);
  background: var(--bg-offset);
}

.job-badge {
  min-width: 82px;
  padding: 2px 8px;
}

.job-pending {
  color: #983705;
  background: #fcf9e9;
}

.job-running {
  color: #075996;
  background: #edfdfd;
}

.job-done {
  color: #0e6245;
  background: #efffed;
}

.job-error {
  color: #a41c4e;
  background: #fff8f5;
}

.chart-card {
  min-height: 330px;
}

.chart-wrap {
  position: relative;
  height: 260px;
  overflow: hidden;
}

.chart-wrap canvas {
  max-width: 100%;
}

.action-panel {
  border-color: rgba(37, 111, 107, 0.24);
  box-shadow: var(--shadow-sm);
}

.latest-job {
  display: grid;
  gap: 6px;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.latest-job > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.disclosure {
  padding: 0;
}

.disclosure summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  color: var(--text-strong);
  cursor: pointer;
  font-weight: 700;
  list-style-position: inside;
}

.disclosure[open] {
  padding-bottom: 16px;
}

.disclosure[open] summary {
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.disclosure form {
  padding: 0 16px;
}

.back {
  display: inline-flex;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.small {
  font-size: 12px;
  line-height: 18px;
}

.small a {
  word-break: break-word;
}

.dynamics-wrap {
  max-height: 70vh;
}

.dynamics-table {
  min-width: 1040px;
}

.dynamics-table th,
.dynamics-table td {
  padding: 8px 10px;
}

.sticky-keyword {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 310px;
  max-width: 420px;
  background: var(--bg-offset);
  box-shadow: 1px 0 0 var(--line);
}

td.sticky-keyword {
  background: var(--panel);
}

th.sticky-keyword {
  z-index: 4;
}

.dynamics-date {
  min-width: 82px;
  text-align: center;
}

.dynamics-date span,
.dynamics-date small {
  display: block;
}

.dynamics-date small {
  margin-top: 2px;
  color: var(--muted-soft);
  font-size: 11px;
  font-weight: 500;
}

.keyword-title {
  max-width: 390px;
  color: var(--text-strong);
  font-weight: 600;
  line-height: 18px;
}

.keyword-meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
  word-break: break-word;
}

.dynamics-cell {
  min-width: 82px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.cell-position {
  display: block;
  color: var(--text-strong);
  font-size: 16px;
  font-weight: 700;
}

.cell-delta {
  min-width: 34px;
  margin-top: 4px;
  padding: 1px 7px;
}

.cell-delta-up {
  color: #0e6245;
  background: #efffed;
}

.cell-delta-down {
  color: #a41c4e;
  background: #fff8f5;
}

.cell-delta-flat {
  color: var(--muted);
  background: var(--bg-offset);
}

.position-top10 {
  background: #efffed;
}

.position-top30 {
  background: #edfdfd;
}

.position-low {
  background: #fcf9e9;
}

.position-missing {
  background: #fff8f5;
  color: var(--muted);
}

::selection {
  background: rgba(37, 111, 107, 0.18);
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(18, 24, 33, 0.04), rgba(18, 24, 33, 0)),
    var(--bg-offset);
}

.auth-card {
  width: min(100%, 380px);
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow-md);
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text-strong);
  font-weight: 650;
}

.auth-card h1 {
  margin: 6px 0 0;
  color: var(--text-strong);
  font-size: 24px;
  line-height: 30px;
  font-weight: 650;
}

.auth-card p {
  margin: 0;
  color: var(--muted);
}

.login-error {
  padding: 10px 12px;
  border: 1px solid rgba(180, 35, 66, 0.25);
  border-radius: var(--radius-md);
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 600;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-thumb {
  background: #c1c9d2;
  border-radius: 999px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .side-nav {
    grid-template-columns: repeat(3, max-content);
    overflow-x: auto;
  }

  .topbar {
    position: static;
    padding: 0 16px;
  }

  .search-box {
    width: 100%;
  }

  .topbar-actions {
    display: none;
  }

  .content {
    padding: 16px;
  }

  .hero,
  .split,
  .filters,
  .page-header,
  .dashboard-grid,
  .projects-grid,
  .project-row {
    grid-template-columns: 1fr;
  }

  .kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .right-rail {
    position: static;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .project-row__stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel {
    padding: 14px;
  }

  table {
    min-width: 760px;
  }

  .panel-head {
    display: grid;
  }

  .sticky-keyword {
    min-width: 240px;
    max-width: 280px;
  }
}

@media (max-width: 620px) {
  .kpi-row {
    grid-template-columns: 1fr;
  }
}
