:root {
  --bg: oklch(96% 0.008 92);
  --surface: oklch(99% 0.006 92);
  --surface-2: oklch(93% 0.012 88);
  --ink: oklch(23% 0.018 105);
  --muted: oklch(48% 0.018 105);
  --line: oklch(84% 0.018 92);
  --accent: oklch(48% 0.105 165);
  --accent-ink: oklch(98% 0.006 150);
  --warn: oklch(62% 0.16 55);
  --danger: oklch(55% 0.15 28);
  --shadow: 0 18px 45px oklch(38% 0.025 92 / 12%);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, oklch(98% 0.01 100), var(--bg) 42%, oklch(91% 0.018 166)),
    var(--bg);
  font-family: "Segoe UI", system-ui, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 7px;
  padding: 0.72rem 1rem;
  color: var(--accent-ink);
  background: var(--accent);
  cursor: pointer;
  transition: transform 180ms ease, filter 180ms ease;
}

button:hover {
  filter: brightness(0.94);
}

button:active {
  transform: translateY(1px);
}

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

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 2rem 1.4rem;
  background: oklch(22% 0.018 115);
  color: oklch(95% 0.01 110);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.sidebar h1 {
  margin: 0.35rem 0 1.7rem;
  font-size: 1.55rem;
  line-height: 1.1;
  max-width: 11ch;
}

.sidebar nav {
  display: grid;
  gap: 0.55rem;
}

.sidebar a {
  color: inherit;
  text-decoration: none;
  padding: 0.7rem 0.8rem;
  border-radius: 7px;
}

.sidebar a:hover {
  background: oklch(32% 0.025 120);
}

.sidebar-note {
  color: oklch(78% 0.012 110);
  line-height: 1.5;
}

main {
  padding: 2rem;
  display: grid;
  gap: 2rem;
}

.page-section {
  display: grid;
  gap: 1rem;
}

.two-column {
  grid-template-columns: minmax(300px, 420px) minmax(320px, 1fr);
  align-items: start;
}

.section-head,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

h2,
h3,
p {
  margin: 0;
}

h2 {
  font-size: 1.55rem;
}

h3 {
  font-size: 1rem;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 0.85rem;
}

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

.metric-card {
  padding: 1rem;
  display: grid;
  gap: 0.4rem;
}

.metric-card span,
.list-item span,
.field-label,
.empty {
  color: var(--muted);
  font-size: 0.86rem;
}

.metric-card strong {
  font-size: 1.45rem;
}

.panel {
  padding: 1rem;
  display: grid;
  gap: 1rem;
}

.form-panel {
  gap: 0.9rem;
}

label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.86rem;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.75rem 0.8rem;
  color: var(--ink);
  background: oklch(100% 0.005 92);
}

input:focus,
textarea:focus {
  outline: 2px solid oklch(75% 0.09 165);
  outline-offset: 1px;
}

textarea {
  resize: vertical;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.checkline input {
  width: auto;
}

.checkbox-list,
.stack-list,
.log-list {
  display: grid;
  gap: 0.7rem;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: oklch(98% 0.006 92);
}

.list-item div {
  min-width: 0;
  display: grid;
  gap: 0.25rem;
}

.list-item strong,
.list-item span {
  overflow-wrap: anywhere;
}

.campaign-item button {
  min-width: 86px;
}

.log-row {
  display: grid;
  grid-template-columns: 72px minmax(160px, 1fr) minmax(120px, 0.7fr);
  gap: 0.75rem;
  align-items: center;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: oklch(98% 0.006 92);
}

.log-row strong {
  color: var(--accent);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.log-row[data-level="warn"] strong {
  color: var(--warn);
}

.log-row[data-level="error"] strong {
  color: var(--danger);
}

.log-row small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.preview-box {
  padding: 0.8rem;
  border-radius: 8px;
  background: var(--surface-2);
}

.image-preview {
  display: grid;
  gap: 0.45rem;
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.image-preview[hidden] {
  display: none;
}

.image-preview img {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 6px;
}

.image-preview span {
  color: var(--muted);
  font-size: 0.84rem;
  overflow-wrap: anywhere;
}

pre {
  margin: 0.45rem 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  max-width: min(420px, calc(100vw - 2rem));
  padding: 0.85rem 1rem;
  color: var(--accent-ink);
  background: oklch(26% 0.024 115);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .sidebar h1 {
    max-width: none;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }
}

@media (max-width: 560px) {
  main {
    padding: 1rem;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .section-head,
  .panel-head,
  .list-item,
  .log-row {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }
}
