:root {
  color-scheme: light;
  --bg: #f7f7f4;
  --surface: #ffffff;
  --surface-soft: #ecefeb;
  --ink: #232823;
  --muted: #697067;
  --line: #d9ded7;
  --accent: #196b69;
  --accent-strong: #0f4f4d;
  --accent-soft: #dcefed;
  --warning: #9f5b18;
  --danger: #a33d3d;
  --shadow: 0 18px 45px rgba(36, 43, 37, 0.11);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

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;
  padding: 22px 18px;
  background: #f0f2ef;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 750;
}

.brand-name {
  font-size: 1.1rem;
  font-weight: 750;
}

.brand-subtitle,
.eyebrow,
.metric-label,
.metric-note,
.quiet-copy {
  color: var(--muted);
}

.brand-subtitle,
.metric-note {
  font-size: 0.85rem;
}

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

.nav-item {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.nav-item:hover,
.nav-item.is-active {
  background: var(--surface);
  border-color: var(--line);
}

.nav-item.is-active {
  box-shadow: 0 1px 2px rgba(30, 36, 31, 0.08);
  color: var(--accent-strong);
  font-weight: 700;
}

.main {
  width: min(1160px, 100%);
  padding: 26px clamp(16px, 3vw, 36px) 96px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 78px;
  margin-bottom: 18px;
}

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

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.88rem;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.1rem);
  line-height: 1;
  letter-spacing: 0;
}

h2,
h3 {
  margin-bottom: 0;
  letter-spacing: 0;
}

.view {
  display: none;
}

.view.is-visible {
  display: block;
}

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

.panel-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  margin-top: 14px;
}

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

.metric-card {
  display: grid;
  gap: 6px;
  min-height: 132px;
  padding: 18px;
}

.metric-value {
  font-size: 2.5rem;
  line-height: 1;
}

.panel {
  padding: 18px;
}

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

.quick-actions,
.data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-action,
.secondary-action,
.install-button,
.file-import {
  min-height: 42px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 700;
}

.primary-action,
.install-button {
  background: var(--accent);
  color: #fff;
}

.primary-action:hover,
.install-button:hover {
  background: var(--accent-strong);
}

.secondary-action,
.file-import {
  display: inline-flex;
  align-items: center;
  background: var(--surface-soft);
  border-color: var(--line);
  color: var(--ink);
}

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

.stack-form,
.check-list,
.history-list,
.recent-list {
  display: grid;
  gap: 10px;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

input,
select {
  min-height: 42px;
  padding: 0 11px;
}

textarea {
  resize: vertical;
  padding: 10px 11px;
}

input[type="range"] {
  padding: 0;
  accent-color: var(--accent);
}

.range-value {
  color: var(--ink);
}

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

.check-row,
.history-row,
.recent-row {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbf9;
}

.check-row {
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
}

.check-row input {
  width: 20px;
  height: 20px;
  min-height: 20px;
  accent-color: var(--accent);
}

.row-title {
  font-weight: 750;
}

.row-meta {
  color: var(--muted);
  font-size: 0.88rem;
}

.row-actions {
  display: flex;
  gap: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.status-pill.is-good {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.status-pill.is-warn {
  background: #f7eadb;
  color: var(--warning);
}

.status-pill.is-bad {
  background: #f7dddd;
  color: var(--danger);
}

.icon-button {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.compact-action {
  width: auto;
  min-height: 34px;
  padding: 0 10px;
}

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

.file-import input {
  display: none;
}

.quiet-copy {
  margin: 14px 0 0;
  max-width: 62ch;
  line-height: 1.5;
}

.compact-copy {
  min-height: 20px;
  margin-top: 10px;
  font-size: 0.9rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 10;
    height: auto;
    padding: 8px max(8px, env(safe-area-inset-left)) calc(8px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-right));
    border-top: 1px solid var(--line);
    border-right: 0;
  }

  .brand {
    display: none;
  }

  .nav-list {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 4px;
  }

  .nav-item {
    min-height: 44px;
    padding: 0 3px;
    text-align: center;
    font-size: 0.78rem;
  }

  .main {
    padding-top: calc(18px + env(safe-area-inset-top));
  }

  .topbar {
    min-height: 66px;
  }

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

  .metric-card {
    min-height: 112px;
  }
}

@media (max-width: 460px) {
  .nav-item {
    font-size: 0.7rem;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    display: grid;
  }

  .quick-actions,
  .data-actions {
    display: grid;
  }

  .primary-action,
  .secondary-action,
  .install-button,
  .file-import {
    width: 100%;
    justify-content: center;
  }
}
