
/* Layout: one column with a bottom tab bar on the cover screen; unfolded, Today stays left and Supply, History or Settings fill the right. */
:root {
  --bg: #EEF2F0;
  --surface: #FFFFFF;
  --ink: #14201C;
  --ink2: #53625C;
  --line: #D3DCD8;
  --accent: #0C6A59;
  --accent-ink: #FFFFFF;
  --accent-soft: #DAEDE7;
  --warn: #A8480A;
  --warn-soft: #F9E5D4;
  --f-display: 'Bricolage Grotesque', 'IBM Plex Sans', system-ui, sans-serif;
  --f-body: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1512; --surface: #16201C; --ink: #E5EEEA; --ink2: #9BAEA6; --line: #2A3833;
    --accent: #4DBFA3; --accent-ink: #04201A; --accent-soft: #1A3A31; --warn: #F2A365; --warn-soft: #3B2514;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0E1512; --surface: #16201C; --ink: #E5EEEA; --ink2: #9BAEA6; --line: #2A3833;
  --accent: #4DBFA3; --accent-ink: #04201A; --accent-soft: #1A3A31; --warn: #F2A365; --warn-soft: #3B2514;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--f-body); font-size: 16px; line-height: 1.45;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 16px 96px;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.app { max-width: 1120px; margin: 0 auto; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 16px; }
.mark { font-family: var(--f-display); font-weight: 700; font-size: 20px; letter-spacing: -0.01em; }
.grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-items: start; }
.pane { min-width: 0; }
.pane[hidden], #right[hidden] { display: none; }
h1, h2 { font-family: var(--f-display); margin: 0; letter-spacing: -0.02em; line-height: 1.1; }
h1 { font-size: 28px; font-weight: 700; }
h2 { font-size: 22px; font-weight: 700; }
.pane-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 14px; }
.muted { color: var(--ink2); }
.label { font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink2); }
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }

/* buttons */
.btn { min-height: 44px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 500; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.warn { border-color: var(--warn); color: var(--warn); }
.btn.sm { min-height: 40px; padding: 0 14px; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; padding: 10px 6px; min-height: 40px; color: var(--ink2); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link.warn { color: var(--warn); }

/* notices */
.notice { background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; margin-bottom: 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.notice.bad { background: var(--warn-soft); }
.notice span { flex: 1 1 220px; min-width: 0; }

/* today */
.progress { display: flex; gap: 4px; margin: 14px 0 6px; }
.progress i { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.progress i.t { background: var(--accent); }
.progress i.s { background: var(--ink2); opacity: .5; }
.alerts { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; }
.chip { display: inline-flex; align-items: center; min-height: 32px; padding: 0 10px; border-radius: 6px; background: var(--warn-soft); color: var(--warn); border: 0; font-size: 14px; font-weight: 500; cursor: pointer; }
.list { list-style: none; margin: 14px 0 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.row { display: grid; grid-template-columns: 78px minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; padding: 12px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row.next { background: var(--accent-soft); border-radius: 10px; }
.when { font-family: var(--f-mono); font-size: 13px; font-variant-numeric: tabular-nums; color: var(--ink2); }
.what { min-width: 0; }
.nm { font-weight: 600; overflow-wrap: anywhere; }
.sub { font-size: 14px; color: var(--ink2); display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: center; }
.sub .over { color: var(--warn); font-weight: 500; }
.sub .ok { color: var(--accent); font-weight: 500; }
.act { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; justify-content: flex-end; }
.kind { font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; padding: 1px 5px; border-radius: 3px; border: 1px solid var(--ink2); color: var(--ink2); }
.kind.inj { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: 10px; padding: 20px 16px; text-align: left; margin-top: 14px; display: grid; gap: 10px; justify-items: start; }
.sec-title { margin: 22px 0 0; }

/* supply */
.cards { display: grid; gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: grid; gap: 10px; min-width: 0; }
.card-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.card-top > div { min-width: 0; }
.remain { text-align: right; flex: none; }
.remain b { font-family: var(--f-mono); font-size: 22px; font-weight: 500; font-variant-numeric: tabular-nums; }
.bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.bar.low i { background: var(--warn); }
@media (prefers-reduced-motion: no-preference) { .bar i { transition: width .25s ease; } }
.facts { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 14px; align-items: center; }
.facts .low { color: var(--warn); font-weight: 600; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline input { width: 110px; }
input[type=text], input[type=number], input[type=date], input[type=time], select, textarea {
  min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); width: 100%;
}
textarea { min-height: 96px; font-family: var(--f-mono); font-size: 12px; resize: vertical; }
.inline input[type=number] { width: 110px; }

/* history */
.hday { margin: 18px 0 6px; }
.hrow { display: grid; grid-template-columns: 78px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.hrow .skipped { color: var(--ink2); }

/* backup */
.stack { display: grid; gap: 16px; }
.block { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: grid; gap: 10px; }
.block h3 { margin: 0; font-size: 16px; font-family: var(--f-display); }
.block p { margin: 0; }

/* tabs */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border-top: 1px solid var(--line);
  padding: 0 max(8px, env(safe-area-inset-left, 0px)) env(safe-area-inset-bottom, 0px) max(8px, env(safe-area-inset-right, 0px)); }
.tab { min-height: 56px; background: none; border: 0; border-top: 3px solid transparent; color: var(--ink2); font-weight: 500; cursor: pointer; }
.tab[aria-current="page"] { color: var(--accent); border-top-color: var(--accent); }
.subtabs { display: none; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.subtabs .tab { min-height: 44px; padding: 0 16px; border-top: 0; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.subtabs .tab[aria-current="page"] { border-bottom-color: var(--accent); }

/* sheet + toast */
.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(8, 14, 12, .5); display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden], .toast[hidden] { display: none; }
.panel { background: var(--surface); width: 100%; max-width: 540px; max-height: 94%; overflow: auto; border-radius: 14px 14px 0 0; padding: 18px max(16px, env(safe-area-inset-left, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)); }
.panel form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; min-width: 0; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg label { text-align: center; padding: 11px 8px; cursor: pointer; font-weight: 500; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:checked + label { background: var(--accent); color: var(--accent-ink); }
.seg input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: -2px; }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.days input { position: absolute; opacity: 0; pointer-events: none; }
.days label { text-align: center; padding: 10px 0; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: 14px; }
.days input:checked + label { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.days input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }
.trow { display: flex; gap: 8px; margin-bottom: 8px; }
.err { color: var(--warn); font-size: 14px; min-height: 0; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(72px + env(safe-area-inset-bottom, 0px)); z-index: 30; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 8px; max-width: min(92vw, 420px); font-size: 14px; }

@media (min-width: 760px) {
  body { padding-block: 24px 40px; }
  .grid { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 36px; }
  .tabbar { display: none; }
  .subtabs { display: flex; }
  .toast { bottom: 24px; }
  .sheet { align-items: center; }
  .panel { border-radius: 14px; max-height: 90%; }
}

/* PWA additions */
:root { color-scheme: light; }
body { margin: 0; padding-top: max(16px, env(safe-area-inset-top, 0px)); }
.statusline { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; font-size: 14px; }
.pill { font-family: var(--f-mono); font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.pill.off { background: var(--line); color: var(--ink2); }
.pill.bad { background: var(--warn-soft); color: var(--warn); }
.snap { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.snap:first-of-type { border-top: 0; }
#snaps-wrap:empty { display: none; }
.stack { grid-template-columns: minmax(0, 1fr); }
.stack > *, .block { min-width: 0; }
input[type=file] { max-width: 100%; }
.block, .card { grid-template-columns: minmax(0, 1fr); }
input[type=file] { width: 100%; }
