:root {
  --forest: #2F4F3E;
  --forest-dark: #243d30;
  --gold: #C4A574;
  --brown: #8B5A2B;
  --cream: #F7F3EB;
  --card: #FFFFFF;
  --text: #1a241c;
  --muted: #5a6b60;
  --border: #d4cbb8;
  --danger: #b33a3a;
  --warn: #b87a1a;
  --ok: #2d7a4f;
  --accent: #3d6b8a;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(47, 79, 62, 0.08);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--cream);
  color: var(--text);
  min-height: 100dvh;
  padding-bottom: calc(72px + var(--safe-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--forest); }

.app-header {
  position: sticky; top: 0; z-index: 40;
  background: var(--forest);
  color: #fff;
  padding: 12px 16px 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,.2);
}
.app-header h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.app-header .sub {
  font-size: 0.75rem;
  opacity: 0.85;
  margin-top: 2px;
}
.header-actions {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px;
}
.header-actions .btn {
  background: rgba(255,255,255,.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,.25);
}
.header-actions .btn.primary {
  background: var(--gold);
  color: var(--forest-dark);
  border-color: var(--gold);
  font-weight: 700;
}

.nav-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 10px 12px 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tabs button {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
}
.nav-tabs button.active {
  background: var(--forest);
  color: #fff;
  border-color: var(--forest);
}

main { padding: 12px 14px 24px; max-width: 720px; margin: 0 auto; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card h2, .section-title {
  margin: 0 0 10px;
  font-size: 1.05rem;
  color: var(--forest);
}
.card h3 { margin: 0 0 6px; font-size: 1rem; }
.muted { color: var(--muted); font-size: 0.9rem; }
.row-between {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: flex-start;
}

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
@media (min-width: 520px) {
  .metrics { grid-template-columns: repeat(4, 1fr); }
}
.metric {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.metric .val { font-size: 1.35rem; font-weight: 700; color: var(--forest); }
.metric .lbl { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.metric.warn .val { color: var(--warn); }
.metric.danger .val { color: var(--danger); }
.metric.ok .val { color: var(--ok); }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 14px;
  min-height: 44px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.98); }
.btn.primary {
  background: var(--forest);
  color: #fff;
  border-color: var(--forest);
}
.btn.gold {
  background: var(--gold);
  color: var(--forest-dark);
  border-color: var(--gold);
}
.btn.danger { color: var(--danger); border-color: #e0b4b4; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.block { width: 100%; }

.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}
.field textarea { min-height: 88px; resize: vertical; }

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e8efe9;
  color: var(--forest);
}
.badge.danger { background: #fce8e8; color: var(--danger); }
.badge.warn { background: #fff3e0; color: var(--warn); }
.badge.ok { background: #e6f5ec; color: var(--ok); }
.badge.accent { background: #e4eef5; color: var(--accent); }

.alpha {
  display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0 12px;
}
.alpha button {
  min-width: 36px; min-height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 13px;
  cursor: pointer;
}
.alpha button.on {
  background: var(--forest);
  color: #fff;
  border-color: var(--forest);
}

.list-item {
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
}
.list-item:last-child { border-bottom: none; }
.list-item .title { font-weight: 650; }
.list-item .detail { font-size: 0.9rem; color: var(--muted); margin-top: 2px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(80px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--forest);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  max-width: 90vw;
  text-align: center;
}

.fab-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  padding: 8px 12px calc(8px + var(--safe-bottom));
  display: flex; justify-content: center; gap: 8px;
}

.install-banner {
  background: linear-gradient(135deg, var(--forest), var(--forest-dark));
  color: #fff;
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.install-banner h3 { margin: 0 0 6px; color: #fff; }
.install-banner ol { margin: 8px 0 0; padding-left: 1.2rem; font-size: 0.9rem; line-height: 1.45; }
.install-banner .btn { margin-top: 10px; }

.filters {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0;
}
.filters .field { flex: 1 1 140px; margin-bottom: 0; }

.pager {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
table.data th, table.data td {
  text-align: left;
  padding: 6px 4px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.data th { color: var(--muted); font-size: 0.75rem; }

.print-sheet {
  background: #fff;
  color: #000;
  border: 1px solid #000;
  padding: 16px;
  margin-bottom: 16px;
  font-family: Georgia, "Times New Roman", serif;
}
.print-sheet table { width: 100%; border-collapse: collapse; }
.print-sheet th {
  border-bottom: 2px solid #000;
  text-align: left;
  font-size: 11px;
  padding: 4px;
}
.print-sheet td {
  border-bottom: 1px solid #333;
  height: 28px;
  font-size: 12px;
  padding: 2px 4px;
}
.check {
  display: inline-block;
  width: 14px; height: 14px;
  border: 1.5px solid #000;
  margin-right: 6px;
  vertical-align: middle;
}

.hidden { display: none !important; }
.grid-2 { display: grid; gap: 12px; }
@media (min-width: 560px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

@media print {
  .app-header, .nav-tabs, .fab-bar, .toast, .no-print, .install-banner { display: none !important; }
  body { padding: 0; background: #fff; }
  main { max-width: none; padding: 0; }
  .print-sheet { border: none; box-shadow: none; page-break-inside: avoid; }
}
