:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-soft: #eef4ef;
  --text: #17211c;
  --muted: #5e6b64;
  --border: #d7ddd6;
  --primary: #176b57;
  --primary-dark: #0d4d3e;
  --accent: #b87718;
  --danger: #b42318;
  --success: #18794e;
  --focus: #1d74d8;
  --shadow: 0 18px 45px rgba(23, 33, 28, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

button,
input,
select,
textarea {
  border-radius: 8px;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -80px;
  z-index: 10;
  padding: 10px 14px;
  background: var(--text);
  color: white;
}

.skip-link:focus {
  top: 16px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 24px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

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

h1 {
  margin-bottom: 6px;
  font-size: clamp(1.65rem, 4vw, 2.35rem);
  line-height: 1.1;
}

h2 {
  margin-bottom: 4px;
  font-size: 1.4rem;
}

h3 {
  margin-bottom: 8px;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.subtle,
.help {
  color: var(--muted);
}

.help {
  font-size: 0.82rem;
}

.status-pill {
  min-width: 160px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  text-align: center;
  font-weight: 700;
}

.status-pill.ok {
  border-color: rgba(24, 121, 78, 0.35);
  background: #e7f6ed;
  color: var(--success);
}

.status-pill.error {
  border-color: rgba(180, 35, 24, 0.35);
  background: #fff0ee;
  color: var(--danger);
}

.layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 20px;
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 20px clamp(12px, 3vw, 32px) 40px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.settings-panel {
  padding: 16px;
}

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

.nav-button {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 13px 14px;
  text-align: left;
  cursor: pointer;
  font-weight: 700;
}

.nav-button.active {
  border-color: var(--primary);
  background: var(--surface-soft);
  color: var(--primary-dark);
}

.workspace {
  min-width: 0;
}

.tab-panel {
  display: none;
  padding: clamp(16px, 3vw, 24px);
}

.tab-panel.active {
  display: block;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.metric-grid,
.split {
  display: grid;
  gap: 12px;
}

.metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.metric {
  padding: 16px;
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 1.6rem;
}

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

.surface {
  padding: 16px;
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--text);
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: #fbfcfa;
  color: var(--text);
  padding: 11px 12px;
}

textarea {
  resize: vertical;
}

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

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

.check input {
  width: auto;
}

button {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #ffffff;
  padding: 11px 14px;
  cursor: pointer;
  font-weight: 800;
}

button.secondary {
  border-color: var(--border);
  background: var(--surface);
  color: var(--primary-dark);
}

button.danger {
  border-color: var(--danger);
  background: var(--danger);
}

button:disabled {
  cursor: progress;
  opacity: 0.7;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.toolbar {
  margin: 14px 0;
}

.list {
  display: grid;
  gap: 10px;
}

.list-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 14px;
}

.list-item-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--primary-dark);
  font-size: 0.82rem;
  font-weight: 800;
}

.empty {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: sticky;
  top: 8px;
  z-index: 2;
  margin-bottom: 12px;
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--text);
  color: #ffffff;
}

.toast.error {
  background: var(--danger);
}

.toast.success {
  background: var(--success);
}

.output {
  max-height: 360px;
  overflow: auto;
  margin: 16px 0 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #111814;
  color: #e9f6ef;
  padding: 16px;
  white-space: pre-wrap;
}

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

  .sidebar {
    position: static;
  }

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

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

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-pill {
    width: 100%;
  }

  .layout {
    padding-inline: 10px;
  }

  .tab-panel,
  .settings-panel {
    padding: 14px;
  }

  .nav-list,
  .metric-grid,
  .split,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .section-heading {
    flex-direction: column;
  }

  .button-row,
  .button-row button {
    width: 100%;
  }

  button {
    min-height: 44px;
  }
}
