/* Irene's Medication Tracker — light theme, large touch targets */
:root {
  --navy: #1d3557; --navy-2: #2b4a7a; --teal: #2a9d8f; --gold: #e9c46a; --gold-2: #c9a227;
  --bg: #f6f7f9; --card: #ffffff; --line: #e3e7ee; --text: #1b2430; --muted: #5b6775;
  --green: #2e7d32; --green-bg: #e8f5e9; --amber: #d98f00; --amber-bg: #fff6e0; --red: #c62828; --red-bg: #fdeaea;
  --blue: #1565c0; --blue-bg: #e8f0fb; --orange: #e65100; --orange-bg: #fff0e6; --gray-bg: #eef1f5;
  --radius: 14px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 4px 14px rgba(16,24,40,.06);
  --tap: 48px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: Inter, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 1.0625rem; line-height: 1.45; color: var(--text); background: var(--bg); }
h1, h2, h3 { color: var(--navy); margin: 0 0 .4rem; line-height: 1.2; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
p { margin: .3rem 0; }
a { color: var(--navy-2); }
.muted { color: var(--muted); } .small { font-size: .9rem; } .tiny { font-size: .8rem; }
.hidden { display: none !important; }
button { font: inherit; }
input, select, textarea { font: inherit; color: var(--text); background: #fff; border: 1px solid #c9d0da; border-radius: 10px; padding: .6rem .75rem; width: 100%; min-height: var(--tap); }
textarea { min-height: 80px; resize: vertical; }
label { display: block; font-weight: 600; font-size: .92rem; margin: .7rem 0 .25rem; color: var(--navy); }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: var(--tap); padding: .55rem 1rem; border-radius: 12px; border: 1px solid var(--line); background: #fff; color: var(--navy); font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #f3f5f8; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-2); }
.btn-teal { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-danger { color: var(--red); border-color: #f1c2c2; }
.btn-sm { min-height: 38px; padding: .35rem .7rem; font-size: .92rem; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-ghost { border-color: transparent; background: transparent; }

/* Layout */
.topbar { position: sticky; top: 0; z-index: 30; background: var(--navy); color: #fff; padding: .55rem 1rem; display: flex; align-items: center; gap: .8rem; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.topbar .brand { font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: .5rem; }
.topbar .brand small { font-weight: 500; opacity: .85; font-size: .8rem; display: block; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: .9rem; background: rgba(255,255,255,.14); padding: .3rem .7rem; border-radius: 999px; }
.topbar .btn-ghost { color: #fff; min-height: 40px; }
.tabs { display: flex; gap: .25rem; background: #fff; border-bottom: 1px solid var(--line); padding: 0 .5rem; overflow-x: auto; position: sticky; top: 58px; z-index: 25; }
.tab { flex: 0 0 auto; min-height: 52px; padding: .6rem .9rem; border: 0; background: transparent; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; cursor: pointer; display: flex; align-items: center; gap: .4rem; }
.tab.active { color: var(--navy); border-bottom-color: var(--gold-2); }
.tab .badge { background: var(--red); color: #fff; font-size: .72rem; padding: .05rem .4rem; border-radius: 999px; }
main { max-width: 1100px; margin: 0 auto; padding: 1rem 1rem 6rem; }
@media (max-width: 700px) {
  .tabs { position: fixed; top: auto; bottom: 0; left: 0; right: 0; border-top: 1px solid var(--line); border-bottom: 0; padding: 0 .2rem env(safe-area-inset-bottom); justify-content: space-around; }
  .tab { flex-direction: column; gap: .1rem; font-size: .72rem; padding: .45rem .4rem; min-height: 58px; border-bottom: 0; border-top: 3px solid transparent; }
  .tab.active { border-top-color: var(--gold-2); }
  .tab .ico { font-size: 1.25rem; }
  main { padding-bottom: 6.5rem; }
}

/* Cards */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; margin-bottom: 1rem; border: 1px solid var(--line); }
.card.alert { border-left: 5px solid var(--red); }
.card.warn { border-left: 5px solid var(--amber); }
.card.info { border-left: 5px solid var(--blue); }
.card.ok { border-left: 5px solid var(--green); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; margin-bottom: .5rem; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .7rem; margin-bottom: 1rem; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem .9rem; box-shadow: var(--shadow); }
.kpi .v { font-size: 1.7rem; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi .l { color: var(--muted); font-size: .85rem; margin-top: .15rem; }
.kpi.red .v { color: var(--red); } .kpi.amber .v { color: var(--amber); } .kpi.green .v { color: var(--green); }

/* Pills */
.pill { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .6rem; border-radius: 999px; font-size: .85rem; font-weight: 700; letter-spacing: .01em; white-space: nowrap; max-width: 100%; }
.sym-row .pill, td .pill, .med .pill { white-space: normal; overflow-wrap: anywhere; }
.pill.rx { background: var(--blue-bg); color: var(--blue); } .pill.otc { background: var(--gray-bg); color: var(--muted); }
.pill.major { background: var(--red-bg); color: var(--red); } .pill.moderate { background: var(--orange-bg); color: var(--orange); }
.pill.minor { background: var(--amber-bg); color: var(--amber); } .pill.info { background: var(--blue-bg); color: var(--blue); }
.pill.ok { background: var(--green-bg); color: var(--green); } .pill.soon { background: var(--amber-bg); color: var(--amber); }
.pill.now { background: var(--red-bg); color: var(--red); } .pill.unknown { background: var(--gray-bg); color: var(--muted); }
.pill.verify { background: #fff3cd; color: #7a5a00; }
.pill.wrap { white-space: normal; text-align: left; line-height: 1.3; }
.ix .card-head .pill { white-space: normal; max-width: 100%; }
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .45rem .8rem; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: .95rem; cursor: pointer; min-height: 42px; }
.chip.sel { background: var(--navy); color: #fff; border-color: var(--navy); }
.chip.red { border-color: #f1c2c2; background: var(--red-bg); color: var(--red); }
.dose .tiny { font-size: .9rem; }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; }

/* Today — slot cards & dose rows */
.slot { margin-bottom: 1rem; }
.slot.current { border: 2px solid var(--gold-2); }
.slot .slot-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .4rem; }
.slot .slot-head h2 { margin: 0; flex: 1; }
.dose { display: flex; align-items: center; gap: .8rem; padding: .6rem 0; border-top: 1px solid var(--line); }
.dose:first-of-type { border-top: 0; }
.dose .chk { flex: 0 0 auto; width: 52px; height: 52px; border-radius: 14px; border: 2px solid #c9d0da; background: #fff; font-size: 1.5rem; display: flex; align-items: center; justify-content: center; cursor: pointer; color: transparent; }
.dose.taken .chk { background: var(--green); border-color: var(--green); color: #fff; }
.dose.skipped .chk { background: var(--amber-bg); border-color: var(--amber); color: var(--amber); }
.dose .info { flex: 1; min-width: 0; }
.dose .name { font-weight: 700; color: var(--navy); }
.dose .sub { color: var(--muted); font-size: .88rem; }
.dose.taken .name { text-decoration: line-through; opacity: .7; }
.dose .acts { flex: 0 0 auto; display: flex; gap: .3rem; }
.progress { height: 10px; background: var(--gray-bg); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--green); border-radius: 999px; transition: width .3s; }

/* Calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .6rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: .78rem; color: var(--muted); font-weight: 700; padding: .2rem 0; }
.cal-day { background: #fff; border: 1px solid var(--line); border-radius: 10px; min-height: 78px; padding: .3rem; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: .15rem; position: relative; }
.cal-day.other { opacity: .45; }
.cal-day.today { border-color: var(--gold-2); box-shadow: 0 0 0 2px var(--gold); }
.cal-day.sel { border-color: var(--navy); box-shadow: 0 0 0 2px var(--navy); }
.cal-day .num { font-size: .8rem; font-weight: 700; color: var(--navy); align-self: flex-start; }
.cal-day svg { width: 34px; height: 34px; }
.cal-day .dots { display: flex; gap: 2px; flex-wrap: wrap; justify-content: center; min-height: 8px; }
.cal-day .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
.cal-day .dot.s4, .cal-day .dot.s5 { background: var(--red); }
.cal-day .dot.s1, .cal-day .dot.s2 { background: #f2c94c; }
.cal-day .dot.good { background: var(--green); }
.cal-day .mk { position: absolute; top: 2px; right: 3px; font-size: .7rem; }
.legend { display: flex; flex-wrap: wrap; gap: .8rem; font-size: .82rem; color: var(--muted); margin-top: .6rem; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .3rem; vertical-align: middle; }
@media (max-width: 560px) { .cal-day { min-height: 64px; } .cal-day svg { width: 26px; height: 26px; } }

/* Drawer (day detail) */
.drawer-bg { position: fixed; inset: 0; background: rgba(17,24,39,.45); z-index: 40; display: none; }
.drawer-bg.open { display: block; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: #fff; z-index: 41; transform: translateX(100%); transition: transform .25s; overflow-y: auto; padding: 1rem 1.1rem 2rem; box-shadow: -8px 0 24px rgba(0,0,0,.15); }
.drawer.open { transform: translateX(0); }
@media (max-width: 700px) { .drawer { top: auto; left: 0; right: 0; width: 100%; max-height: 88vh; border-radius: 18px 18px 0 0; transform: translateY(100%); } .drawer.open { transform: translateY(0); } }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(17,24,39,.5); z-index: 50; display: none; align-items: flex-start; justify-content: center; padding: 2rem 1rem; overflow-y: auto; }
.modal-bg.open { display: flex; }
.modal { background: #fff; border-radius: 16px; width: min(640px, 100%); padding: 1.2rem 1.2rem 1.4rem; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal h2 { margin-bottom: .6rem; }
.modal .acts { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--navy); color: #fff; padding: .6rem 1rem; border-radius: 999px; box-shadow: var(--shadow); z-index: 60; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 92vw; }
.toast.show { opacity: 1; }
.toast.err { background: var(--red); }

/* Med cards */
.med-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: .8rem; }
.med { margin: 0; display: flex; flex-direction: column; gap: .35rem; }
.med .title { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; }
.med .title h3 { margin: 0; }
.med dl { display: grid; grid-template-columns: auto 1fr; gap: .15rem .6rem; margin: .3rem 0; font-size: .92rem; }
.med dt { color: var(--muted); } .med dd { margin: 0; }
.med .supply { background: var(--bg); border-radius: 10px; padding: .5rem .7rem; font-size: .92rem; }
.med .acts { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .3rem; }
.verify-list { margin: .3rem 0 0; padding-left: 1.1rem; font-size: .88rem; color: #7a5a00; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .93rem; }
table.tbl th, table.tbl td { text-align: left; padding: .5rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.tbl th { color: var(--muted); font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.tbl-wrap { overflow-x: auto; }

/* Interactions */
.ix { border-left: 5px solid var(--blue); }
.ix.major { border-left-color: var(--red); } .ix.moderate { border-left-color: var(--orange); } .ix.minor { border-left-color: var(--amber); }
.ix .items { display: flex; flex-wrap: wrap; gap: .35rem; margin: .3rem 0; }
.ix .items span { background: var(--gray-bg); border-radius: 8px; padding: .15rem .5rem; font-size: .85rem; font-weight: 600; color: var(--navy); }
.ix .do { background: var(--bg); border-radius: 10px; padding: .5rem .7rem; margin-top: .4rem; }
.sched { display: grid; grid-template-columns: 90px 1fr; gap: .4rem .8rem; }
.sched .t { font-weight: 700; color: var(--navy); }
.disclaimer { font-size: .85rem; color: var(--muted); border: 1px dashed #c9d0da; border-radius: 10px; padding: .6rem .8rem; }

/* Symptoms */
.sev { display: flex; gap: .4rem; }
.sev button { flex: 1; min-height: var(--tap); border-radius: 10px; border: 1px solid var(--line); background: #fff; font-weight: 700; cursor: pointer; }
.sev button.sel { background: var(--navy); color: #fff; border-color: var(--navy); }
.sym-row { display: flex; gap: .6rem; align-items: flex-start; padding: .5rem 0; border-top: 1px solid var(--line); }
.sym-row:first-child { border-top: 0; }
.sym-row .ico { font-size: 1.3rem; width: 2rem; text-align: center; }
.sym-row .body { flex: 1; min-width: 0; }
.chart-wrap { position: relative; height: 260px; }
.chart-wrap.sm { height: 200px; }
.matrix td.up { color: var(--red); font-weight: 700; } .matrix td.down { color: var(--green); font-weight: 700; }

/* Login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
.login-card { background: #fff; border-radius: 18px; box-shadow: var(--shadow); padding: 1.6rem; width: min(420px, 100%); text-align: center; }
.login-card form { text-align: left; }
.login-card .btn { margin-top: 1rem; }
.login-logo { font-size: 2.6rem; }
.err { color: var(--red); font-weight: 600; }

/* Tour overrides (navy/gold engine restyled to match) */
.sgatour-launcher { bottom: 84px !important; }
@media (min-width: 701px) { .sgatour-launcher { bottom: 24px !important; } }
.print-only { display: none; }
@media print {
  .topbar, .tabs, .sgatour-launcher, .btn, .toast { display: none !important; }
  main { padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
  .tbl-wrap { overflow: visible; }
  .print-only { display: block; }
}
