:root {
  --green: #2d7a2d;
  --green-bg: #e8f5e9;
  --yellow: #7a6200;
  --yellow-bg: #fff9c4;
  --red: #b71c1c;
  --red-bg: #ffebee;
  --primary: #1565c0;
  --primary-hover: #0d47a1;
  --border: #ddd;
  --text: #222;
  --muted: #666;
  --bg: #f5f5f5;
  --card: #fff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}

/* ── NAVBAR ── */
.navbar {
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 52px;
}
.nav-brand { color: #fff; font-size: 1.1rem; font-weight: 600; text-decoration: none; }
.nav-links { display: flex; gap: 1rem; align-items: center; }
.nav-links a { color: rgba(255,255,255,.9); text-decoration: none; }
.nav-links a:hover { color: #fff; text-decoration: underline; }
.btn-link {
  background: none; border: none; color: rgba(255,255,255,.9);
  cursor: pointer; font-size: 14px; padding: 0;
}
.btn-link:hover { color: #fff; text-decoration: underline; }

/* ── CONTAINER ── */
.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }

/* ── PAGE HEADER ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
  gap: .5rem;
}
.page-header h1 { font-size: 1.4rem; }
.header-actions { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.inline-form { display: flex; align-items: center; gap: .5rem; }

/* ── BUTTONS ── */
.btn {
  display: inline-block;
  padding: .45rem .9rem;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: #e0e0e0; color: #333; }
.btn-secondary:hover { background: #d0d0d0; }
.btn-danger { background: #e53935; color: #fff; }
.btn-danger:hover { background: #c62828; }
.btn-sm { padding: .28rem .6rem; font-size: 12px; }
.btn-block { width: 100%; }

/* ── TABLE ── */
.table-wrapper { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
}
.data-table th {
  background: #f0f0f0;
  text-align: left;
  padding: .6rem .8rem;
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: .55rem .8rem;
  border-bottom: 1px solid #eee;
  vertical-align: middle;
}
.data-table tbody tr:hover { background: rgba(0,0,0,.02); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* zone row tints */
.zone-green td:nth-child(4) { /* only badge */ }
.zone-yellow td:nth-child(4) { }
.zone-red td:nth-child(4) { }

/* ── BADGES ── */
.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-ok { background: var(--green-bg); color: var(--green); }
.badge-warn { background: var(--red-bg); color: var(--red); cursor: default; }

/* row background by zone */
tr.zone-green { background: #f1fbf1; }
tr.zone-yellow { background: #fffde7; }
tr.zone-red { background: #fff5f5; }

/* ── FORMS ── */
.form-section {
  background: var(--card);
  border-radius: 6px;
  padding: 1.2rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.form-section h2 { font-size: 1rem; margin-bottom: .8rem; color: var(--primary); border-bottom: 1px solid #eee; padding-bottom: .4rem; }
.form-group { margin-bottom: .8rem; }
.form-group label { display: block; font-size: 13px; color: var(--muted); margin-bottom: .25rem; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: .45rem .6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
  background: #fff;
}
.form-group textarea { resize: vertical; }
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 140px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .8rem; }

.entry-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .5rem;
  flex-wrap: wrap;
}
.select-wide { flex: 1; min-width: 180px; padding: .4rem .5rem; border: 1px solid var(--border); border-radius: 4px; }

.activity-group { display: flex; gap: 1rem; padding-top: .3rem; }
.activity-label { display: flex; align-items: center; gap: .3rem; cursor: pointer; }

.form-actions { display: flex; justify-content: flex-end; gap: .75rem; margin-top: 1rem; }

.compact-form { max-width: 400px; }
.compact-form .form-group input { max-width: 100%; }

/* ── LAYOUT ── */
.two-col { display: grid; grid-template-columns: 360px 1fr; gap: 1.5rem; align-items: start; }
@media (max-width: 700px) { .two-col { grid-template-columns: 1fr; } }

/* ── LOGIN ── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box {
  background: var(--card);
  border-radius: 8px;
  padding: 2rem;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 2px 10px rgba(0,0,0,.15);
}
.login-box h1 { text-align: center; margin-bottom: 1.5rem; font-size: 1.4rem; }

/* ── MISC ── */
.required { color: #e53935; }
.notes-cell { max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.actions-cell { white-space: nowrap; }
.empty-state { padding: 2rem; text-align: center; color: var(--muted); }
.alert { padding: .75rem 1rem; border-radius: 4px; margin-bottom: 1rem; font-size: 13px; }
.alert-error { background: var(--red-bg); color: var(--red); }
.text-warn { color: var(--red); font-weight: 600; }
.muted { color: var(--muted); }

/* ── REPORT ── */
.report-form { margin-bottom: 1.5rem; }
.section-title { font-size: 1rem; font-weight: 600; color: var(--primary); margin: 1.4rem 0 .6rem; }

.summary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .8rem; margin-bottom: .5rem; }
.summary-card { background: var(--card); border-radius: 6px; padding: .9rem 1rem; box-shadow: 0 1px 3px rgba(0,0,0,.08); text-align: center; }
.summary-label { font-size: 11px; color: var(--muted); margin-bottom: .3rem; }
.summary-value { font-size: 1.3rem; font-weight: 700; }

.report-table th, .report-table td { font-size: 12px; padding: .4rem .6rem; }
.list-cell { min-width: 140px; }
.list-cell div { white-space: nowrap; line-height: 1.6; }

.wellbeing-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.wellbeing-grid h3 { font-size: .9rem; margin-bottom: .7rem; color: var(--muted); }
.stat-row { display: flex; align-items: center; gap: .5rem; margin-bottom: .4rem; }
.stat-label { width: 80px; font-size: 12px; flex-shrink: 0; }
.stat-bar-wrap { flex: 1; background: #e8e8e8; border-radius: 3px; height: 10px; overflow: hidden; }
.stat-bar { background: var(--primary); height: 100%; border-radius: 3px; min-width: 4px; }
.stat-bar-warn { background: var(--red); }
.stat-count { font-size: 12px; color: var(--muted); width: 40px; text-align: right; flex-shrink: 0; }
.activity-summary { display: flex; align-items: baseline; gap: .3rem; margin: .5rem 0 .2rem; }
.activity-big { font-size: 2rem; font-weight: 700; color: var(--primary); }
.activity-sub { font-size: 13px; color: var(--muted); }
.activity-minmax { font-size: 12px; color: var(--muted); }

/* ── PRINT ── */
@media print {
  .no-print { display: none !important; }
  .print-only { display: block !important; }
  body { background: #fff; font-size: 11px; }
  .container { padding: 0; max-width: 100%; }
  .data-table { box-shadow: none; }
  .data-table th, .data-table td { padding: .3rem .4rem; font-size: 10px; }
  .form-section { box-shadow: none; border: 1px solid #ddd; }
  .summary-card { box-shadow: none; border: 1px solid #ddd; }
  .report-table { page-break-inside: auto; }
  .report-table tr { page-break-inside: avoid; }
  h2.section-title { page-break-before: auto; }
}
.alert-success { background: var(--green-bg); color: var(--green); }
.alert-warning { background: var(--yellow-bg); color: var(--yellow); border-radius: 4px; padding: .75rem 1rem; font-size: 13px; margin-bottom: .8rem; }

.backup-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.restore-section { grid-column: 1 / -1; }
.muted-text { color: var(--muted); font-size: 13px; margin-bottom: .3rem; }
.code-block { background: #f0f0f0; border-radius: 4px; padding: .6rem .9rem; font-family: monospace; font-size: 12px; white-space: pre-wrap; word-break: break-all; }
