/* ---------- Theme Tokens ---------- */
:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e5e7eb;
  --brand: #4f46e5;
  --brand-2: #7c78ff;
  --shadow: 0 8px 28px rgba(2, 6, 23, 0.06);
  --radius: 14px;
}

.dark {
  --bg: #0b1220;
  --card: #0f172a;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --border: #1f2937;
  --brand: #818cf8;
  --brand-2: #a5b4fc;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
}

/* ---------- Reset ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial;
  color: var(--text);
  background:
    radial-gradient(90rem 60rem at 10% -20%, #1f2937 0%, transparent 35%),
    radial-gradient(60rem 40rem at 110% 10%, #111827 0%, transparent 35%),
    linear-gradient(120deg, var(--bg), var(--bg));
  transition: background .3s, color .3s;
}

/* --- Attractive Aurora BG for LIGHT mode only --- */
body:not(.dark) {
  background:
    radial-gradient(1200px 800px at -10% -20%, #eaf2ff 0%, transparent 60%),
    radial-gradient(900px 600px at 120% 0%,   #ffe9f2 0%, transparent 55%),
    radial-gradient(700px 500px at 50% 120%,  #e8fff5 0%, transparent 55%),
    linear-gradient(180deg, #fbfdff 0%, #f6f8ff 45%, #f7f7fb 100%);
  transition: background .4s ease, color .3s ease;
}

/* Optional: subtle dot grid overlay for depth */
.page::before {
  content: "";
  position: fixed; inset: 0; z-index: -1;
  background-image: radial-gradient(#00000010 1px, transparent 1px);
  background-size: 18px 18px;
  pointer-events: none;
}

/* ---------- Layout ---------- */
.page { padding: 18px; }
.container {
  max-width: 980px;
  margin: 16px auto;
  display: grid;
  gap: 16px;
}
.hidden { display: none !important; }

/* ---------- Header ---------- */
.header {
  max-width: 980px; margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; letter-spacing: .2px; }
.logo-pill { font-size: 22px; }
.brand-text { font-size: 16px; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  background: rgba(255,255,255,.15); color:#fff;
  border: 1px solid rgba(255,255,255,.25);
  outline: none; cursor: pointer;
  border-radius: 999px; padding: 8px 10px;
  transition: transform .15s ease, background .2s ease;
}
.icon-btn:hover { transform: translateY(-1px); background: rgba(255,255,255,.28); }
.auth-area { display:flex; gap: 8px; }

/* ---------- Cards & Sections ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}
.section-header { display:flex; align-items:center; justify-content:space-between; gap: 8px; margin-bottom: 12px; }
.section-title { display:flex; align-items:center; gap: 10px; }
.section-title h2 { margin: 0; font-size: 18px; }
.section-actions { display:flex; align-items:center; gap: 8px; }
.emoji { font-size: 18px; }

/* ---------- Forms ---------- */
.field { display:flex; flex-direction:column; gap:6px; }
.field > span { font-size: 12px; color: var(--muted); }
input[type="text"], input[type="number"], input[type="time"], input[type="password"] {
  background: rgba(255,255,255,.7);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
}
.dark input[type="text"], .dark input[type="number"], .dark input[type="time"], .dark input[type="password"] {
  background: #0b1020;
}
.grid-2 { display:grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display:grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid-4 { display:grid; grid-template-columns: 2fr 2fr 1fr 1fr; gap: 10px; align-items:end; }
.grid-2-col { display:grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.align-end { align-self: end; }
@media (max-width: 900px) {
  .grid-4 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-2-col { grid-template-columns: 1fr; }
}

/* ---------- Buttons ---------- */
.btn {
  background: #e2e8f0;
  color: #0f172a;
  border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 12px;
  cursor: pointer;
  transition: transform .1s ease, background .2s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn.primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  border: none;
}
.btn.ghost { background: transparent; border: 1px dashed var(--border); }
.w-full { width: 100%; }

/* ---------- Lists ---------- */
.list { display: grid; gap: 8px; }
.med-card {
  display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,.6);
  padding: 8px 10px;
}
.dark .med-card { background: #0b1020; }
.med-name { font-weight: 700; }
.med-notes { color: var(--muted); font-size: 12px; }
.badge {
  display:inline-grid; place-items:center;
  font-size: 11px; padding: 4px 8px;
  background: #10b98122; color:#34d399; border: 1px solid #34d39944; border-radius: 999px;
}

/* Action buttons inside cards */
.small-icon {
  font-size: 16px; line-height: 1;
  border-radius: 10px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.5);
  cursor: pointer;
}
.small-icon:hover { background: rgba(255,255,255,.7); }
.del { border-color: #ef4444; color:#ef4444; background: #fee2e2; }
.dark .del { background: #7f1d1d; color:#fecaca; }
.done { border-color: #10b981; color:#047857; background: #d1fae5; }
.dark .done { background: #064e3b; color:#a7f3d0; }

/* ---------- Calendar ---------- */
.calendar { display:grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.cal-cell {
  position: relative;
  border-radius: 12px;
  padding: 14px 10px;
  text-align: center;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
  border: 1px solid var(--border);
}
.cal-cell .count {
  position: absolute;
  right: 6px; top: 6px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.35);
}
.cal-cell.muted { color: #cbd5e1; background: #94a3b8; }
.today-outline {
  position:absolute; inset:0;
  border:2px dashed rgba(255,255,255,.9);
  border-radius:12px; pointer-events:none;
}
.calendar-nav { display:flex; gap: 6px; }

/* ---------- History ---------- */
.history { display:grid; gap: 8px; }
.h-row {
  display:grid; grid-template-columns: 110px 1fr; gap: 10px; align-items: start;
  border: 1px solid var(--border);
  border-radius: 12px; padding: 10px;
}
.h-date { font-weight: 800; color: var(--muted); }
.h-items { display:flex; flex-wrap: wrap; gap: 6px; }
.h-chip {
  border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 8px; font-size: 12px;
  background: rgba(255,255,255,.6);
}
.dark .h-chip { background: #0b1020; }

/* ---------- Footer ---------- */
.footer { max-width: 980px; margin: 20px auto; }
.footer h3 { margin-top: 0; margin-bottom: 6px; }
.footer h4 { margin-bottom: 6px; }
.muted { color: var(--muted); }
.sm { font-size: 12px; }

/* ---------- Modal ---------- */
.modal { border: none; padding: 0; background: transparent; }
.modal-card {
  width: min(520px, 92vw);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 14px;
}
.modal-header { display:flex; align-items:center; justify-content:space-between; margin-bottom: 10px; }
.tabs { display:flex; gap: 6px; margin-bottom: 10px; }
.tab {
  border:1px solid var(--border);
  border-radius: 999px; padding: 6px 10px; cursor: pointer; background: transparent;
}
.tab.active { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border: none; }

/* ---------- Confetti ---------- */
@keyframes pop {
  to { transform: translate(var(--dx), var(--dy)) rotate(720deg); opacity: 0; }
}
