/* Peplogs Phase 6 dashboard — dark theme, external only */
:root {
  --bg: #080b12;
  --card: #101626;
  --line: #1e2a44;
  --text: #e8eefc;
  --muted: #8b97b3;
  --accent: #7c5cff;
  --cyan: #2fd3c8;
  --warn: #f0b429;
  --danger: #ff5d6c;
  --ok: #3dd68c;
}
* { box-sizing: border-box; }
/* Layout rules must never reveal a collapsed calendar, form, or history row. */
[hidden] { display: none !important; }
html { color-scheme: dark; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
input, select, textarea { min-width: 0; max-width: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 980px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.top { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: 1rem; }
.brand { font-weight: 700; letter-spacing: 0.02em; font-size: 1.15rem; }
.tabs {
  display: flex; flex-wrap: wrap; gap: 0.35rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.25rem; padding-bottom: 0.5rem;
}
.tabs a {
  color: var(--muted);
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  border: 1px solid transparent;
}
.tabs a.on, .tabs a:hover {
  color: var(--text);
  background: #151d31;
  border-color: var(--line);
}
.tabs a.on { box-shadow: inset 0 0 0 1px var(--accent); }
.panel h2 { font-size: 1.05rem; margin: 1.25rem 0 0.55rem; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 0.75rem;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem 1rem;
}
.form-grid label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--muted); }
.form-grid .span2 { grid-column: 1 / -1; }
.form-grid .check { flex-direction: row; align-items: center; gap: 0.5rem; }
input, select, button {
  font: inherit;
  color: var(--text);
  background: #0b1020;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
}
button {
  background: linear-gradient(135deg, var(--accent), #4f7cff);
  border: none;
  cursor: pointer;
  font-weight: 600;
}
button.danger { background: var(--danger); }
button.secondary {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 500;
}
button.secondary:hover {
  color: var(--text);
  border-color: var(--muted);
  filter: none;
}
button:hover { filter: brightness(1.08); }
button.secondary:hover { filter: none; }
.actions { display: flex; gap: 0.5rem; align-items: end; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.45rem 0.35rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }
.warn { color: var(--warn); }
.flash { padding: 0.65rem 0.8rem; border-radius: 8px; border: 1px solid var(--line); }
.flash.err { border-color: var(--danger); color: #ffc2c8; background: #2a1216; }
.flash.ok { border-color: var(--ok); color: #b8f5d4; background: #10261c; }
.plain { margin: 0; padding-left: 1.1rem; }
.plain.dates { margin-top: 0.25rem; }
.inline { display: inline; }
.foot { margin-top: 2rem; font-size: 0.8rem; }
details.quick-log { padding-top: 0.65rem; }
details.quick-log > summary {
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 600;
  list-style: none;
  margin-bottom: 0.35rem;
}
details.quick-log > summary::-webkit-details-marker { display: none; }
details.quick-log > summary::before {
  content: "▸ ";
  color: var(--muted);
}
details.quick-log[open] > summary::before { content: "▾ "; }
details.quick-log > summary:hover { color: var(--cyan); }
details.quick-log[open] .form-grid { margin-top: 0.75rem; }
details.protocol-form { padding: 0.9rem 1rem; }
details.protocol-form > summary { cursor: pointer; font-size: 1.05rem; font-weight: 700; }
details.protocol-form > summary::marker { color: var(--cyan); }
details.protocol-form[open] > summary { margin-bottom: 0.75rem; }
.protocol-days { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; }
.time-picker { display: flex; flex-direction: column; gap: 0.45rem; }
.time-picker-label { color: var(--muted); font-size: 0.85rem; }
.time-choice-row { display: grid; grid-template-columns: 5rem minmax(4.5rem, 1fr) auto minmax(4.5rem, 1fr) minmax(5.5rem, 1fr); gap: 0.45rem; align-items: center; }
.time-choice-row select { width: 100%; }
.protocol-days label { flex-direction: row; align-items: center; gap: 0.3rem; }
.daterow { display: flex; gap: 0.75rem; }
.daterow label { flex: 1; }
.protocol-help { margin-bottom: 0; }
.guide-card { border-color: rgba(104, 225, 253, 0.35); }
.guide-card h2 { color: var(--cyan); }
.guide-card p { margin-top: 0; }
.guide-steps { margin: 0.5rem 0 0.75rem; padding-left: 1.25rem; }
.guide-steps li { margin: 0.35rem 0; }
.page-guide { color: var(--muted); max-width: 70rem; margin: -0.35rem 0 0.9rem; }

/* Phase D — dose edit/delete */
.dose-actions { white-space: nowrap; display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.inline-form { display: inline; margin: 0; }
.signout-form { display: inline; margin: 0; }
.link-button { background: transparent; border: 0; color: var(--cyan); padding: 0; font: inherit; cursor: pointer; }
.link-button:hover { text-decoration: underline; }
.dose-edit-row td { background: var(--card, #121820); border-top: none; }
.dose-edit-form { margin: 0.25rem 0 0.5rem; }
button.danger { border-color: #a44; color: #f88; }

.chart-card { overflow: hidden; }
#dose-chart, canvas[data-role="dose-chart"] {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  background: #0b1020;
  cursor: crosshair;
}
#dose-chart:focus, canvas[data-role="dose-chart"]:focus {
  outline: 2px solid var(--accent, #5b8cff);
  outline-offset: 2px;
}
.dose-chart-readout { min-height: 1.25rem; margin: 0.35rem 0 0; font-size: 0.85rem; }
.chart-legend { font-size: 0.8rem; margin: 0.35rem 0 0; }

.chart-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 0.65rem;
}

.chart-toolbar {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}
.chart-toolbar select { min-width: 7.5rem; }
.feedback-link {
  color: var(--text) !important;
  background: #151d31;
  border-color: var(--cyan) !important;
  white-space: nowrap;
  font-weight: 600;
}
.feedback-card { margin-top: 1rem; }
.feedback-card h3 { margin-top: 0; }
.feedback-card textarea { min-height: 7rem; resize: vertical; }
.feedback-inbox { margin-top: 1rem; }
.feedback-inbox li { margin: 0.75rem 0; white-space: pre-wrap; }
.chart-unit {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.chart-unit select { min-width: 8rem; }

details.stack-members { margin-top: 0.25rem; font-size: 0.85rem; }
details.stack-members > summary { cursor: pointer; list-style: none; }
details.stack-members > summary::-webkit-details-marker { display: none; }
details.stack-members > summary::before { content: "▸ "; }
details.stack-members[open] > summary::before { content: "▾ "; }
ul.stack-member-list { margin: 0.35rem 0 0 1rem; padding: 0; color: var(--muted, #8b97b3); }
ul.stack-member-list li { margin: 0.15rem 0; }


/* Quick log — syringe fill + injection sites */
.log-viz {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0b1020;
}
.log-viz .syringe-cap-label {
  max-width: 14rem;
  color: var(--muted);
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.syringe-viz {
  width: 100%;
}
.syringe-viz svg {
  display: block;
  width: 100%;
  height: auto;
}
.syringe-caption {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 6px 0 0;
  text-align: center;
}
.syringe-readout {
  margin: 0;
  font-size: 0.9rem;
  min-height: 1.25rem;
}
.syringe-help,
.syringe-disclaimer {
  margin: 0;
  font-size: 0.8rem;
}
.injection-sites-img {
  display: block;
  max-width: 780px;
  width: 100%;
  height: auto;
  margin-top: 0.35rem;
  border-radius: 8px;
  border: 1px solid var(--line);
}

/* Calculator tab — standalone recon UI (scoped) */
#panel-calc .card.wide { max-width: 100%; }
#panel-calc .cfield {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  flex: 1;
  min-width: 160px;
}
#panel-calc .cfield .unitrow {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
#panel-calc .cfield .unitrow input { flex: 1; min-width: 0; }
#panel-calc .ccustom {
  display: flex;
  gap: 6px;
  flex: 1 0 100%;
  width: 100%;
  min-width: 0;
  align-items: stretch;
}
#panel-calc .ccustom[hidden] { display: none !important; }
#panel-calc .ccustom input { flex: 1 1 auto; min-width: 0; width: auto; }
#panel-calc .ccustom select { flex: 0 0 auto; width: auto; max-width: none; }
#panel-calc .cfield input { font-size: 15px; }
#panel-calc .cfield select { font-size: 0.85rem; max-width: 100%; }
#panel-calc .result {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ok);
  margin-top: 12px;
}
#panel-calc .guard {
  font-size: 0.9rem;
  margin-top: 10px;
  font-weight: 700;
  color: var(--ok);
  white-space: pre-wrap;
}
#panel-calc .guard.warn { color: var(--warn); }
#panel-calc .working {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  margin-top: 8px;
  color: var(--text);
}
#panel-calc .calc-syringe {
  margin-top: 14px;
  width: 100%;
  max-width: 750px;
}
#panel-calc .calc-syringe svg {
  width: 100%;
  height: auto;
  display: block;
}
#panel-calc .calc-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
#panel-calc .calc-head h2 {
  margin: 0;
  font-size: 1.22rem;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
}
#panel-calc .calc-sub {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 4px 0 0;
}
#panel-calc .calc-reset {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #0d1424;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 10px;
  padding: 7px 13px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.85rem;
}
#panel-calc .calc-reset:hover {
  color: var(--text);
  border-color: var(--accent);
  filter: none;
}
#panel-calc .calc-section {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
#panel-calc .calc-section:first-of-type {
  border-top: 0;
  margin-top: 0;
  padding-top: 2px;
}
#panel-calc .calc-sec-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
#panel-calc .secbadge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 27px;
  height: 27px;
  border-radius: 8px;
  background: var(--ok);
  color: #07140b;
  font-weight: 900;
  font-size: 0.92rem;
}
#panel-calc .secbadge.bg2 {
  background: #68e1fd;
  color: #06141c;
}
#panel-calc .calc-sec-head h3 {
  margin: 0;
  font-size: 1.02rem;
  color: var(--text);
}
#panel-calc .input-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 12px;
}
#panel-calc .calc-banner {
  margin: 16px 0 0;
  background: rgba(124, 92, 255, 0.08);
  border: 1px solid rgba(124, 92, 255, 0.28);
  color: var(--muted);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 0.86rem;
}
#panel-calc .draw-row {
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: flex-start;
}
#panel-calc .draw-viz { margin: 0 auto; flex: 0 0 auto; }
#panel-calc .draw-results {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  width: 100%;
}
#panel-calc .draw-row-item {
  background: #0d1424;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
#panel-calc .row-k {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  min-width: 108px;
}
#panel-calc .row-v {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
}
#panel-calc .badge {
  background: rgba(98, 217, 140, 0.14);
  color: var(--ok);
  border: 1px solid rgba(98, 217, 140, 0.42);
  font-weight: 800;
  font-size: 0.82rem;
  border-radius: 999px;
  padding: 2px 11px;
}
#panel-calc .calc-summary {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
  background: rgba(98, 217, 140, 0.07);
  border: 1px solid rgba(98, 217, 140, 0.3);
  border-radius: 12px;
  padding: 12px 14px;
}
#panel-calc .sum-check {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--ok);
  color: #07140b;
  font-weight: 900;
  font-size: 0.95rem;
}
#panel-calc .sum-text {
  flex: 1;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.5;
}
#panel-calc .target-badge {
  flex: 0 0 auto;
  align-self: flex-start;
  background: #0d1424;
  border: 1px solid var(--line);
  color: #68e1fd;
  border-radius: 10px;
  padding: 6px 12px;
  font-weight: 800;
  font-size: 0.85rem;
  white-space: nowrap;
}
#panel-calc .calc-disclaimer {
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.76rem;
  border-top: 1px dashed var(--line);
  padding-top: 12px;
}
#panel-calc .calc-stack-note {
  margin-top: 14px;
  background: rgba(255, 180, 84, 0.08);
  border: 1px solid rgba(255, 180, 84, 0.32);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.86rem;
  line-height: 1.55;
}
#panel-calc .calc-stack-note strong {
  color: var(--warn);
  display: block;
  margin-bottom: 6px;
  font-size: 0.78rem;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
#panel-calc .calc-stack-note p { margin: 0 0 8px; }
#panel-calc .calc-stack-note p:last-child { margin: 0; }

/* Stock inventory dashboard */
.ql-conc {
  margin: 0;
  min-height: 1.2em;
  font-size: 0.88rem;
}
.stock-panel { --stock-surface: #0d1423; --stock-raised: #121b2e; }
.stock-hero { position: relative; isolation: isolate; display: flex; align-items: flex-end; justify-content: space-between; gap: 2rem; overflow: hidden; padding: 2rem; margin-bottom: 1rem; border: 1px solid rgba(104, 225, 253, 0.22); border-radius: 22px; background: radial-gradient(circle at 82% 18%, rgba(47, 211, 200, 0.18), transparent 27%), radial-gradient(circle at 58% 110%, rgba(124, 92, 255, 0.25), transparent 43%), linear-gradient(145deg, #111a2d, #0b1120 72%); box-shadow: 0 22px 70px rgba(0, 0, 0, 0.28); }
.stock-hero::after { content: ""; position: absolute; z-index: -1; width: 260px; height: 260px; right: -105px; top: -125px; border: 1px solid rgba(104, 225, 253, 0.2); border-radius: 50%; box-shadow: 0 0 0 36px rgba(104, 225, 253, 0.035), 0 0 0 72px rgba(124, 92, 255, 0.025); }
.stock-eyebrow { margin: 0 0 0.45rem; color: var(--cyan); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.18em; text-transform: uppercase; }
.stock-hero h1 { margin: 0; font-size: clamp(2rem, 5vw, 3.1rem); line-height: 1; letter-spacing: -0.045em; }
.stock-hero p:last-child { max-width: 35rem; margin: 0.75rem 0 0; color: #aebbd4; font-size: 1rem; }
.button-link { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 0.75rem; min-height: 46px; padding: 0.65rem 0.8rem 0.65rem 1rem; color: #07101b; background: var(--cyan); border-radius: 12px; font-weight: 800; box-shadow: 0 10px 24px rgba(47, 211, 200, 0.2); }
.button-link span { display: grid; place-items: center; width: 26px; height: 26px; background: rgba(7, 16, 27, 0.12); border-radius: 8px; font-size: 1.25rem; }
.button-link:hover { text-decoration: none; filter: brightness(1.06); }
.stock-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.75rem; margin-bottom: 2rem; }
.stock-stat { display: flex; align-items: center; gap: 0.85rem; min-height: 84px; padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: 16px; background: linear-gradient(145deg, rgba(18, 27, 46, 0.96), rgba(13, 20, 35, 0.96)); }
.stock-stat-icon { position: relative; width: 34px; height: 34px; flex: 0 0 auto; border-radius: 11px; background: rgba(139, 151, 179, 0.12); }
.stock-stat-icon::before { content: ""; position: absolute; inset: 8px 10px; border: 2px solid #8b97b3; border-top-width: 5px; border-radius: 3px; }
.stock-stat-primary .stock-stat-icon { background: rgba(47, 211, 200, 0.14); }
.stock-stat-primary .stock-stat-icon::before { border-color: var(--cyan); }
.stock-stat-alert .stock-stat-icon { background: rgba(240, 180, 41, 0.14); }
.stock-stat-alert .stock-stat-icon::before { border-color: var(--warn); }
.stock-stat strong, .stock-stat small { display: block; }
.stock-stat strong { font-size: 1.45rem; line-height: 1.05; }
.stock-stat small { margin-top: 0.25rem; color: var(--muted); font-size: 0.76rem; }
.stock-section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin: 0 0 0.8rem; }
.stock-section-heading h2 { margin: 0; font-size: 1.15rem; }
.stock-section-heading p { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.86rem; }
.stock-section-count, .stock-step { flex: 0 0 auto; color: var(--cyan); font-size: 0.74rem; font-weight: 750; letter-spacing: 0.05em; text-transform: uppercase; }
.inventory-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.85rem; }
.inventory-card { display: grid; grid-template-columns: 112px minmax(0, 1fr); min-height: 214px; overflow: hidden; border: 1px solid #253351; border-radius: 18px; background: linear-gradient(145deg, var(--stock-raised), var(--stock-surface)); box-shadow: 0 14px 34px rgba(0, 0, 0, 0.18); transition: transform 160ms ease, border-color 160ms ease; }
.inventory-card:hover { transform: translateY(-2px); border-color: #3e527b; }
.inventory-card.is-low { border-color: rgba(240, 180, 41, 0.42); }
.inventory-card-visual { position: relative; display: grid; place-items: center; overflow: hidden; background: radial-gradient(circle at 50% 42%, rgba(104, 225, 253, 0.13), transparent 46%), rgba(7, 12, 22, 0.55); border-right: 1px solid rgba(139, 151, 179, 0.13); }
.inventory-card-visual::after { content: ""; position: absolute; left: 14%; right: 14%; bottom: 18px; height: 8px; border-radius: 50%; background: #0008; filter: blur(5px); }
.inventory-card-visual img { z-index: 1; width: 82px; height: 112px; object-fit: contain; filter: drop-shadow(0 10px 12px #0009); }
.inventory-monogram { z-index: 1; display: grid; place-items: center; width: 64px; height: 64px; color: var(--cyan); background: #101a2d; border: 1px solid #33476c; border-radius: 18px; font-size: 1.75rem; font-weight: 800; }
.inventory-card-body { display: flex; min-width: 0; flex-direction: column; padding: 1rem; }
.inventory-card-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; }
.inventory-card-title h3 { margin: 0; overflow-wrap: anywhere; font-size: 1rem; }
.inventory-card-title p { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.74rem; }
.stock-badge { flex: 0 0 auto; padding: 0.28rem 0.48rem; color: #8ff0d0; background: rgba(61, 214, 140, 0.1); border: 1px solid rgba(61, 214, 140, 0.3); border-radius: 999px; font-size: 0.68rem; font-weight: 800; text-transform: uppercase; }
.stock-badge.is-low { color: #ffd783; background: rgba(240, 180, 41, 0.1); border-color: rgba(240, 180, 41, 0.34); }
.inventory-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; margin: 1rem 0 0; }
.inventory-metrics div { min-width: 0; padding: 0.65rem; background: rgba(6, 10, 19, 0.42); border: 1px solid rgba(139, 151, 179, 0.12); border-radius: 10px; }
.inventory-metrics dt { color: var(--muted); font-size: 0.67rem; }
.inventory-metrics dd { margin: 0.2rem 0 0; font-size: 1.02rem; font-weight: 800; overflow-wrap: anywhere; }
.inventory-metrics dd small { color: var(--muted); font-size: 0.65rem; font-weight: 600; }
.inventory-metrics dd .muted { font-size: 0.8rem; font-weight: 500; }
.inventory-card-meta { display: flex; flex-wrap: wrap; gap: 0.3rem 0.6rem; margin-top: auto; padding-top: 0.8rem; color: var(--muted); font-size: 0.7rem; }
.inventory-card-meta span + span::before { content: "•"; margin-right: 0.6rem; color: #465474; }
.inventory-empty { grid-column: 1 / -1; padding: 2.2rem 1.5rem; text-align: center; border: 1px dashed #334563; border-radius: 18px; background: rgba(16, 22, 38, 0.65); }
.inventory-empty-icon { display: grid; place-items: center; width: 44px; height: 44px; margin: 0 auto 0.8rem; color: var(--cyan); background: rgba(47, 211, 200, 0.1); border: 1px solid rgba(47, 211, 200, 0.3); border-radius: 14px; font-size: 1.5rem; }
.inventory-empty h3 { margin: 0; }
.inventory-empty p { max-width: 32rem; margin: 0.45rem auto 0.75rem; color: var(--muted); }
.stock-add-heading { margin-top: 2.25rem; scroll-margin-top: 1rem; }
.stock-add-card { padding: 1.2rem; border-radius: 18px; background: linear-gradient(145deg, var(--stock-raised), var(--stock-surface)); }
.stock-form-note { margin: 0 0 0.2rem; padding: 0.8rem 0.9rem; color: #acb9d2; background: rgba(47, 211, 200, 0.055); border-left: 3px solid var(--cyan); border-radius: 0 9px 9px 0; font-size: 0.82rem; }
.stock-form-note strong { color: var(--text); }
.stock-records-heading { margin-top: 2rem; }
.stock-records { border-radius: 18px; }
.mrow {
  display: grid;
  grid-template-columns: 1.4fr 1fr 0.8fr auto;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}
.mrow select,
.mrow input,
.mrow button {
  width: 100%;
  min-height: 40px;
}
@media (max-width: 640px) {
  .mrow {
    grid-template-columns: 1fr;
  }
}

/* Chart series color legend */
.chart-series-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 1rem;
  margin: 0.55rem 0 0.25rem;
  align-items: center;
}
.chart-series-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--tx, #e6edff);
}
.chart-series-swatch {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  display: block;
}
.chart-series-label { font-weight: 600; }
.chart-card { margin-bottom: 1rem; }

/* Stock stack builder */
details.stack-config {
  margin: 1rem 0;
  padding: 0.8rem 1rem;
}
details.stack-config > summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  list-style: none;
  color: var(--text);
  font-weight: 700;
}
details.stack-config > summary::-webkit-details-marker { display: none; }
details.stack-config > summary::before {
  content: "+";
  color: var(--cyan);
  font-size: 1.15rem;
  line-height: 1;
}
details.stack-config[open] > summary::before { content: "−"; }
details.stack-config[open] > summary { margin-bottom: 0.9rem; }
details.stack-config .form-grid { margin: 0; }

/* Upcoming doses calendar */
.expected-cal-card { overflow-x: auto; }
.expected-cal-range { margin: 0 0 0.65rem; font-size: 0.85rem; }
.expected-cal {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0.35rem;
  font-size: 0.82rem;
}
.expected-cal thead th {
  text-align: center;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  padding: 0.2rem;
  border-bottom: none;
}
.expected-cal-cell {
  vertical-align: top;
  background: #0b1020;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.35rem 0.3rem 0.4rem;
  min-height: 4.25rem;
  height: 100%;
}
.expected-cal-cell.is-pad {
  opacity: 0.38;
  background: transparent;
  border-style: dashed;
}
.expected-cal-cell.is-empty .expected-cal-empty {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.75rem;
}
.expected-cal-cell.has-events {
  border-color: #2a3a62;
  box-shadow: inset 0 0 0 1px rgba(124, 92, 255, 0.18);
}
.expected-cal-daynum {
  display: block;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text);
  margin-bottom: 0.2rem;
}
.expected-cal-mobile-date { display: none; }
.expected-cal-cell.is-pad .expected-cal-daynum { color: var(--muted); font-weight: 500; }
.expected-cal-events {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.expected-cal-chip {
  display: block;
  width: 100%;
  text-align: left;
  color: inherit;
  font: inherit;
  cursor: pointer;
  background: #151d31;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.2rem 0.3rem;
  line-height: 1.25;
  word-break: break-word;
}
.expected-cal-chip:hover, .expected-cal-chip:focus-visible { border-color: var(--acc2, #68e1fd); color: var(--text); }
.expected-cal-name { font-weight: 600; color: var(--text); }
.expected-cal-time { display: block; color: var(--cyan); font-size: 0.75rem; font-weight: 700; }
.expected-cal-dose { color: var(--muted); font-size: 0.75rem; white-space: nowrap; }
.expected-gaps {
  margin: 0.85rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.85rem;
}
.expected-gaps li { margin-bottom: 0.25rem; }
.vial-protocol { display: block; font-size: 0.75rem; }
.protocol-times { display: block; margin-top: 0.2rem; font-size: 0.78rem; }
@media (max-width: 640px) {
  .expected-cal-card { overflow-x: visible; }
  .expected-cal { display: block; font-size: 0.85rem; }
  .expected-cal thead { display: none; }
  .expected-cal tbody { display: grid; gap: 0.5rem; }
  .expected-cal tr { display: contents; }
  .expected-cal-cell { display: none; }
  .expected-cal-cell.has-events {
    display: grid;
    grid-template-columns: 5.75rem minmax(0, 1fr);
    gap: 0.65rem;
    min-height: 0;
    padding: 0.55rem 0.65rem;
    align-items: start;
  }
  .expected-cal-daynum { display: none; }
  .expected-cal-mobile-date {
    display: block;
    color: var(--cyan);
    font-weight: 700;
    white-space: nowrap;
    padding-top: 0.2rem;
  }
  .expected-cal-events { gap: 0.35rem; }
  .expected-cal-chip { padding: 0.4rem 0.5rem; }
  .expected-cal-dose { white-space: nowrap; }
}

.expected-cal-cell.is-today {
  outline: 1px solid var(--acc2, #68e1fd);
  outline-offset: -1px;
}
.expected-cal-range {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.section-heading h2, .section-heading p { margin-top: 0; }
.guide-show { margin-bottom: 1rem; }
.protocol-days input:disabled { opacity: 0.85; }
.calendar-selection { margin: 0; padding: 0.75rem; border-left: 3px solid var(--cyan); background: #0b1020; border-radius: 6px; color: var(--text); overflow-wrap: anywhere; }

/* Phone layouts: readable records, complete controls, and a full-width agenda. */
@media (max-width: 640px) {
  .wrap { padding: 1rem 0.875rem calc(2rem + env(safe-area-inset-bottom)); }
  .top { align-items: flex-start; flex-direction: column; gap: 0.25rem; margin-bottom: 0.8rem; }
  .brand { font-size: 1.1rem; }
  .who { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; color: var(--muted); font-size: 0.85rem; overflow-wrap: anywhere; }
  .tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.35rem; padding-bottom: 0.75rem; margin-bottom: 1rem; }
  .tabs a { display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 0.45rem 0.25rem; border-radius: 10px; font-size: 0.9rem; }
  .card { padding: 0.875rem; border-radius: 14px; }
  .panel, .panel > *, .form-grid > *, .daterow > * { min-width: 0; }
  .form-grid, #panel-calc .input-grid { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .form-grid label { font-size: 0.9rem; gap: 0.4rem; }
  input, select, textarea, #panel-calc .cfield input, #panel-calc .cfield select {
    font-size: 16px; min-height: 46px; width: 100%; padding: 0.65rem 0.7rem;
  }
  input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; min-height: 22px; flex: 0 0 auto; }
  button, summary { min-height: 44px; }
  button { padding: 0.65rem 0.9rem; }
  .link-button { min-height: 44px; }
  summary { align-content: center; }
  .actions { gap: 0.6rem; align-items: stretch; }
  .actions > button { flex: 1 1 120px; }
  .daterow { flex-direction: column; gap: 1rem; }
  .protocol-days label { min-height: 44px; padding-right: 0.5rem; }
  .section-heading { flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-bottom: 0.65rem; }
  .section-heading h2, .section-heading p { margin-bottom: 0; }
  .section-heading > button { flex: 0 0 auto; }
  .page-guide, .flash, .muted, .vial-protocol, .protocol-times { overflow-wrap: anywhere; }
  .vial-protocol, .protocol-times { font-size: 0.85rem; }
  #panel-home { display: flex; flex-direction: column; }
  #panel-home > .quick-log { order: 1; border-color: #465588; }
  #panel-home > .home-upcoming { order: 2; }
  #panel-home > .home-chart { order: 3; }
  #panel-home > .home-vials { order: 4; }
  #panel-home > .home-history { order: 5; }
  .guide-show { align-self: flex-start; }
  .expected-cal { margin: 0; }
  .expected-cal tbody { gap: 0.75rem; }
  .expected-cal-cell.has-events { grid-template-columns: minmax(0, 1fr); padding: 0.75rem; gap: 0.55rem; border-radius: 12px; }
  .expected-cal-mobile-date { padding: 0; font-size: 0.9rem; }
  .expected-cal-events { gap: 0.45rem; }
  .expected-cal-chip { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 0.65rem; row-gap: 0.2rem; min-height: 60px; padding: 0.65rem; border-radius: 9px; }
  .expected-cal-name { grid-column: 1; grid-row: 1 / 3; font-size: 0.9rem; line-height: 1.4; overflow-wrap: anywhere; word-break: normal; }
  .expected-cal-time { grid-column: 2; grid-row: 1; font-size: 0.8rem; text-align: right; }
  .expected-cal-dose { grid-column: 2; grid-row: 2; font-size: 0.8rem; text-align: right; }
  .expected-cal-week .expected-cal-cell.is-empty { display: flex; align-items: center; justify-content: space-between; padding: 0.7rem; min-height: 0; gap: 0.5rem; }
  .expected-cal-cell.is-empty .expected-cal-empty { margin: 0; }
  .table-wrap { overflow: visible; }
  .card.table-wrap { padding: 0; border: 0; background: transparent; }
  .record-table, .record-table tbody { display: block; width: 100%; }
  .record-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .record-table tbody > tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8rem 1rem; padding: 1rem; margin-bottom: 0.75rem; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
  .record-table td { display: block; min-width: 0; border: 0; padding: 0; overflow-wrap: anywhere; font-size: 0.95rem; }
  .record-table td::before { content: attr(data-label); display: block; margin-bottom: 0.25rem; color: var(--muted); font-size: 0.75rem; font-weight: 500; }
  .record-table td:first-child { grid-column: 1 / -1; font-weight: 650; font-size: 1rem; }
  .record-table td:first-child::before { display: none; }
  .record-table td.mobile-wide, .record-table td[colspan] { grid-column: 1 / -1; }
  .record-table td[colspan] { font-weight: normal; }
  .record-table td.dose-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; padding-top: 0.25rem; }
  .record-table td.dose-actions::before { display: none; }
  .dose-actions > button, .dose-actions > form { flex: 1 1 100px; }
  .dose-actions > form button { width: 100%; }
  .record-table .dose-edit-row { border-color: #465588; }
  .stock-hero { align-items: flex-start; flex-direction: column; gap: 1.25rem; padding: 1.4rem; border-radius: 18px; }
  .stock-hero p:last-child { font-size: 0.9rem; }
  .stock-hero .button-link { width: 100%; justify-content: space-between; min-height: 48px; }
  .stock-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.45rem; margin-bottom: 1.6rem; }
  .stock-stat { min-height: 78px; flex-direction: column; align-items: flex-start; gap: 0.5rem; padding: 0.75rem; }
  .stock-stat-icon { width: 26px; height: 26px; border-radius: 8px; }
  .stock-stat-icon::before { inset: 6px 8px; border-width: 1.5px; border-top-width: 4px; }
  .stock-stat strong { font-size: 1.2rem; }
  .stock-stat small { font-size: 0.68rem; }
  .stock-section-heading { align-items: flex-start; }
  .stock-section-count, .stock-step { padding-top: 0.2rem; }
  .inventory-grid { grid-template-columns: minmax(0, 1fr); }
  .inventory-card { grid-template-columns: 92px minmax(0, 1fr); min-height: 200px; }
  .inventory-card:hover { transform: none; }
  .inventory-card-visual img { width: 72px; height: 100px; }
  .inventory-card-body { padding: 0.85rem; }
  .inventory-card-title { gap: 0.35rem; }
  .inventory-metrics { gap: 0.4rem; margin-top: 0.8rem; }
  .inventory-metrics div { padding: 0.55rem; }
  .stock-add-card { padding: 1rem; }
  .mrow { padding: 0.75rem; border: 1px solid var(--line); border-radius: 10px; gap: 0.65rem; }
  #panel-calc .cfield { min-width: 0; }
  #panel-calc .calc-head { flex-wrap: wrap; }
  #panel-calc .target-badge { white-space: normal; }
  #panel-calc .draw-viz { max-width: 100%; }
  #panel-calc .calc-reset { min-height: 44px; }
  .syringe-viz { min-width: 0; }
  .time-choice-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); gap: 0.5rem; }
  .time-choice-row > .muted { grid-column: 1 / -1; }
  .time-choice-row > [aria-hidden="true"] { display: none; }
  .chart-legend, .dose-chart-readout { font-size: 0.85rem; line-height: 1.5; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
