/* DoseGrid – styles. Brand: navy #01234C, green #11AE06. Light theme. */
:root {
  --navy: #01234c; --navy-2: #0b3a73; --green: #11ae06; --green-d: #0b7d04; --green-bg: #e8f7e6;
  --bg: #f3f6fb; --card: #ffffff; --line: #e0e6f0; --ink: #0f1c2e; --muted: #596a82;
  --danger: #b42318; --danger-bg: #fdecea; --radius: 14px;
  --shadow: 0 1px 2px rgba(1, 35, 76, .06), 0 4px 14px rgba(1, 35, 76, .05);
  --font-body: 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-head: 'Outfit', 'Figtree', system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 16px/1.45 var(--font-body); -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-head); color: var(--navy); margin: 0; line-height: 1.2; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 600; }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #5aa0ff; outline-offset: 2px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 20px; height: 20px; flex: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .9rem; }
.pad { padding: 18px; }

/* ---------- boot ---------- */
.boot { min-height: 100dvh; display: flex; gap: 12px; align-items: center; justify-content: center; color: var(--muted); }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--green); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- buttons / fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1.5px solid var(--line);
  background: #fff; color: var(--navy); font-weight: 600; text-decoration: none; transition: background .15s, border-color .15s;
}
.btn:hover { border-color: #c6d1e2; background: #f8fafd; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); border-color: var(--navy-2); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { background: #8f1c12; border-color: #8f1c12; }
.btn.danger-o { color: var(--danger); border-color: #f1c5c0; }
.btn.danger-o:hover { background: var(--danger-bg); border-color: #e6a39b; }
.btn.small { min-height: 38px; padding: 0 14px; font-size: .92rem; }
.btn.block { width: 100%; }
.link { background: none; border: 0; padding: 8px 0; color: var(--green-d); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.link.tiny { padding: 0 0 0 10px; font-size: .85rem; }
.icon-btn {
  width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 12px;
  border: 0; background: transparent; color: var(--navy);
}
.icon-btn:hover { background: #e9eef6; }
.icon-btn.danger { color: var(--danger); }
.icon-btn.danger:hover { background: var(--danger-bg); }
.icon-btn.tiny { width: 32px; height: 32px; }
.icon-btn.tiny .ic { width: 16px; height: 16px; }

.field { display: block; margin: 0 0 14px; padding: 0; border: 0; min-width: 0; }
.field > span, .field > legend { display: block; font-weight: 600; font-size: .92rem; color: var(--navy); margin-bottom: 6px; padding: 0; }
.field input[type=text], .field input[type=email], .field input[type=password], .field input[type=number], .field input[type=date] {
  width: 100%; min-height: 46px; padding: 0 14px; border-radius: 12px; border: 1.5px solid #cfd8e6; background: #fff;
}
.field input:focus { border-color: var(--navy-2); outline: 3px solid rgba(90, 160, 255, .35); outline-offset: 0; }
.field input[aria-invalid=true] { border-color: var(--danger); background: #fffafa; }
.field small.hint { display: block; margin-top: 5px; }
.msg { min-height: 1.3em; margin: 0 0 10px; font-size: .92rem; }
.msg.err { color: var(--danger); font-weight: 500; }
.msg.ok { color: var(--green-d); font-weight: 500; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; gap: 10px; align-items: center; margin: 4px 0 10px; font-size: .95rem; }
.check input { width: 20px; height: 20px; accent-color: var(--navy); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 999px;
  border: 1.5px solid #cfd8e6; background: #fff; font-weight: 600; font-size: .92rem; cursor: pointer; user-select: none;
}
.chip input:checked + span { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip input:focus-visible + span { outline: 3px solid #5aa0ff; outline-offset: 2px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.swatch span { display: block; width: 34px; height: 34px; border-radius: 50%; background: var(--c); cursor: pointer; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .6); }
.swatch input:checked + span { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--navy); }
.swatch input:focus-visible + span { outline: 3px solid #5aa0ff; outline-offset: 4px; }

/* ---------- auth ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 20px 16px; background:
  radial-gradient(900px 400px at 85% -10%, rgba(17, 174, 6, .10), transparent 60%),
  radial-gradient(900px 500px at -10% 0%, rgba(1, 35, 76, .08), transparent 60%), var(--bg); }
.auth-card { position: relative; width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 60px 24px 24px; }
.auth-logo { display: block; width: 240px; max-width: 80%; height: auto; margin: 0 auto 18px; }
.lang-auth { position: absolute; top: 12px; right: 12px; }
.auth-h { font-size: 1.3rem; margin-bottom: 8px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: #eef2f8; padding: 4px; border-radius: 12px; margin-bottom: 18px; }
.tab { min-height: 40px; border: 0; background: transparent; border-radius: 9px; font-weight: 600; color: var(--muted); }
.tab.is-on { background: #fff; color: var(--navy); box-shadow: 0 1px 3px rgba(1, 35, 76, .15); }
.auth form .link { display: block; margin: 10px auto 0; }
.auth .hint { margin-bottom: 14px; }

/* ---------- header / nav ---------- */
.top { position: sticky; top: 0; z-index: 20; background: #fff; border-bottom: 1px solid var(--line); }
.top-in { max-width: 1280px; margin: 0 auto; padding: 8px 16px; display: flex; align-items: center; gap: 16px; }
.brand { display: block; flex: none; line-height: 0; }
.brand-wide { height: 38px; width: auto; }
.brand-icon { display: none; width: 40px; height: 40px; border-radius: 10px; }
.nav-top { display: flex; gap: 4px; margin-left: 12px; flex: 1; }
.nav button {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border: 0; border-radius: 12px;
  background: transparent; color: var(--muted); font-weight: 600;
}
.nav button:hover { background: #eef2f8; color: var(--navy); }
.nav button.is-on { color: var(--navy); background: var(--green-bg); }
.nav button.is-on .ic { color: var(--green-d); }
.nav-bottom { display: none; }

.lang-switch { display: inline-flex; background: #eef2f8; border-radius: 999px; padding: 3px; }
.lang-switch button { min-width: 44px; min-height: 36px; border: 0; background: transparent; border-radius: 999px; font-weight: 700; font-size: .85rem; color: var(--muted); }
.lang-switch button.is-on { background: var(--navy); color: #fff; }
.lang-switch.big button { min-width: 110px; min-height: 42px; font-size: .95rem; }

.demo { background: #fff7e0; border-bottom: 1px solid #f2dc9a; color: #6b4a00; padding: 10px 16px; font-size: .9rem; text-align: center; }
.loaderr { display: flex; gap: 12px; align-items: center; justify-content: center; padding: 10px 16px; background: var(--danger-bg); color: var(--danger); font-weight: 500; flex-wrap: wrap; }

/* ---------- layout ---------- */
.view { max-width: 1280px; margin: 0 auto; padding: 20px 16px 48px; }
.view:focus { outline: none; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card > h2 { margin-bottom: 10px; }
.pagehead { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
#v-supps, #v-settings { max-width: 760px; margin: 0 auto; }
#v-settings .card, #v-supps .slist { margin-bottom: 14px; }

/* ---------- week ---------- */
.weekbar { display: flex; align-items: center; gap: 6px; margin-bottom: 16px; }
.weektitle { display: flex; flex-direction: column; flex: 1; min-width: 0; text-align: center; }
.weektitle strong { font-family: var(--font-head); font-size: 1.25rem; color: var(--navy); }
.weektitle span { color: var(--muted); font-size: .92rem; }
.strip { display: none; }
.grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 12px; align-items: stretch; transition: opacity .15s; }
.grid.is-loading { opacity: .55; }
.day { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; min-height: 200px; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 12px; background: #eef2f8; border-bottom: 1px solid var(--line); }
.day-name { font-family: var(--font-head); font-weight: 700; color: var(--navy); }
.day-date { font-size: .85rem; color: var(--muted); }
.day.today { border-color: var(--green); box-shadow: 0 0 0 1.5px var(--green), var(--shadow); }
.day.today .day-head { background: var(--navy); border-color: var(--navy); }
.day.today .day-name, .day.today .day-date { color: #fff; }
.day-body { flex: 1; padding: 6px 8px; }
.day-none { color: var(--muted); font-size: .9rem; padding: 14px 4px; }
.slot { margin: 10px 4px 2px; font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.dose { display: flex; align-items: center; gap: 2px; padding: 4px 6px 4px 2px; margin: 4px 0; border-left: 4px solid var(--c); border-radius: 4px 10px 10px 4px; background: color-mix(in srgb, var(--c) 9%, #fff); }
.chk { position: relative; flex: none; width: 44px; height: 44px; display: grid; place-items: center; background: none; border: 0; padding: 0; }
.chk::before { content: ""; position: absolute; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--c); background: #fff; transition: background .12s; }
.chk .ic { position: relative; width: 16px; height: 16px; color: #fff; opacity: 0; }
.dose.on .chk::before { background: var(--c); }
.dose.on .chk .ic { opacity: 1; }
.dose-main { display: flex; flex-direction: column; min-width: 0; }
.dose-name { font-weight: 600; font-size: .95rem; overflow-wrap: anywhere; line-height: 1.25; }
.dose-amt { font-size: .85rem; color: var(--muted); }
.dose.on .dose-name { text-decoration: line-through; color: var(--muted); }
.day-foot { border-top: 1px solid var(--line); padding: 10px 12px; background: #fafcfe; }
.day-foot .left { display: flex; flex-direction: column; gap: 0; }
.day-foot .left span { font-size: .85rem; color: var(--muted); font-weight: 600; }
.day-foot .left strong { font-family: var(--font-head); color: var(--navy); font-size: 1.05rem; }
.day-foot .left.done strong { color: var(--green-d); }
.day-foot .sub { display: flex; flex-direction: column; margin-top: 4px; font-size: .78rem; color: var(--muted); }

.summary { margin-top: 20px; padding: 18px; }
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .95rem; }
.tbl th, .tbl td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--line); }
.tbl thead th { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.tbl .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl .strong { font-weight: 700; color: var(--navy); }
.tbl tbody th { font-weight: 600; }
.tbl tfoot th, .tbl tfoot td { border-bottom: 0; border-top: 2px solid var(--navy); font-weight: 700; color: var(--navy); }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--c); margin-right: 8px; vertical-align: -1px; }

.empty { text-align: center; padding: 40px 20px; max-width: 520px; margin: 24px auto; }
.empty-ic { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 50%; background: var(--green-bg); color: var(--green-d); display: grid; place-items: center; }
.empty-ic .ic { width: 30px; height: 30px; }
.empty p { color: var(--muted); margin: 8px 0 18px; }

/* ---------- supplements ---------- */
.slist { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.scard { display: flex; align-items: stretch; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.sbar { width: 8px; background: var(--c); flex: none; }
.sinfo { flex: 1; min-width: 0; padding: 14px 14px; }
.sname { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 1.05rem; }
.sline { font-size: .95rem; }
.sline.muted { font-size: .88rem; }
.badge { font-size: .72rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: #eef2f8; color: var(--muted); }
.sact { display: flex; align-items: center; padding-right: 4px; }

/* ---------- settings ---------- */
.btnrow { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.inline-form { margin: 12px 0 14px; max-width: 340px; }
.namechips { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.namechips li { display: inline-flex; align-items: center; gap: 2px; padding: 2px 4px 2px 14px; border-radius: 999px; background: #eef2f8; font-weight: 600; font-size: .92rem; }

/* ---------- dialogs ---------- */
.dlg { border: 0; border-radius: 18px; padding: 0; width: calc(100% - 24px); max-width: 520px; max-height: calc(100dvh - 24px); color: var(--ink); box-shadow: 0 20px 60px rgba(1, 35, 76, .35); }
.dlg::backdrop { background: rgba(1, 20, 45, .55); }
.dlg form { display: flex; flex-direction: column; max-height: calc(100dvh - 24px); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 8px 4px 20px; }
.dlg-body { padding: 14px 20px 6px; overflow-y: auto; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 20px 16px; border-top: 1px solid var(--line); background: #fff; }
.dlg-small { max-width: 400px; }
.dlg-small .dlg-body { padding-top: 20px; }
.dlg-small h2 { margin-bottom: 8px; }

.toasts { position: fixed; left: 0; right: 0; bottom: calc(76px + var(--safe-b)); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 50; pointer-events: none; padding: 0 16px; }
.toast { background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 12px; font-weight: 600; box-shadow: 0 8px 24px rgba(1, 35, 76, .3); max-width: 520px; }
.toast.err { background: var(--danger); }

/* ---------- responsive ---------- */
@media (min-width: 761px) { .toasts { bottom: 24px; } }
@media (max-width: 1180px) and (min-width: 761px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
}
@media (max-width: 760px) {
  body { padding-bottom: calc(68px + var(--safe-b)); }
  .nav-top { display: none; }
  .top-in { padding: 8px 12px; justify-content: space-between; }
  .brand-wide { height: 34px; }
  .nav-bottom {
    display: grid; grid-template-columns: repeat(3, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: #fff; border-top: 1px solid var(--line); padding: 6px 8px calc(6px + var(--safe-b));
  }
  .nav-bottom button { flex-direction: column; gap: 2px; font-size: .75rem; min-height: 54px; padding: 0 4px; }
  .view { padding: 14px 12px 32px; }
  .strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 14px; }
  .strip-day { display: flex; flex-direction: column; align-items: center; gap: 1px; min-height: 64px; padding: 6px 0 8px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; color: var(--navy); }
  .sd-n { font-size: .72rem; font-weight: 600; color: var(--muted); }
  .sd-d { font-family: var(--font-head); font-weight: 700; font-size: 1.1rem; }
  .sd-dot { width: 6px; height: 6px; border-radius: 50%; background: transparent; margin-top: 2px; }
  .strip-day:not(.none) .sd-dot { background: #b8c4d8; }
  .strip-day.done .sd-dot { background: var(--green); }
  .strip-day.today .sd-d { color: var(--green-d); }
  .strip-day.sel { background: var(--navy); border-color: var(--navy); color: #fff; }
  .strip-day.sel .sd-n { color: #cfe0f7; }
  .strip-day.sel.today .sd-d { color: #fff; }
  .grid { display: block; }
  .day { display: none; min-height: 0; }
  .day.sel { display: flex; }
  .weekbar .btn { display: none; }
  .row2 { grid-template-columns: 1fr 1fr; }
  .dlg { width: 100%; max-width: none; margin: auto 0 0; border-radius: 20px 20px 0 0; max-height: 94dvh; }
  .dlg form { max-height: 94dvh; }
  .dlg-small { width: calc(100% - 24px); margin: auto; border-radius: 18px; }
  .dlg-foot { padding-bottom: calc(16px + var(--safe-b)); }
}
@media (max-width: 560px) {
  .brand-wide { display: none; }
  .brand-icon { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation-duration: .01ms !important; }
}

/* ---------- admin catalog ---------- */
.admin { border-color: var(--green); }
.admin-form { margin: 12px 0 8px; }
.catlist { list-style: none; margin: 8px 0 0; padding: 0; max-height: 420px; overflow-y: auto; border-top: 1px solid var(--line); }
.catlist li { display: flex; align-items: center; gap: 2px; border-bottom: 1px solid var(--line); padding: 4px 0 4px 2px; }
.cat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cat-main .muted { font-size: .88rem; }

/* ---------- day / week / month ---------- */
.segrow { display: flex; justify-content: center; margin: -4px 0 16px; }
.seg { display: inline-flex; background: #e6ecf5; border-radius: 12px; padding: 4px; }
.seg button { min-height: 40px; min-width: 88px; padding: 0 16px; border: 0; background: transparent; border-radius: 9px; font-weight: 600; color: var(--muted); }
.seg button.is-on { background: #fff; color: var(--navy); box-shadow: 0 1px 3px rgba(1, 35, 76, .18); }
.grid.one { grid-template-columns: minmax(0, 520px); justify-content: center; }
.month { transition: opacity .15s; }
.month.is-loading { opacity: .55; }
.mgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.mhead { margin-bottom: 6px; }
.mhead span { text-align: center; font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.mcell { display: flex; flex-direction: column; gap: 6px; min-height: 96px; padding: 8px; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.mcell:hover { border-color: #b9c6db; }
.mcell.out { opacity: .5; box-shadow: none; background: transparent; }
.mcell.today { border-color: var(--green); box-shadow: 0 0 0 1.5px var(--green), var(--shadow); }
.mcell.today .mnum { background: var(--navy); color: #fff; }
.mnum { align-self: flex-start; min-width: 26px; height: 26px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: 999px; font-family: var(--font-head); font-weight: 700; color: var(--navy); }
.mdots { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.mdot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.mmore { font-size: .72rem; color: var(--muted); font-weight: 600; }
.mprog { margin-top: auto; font-size: .8rem; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.mcell.done { background: var(--green-bg); border-color: #b7e3b2; }
.mcell.done .mprog { color: var(--green-d); }
@media (max-width: 640px) {
  .mgrid { gap: 3px; }
  .mcell { min-height: 66px; padding: 4px; gap: 3px; border-radius: 8px; }
  .mnum { min-width: 22px; height: 22px; font-size: .85rem; padding: 0 4px; }
  .mdot { width: 7px; height: 7px; }
  .mprog { font-size: .68rem; }
  .seg button { min-width: 0; padding: 0 12px; }
}
@media (max-width: 520px) {
  .summary { padding: 12px; }
  .tbl { font-size: .8rem; }
  .tbl th, .tbl td { padding: 8px 3px; }
  .tbl thead th { font-size: .66rem; letter-spacing: 0; }
  .tbl tfoot .num { white-space: normal; }
  .dot { margin-right: 5px; }
}

/* reminders */
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--navy); margin: 8px 0 14px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--green); }
.remtimes { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.remtime span { display: block; font-size: .85rem; margin-bottom: 4px; color: var(--muted, #50627a); }
.remtime input, .rem-form select, .urlbox { width: 100%; min-height: 44px; padding: 8px 10px; font: inherit; border: 1px solid var(--line, #c9d3e0); border-radius: 8px; background: #fff; color: inherit; box-sizing: border-box; }
.urlbox { font-size: .82rem; font-family: ui-monospace, Menlo, Consolas, monospace; }
.remtime input[aria-invalid=true] { border-color: var(--danger); }
.smallh { font-size: 1rem; margin: 18px 0 6px; color: var(--navy); }
.howto { margin: 0 0 12px; padding-left: 20px; line-height: 1.5; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.rem-form { margin-bottom: 18px; }
