/* ══════════════════════════════════════════════
   Life Dashboard — JB
   Mobile-first, dark theme
══════════════════════════════════════════════ */

:root {
  --bg:        #0f172a;
  --surface:   #1e293b;
  --surface2:  #273549;
  --border:    #334155;
  --text:      #f1f5f9;
  --text-muted:#94a3b8;
  --primary:   #3b82f6;
  --primary-d: #2563eb;
  --success:   #22c55e;
  --warning:   #f59e0b;
  --danger:    #ef4444;
  --aceno:     #a855f7;
  --radius:    14px;
  --radius-sm: 8px;
  --gap:       16px;
}

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

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  padding-bottom: 80px;
}

/* ── Header ── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 12px var(--gap);
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 600px;
  margin: 0 auto;
}

.header-title {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Tabs ── */
.tabs {
  display: flex;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 61px;
  z-index: 99;
  padding: 0 var(--gap);
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.tab {
  flex: 1;
  min-width: 70px;
  padding: 12px 8px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ── Content ── */
.tab-content {
  max-width: 600px;
  margin: 0 auto;
  padding: var(--gap);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.tab-content.hidden { display: none; }

/* ── Section header ── */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.text-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.text-btn:hover { color: var(--text); border-color: var(--text-muted); }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--gap);
}

.card-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.info-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* ── Medication Slot Card ── */
.slot-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--gap);
  transition: border-color 0.2s;
}

.slot-card.taken {
  border-color: var(--success);
  background: #0f2a1a;
}

.slot-card.slot-aceno {
  border-left: 3px solid var(--aceno);
}

.slot-card.slot-aceno.taken {
  border-color: var(--aceno);
  background: #1a0f2a;
}

.slot-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.slot-name {
  font-weight: 700;
  font-size: 1rem;
}

.slot-time {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.slot-badge {
  font-size: 1.3rem;
}

.med-list {
  list-style: none;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.med-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.med-item .med-dose {
  font-weight: 600;
  color: var(--text);
}

/* Big take button */
.take-btn {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.take-btn.untaken {
  background: var(--primary);
  color: #fff;
}

.take-btn.untaken:hover { background: var(--primary-d); }

.take-btn.taken {
  background: transparent;
  border: 1px solid var(--success);
  color: var(--success);
}

.take-btn .taken-time {
  font-size: 0.8rem;
  opacity: 0.8;
}

/* ── Health readings ── */
.readings-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.reading-item { text-align: center; }

.reading-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.reading-value {
  font-size: 1.3rem;
  font-weight: 700;
}

/* ── Forms ── */
.form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.form-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  padding: 10px 12px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}

.form-group input:focus { border-color: var(--primary); }

/* ── Buttons ── */
.btn-primary {
  display: block;
  width: 100%;
  padding: 13px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
  transition: background 0.15s;
}

.btn-primary:hover { background: var(--primary-d); }

.btn-secondary {
  padding: 11px 20px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  cursor: pointer;
}

/* ── History ── */
.history-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--gap);
}

.history-panel h3 {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.history-panel.hidden { display: none; }

.history-row {
  display: grid;
  grid-template-columns: 100px 1fr 1fr 1fr;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  align-items: center;
}

.history-row:last-child { border-bottom: none; }

.history-date { color: var(--text-muted); }

.dot-ok   { color: var(--success); font-size: 1rem; text-align: center; }
.dot-miss { color: var(--danger);  font-size: 1rem; text-align: center; }
.dot-na   { color: var(--border);  font-size: 1rem; text-align: center; }

.history-header {
  display: grid;
  grid-template-columns: 100px 1fr 1fr 1fr;
  gap: 8px;
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-muted);
  padding-bottom: 6px;
  letter-spacing: 0.06em;
}

/* Health history table */
.health-history-row {
  display: grid;
  grid-template-columns: 80px 60px 80px 70px 70px;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}

.health-history-row:last-child { border-bottom: none; }

/* ── Activities ── */
.filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-row.hidden { display: none; }

.filter-btn {
  padding: 6px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 999px;
  font-size: 0.82rem;
  cursor: pointer;
}

.filter-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.activity-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px var(--gap);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.activity-info {}
.activity-name { font-weight: 600; font-size: 0.95rem; }
.activity-meta { font-size: 0.78rem; color: var(--text-muted); margin-top: 3px; }
.activity-type {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface2);
  color: var(--text-muted);
}

/* ── Modal ── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: var(--gap);
}

.modal.hidden { display: none; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 340px;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.modal-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 14px;
}

.modal-box input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1.5rem;
  font-weight: 700;
  padding: 12px 16px;
  width: 100%;
  text-align: center;
  margin-bottom: 16px;
  outline: none;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-actions .btn-primary { margin-top: 0; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 0.9rem;
  z-index: 300;
  transition: opacity 0.3s;
  white-space: nowrap;
}

.toast.hidden { display: none; }

/* ── Utilities ── */
.hidden { display: none !important; }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 0;
  font-size: 0.9rem;
}
