:root {
  --bg: #f4f1eb;
  --bg-strong: #e9e2d7;
  --panel: #fffdf9;
  --panel-soft: #f8f4ed;
  --ink: #15130f;
  --muted: #756f66;
  --line: #ded6ca;
  --line-strong: #c9bfb0;
  --blue: #174d6f;
  --blue-strong: #0d334c;
  --blue-soft: #dcebf1;
  --client-detail-label: #1b6da8;
  --green: #2f7d62;
  --orange: #b6622a;
  --purple: #6f4a8e;
  --red: #b5453f;
  --cyan: #247985;
  --gold: #c39b53;
  --shadow: 0 24px 70px rgba(38, 33, 26, 0.1);
  --shadow-hover: 0 30px 80px rgba(38, 33, 26, 0.16);
  --radius: 8px;
  --sidebar: #15130f;
  --sidebar-muted: rgba(255, 253, 249, 0.62);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

:root[data-theme="dark"] {
  --bg: #0f1113;
  --bg-strong: #171a1d;
  --panel: #181b1e;
  --panel-soft: #202429;
  --ink: #f7f2ea;
  --muted: #aaa197;
  --line: #30343a;
  --line-strong: #464b53;
  --blue: #4f95b7;
  --blue-strong: #2e6f92;
  --blue-soft: #172f3c;
  --client-detail-label: #e7d57a;
  --green: #7fc8a4;
  --orange: #e0a071;
  --purple: #c0a0de;
  --red: #e78a84;
  --cyan: #88cbd3;
  --gold: #d7b76d;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  --shadow-hover: 0 30px 90px rgba(0, 0, 0, 0.46);
  --sidebar: #090a0b;
  --sidebar-muted: rgba(247, 242, 234, 0.62);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top right, rgba(195, 155, 83, 0.13), transparent 30vw),
    linear-gradient(135deg, var(--bg) 0%, var(--bg-strong) 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
}

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

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  width: 252px;
  background: var(--sidebar);
  color: #fffdf9;
  padding: 26px 18px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 34px;
  font-weight: 850;
  line-height: 1.05;
  letter-spacing: 0;
}

.brand small,
.sidebar-user span {
  display: block;
  color: var(--sidebar-muted);
  font-size: 12px;
  font-weight: 600;
  margin-top: 3px;
}

.brand-mark,
.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
  font-weight: 850;
}

.sidebar nav {
  display: grid;
  gap: 7px;
}

.sidebar a {
  color: #fffdf9;
  text-decoration: none;
  padding: 12px 13px;
  border-radius: var(--radius);
  font-weight: 760;
  transition: background 180ms ease, color 180ms ease, transform 180ms ease;
}

.sidebar a:hover,
.sidebar a.active {
  background: rgba(255, 255, 255, 0.1);
  transform: translateX(2px);
}

.sidebar a.active {
  color: #fff;
  box-shadow: inset 3px 0 0 var(--gold);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.main {
  margin-left: 252px;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  min-height: 78px;
  padding: 16px clamp(20px, 4vw, 46px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: blur(18px);
}

.topbar strong {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 25px;
  font-weight: 700;
  letter-spacing: 0;
}

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

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-box {
  display: flex;
  align-items: center;
  width: min(310px, 31vw);
  min-height: 42px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.search-box span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  padding: 12px 13px;
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: 0;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 18%, transparent);
}

.search-box input {
  border: 0;
  background: transparent;
  padding: 0;
  box-shadow: none;
}

.icon-link,
.logout-link,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  width: max-content;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--panel);
  font-weight: 820;
  line-height: 1.1;
  text-decoration: none;
  white-space: nowrap;
  padding: 0 17px;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease, border-color 180ms ease, color 180ms ease;
}

.button:hover,
.logout-link:hover,
.icon-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(21, 19, 15, 0.14);
}

.icon-link {
  width: 42px;
  padding: 0;
  background: var(--panel);
  color: var(--ink);
  border-color: var(--line);
}

.logout-link,
.button.secondary {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--line);
}

.button.danger {
  background: #fee2e2;
  color: #a82323;
  border-color: #fecaca;
}

.button.ghost {
  background: rgba(255, 253, 249, 0.12);
  border-color: rgba(255, 253, 249, 0.28);
  color: #fffdf9;
}

.flash-stack {
  padding: 18px clamp(20px, 4vw, 46px) 0;
}

.flash {
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--green) 25%, transparent);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--green) 11%, var(--panel));
  color: var(--green);
  font-weight: 760;
}

.dashboard-hero,
.hero-panel,
.detail-header {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(260px, 0.65fr);
  align-items: end;
  gap: 28px;
  margin: 30px clamp(20px, 4vw, 46px) 22px;
  padding: clamp(28px, 5vw, 58px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--panel) 86%, transparent), color-mix(in srgb, var(--panel-soft) 96%, transparent)),
    radial-gradient(circle at 88% 18%, color-mix(in srgb, var(--gold) 18%, transparent), transparent 24rem);
  box-shadow: var(--shadow);
}

.hero-panel,
.detail-header {
  display: flex;
  justify-content: space-between;
  color: var(--ink);
}

.hero-panel.compact {
  padding: 30px clamp(24px, 4vw, 38px);
}

.hero-copy h1,
.hero-panel h1,
.detail-header h1 {
  max-width: 980px;
  margin: 8px 0 14px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(26px, 3vw, 40px);
  line-height: 1.08;
  letter-spacing: 0;
}

.hero-panel h1,
.detail-header h1 {
  font-size: clamp(28px, 3vw, 40px);
}

.hero-copy p,
.hero-panel p,
.detail-header p {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.65;
}

.eyebrow {
  margin: 0;
  color: var(--orange);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 26px;
}

.hero-insight {
  display: grid;
  gap: 12px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.hero-insight strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 62px;
  line-height: 0.9;
}

.hero-insight p {
  margin: 0 0 8px;
  color: var(--muted);
}

.mini-stat-row,
.setting-row,
.client-row,
.activity-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.mini-stat-row {
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.metric-grid,
.dashboard-grid,
.ops-row,
.client-detail-grid,
.app-showcase,
.form-shell {
  padding: 0 clamp(20px, 4vw, 46px) 24px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.keyword-metric-grid {
  grid-template-columns: repeat(4, minmax(190px, 1fr));
}

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

.ops-row {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(340px, 0.82fr);
  gap: 22px;
  align-items: stretch;
}

.ops-row.single {
  grid-template-columns: 1fr;
}

.ops-row > .panel {
  height: 100%;
}

.client-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.8fr);
  grid-template-areas:
    "profile apps"
    "profile competitors"
    "baseline baseline";
  gap: 22px;
  align-items: start;
}

.client-detail-grid > .panel:nth-child(1) {
  grid-area: profile;
}

.client-detail-grid > .panel:nth-child(2) {
  grid-area: apps;
}

.client-detail-grid > .panel:nth-child(3) {
  grid-area: competitors;
}

.client-detail-grid > .panel:nth-child(4) {
  grid-area: baseline;
}

.editorial-grid {
  padding-bottom: 44px;
}

.full-span {
  grid-column: 1 / -1;
}

.metric-card,
.panel,
.empty-state {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 200ms ease, box-shadow 200ms ease, border-color 200ms ease, background 200ms ease;
}

.empty-state {
  display: grid;
  align-content: center;
  gap: 18px;
  min-height: 230px;
  padding: clamp(28px, 4vw, 46px);
}

.empty-state.embedded {
  min-height: 220px;
  box-shadow: none;
}

.empty-state h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(26px, 3vw, 36px);
  line-height: 1.08;
}

.empty-state p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.empty-state .button {
  width: fit-content;
}

.metric-card:hover,
.panel:hover,
.client-row:hover,
.app-tile:hover,
.quick-card:hover,
.module-launch:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.metric-card {
  display: grid;
  align-content: space-between;
  gap: 10px;
  min-height: 148px;
  padding: 20px;
}

.clickable-card {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.metric-card span,
.metric-card small {
  color: var(--muted);
}

.metric-card strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 38px;
  line-height: 1;
}

.metric-card::before {
  content: "";
  width: 38px;
  height: 3px;
  background: var(--blue);
}

.metric-card.green::before { background: var(--green); }
.metric-card.orange::before { background: var(--orange); }
.metric-card.purple::before { background: var(--purple); }
.metric-card.red::before { background: var(--red); }
.metric-card.cyan::before { background: var(--cyan); }

.panel {
  padding: clamp(26px, 3vw, 36px);
}

.wide,
.client-picker {
  min-width: 0;
}

.panel-heading,
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 28px;
  margin-bottom: 26px;
}

.section-heading {
  align-items: center;
}

.panel-heading h2,
.section-heading h2 {
  margin: 0 0 6px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.05;
}

.section-heading h2 {
  font-size: clamp(28px, 3.6vw, 44px);
}

.panel-heading h2 {
  font-size: 24px;
}

.panel-heading p,
.section-heading p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.panel-heading a,
.section-heading a {
  color: var(--blue);
  font-weight: 850;
  text-decoration: none;
  white-space: nowrap;
}

.app-showcase {
  margin-top: 8px;
}

.showcase-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 1fr;
  grid-auto-rows: minmax(190px, auto);
  gap: 16px;
}

.app-tile {
  display: grid;
  align-content: space-between;
  gap: 20px;
  min-height: 220px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: #fffdf9;
  background: linear-gradient(135deg, var(--blue-strong), var(--blue));
  overflow: hidden;
  text-decoration: none;
  cursor: pointer;
}

.app-tile.featured {
  grid-row: span 2;
  min-height: 456px;
}

.app-tile h3 {
  margin: 0;
  max-width: 14ch;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(28px, 3.2vw, 42px);
  line-height: 1.04;
}

.app-tile:not(.featured) h3 {
  font-size: 26px;
}

.app-tile p {
  margin: 0;
  color: rgba(255, 253, 249, 0.78);
  line-height: 1.55;
}

.app-tile span,
.app-tile strong {
  width: fit-content;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 850;
}

.app-tile.orange { background: linear-gradient(135deg, #7a3516, var(--orange)); }
.app-tile.purple { background: linear-gradient(135deg, #422455, var(--purple)); }
.app-tile.green { background: linear-gradient(135deg, #174b3a, var(--green)); }
.app-tile.cyan { background: linear-gradient(135deg, #164f58, var(--cyan)); }
.app-tile.red { background: linear-gradient(135deg, #6e2421, var(--red)); }

.status-bars,
.activity-list,
.pending-list,
.client-list,
.module-launch-list {
  display: grid;
  gap: 16px;
}

.recent-activity-scroll {
  max-height: 300px;
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.recent-activity-scroll::-webkit-scrollbar {
  width: 8px;
}

.recent-activity-scroll::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 999px;
}

.recent-activity-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.status-bar {
  display: grid;
  grid-template-columns: 170px 1fr 34px;
  align-items: center;
  gap: 12px;
}

.status-bar div {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  overflow: hidden;
}

.status-bar i {
  display: block;
  height: 100%;
  min-width: 4px;
  background: linear-gradient(90deg, var(--blue), var(--gold));
}

.activity-item,
.client-row,
.setting-row {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  text-decoration: none;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease, background 180ms ease;
}

.activity-item {
  justify-content: flex-start;
}

.activity-item > span {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
}

.activity-item small,
.client-row span,
.client-row small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.quick-grid,
.pending-list.horizontal {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.quick-grid.horizontal {
  grid-template-columns: repeat(4, minmax(170px, 1fr));
}

.pending-list.horizontal {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.quick-card {
  display: grid;
  align-content: space-between;
  min-height: 116px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: #fffdf9;
  text-decoration: none;
  background: var(--blue);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.quick-card.green { background: var(--green); }
.quick-card.orange { background: var(--orange); }
.quick-card.purple { background: var(--purple); }

.quick-card span {
  display: block;
  margin-top: 8px;
  color: rgba(255, 253, 249, 0.78);
}

.pending-list div {
  display: grid;
  grid-template-columns: 52px 1fr;
  align-items: center;
  gap: 16px;
  min-height: 86px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.pending-list strong {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--blue-soft);
  color: var(--blue);
  line-height: 1;
}

.form-shell {
  display: grid;
  gap: 18px;
  padding-top: 24px;
}

.form-grid,
.definition-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.form-grid label {
  display: block;
  color: var(--muted);
  font-weight: 760;
}

.modal-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 760;
}

.form-grid label > input,
.form-grid label > select,
.form-grid label > textarea {
  margin-top: 7px;
}

.required-mark {
  color: var(--red);
  font-weight: 900;
}

.label-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.field-hint {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.45;
}

.selected-preview {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  color: var(--ink);
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 760;
}

.selected-preview.is-empty {
  color: var(--muted);
}

.span-2 {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.repeatable-group {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.repeatable-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.repeatable-list {
  display: grid;
  gap: 12px;
}

.repeatable-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.repeatable-row.single {
  grid-template-columns: minmax(0, 1fr) auto;
}

.conditional-field[hidden] {
  display: none;
}

.detail-header {
  align-items: flex-end;
}

.detail-header > .button,
.detail-header > form,
.detail-header > .hero-actions {
  flex: 0 0 auto;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid color-mix(in srgb, var(--blue) 22%, transparent);
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 850;
}

.pill.neutral {
  color: var(--ink);
  background: var(--panel-soft);
  border-color: var(--line);
}

.definition-grid div {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.definition-grid.single-column {
  grid-template-columns: 1fr;
}

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

.upload-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.upload-card label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 760;
}

.keyword-manual-row {
  margin-top: 18px;
  align-items: end;
}

.seed-review-actions,
.seed-save-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.seed-review-actions {
  justify-content: space-between;
}

.seed-save-row {
  justify-content: flex-end;
  margin-bottom: 0;
}

.keyword-table input[type="checkbox"] {
  width: auto;
}

.keyword-table {
  table-layout: auto;
  min-width: 920px;
}

.keyword-table th,
.keyword-table td {
  vertical-align: top;
}

.keyword-table td small {
  display: block;
  color: var(--muted);
  margin-top: 6px;
}

.results-table textarea,
.results-table input,
.results-table select {
  min-width: 180px;
  margin-bottom: 8px;
}

.keyword-review-panel {
  display: block;
  opacity: 1;
  transform: none;
  visibility: visible;
}

.keyword-preview-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  padding: 0;
  margin-top: 22px;
  overflow: hidden;
}

.keyword-section-heading,
.keyword-preview-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.keyword-section-heading {
  cursor: pointer;
  padding: 20px 22px;
  margin-bottom: 0;
  list-style: none;
}

.keyword-section-heading::-webkit-details-marker {
  display: none;
}

.keyword-section-heading h3 {
  margin: 0;
  font-family: var(--display-font);
  font-size: clamp(22px, 2.2vw, 30px);
}

.keyword-section-heading p {
  margin: 4px 0 0;
  color: var(--muted);
}

.section-toggle {
  display: inline-flex;
  align-items: center;
  gap: 18px;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.05;
}

.chevron {
  width: 18px;
  height: 18px;
  border-right: 3px solid currentColor;
  border-bottom: 3px solid currentColor;
  transform: rotate(45deg);
  transform-origin: center;
  transition: transform 180ms var(--ease);
}

details[open] .chevron {
  transform: rotate(225deg) translate(-2px, -2px);
}

.keyword-review-tools {
  display: flex;
  align-items: end;
  gap: 14px;
}

.keyword-review-tools label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.keyword-review-tools select {
  min-width: 190px;
  min-height: 46px;
  font-size: 14px;
  font-weight: 850;
}

.keyword-table-controls {
  display: flex;
  justify-content: flex-start;
  padding: 0 22px 16px;
}

.keyword-preview-table {
  min-width: 760px;
  background: transparent;
}

.keyword-preview-table th:first-child,
.keyword-preview-table td:first-child {
  width: 92px;
  text-align: center;
}

.data-table.keyword-preview-table th:first-child,
.data-table.keyword-preview-table td:first-child {
  width: 92px;
}

.data-table.keyword-preview-table th:nth-child(2),
.data-table.keyword-preview-table td:nth-child(2) {
  width: 46%;
}

.keyword-preview-table strong {
  overflow-wrap: anywhere;
}

.keyword-preview-table input[type="checkbox"],
.select-all-control input[type="checkbox"],
.check-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
}

.info-button,
.icon-action {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
  transition: transform 180ms var(--ease), border-color 180ms var(--ease), box-shadow 180ms var(--ease);
}

.info-button {
  border-radius: 999px;
}

.info-popover-shell {
  position: relative;
}

.info-popover {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  z-index: 20;
  width: min(460px, 80vw);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  color: var(--ink);
  box-shadow: var(--shadow);
  padding: 16px;
  font-size: 13px;
  line-height: 1.55;
  backdrop-filter: blur(14px);
}

.info-button:hover,
.icon-action:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}

.select-all-control,
.keyword-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.select-all-control {
  align-items: center;
  white-space: nowrap;
  color: var(--muted);
  font-size: 14px;
  font-weight: 850;
}

.keyword-check {
  flex: 1;
  min-width: 0;
}

.keyword-preview-actions {
  border-top: 1px solid var(--line);
  padding-top: 18px;
  margin-top: 22px;
}

.definition-grid dt {
  color: var(--muted);
  font-weight: 850;
}

.definition-grid dd {
  margin: 5px 0 0;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tag-list span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  padding: 8px 10px;
  font-weight: 760;
}

.client-overview-card {
  position: relative;
  padding-right: 58px;
}

.edit-client-overview {
  position: absolute;
  top: 18px;
  right: 18px;
  text-decoration: none;
}

.edit-client-overview svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.client-overview-card .definition-grid dt {
  color: var(--client-detail-label);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.client-overview-card .definition-grid dd {
  color: var(--ink);
  font-size: 16px;
  font-weight: 850;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.competitor-name-list {
  margin: 0;
  padding-left: 22px;
  color: var(--ink);
  display: grid;
  gap: 10px;
}

.competitor-name-list li {
  font-weight: 760;
}

.scoring-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.scoring-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 760;
}

.scoring-form .form-actions {
  grid-column: 1 / -1;
}

.scoring-source-controls {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  padding: 16px;
}

.scoring-source-controls > strong {
  display: block;
  margin-bottom: 4px;
  font-family: var(--display-font);
  font-size: 18px;
}

.scoring-source-controls p {
  margin: 0 0 12px;
  color: var(--muted);
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.custom-factor-panel {
  display: grid;
  gap: 14px;
}

.custom-factor-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1.2fr) minmax(0, 1.4fr) 130px;
  gap: 12px;
  align-items: end;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.custom-factor-row label {
  min-width: 0;
}

.add-factor-box {
  display: grid;
  gap: 14px;
}

.add-factor-box summary {
  width: max-content;
  list-style: none;
  cursor: pointer;
}

.add-factor-box summary::-webkit-details-marker {
  display: none;
}

.new-factor-row {
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.4fr) 130px;
}

.back-to-top-row {
  display: flex;
  justify-content: center;
  margin-top: 18px;
}

.back-to-top-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--ink);
  text-decoration: none;
  transition: transform 180ms var(--ease), border-color 180ms var(--ease), box-shadow 180ms var(--ease);
}

.back-to-top-button span {
  width: 14px;
  height: 14px;
  border-top: 3px solid currentColor;
  border-left: 3px solid currentColor;
  transform: translateY(3px) rotate(45deg);
}

.back-to-top-button:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}

.settings-list,
.users-panel,
.app-shelf,
.settings-section,
.scoring-panel {
  margin: 0 clamp(24px, 4vw, 52px) 28px;
}

.settings-section,
.settings-list {
  min-height: 210px;
}

.scoring-panel {
  display: grid;
  gap: 24px;
}

.module-launch {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  padding: 15px;
  text-decoration: none;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.module-launch span {
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.data-table th,
.data-table td {
  padding: 14px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.data-table th:nth-child(1),
.data-table td:nth-child(1) {
  width: 22%;
}

.data-table th:nth-child(2),
.data-table td:nth-child(2) {
  width: 21%;
}

.data-table th:nth-child(3),
.data-table td:nth-child(3) {
  width: 14%;
}

.data-table th:nth-child(4),
.data-table td:nth-child(4) {
  width: 22%;
}

.data-table th:nth-child(5),
.data-table td:nth-child(5) {
  width: 21%;
}

.data-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.data-table select {
  min-width: 0;
  max-width: 180px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 760;
}

.check-row input {
  width: auto;
}

.table-button {
  min-height: 36px;
  padding: 0 12px;
}

.table-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
}

.empty-cell {
  color: var(--muted);
  text-align: center;
}

.modal {
  width: min(680px, calc(100vw - 32px));
  border: 0;
  border-radius: 14px;
  padding: 0;
  color: var(--ink);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(15, 17, 19, 0.58);
}

.modal-card {
  display: grid;
  gap: 18px;
  padding: 22px;
}

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

.suggestion-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  padding: 12px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.suggestion-item span {
  color: var(--muted);
}

.status {
  text-transform: capitalize;
}

.configured,
.connected {
  color: var(--green);
}

.missing {
  color: var(--orange);
}

.unavailable {
  color: var(--red);
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  display: grid;
  gap: 16px;
  width: min(460px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 34px;
}

.login-panel h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 34px;
  line-height: 1.06;
}

.login-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.setup-note {
  border: 1px solid color-mix(in srgb, var(--orange) 28%, transparent);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--orange) 10%, var(--panel));
  color: var(--orange);
  padding: 12px;
}

[data-reveal] {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 620ms var(--ease), transform 620ms var(--ease);
}

[data-reveal].is-visible {
  opacity: 1;
  transform: translateY(0);
}

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

  [data-reveal] {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 1180px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

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

  .app-tile.featured {
    grid-row: auto;
    min-height: 260px;
  }
}

@media (max-width: 900px) {
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    width: 100%;
    min-height: auto;
    padding: 16px 18px;
  }

  .sidebar nav {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
  }

  .sidebar-user {
    display: none;
  }

  .main {
    margin-left: 0;
  }

  .topbar,
  .topbar-actions,
  .section-heading,
  .dashboard-hero,
  .hero-panel,
  .detail-header,
  .setting-row {
    align-items: stretch;
    flex-direction: column;
  }

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

  .search-box {
    width: 100%;
  }

  .dashboard-grid,
  .ops-row,
  .client-detail-grid,
  .form-grid,
  .definition-grid,
  .scoring-form,
  .quick-grid,
  .quick-grid.horizontal,
  .repeatable-row,
  .repeatable-row.single,
  .pending-list.horizontal {
    grid-template-columns: 1fr;
  }

  .client-detail-grid {
    grid-template-areas:
      "profile"
      "apps"
      "competitors"
      "baseline";
  }

  .status-bar {
    grid-template-columns: 1fr;
  }

  .data-table {
    min-width: 760px;
  }

  .checkbox-grid,
  .keyword-review-tools {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .keyword-review-tools select {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .metric-grid,
  .showcase-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    position: static;
  }

  .hero-copy h1,
  .hero-panel h1,
  .detail-header h1 {
    font-size: clamp(28px, 10vw, 38px);
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
  }

  .logout-link {
    padding-inline: 12px;
  }
}
