:root {
  color-scheme: light;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: #192932;
  background: #f2f6f5;
  font-synthesis: none;
  --ink: #192932;
  --muted: #50646a;
  --line: #dbe5e3;
  --teal: #075f55;
  --teal-hover: #064d45;
  --tint: #e6f4ef;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 275px; }
h1, h2, p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
svg { width: 1.3rem; height: 1.3rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
:focus-visible { outline: 3px solid #148c78; outline-offset: 3px; }
.skip { position: absolute; transform: translateY(-150%); background: white; padding: .65rem 1rem; z-index: 4; }
.skip:focus { transform: none; }

.account-gate { min-height: 100vh; display: grid; place-items: center; padding: 1.2rem; }
.account-form { max-width: 26rem; width: 100%; padding: 2rem; }
.account-form h1 { font-size: 2.2rem; letter-spacing: -.045em; margin-top: .65rem; }
.account-form > p { margin-top: .55rem; color: var(--muted); line-height: 1.5; }
.account-form form { margin-top: 1.3rem; display: grid; gap: .85rem; }
.account-form .button { justify-self: start; }
.account-form #account-notice { margin-top: 1.05rem; }
.account-form #account-notice:empty { display: none; }
.account-actions { display: flex; justify-content: flex-end; margin: -.85rem 0 .3rem; }
.account-actions button { min-height: 2.2rem; }

.shell { display: grid; min-height: 100vh; grid-template-columns: 14.5rem minmax(0, 1fr); }
.rail { background: #142830; color: #edf7f4; height: 100vh; position: sticky; top: 0; display: flex; flex-direction: column; padding: 2rem 1.1rem 1.6rem; }
.brand { display: flex; align-items: center; gap: .75rem; padding: 0 .6rem; font-size: 1.05rem; font-weight: 720; line-height: 1.15; letter-spacing: -.02em; }
.brand img { flex: none; }
.navigation { margin-top: 3rem; display: grid; gap: .4rem; }
.navigation a { display: flex; align-items: center; gap: .65rem; min-height: 2.95rem; border-radius: .6rem; padding: .6rem .75rem; color: #c4d7d9; text-decoration: none; font-size: .92rem; font-weight: 600; }
.navigation a:hover { background: #233d44; color: #fff; }
.navigation a[aria-current="page"] { background: #24474b; color: #d5fff3; }
.navigation a[aria-current="page"] svg { color: #94dfce; }
.rail :focus-visible { outline-color: #94dfce; }
.rail-footer { margin-top: auto; display: flex; align-items: flex-start; gap: .65rem; border-top: 1px solid #375055; padding: 1.15rem .25rem 0; font-size: .82rem; line-height: 1.45; }
.rail-footer svg { color: #94dfce; }
.rail-footer strong { color: #edf7f4; }
.rail-footer p { margin-top: .2rem; color: #bfcecd; }
.mobile-footer { display: none; }

main { width: min(100%, 88rem); margin: 0 auto; min-width: 0; padding: 2.55rem clamp(1.45rem, 3.65vw, 3.8rem) 3.2rem; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.25rem; margin-bottom: 1.75rem; }
.page-heading h1 { font-size: clamp(1.95rem, 3.5vw, 2.95rem); font-weight: 730; letter-spacing: -.055em; line-height: 1.08; }
.page-heading p { margin-top: .55rem; color: var(--muted); line-height: 1.55; }
.page-heading .button { flex-shrink: 0; }
.notice { border-radius: .65rem; background: #e0f3eb; border: 1px solid #a8cfbe; color: #174c3e; padding: .75rem 1rem; margin-bottom: 1rem; line-height: 1.45; }
.notice.error { background: #fff1ee; border-color: #eeb5aa; color: #84291c; }

.summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .9rem; margin-bottom: 1.15rem; }
.stat { display: flex; align-items: flex-start; gap: .75rem; background: #e7f0ee; border: 1px solid #d9e6e2; border-radius: .85rem; padding: 1rem; min-width: 0; }
.stat-icon, .card-icon { display: inline-flex; align-items: center; justify-content: center; width: 2.35rem; height: 2.35rem; border-radius: .65rem; color: var(--teal); background: #d6ece5; flex: none; }
.stat h2 { font-size: .85rem; font-weight: 650; color: #3e565b; line-height: 1.3; }
.stat-value { font-size: clamp(1.02rem, 1.6vw, 1.3rem); font-weight: 710; letter-spacing: -.02em; margin-top: .3rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-note { font-size: .8rem; color: var(--muted); margin-top: .17rem; }
.stat-note:empty { display: none; }

.editor-grid { display: grid; grid-template-columns: minmax(0, 2.15fr) minmax(13.5rem, 1fr); align-items: start; gap: 1.1rem; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 1rem; box-shadow: 0 2px 5px #173c3510; min-width: 0; padding: clamp(1.1rem, 2vw, 1.65rem); }
.card-heading { display: flex; align-items: flex-start; gap: .72rem; margin-bottom: 1.3rem; }
.card-icon { background: var(--tint); }
.card h2, dialog h2 { font-size: 1.24rem; letter-spacing: -.025em; font-weight: 720; line-height: 1.24; }
.card-heading p, .history-heading p, .backup-card p { margin-top: .22rem; color: var(--muted); font-size: .92rem; line-height: 1.45; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .95rem; }
fieldset { padding: 0; margin: 0; min-width: 0; border: 0; }
legend { padding: 0; font-size: 1rem; font-weight: 680; margin-bottom: .7rem; }
label { display: grid; gap: .35rem; color: #31454d; font-weight: 620; font-size: .9rem; line-height: 1.35; min-width: 0; }
input:not([type="file"]), select, textarea { min-width: 0; width: 100%; min-height: 2.75rem; border: 1px solid #bfcecc; border-radius: .5rem; padding: .57rem .68rem; background: #fff; color: var(--ink); font-size: 1rem; font-weight: 450; }
input::placeholder { color: #617178; }
input[type="date"] { color-scheme: light; }
select { appearance: none; padding-right: 2rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%2331454d' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-position: right .7rem center; background-repeat: no-repeat; }
textarea { resize: vertical; }
.dose-section { margin-top: 1.2rem; }
.dose-section legend { margin-bottom: .24rem; }
.field-note { color: var(--muted); font-size: .88rem; line-height: 1.45; }
.dose-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .45rem; margin-top: .65rem; }
.dose-grid label { text-align: center; }
.dose-grid input { text-align: center; padding-inline: .2rem; font-variant-numeric: tabular-nums; }
.next-field { border-top: 1px solid var(--line); margin-top: 1.15rem; padding-top: 1.05rem; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; margin-top: 1.15rem; }
.button { min-height: 2.65rem; border: 1px solid transparent; border-radius: .55rem; padding: .57rem .85rem; display: inline-flex; align-items: center; justify-content: center; text-align: center; font-size: .9rem; font-weight: 670; line-height: 1.25; text-decoration: none; }
.primary { background: var(--teal); color: #fff; }
.primary:hover { background: var(--teal-hover); }
.secondary { border-color: #b9cdca; background: #fff; color: #214d49; }
.secondary:hover { background: var(--tint); border-color: #9fbab5; }
.plain { background: transparent; color: #395458; }
.plain:hover { background: #eef4f3; }
.danger { background: #973b2e; color: white; }
.danger:hover { background: #762b23; }
.button:disabled { opacity: .55; cursor: default; }

.context-card .card-heading { margin-bottom: .8rem; }
.details-summary { margin: 0 0 1rem; }
.details-summary > div { padding: .7rem 0; border-bottom: 1px solid var(--line); }
.details-summary dt { color: var(--muted); font-size: .84rem; }
.details-summary dd { margin: .2rem 0 0; font-size: .95rem; font-weight: 650; overflow-wrap: anywhere; }
.history { margin-top: 1.1rem; }
.history-heading { display: flex; align-items: center; justify-content: space-between; gap: .8rem; }
.empty { background: #f5f8f7; color: var(--muted); border: 1px dashed #cbd9d6; border-radius: .6rem; padding: 1.3rem; margin-top: 1rem; text-align: center; font-size: .95rem; }
.table-scroll { overflow: auto; margin-top: .9rem; max-width: 100%; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .86rem; font-variant-numeric: tabular-nums; }
th { background: #eaf2f0; color: #315258; font-weight: 690; }
th, td { padding: .65rem; vertical-align: top; border-bottom: 1px solid #dee8e6; }
td:first-child, td:nth-child(6) { white-space: nowrap; }
.dose-column { min-width: 13rem; }
.dose-display { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .25rem; }
.dose-display span { overflow-wrap: anywhere; text-align: center; }
.dose-display small { display: block; color: var(--muted); font-size: .72rem; }
.row-actions { display: flex; white-space: nowrap; gap: .05rem; }
.row-button { min-height: 2.25rem; padding: .35rem .5rem; font-size: .82rem; }
.row-button.remove { color: #8b392c; }
.report-card, .profile-card, .backup-card { max-width: 53rem; }
.report-dates { max-width: 31rem; }
#report-count { margin-top: .75rem; }
.profile-card form, .profile-card form > label { margin-top: 1rem; }
.backup-card { margin-top: 1.1rem; }
dialog { color: var(--ink); width: min(28rem, calc(100% - 2rem)); border: 1px solid var(--line); border-radius: .9rem; padding: 1.4rem; box-shadow: 0 12px 50px #101e3050; }
dialog p { color: var(--muted); margin-top: .55rem; line-height: 1.5; }
dialog::backdrop { background: #10253075; }

@media (max-width: 1120px) {
  .shell { grid-template-columns: 12.3rem minmax(0, 1fr); }
  .rail { padding-inline: .75rem; }
  .editor-grid { grid-template-columns: minmax(0, 1.85fr) minmax(12rem, 1fr); }
}
@media (max-width: 930px) {
  .editor-grid { grid-template-columns: minmax(0, 1fr); }
  .context-card .details-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; }
}
@media (max-width: 740px) {
  .shell { display: block; }
  .rail { height: auto; position: static; padding: .75rem 1rem .5rem; }
  .brand { padding: 0 .25rem; font-size: 1rem; line-height: 1.25; }
  .brand br { display: none; }
  .brand img { width: 1.85rem; height: 1.85rem; }
  .navigation { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .65rem; }
  .navigation a { gap: .32rem; min-height: 2.5rem; padding: .42rem .55rem; font-size: .85rem; }
  .navigation svg { width: 1.1rem; height: 1.1rem; }
  .rail-footer { display: none; }
  .mobile-footer { display: block; color: var(--muted); font-size: .82rem; margin-top: 1.35rem; }
  main { padding: 1.35rem 1rem 2rem; }
}
@media (max-width: 480px) {
  .page-heading { align-items: flex-start; flex-direction: column; gap: .85rem; margin-bottom: 1rem; }
  .page-heading > .button { display: none; }
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
  .stat { padding: .65rem; gap: .38rem; }
  .stat:last-child { grid-column: 1 / -1; }
  .stat-icon { width: 1.65rem; height: 1.65rem; border-radius: .38rem; }
  .stat-icon svg { width: 1.05rem; height: 1.05rem; }
  .card { padding: .9rem; }
  .field-grid { gap: .7rem; }
  .dose-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .context-card .details-summary { grid-template-columns: minmax(0, 1fr); gap: 0; }
}
@media (max-width: 340px) {
  .field-grid { grid-template-columns: minmax(0, 1fr); }
  .navigation svg { display: none; }
}
