:root {
  --bg: oklch(0.985 0.004 250);
  --surface: oklch(1 0 0);
  --surface-2: oklch(0.965 0.006 250);
  --ink: oklch(0.19 0.018 255);
  --muted: oklch(0.46 0.018 255);
  --line: oklch(0.88 0.01 255);
  --accent: oklch(0.55 0.16 155);
  --accent-soft: oklch(0.92 0.055 155);
  --accent-ink: oklch(0.98 0.01 155);
  --warning: oklch(0.68 0.16 70);
  --danger: oklch(0.58 0.2 25);
  --success: oklch(0.55 0.16 155);
  --shadow: 0 18px 40px oklch(0.28 0.018 255 / 0.08);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: inherit;
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 20px 16px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 4px 20px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: var(--accent-ink);
  font-weight: 800;
  letter-spacing: 0;
}

.brand strong,
.brand span {
  display: block;
}

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

.nav {
  display: grid;
  gap: 4px;
}

.nav a {
  border-radius: 8px;
  color: var(--muted);
  padding: 10px 12px;
  text-decoration: none;
}

.nav a:hover,
.nav a.active {
  background: var(--surface-2);
  color: var(--ink);
}

.main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 20px;
}

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

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 19px;
}

h3 {
  font-size: 15px;
}

.topbar p,
.section-heading span,
.panel-heading span {
  color: var(--muted);
}

.health {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  padding: 7px 12px;
  white-space: nowrap;
}

.health.ok {
  border-color: var(--accent);
  color: var(--success);
}

.section {
  scroll-margin-top: 24px;
  margin-bottom: 28px;
}

.section-heading,
.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 12px;
}

.grid {
  display: grid;
  gap: 16px;
}

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

.panel,
.metric,
.export-link {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  padding: 14px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
  line-height: 1;
}

.task-form,
.filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 12px;
}

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

label.wide {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 9px 10px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px oklch(0.55 0.16 155 / 0.16);
}

.form-actions {
  display: flex;
  gap: 10px;
  grid-column: 1 / -1;
}

.primary-button,
.secondary-button,
.segmented button {
  min-height: 36px;
  border-radius: 8px;
  padding: 8px 12px;
}

.primary-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

.secondary-button,
.segmented button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.secondary-button:hover,
.segmented button:hover {
  background: var(--surface-2);
}

.segmented {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segmented button {
  border: 0;
  border-radius: 0;
  min-height: 34px;
}

.segmented button.active {
  background: var(--ink);
  color: white;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.num {
  text-align: right;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 2px 8px;
  font-size: 12px;
  white-space: nowrap;
}

.badge.good {
  background: var(--accent-soft);
  color: oklch(0.35 0.13 155);
}

.copy-code {
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  background: var(--surface-2);
  padding: 4px 7px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.ad-feed {
  display: grid;
  gap: 10px;
}

.ad-item {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.thumb {
  width: 58px;
  height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  object-fit: cover;
}

.thumb.empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 11px;
}

.ad-title {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.muted {
  color: var(--muted);
}

.domain-link {
  color: oklch(0.42 0.14 155);
  font-weight: 700;
  text-decoration: none;
}

.filters {
  align-items: end;
  margin-bottom: 12px;
}

.export-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.export-link {
  display: grid;
  gap: 4px;
  padding: 16px;
  text-decoration: none;
}

.export-link span {
  color: var(--muted);
}

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

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

  .nav {
    display: flex;
    overflow: auto;
  }

  .metrics,
  .grid.two,
  .task-form,
  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .main {
    padding: 16px;
  }

  .topbar,
  .section-heading,
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .metrics,
  .task-form,
  .filters {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
