:root {
  --bg: #f4efe8;
  --bg-strong: #efe5d9;
  --panel: rgba(255, 252, 247, 0.94);
  --panel-muted: #f8f2e9;
  --ink: #1c1814;
  --muted: #6e665e;
  --line: #dfd4c6;
  --accent: #145c48;
  --accent-strong: #0d4838;
  --accent-soft: #dceddf;
  --danger: #8c3030;
  --danger-soft: #f6e4e4;
  --shadow: 0 18px 40px rgba(54, 36, 18, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  background:
    radial-gradient(circle at top right, rgba(20, 92, 72, 0.1), transparent 26%),
    radial-gradient(circle at bottom left, rgba(179, 131, 76, 0.08), transparent 28%),
    linear-gradient(180deg, var(--bg-strong) 0%, var(--bg) 50%, #f1e8db 100%);
}

a {
  color: inherit;
}

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

.app-shell {
  padding: 1rem;
}

.page {
  max-width: 720px;
  margin: 0 auto;
}

.site-header,
.panel,
.stat-card,
.table-card {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.site-header {
  max-width: 720px;
  margin: 0 auto 1rem;
  padding: 0.9rem 1rem;
  display: grid;
  gap: 0.85rem;
}

.brand,
.site-nav a {
  text-decoration: none;
}

.brand {
  font-size: 1.35rem;
  font-weight: 700;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}

.button,
.button-link,
.nav-button,
button,
input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0.7rem 1rem;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
}

.button:hover,
.button-link:hover,
.nav-button:hover,
button:hover,
input[type="submit"]:hover {
  background: var(--accent-strong);
}

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

.button-secondary:hover {
  background: #f3ece3;
}

.nav-button {
  min-height: 40px;
  padding: 0.55rem 0.9rem;
}

.flash {
  margin-bottom: 1rem;
  padding: 0.95rem 1rem;
  border-radius: 18px;
  border: 1px solid transparent;
}

.flash-notice {
  background: var(--accent-soft);
  border-color: #bdd7c8;
}

.flash-alert {
  background: var(--danger-soft);
  border-color: #ebc8c8;
  color: var(--danger);
}

.page-section {
  margin-bottom: 0.85rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
  color: var(--muted);
  font-weight: 700;
}

.back-link::before {
  content: "\2039";
  font-size: 1.2rem;
}

.panel,
.table-card,
.stat-card {
  padding: 1rem;
}

.hero {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 1rem;
  margin-bottom: 0.9rem;
}

.history-hero {
  display: grid;
  gap: 0.75rem;
}

.history-hero-stats {
  display: grid;
  gap: 0.75rem;
}

.mobile-hero,
.stack > *,
.stats-grid,
.quick-log-grid,
.mobile-action-stack {
  margin-bottom: 0.9rem;
}

.page-title,
.mobile-hero h1 {
  margin: 0 0 0.75rem;
  line-height: 0.95;
  font-size: clamp(2.1rem, 8vw, 3.3rem);
}

.eyebrow {
  margin: 0 0 0.55rem;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.lead,
.muted,
.hero-kpi span,
.field-hint,
.empty {
  color: var(--muted);
}

.lead,
.panel p,
.table-card p {
  line-height: 1.6;
}

.mobile-hero-grid,
.stats-grid,
.quick-log-grid,
.onboarding-summary,
.form-grid,
.list-grid {
  display: grid;
  gap: 0.75rem;
}

.mobile-hero-grid {
  margin-top: 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.hero-kpi,
.mini-stat {
  padding: 1rem;
  border-radius: 18px;
  background: var(--panel-muted);
  border: 1px solid var(--line);
  display: grid;
  gap: 0.2rem;
}

.hero-kpi strong,
.stat-card .value,
.onboarding-summary strong {
  font-size: 1.9rem;
}

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

.compact-panel h2,
.action-panel h2,
.table-card h2,
.panel h2 {
  margin: 0 0 0.45rem;
  font-size: 1.35rem;
}

.quick-log-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.65rem;
  margin-top: 1rem;
}

.quick-log-form input[type="number"] {
  text-align: center;
  font-size: 1.1rem;
}

.mobile-action-stack {
  display: grid;
  gap: 0.75rem;
}

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

.action-panel .button {
  flex-shrink: 0;
}

.stack {
  display: grid;
  gap: 0.9rem;
}

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

.field {
  display: grid;
  gap: 0.45rem;
}

.field label {
  font-weight: 700;
}

input[type="date"],
input[type="email"],
input[type="number"],
input[type="password"],
input[type="search"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.85rem 0.95rem;
  background: #fffdfa;
  color: var(--ink);
}

textarea {
  min-height: 110px;
  resize: vertical;
}

.actions,
.inline-actions,
.split,
.hero-actions {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.split {
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.9rem;
}

.summary-label {
  font-size: 0.9rem;
  color: var(--muted);
}

.onboarding-summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 1rem;
}

.simple-list {
  display: grid;
  gap: 0.7rem;
}

.simple-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.9rem;
  padding: 0.9rem 0;
  border-top: 1px solid var(--line);
}

.simple-item:first-child {
  border-top: none;
  padding-top: 0;
}

.simple-item:last-child {
  padding-bottom: 0;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 0.8rem 0;
  border-top: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.table thead th {
  border-top: none;
  font-size: 0.9rem;
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: #ece5da;
}

.pill-success {
  background: var(--accent-soft);
}

.meter {
  height: 10px;
  margin-top: 0.45rem;
  border-radius: 999px;
  overflow: hidden;
  background: #e7ddd0;
}

.meter span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.empty {
  padding: 0.3rem 0;
}

.errors {
  margin-bottom: 0.85rem;
  padding: 0.85rem 0.95rem;
  border-radius: 18px;
  border: 1px solid #ebc8c8;
  background: var(--danger-soft);
  color: var(--danger);
}

.errors ul {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
}

@media (min-width: 721px) {
  .app-shell {
    padding: 1.5rem;
  }

  .page,
  .site-header {
    max-width: 980px;
  }

  .site-header {
    grid-template-columns: auto 1fr;
    align-items: center;
  }

  .site-nav {
    justify-content: flex-end;
  }

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

  .stack {
    gap: 1rem;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 0.85rem;
  }

  .mobile-hero-grid,
  .quick-log-grid,
  .compact-stats,
  .onboarding-summary {
    grid-template-columns: 1fr;
  }

  .quick-log-form {
    grid-template-columns: 1fr;
  }

  .action-panel,
  .simple-item,
  .split {
    flex-direction: column;
    align-items: stretch;
  }

  .table,
  .table thead,
  .table tbody,
  .table tr,
  .table th,
  .table td {
    display: block;
    width: 100%;
  }

  .table thead {
    display: none;
  }

  .table td {
    padding: 0.4rem 0 0.65rem;
  }
}
