/* ========================================
   Birk Family Trackers — Shared Design System
   ======================================== */

:root {
  /* Brand palette (from spec) */
  --teal: #1D9E75;
  --teal-dark: #0F6E56;
  --blue: #378ADD;
  --blue-dark: #185FA5;
  --amber: #EF9F27;
  --amber-dark: #BA7517;
  --coral: #D85A30;
  --purple: #7F77DD;
  --pink: #D4537E;

  /* Neutrals */
  --bg: #F7F7F5;
  --surface: #FFFFFF;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.16);
  --text: #1A1A1A;
  --text-muted: #6B6B6B;
  --text-faint: #A3A3A3;

  /* Status */
  --success: var(--teal);
  --warn: var(--amber);
  --danger: var(--coral);

  /* Layout */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --pad: 16px;
  --pad-lg: 24px;
  --gap: 12px;

  /* Typography */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, monospace;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--teal);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

/* ========================================
   Layout primitives
   ======================================== */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--pad);
}

.container-wide {
  max-width: 1024px;
  margin: 0 auto;
  padding: var(--pad);
}

.stack { display: flex; flex-direction: column; gap: var(--gap); }
.stack-lg { display: flex; flex-direction: column; gap: var(--pad-lg); }
.row { display: flex; gap: var(--gap); align-items: center; }
.row-between { display: flex; gap: var(--gap); align-items: center; justify-content: space-between; }
.spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--gap); }

@media (max-width: 480px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
}

/* ========================================
   Cards
   ======================================== */
.card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: var(--pad);
}

.card-lg {
  padding: var(--pad-lg);
}

.card-flat {
  background: transparent;
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: var(--pad);
}

.card-clickable {
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.card-clickable:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

/* ========================================
   Stat displays
   ======================================== */
.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-value {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.stat-value-sm { font-size: 1.25rem; }
.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ========================================
   Buttons
   ======================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 0.5px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-decoration: none;
}
.btn:hover { background: #FAFAF8; border-color: rgba(0,0,0,0.24); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--teal);
  color: white;
  border-color: var(--teal);
}
.btn-primary:hover { background: var(--teal-dark); border-color: var(--teal-dark); }

.btn-danger {
  background: var(--coral);
  color: white;
  border-color: var(--coral);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
}
.btn-ghost:hover { background: rgba(0,0,0,0.04); }

.btn-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.btn-block { width: 100%; }

.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* ========================================
   Inputs
   ======================================== */
.input,
.select,
.textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 0.5px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  -webkit-appearance: none;
  appearance: none;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(29, 158, 117, 0.15);
}
.textarea { resize: vertical; min-height: 60px; }

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.field-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ========================================
   Progress bars
   ======================================== */
.bar {
  height: 8px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--teal);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.bar-thick { height: 12px; }

/* ========================================
   Headers / Nav
   ======================================== */
.appbar {
  background: var(--surface);
  border-bottom: 0.5px solid var(--border);
  padding: 12px var(--pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: saturate(140%) blur(8px);
}
.appbar-title {
  font-weight: 600;
  font-size: 1.05rem;
}
.appbar-back {
  color: var(--text-muted);
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.appbar-back:hover { color: var(--text); text-decoration: none; }

/* ========================================
   Badges / pills
   ======================================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-muted);
}
.badge-success { background: rgba(29, 158, 117, 0.12); color: var(--teal-dark); }
.badge-warn { background: rgba(239, 159, 39, 0.14); color: var(--amber-dark); }
.badge-danger { background: rgba(216, 90, 48, 0.12); color: var(--coral); }

/* ========================================
   Tables
   ======================================== */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.table th, .table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 0.5px solid var(--border);
}
.table th {
  font-weight: 500;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.table tr:last-child td { border-bottom: none; }
.table-tight th, .table-tight td { padding: 6px; }

/* ========================================
   Utilities
   ======================================== */
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.text-success { color: var(--teal-dark); }
.text-warn { color: var(--amber-dark); }
.text-danger { color: var(--coral); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.78rem; }
.bold { font-weight: 600; }
.center { text-align: center; }
.right { text-align: right; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.hidden { display: none !important; }

/* ========================================
   Toast / alerts
   ======================================== */
.alert {
  padding: 12px var(--pad);
  border-radius: var(--radius-sm);
  border: 0.5px solid var(--border);
  background: var(--surface);
  font-size: 0.9rem;
}
.alert-warn { background: rgba(239, 159, 39, 0.08); border-color: rgba(239, 159, 39, 0.3); color: var(--amber-dark); }
.alert-danger { background: rgba(216, 90, 48, 0.08); border-color: rgba(216, 90, 48, 0.3); color: var(--coral); }
.alert-success { background: rgba(29, 158, 117, 0.08); border-color: rgba(29, 158, 117, 0.3); color: var(--teal-dark); }

/* ========================================
   Color dots (muscle group, habit indicators, etc)
   ======================================== */
.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

/* iOS-friendly tap targets */
button, .btn, a.btn, input[type=checkbox], input[type=radio] {
  min-height: 36px;
}

/* PWA / standalone-mode tweaks */
@media (display-mode: standalone) {
  body { padding-top: env(safe-area-inset-top); }
}
