:root {
  --bg: #f7f3ed;
  --surface: #fffaf2;
  --surface-strong: #ffffff;
  --text: #1f1a17;
  --muted: #665f59;
  --border: #e3d8c9;
  --accent: #7f3f2a;
  --accent-dark: #5c2d1f;
  --shadow: 0 12px 35px rgba(60, 35, 20, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }

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

a { color: var(--accent); text-decoration: none; }
a:hover, a:focus { color: var(--accent-dark); text-decoration: underline; }
button, input, select, textarea { font: inherit; }

.skip-link { position: absolute; left: -999px; top: 1rem; background: var(--surface-strong); padding: 0.75rem 1rem; z-index: 20; }
.skip-link:focus { left: 1rem; }

.site-header {
  background: rgba(255, 250, 242, 0.94);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
}

.nav {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand { color: var(--text); font-weight: 800; font-size: 1.15rem; }
.nav-links { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 0.9rem; }
.disabled-link { color: var(--muted); opacity: 0.55; }
.logout-form { margin: 0; }
.logout-form button { border: 0; background: transparent; color: var(--accent); cursor: pointer; padding: 0; }

.page-shell {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

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

.card { padding: clamp(1.25rem, 3vw, 2rem); }
.hero { padding: clamp(2rem, 6vw, 4.5rem); }
.narrow { max-width: 640px; margin: 0 auto; }
.narrow-form { max-width: 760px; margin: 0 auto; }
.auth-card { max-width: 560px; margin: 2rem auto 0; }
.page-header { margin-bottom: 1.5rem; }
.split-header { align-items: flex-start; display: flex; justify-content: space-between; gap: 1rem; }
.compact-actions { margin-top: 0; }

.eyebrow {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin: 0 0 0.5rem;
  text-transform: uppercase;
}

h1, h2 { line-height: 1.1; margin: 0 0 1rem; }
h1 { font-size: clamp(2rem, 5vw, 4rem); }
h2 { font-size: clamp(1.25rem, 3vw, 1.65rem); }
.lede { color: var(--muted); font-size: clamp(1.05rem, 2vw, 1.25rem); max-width: 760px; }
.lede.compact { font-size: 1rem; }
.metadata { color: var(--muted); }

.button-row { display: flex; flex-wrap: wrap; gap: 0.85rem; margin-top: 1.5rem; }
.button {
  align-items: center;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  font-weight: 750;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.65rem 1.1rem;
}
.button:hover, .button:focus { background: var(--accent-dark); color: #ffffff; text-decoration: none; }
.button.secondary { background: transparent; color: var(--accent); }
.button.secondary.danger { border-color: #9b2f24; color: #9b2f24; }
.button.secondary.danger:hover, .button.secondary.danger:focus { background: #9b2f24; color: #ffffff; }
.button.small { min-height: 2.2rem; padding: 0.35rem 0.85rem; }
.button.full-width { width: 100%; }

.grid { display: grid; gap: 1rem; margin-top: 1rem; }
.two-up { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three-up { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.four-up { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric-card { display: grid; gap: 0.35rem; padding: 1.35rem; }
.metric-value { font-size: 2rem; font-weight: 850; }
.metric-label { color: var(--muted); }

.form-stack { display: grid; gap: 0.75rem; margin-top: 1.25rem; }
.field-group { display: grid; gap: 0.35rem; }
.form-stack input, .form-stack select, .form-stack textarea, .filter-row input, .filter-row select {
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  padding: 0.75rem 0.9rem;
  width: 100%;
}
.form-stack input:focus, .form-stack select:focus, .form-stack textarea:focus, .filter-row input:focus, .filter-row select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(127, 63, 42, 0.12);
  outline: none;
}
.form-stack label { font-weight: 700; }
.help-text { color: var(--muted); font-size: 0.9rem; }
.help-text ul { margin: 0.35rem 0 0; padding-left: 1.25rem; }
.checkbox-field label { align-items: center; display: flex; gap: 0.5rem; }
.checkbox-field input { width: auto; }
.auth-switch { color: var(--muted); margin: 1.25rem 0 0; text-align: center; }
.errorlist { color: #8f1f1f; margin: 0; padding-left: 1.25rem; }
.filter-row { align-items: center; display: grid; gap: 0.75rem; grid-template-columns: 1fr auto auto auto; }

.messages { display: grid; gap: 0.75rem; margin-bottom: 1rem; }
.message { background: var(--surface-strong); border: 1px solid var(--border); border-radius: 12px; padding: 0.85rem 1rem; }
.message.success { border-color: #7d9d75; }
.message.warning { border-color: #c7953b; }

.detail-list { display: grid; gap: 0.75rem; margin: 1.25rem 0 0; }
.detail-list div { border-top: 1px solid var(--border); padding-top: 0.75rem; }
.detail-list dt { color: var(--muted); font-size: 0.85rem; font-weight: 700; }
.detail-list dd { margin: 0.2rem 0 0; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { border-bottom: 1px solid var(--border); padding: 0.8rem; text-align: left; }
th { color: var(--muted); font-size: 0.85rem; text-transform: uppercase; }

.record-list { display: grid; gap: 1rem; margin-top: 1rem; }
.record-card { align-items: flex-start; display: flex; justify-content: space-between; gap: 1rem; }
.record-card h2 { margin-bottom: 0.35rem; }
.record-actions { flex: 0 0 auto; }
.action-pair { display: flex; gap: 0.85rem; }
.danger-link { color: #9b2f24; }
.tag-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0; }
.badge { background: var(--surface-strong); border: 1px solid var(--border); border-radius: 999px; display: inline-flex; font-size: 0.85rem; margin: 0 0.25rem 0.25rem 0; padding: 0.2rem 0.55rem; }
.empty-state { text-align: left; }
.plain-list { display: grid; gap: 0.75rem; margin: 0; padding-left: 1.1rem; }

@media (max-width: 820px) {
  .nav { align-items: flex-start; flex-direction: column; }
  .nav-links { justify-content: flex-start; }
  .split-header, .record-card { flex-direction: column; }
  .filter-row { grid-template-columns: 1fr; }
  .two-up, .three-up, .four-up { grid-template-columns: 1fr; }
}
