/* Siklos® calculator — application styling.
   Materialize is loaded first. The rules below preserve the bespoke interface.
   Edit colors and layout here; functionality lives in app.js. */

:root{
  --paper:#f8f7f4; --surface:#fff; --ink:#22242b; --muted:#70727a;
  --line:#e8e5e1; --wine:#a9294a; --wine-dark:#7f1b36;
  --wine-soft:#fff0f4; --gold:#b58949; --gold-soft:#fff8ec;
  --shadow:0 22px 72px rgba(39,31,39,.08);
}
*{box-sizing:border-box}
html{scroll-behavior:smooth}
body{margin:0;background:var(--paper);color:var(--ink);font:16px/1.55 system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}
button,input,select{font:inherit}
button{cursor:pointer}
button:focus-visible,input:focus-visible,select:focus-visible{outline:3px solid rgba(169,41,74,.27);outline-offset:3px}
a{color:var(--wine-dark)}
.shell{max-width:1110px;margin:auto;padding:0 28px}
.site-header{border-bottom:1px solid var(--line);background:rgba(255,255,255,.89)}
.header-inner{height:84px;display:flex;align-items:center;justify-content:space-between;gap:20px}
.wordmark{font-size:27px;font-weight:850;letter-spacing:-1.2px;line-height:1}
.wordmark span{color:var(--wine)}
.wordmark small{font-size:14px;letter-spacing:0;font-weight:500;color:#7a7a80}
.header-tag{font-size:11px;letter-spacing:1.5px;font-weight:700;text-transform:uppercase;color:#77747b}
.main{padding-top:32px;padding-bottom:48px}
.eyebrow{display:block;font-size:11px;font-weight:800;letter-spacing:2px;text-transform:uppercase;color:var(--wine)}
h1{font-size:clamp(34px,5.2vw,58px);letter-spacing:-2.1px;line-height:1.13;margin:11px 0 16px;font-weight:770}
.intro{max-width:745px;margin-bottom:40px}
.intro p{max-width:640px;color:var(--muted);font-size:17px;margin:0}
.result-view{opacity:0;transform:translateY(13px);transition:opacity .45s ease,transform .45s ease;display:none}
.result-view.visible{display:block;opacity:1;transform:none}
.toolbar{display:flex;align-items:center;justify-content:flex-end;gap:16px;margin-bottom:16px}
.step-meta{display:inline-flex;align-items:center;gap:10px;text-transform:uppercase;letter-spacing:1.15px;font-size:12px;font-weight:800;color:#79767a}
.dot{width:29px;height:29px;border-radius:50%;display:grid;place-items:center;background:var(--wine-soft);color:var(--wine);font-size:13px;letter-spacing:0}
.edit-button{width:46px;height:46px;display:grid;place-items:center;border:1px solid #ded6d9;border-radius:15px;background:white;color:var(--wine);box-shadow:0 6px 20px #22222209;transition:transform .2s,border-color .2s}
.edit-button:hover{border-color:var(--wine);transform:translateY(-2px)}
.edit-button .material-icons{font-size:21px;line-height:1}
.toolbar-actions{display:flex;align-items:center;gap:10px}
.edit-caption{font-size:13px;color:#6d6870;font-weight:650}
.card{border:1px solid var(--line);background:var(--surface);border-radius:24px;box-shadow:var(--shadow)}
.dose-hero{padding:36px 39px;background:linear-gradient(115deg,#fff9fa 0%,#fff 75%);display:grid;grid-template-columns:1.1fr .9fr;gap:32px;align-items:center}
.label-top{text-transform:uppercase;letter-spacing:1.35px;font-size:11px;font-weight:800;color:#9f3b52}
.big-dose{font-size:clamp(48px,7.2vw,79px);font-weight:780;letter-spacing:-3.3px;line-height:1.14;color:var(--wine-dark);margin:13px 0 8px;white-space:nowrap}
.big-dose small{font-size:20px;letter-spacing:0;font-weight:630;color:var(--wine-dark)}
.dose-sub{font-size:15px;color:#727076;margin:0}
.hero-details{border-left:1px solid #efe3e6;padding-left:33px;display:grid;gap:19px}
.detail-item{display:flex;flex-direction:column;gap:2px}
.detail-item span{font-size:12px;color:#77737a}
.detail-item strong{font-weight:700;font-size:19px;letter-spacing:-.3px}
.status{display:inline-flex;gap:8px;align-items:center;padding:8px 11px;background:#eff5ef;border-radius:9px;color:#3c6743;font-size:12px;font-weight:800;width:fit-content}
.status.warn{background:#fff4e5;color:#99602b}
.status svg{width:15px;height:15px;stroke:currentColor;fill:none;stroke-width:2}
.section-card{margin-top:30px;padding:0}
.section-head{display:flex;justify-content:space-between;align-items:flex-start;gap:18px;margin-bottom:22px}
h2{font-size:23px;letter-spacing:-.7px;line-height:1.3;margin:0 0 6px}
h3{font-size:16px;letter-spacing:-.3px;margin:0 0 7px}
.section-head p,.subhead{margin:0;color:var(--muted);font-size:14px}
.tablet-list{display:grid;gap:13px}
.tablet-card{border:1px solid #eee4e3;background:#fffdfb;border-radius:17px;padding:21px 24px;display:grid;grid-template-columns:1fr auto;gap:18px;align-items:center}
.tablet-card.tablet-1000{background:#fff9fa;border-color:#f0dce1}
.tablet-name{display:flex;align-items:center;gap:10px;font-size:16px;font-weight:750}
.strength-mark{width:9px;height:9px;background:#b38c4c;border-radius:50%}
.tablet-1000 .strength-mark{background:var(--wine)}
.tablet-card p{font-size:14px;color:#68646b;margin:5px 0 7px}
.pill-row{display:flex;flex-wrap:wrap;gap:7px;margin-top:11px;align-items:center}
.pill{display:inline-flex;align-items:stretch;gap:2px;min-height:28px;padding:4px;background:#fbefdb;border:1.5px solid #b38c4c;border-radius:17px;overflow:hidden}
.pill.pill-1000{background:#fde9ef;border-color:#b62a4b}
.pill i{display:block;width:21px;min-height:20px;background:#d8b573;border-right:1px solid #b38c4c;border-radius:2px}
.pill.pill-1000 i{background:#c84b67;border-color:#a5294a}
.pill i.off{opacity:.13}
.more-pills{font-size:12px;color:#797079;margin-left:5px}
.mg-contribution{text-align:right;color:var(--ink);font-size:23px;font-weight:790;white-space:nowrap}
.mg-contribution small{font-size:13px;color:#777;font-weight:550}
.total-line{margin-top:19px;padding:16px 20px;border-radius:13px;background:#f1f5f0;color:#42634c;font-size:14px}
.note-box{border-radius:13px;padding:17px 20px;line-height:1.6;font-size:13px;color:#765e4c;background:#f9f4ea;margin-top:21px}
.notice-warning{background:#fff5e8;color:#845b2b;border-radius:14px;padding:18px 20px;line-height:1.6;font-size:14px;margin-top:17px}
.notice-warning strong{display:block;margin-bottom:5px}
.planning{margin-top:28px;padding:34px 39px}
.planning-head{display:flex;align-items:center;gap:15px;margin-bottom:22px}
.planning-symbol{width:47px;height:47px;flex-shrink:0;display:grid;place-items:center;border-radius:14px;background:var(--wine-soft);color:var(--wine)}
.planning-symbol .material-icons{font-size:25px;line-height:1}
.planning .subhead{max-width:690px}
.date-row{display:grid;grid-template-columns:1fr 1fr auto;gap:17px;align-items:end}
label{font-weight:680;font-size:13px;display:block;margin:0 0 9px}
.control{width:100%;min-height:52px;background:#fff;border:1px solid #dcd9d6;border-radius:12px;padding:13px 14px;color:var(--ink);font-size:16px}
.control:focus{border-color:var(--wine);outline:3px solid #a9294a20}
.field-hint{font-size:12px;color:#78767b;line-height:1.5;margin:8px 0 0}
.primary{background:var(--wine);color:#fff;border:1px solid var(--wine);border-radius:12px;font-weight:760;min-height:52px;padding:13px 24px;transition:background .2s,transform .2s}
.primary:hover{background:var(--wine-dark);transform:translateY(-1px)}
.ghost{background:white;color:#5d5960;border:1px solid #e0dbde;border-radius:12px;padding:12px 19px;min-height:49px;font-weight:650}
.ghost:hover{border-color:#bd9da6;color:var(--wine-dark)}
.small-illustration{display:flex;gap:10px;align-items:center;font-size:12px;color:#89838a;margin-top:20px}
.small-illustration b{font-weight:650;color:#625d63}
.small-illustration .material-icons{font-size:18px;flex-shrink:0}
.supply-result{margin-top:24px;border-top:1px solid var(--line);padding-top:23px}
.supply-summary{font-size:14px;color:#5d5962;margin-bottom:18px}
.supply-summary strong{color:var(--ink)}
.box-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}
.box-estimate{padding:19px 21px;border:1px solid #ecdfc9;border-radius:15px;background:var(--gold-soft)}
.box-estimate.box-1000{background:#fff5f8;border-color:#edd2d9}
.box-estimate .box-name{font-size:14px;font-weight:750}
.box-estimate .boxes-number{font-size:33px;font-weight:790;letter-spacing:-.9px;margin:8px 0 1px;color:#85602e}
.box-estimate.box-1000 .boxes-number{color:var(--wine-dark)}
.box-estimate p{font-size:12px;color:#66616a;margin:7px 0 0}
.pack-note{color:#79727a;font-size:12px;line-height:1.6;margin:17px 0 0}
.planning-alert{margin:15px 0 0;color:#a13b48;font-size:13px;font-weight:650}
.planning-alert:empty{display:none}
.resources{margin-top:28px;display:grid;grid-template-columns:1fr 1fr;gap:18px}
.resource{border:1px solid #eae4e1;border-radius:18px;padding:22px 24px;background:#fff9}
.resource p{font-size:13px;color:#6e6b70;margin:0}
footer{padding:28px 0 50px;color:#827e83;font-size:11px;line-height:1.7}
/* Initial form + editable modal overlay. Results stay behind it. */
.overlay{position:fixed;inset:0;z-index:20;display:flex;align-items:flex-start;justify-content:center;
  overflow:auto;padding:48px 18px;background:rgba(248,247,244,.88);backdrop-filter:blur(10px);
  -webkit-backdrop-filter:blur(10px);opacity:0;visibility:hidden;pointer-events:none;
  transition:opacity .4s ease,visibility .4s ease}
.overlay.is-open{opacity:1;visibility:visible;pointer-events:auto}
.dialog{width:min(100%,670px);margin:auto;overflow:hidden;background:var(--surface);border:1px solid #ece3e6;
  border-radius:27px;box-shadow:0 26px 90px #482c3830;opacity:0;transform:translateY(23px) scale(.987);
  transition:opacity .45s cubic-bezier(.2,.8,.2,1),transform .45s cubic-bezier(.2,.8,.2,1)}
.overlay.is-open .dialog{opacity:1;transform:none}
.dialog-top{padding:37px 43px 26px;border-bottom:1px solid #f0edef}
.dialog-step{color:var(--wine);font-size:11px;letter-spacing:1.5px;font-weight:800;text-transform:uppercase}
.dialog h2{margin:10px 0 10px;font-size:30px;font-weight:770;letter-spacing:-1px}
.dialog-top p{color:#77717a;font-size:14px;max-width:470px;margin:0}
.dialog-content{padding:31px 43px 35px}
.field-grid{display:grid;grid-template-columns:1fr 1fr;gap:22px}
.form-field{margin-bottom:26px}
.form-field:last-child{margin-bottom:0}
.input-wrap{display:flex;align-items:center;position:relative}
.input-wrap .control{padding-right:106px}
.input-wrap .suffix{position:absolute;right:14px;font-size:12px;color:#827a80;pointer-events:none}
.form-foot{display:flex;align-items:center;justify-content:space-between;gap:15px;border-top:1px solid var(--line);padding:21px 43px 29px;background:#fffdfd}
.form-foot .primary{min-width:180px}
.form-foot .btns{display:flex;justify-content:flex-end;gap:11px}
.form-foot p{max-width:260px;margin:0;color:#858088;font-size:11px;line-height:1.5}
.error-message{display:none;background:#fff1e9;color:#9b4431;border:1px solid #f6cfbf;border-radius:12px;padding:13px 15px;font-size:13px;line-height:1.5;margin:0 0 19px}
.error-message.show{display:block}
body.modal-open{overflow:hidden}
body.modal-open .result-view{filter:blur(2.5px);transition:filter .35s ease,opacity .45s,transform .45s}
@media(max-width:760px){
  .shell{padding:0 18px}.header-inner{height:72px}.header-tag{display:none}.main{padding-top:37px}
  .intro{margin-bottom:25px}.intro p{font-size:15px}
  .dose-hero{grid-template-columns:1fr;padding:27px;gap:20px}
  .hero-details{border-left:0;border-top:1px solid #efe3e6;padding:22px 0 0;grid-template-columns:1fr 1fr;gap:14px}
  .planning{padding:26px 23px}.date-row{grid-template-columns:1fr 1fr}
  .date-row button{grid-column:1/-1;width:100%}.resources{grid-template-columns:1fr}
  .dialog-top{padding:30px 25px 22px}.dialog-content{padding:26px 25px 24px}.form-foot{padding:20px 25px 25px}
}
@media(max-width:520px){
  .field-grid,.date-row,.box-grid{grid-template-columns:1fr;gap:0}
  .date-row{gap:17px}.form-field{margin-bottom:23px}
  .tablet-card{padding:17px 15px;grid-template-columns:1fr;gap:9px}.mg-contribution{text-align:left}
  .toolbar{align-items:flex-start}.edit-caption{display:none}.dialog{border-radius:20px}
  .dialog h2{font-size:26px}.form-foot{align-items:stretch;flex-direction:column}
  .form-foot .btns{width:100%}.form-foot .primary{flex:1;min-width:0}
  .form-foot .ghost{flex:0 0 auto}.overlay{padding:14px}
  .big-dose{font-size:clamp(45px,12vw,65px)}
}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important;scroll-behavior:auto!important}}
@media print{
  body{background:#fff}.site-header,.overlay,.toolbar-actions,.date-row,.planning-alert,.resources,.print-hide,footer{display:none!important}
  .result-view{display:block!important;opacity:1!important;transform:none!important;filter:none!important}
  .main{padding-top:0}.intro{margin-bottom:10px}.card{box-shadow:none;break-inside:avoid}
  .dose-hero,.planning{padding:16px 20px}.section-card{padding:0}.planning{break-before:avoid}
  .supply-result{margin-top:0}.small-illustration{display:none}
}

/* Materialize compatibility / components */
.card{margin:0;overflow:visible}
.card.planning{margin-top:28px}
input.browser-default.control,
select.browser-default.control{
  display:block;
  box-sizing:border-box;
  width:100%;
  height:52px;
  min-height:52px;
  margin:0;
  padding:12px 14px;
  border:1px solid #dcd9d6;
  border-radius:12px;
  background:#fff;
  color:var(--ink);
  box-shadow:none;
  font-size:16px;
  font-family:inherit;
}
input.browser-default.control:focus,
select.browser-default.control:focus{
  border-color:var(--wine);
  box-shadow:none;
  outline:3px solid #a9294a20;
}
.input-wrap input.browser-default.control{padding-right:106px}
button.primary,button.ghost{height:auto;line-height:1.35;text-transform:none;letter-spacing:normal;box-shadow:none}
button.primary:focus{background:var(--wine-dark)}
button.ghost:focus{background:#fff}
.edit-button .material-icons{font-size:21px;line-height:1}
.planning-symbol .material-icons{font-size:25px;line-height:1}
.small-illustration .material-icons{font-size:18px;flex-shrink:0}
.print-actions{margin-top:20px}
.print-action{display:inline-flex;align-items:center;gap:9px}
.print-action .material-icons{font-size:18px}
.form-foot .primary{display:inline-flex;align-items:center;justify-content:center;gap:7px}

/* Keep native hidden attributes in spite of Materialize display rules. */
[hidden]{display:none!important}
@media(max-width:760px){.main{padding-top:24px}}

/* One contextual information icon, opening an accessible modal dialog. */
.section-info{flex-shrink:0}
.info-button{display:inline-grid;place-items:center;width:34px;height:34px;padding:0;
  border:1px solid #e6dfe1;border-radius:50%;background:#fff;color:#8a7a82;
  cursor:pointer;transition:background .18s,border-color .18s,color .18s}
.info-button:hover{color:var(--wine);background:var(--wine-soft);border-color:#e6b7c3}
.info-button:focus-visible{outline:3px solid rgba(169,41,74,.27);outline-offset:3px}
.info-button .material-icons{font-size:20px;line-height:1}
.info-button svg{width:20px;height:20px;display:block}
.information-modal{box-sizing:border-box;width:min(490px,calc(100vw - 32px));max-height:min(88vh,640px);
  padding:28px 30px;background:#fff;border:1px solid #e9e0e2;border-radius:22px;
  color:var(--ink);box-shadow:0 25px 80px #24182235;overflow-y:auto;position:fixed;
  inset:0;margin:auto}
.information-modal::backdrop{background:rgba(34,25,32,.44);backdrop-filter:blur(4px)}
.information-modal-head{display:flex;justify-content:space-between;align-items:flex-start;gap:12px;margin-bottom:15px}
.information-modal h2{font-size:22px;line-height:1.25;margin:0}
.information-modal p{font-size:14px;line-height:1.7;margin:0 0 15px;color:#48454b}
.information-modal p.information-modal-secondary{font-size:12px;color:#77717a;
  border-top:1px solid var(--line);padding-top:15px;margin-top:18px}
.modal-close{width:34px;height:34px;padding:0;border:0;border-radius:50%;background:#f6f2f4;color:#64585e;
  display:grid;place-items:center;flex-shrink:0}
.modal-close .material-icons{font-size:20px}
.modal-close svg{width:19px;height:19px}
.information-modal-actions{margin-top:23px;display:flex;justify-content:flex-end}
.information-modal-actions .primary{min-height:43px}

/* Classic attached tabs: the active tab visually merges with the content border.
   No separating rule may pass under the active tab. */
.dose-tabs{
  display:flex;align-items:flex-end;gap:4px;
  padding:0;margin:4px 0 -1px;
  border:0;border-radius:0;background:transparent;
  position:relative;z-index:2;overflow:visible;
}
.dose-tab{
  display:inline-flex;align-items:center;justify-content:center;
  flex:0 0 auto;min-width:124px;min-height:44px;padding:10px 19px;
  border:1px solid #e3d9dc;border-radius:10px 10px 0 0;
  background:#f3eff0;color:#81737a;box-shadow:none;
  font-size:14px;line-height:1.2;font-weight:750;text-transform:none;
  white-space:nowrap;position:relative;transition:background .15s,color .15s;
}
.dose-tab strong{font-size:14px;font-weight:750;letter-spacing:0}
.dose-tab:hover{background:#fdf7f9;color:var(--wine-dark)}
.dose-tab.is-active{
  background:#fff;color:var(--wine-dark);
  border-color:#e3d9dc;border-bottom-color:#fff;
  z-index:3;box-shadow:none;
}
.dose-tab.is-active::after{
  content:"";position:absolute;left:0;right:0;bottom:-2px;height:3px;background:#fff;
}
.dose-tab:focus-visible{outline:3px solid rgba(169,41,74,.25);outline-offset:-3px}
.tab-panel{
  margin:0;padding:22px 23px 23px;border:1px solid #e3d9dc;
  border-radius:0 14px 14px 14px;background:#fff;outline:none;
  position:relative;z-index:1;
}
.simulation-metrics{display:grid;grid-template-columns:1fr 1.1fr 1.4fr;gap:12px;margin-bottom:17px}
.simulation-metric{
  display:flex;flex-direction:column;gap:7px;min-width:0;
  padding:15px 17px;border:1px solid #eee6e9;border-radius:12px;background:#fcfafb;
}
.simulation-metric > span{font-size:11px;letter-spacing:.3px;text-transform:uppercase;color:#877880;font-weight:750}
.simulation-metric > strong{font-size:18px;line-height:1.35;letter-spacing:-.3px;color:#40424a;font-weight:770;font-variant-numeric:tabular-nums;overflow-wrap:anywhere}
/* Both directions deliberately use the same neutral colour: lower != safer. */
.simulation-metric > strong.difference-up,
.simulation-metric > strong.difference-down,
.simulation-metric > strong.difference-zero{color:#40424a}
.simulation-metric.validation{background:#f9f7f4;border-color:#e9e4de}
.simulation-metric.validation strong{display:flex;align-items:center;gap:8px;font-size:13px;
  color:#746c66;letter-spacing:0;line-height:1.4;font-weight:660}
.simulation-metric.validation svg{width:17px;height:17px;flex-shrink:0}

/* Compact composition row, matching the original visual reference. */
.tablet-card{min-height:80px;padding:15px 24px;
  grid-template-columns:minmax(180px,1.1fr) minmax(220px,1.3fr) minmax(110px,.48fr);
  gap:19px;align-items:center}
.tablet-product{min-width:0}
.tablet-amount{display:flex;align-items:center;gap:10px;min-width:0}
.tablet-name{font-size:15px}
.tablet-amount-text{font-size:13px;color:#63525d;line-height:1.4}
.tablet-amount .pill-row{margin:0;gap:6px;flex:0 0 auto}
.mg-contribution{display:block;text-align:right}
.mg-contribution strong{color:var(--wine-dark);font-size:25px;line-height:1.25;white-space:nowrap}
.mg-contribution small{font-size:13px;font-weight:580;color:#777}
@media(max-width:820px){
  .simulation-metrics{grid-template-columns:1fr 1fr}
  .simulation-metric.validation{grid-column:1/-1}
}
@media(max-width:570px){
  .dose-tabs{gap:4px}
  .dose-tab{min-width:97px;min-height:43px;padding:9px 12px}
  .dose-tab strong{font-size:13px}
  .tab-panel{padding:14px 12px;border-radius:0 10px 10px 10px}
  .simulation-metrics{grid-template-columns:1fr 1fr;gap:9px}
  .simulation-metric{padding:13px 12px}
  .simulation-metric > strong{font-size:16px}
  .information-modal{padding:24px 21px}
  .tablet-card{grid-template-columns:1fr auto;gap:8px 10px;padding:14px 13px}
  .tablet-product{grid-column:1;grid-row:1}
  .tablet-amount{grid-column:1/-1;grid-row:2;flex-wrap:wrap;gap:8px}
  .mg-contribution{grid-column:2;grid-row:1;align-self:center}
  .mg-contribution strong{font-size:21px}
  .tablet-name{font-size:13px}
}
@media print{
  .dose-tabs,.information-modal,.section-info{display:none!important}
}


/* Materialize defines global .red with a bright background; presentation styles
   are deliberately scoped to avoid that utility class collision. */
.tablet-card.tablet-1000{background:#fff9fa!important;border-color:#efdce1}
.tablet-card.tablet-1000 .mg-contribution strong{color:var(--wine-dark)}
.pill.pill-1000{background:#fde9ef;border-color:#b62a4b}
.pill.pill-1000 i{background:#c84b67;border-color:#a5294a}

/* The supply calculation is part of the selected simulation, not a separate card. */
.embedded-planning{margin-top:25px;padding-top:24px;border-top:1px solid #ede6e8}
.embedded-planning .planning-head{margin-bottom:18px}
.embedded-planning .planning-symbol{width:39px;height:39px;border-radius:12px}
.embedded-planning h3{font-size:17px;letter-spacing:-.35px;margin:0 0 2px}
.embedded-planning .subhead{font-size:12px}
.embedded-planning .date-row{grid-template-columns:repeat(3,minmax(0,1fr));gap:13px}
.embedded-planning .date-row label{color:#625d63}
.embedded-planning .pack-size-field[hidden]{display:none!important}
.embedded-planning .supply-result{border-top:0;padding-top:0;margin-top:19px}
.embedded-planning .box-estimate{padding:16px 19px}
.embedded-planning .box-estimate .boxes-number{font-size:28px}
.information-modal h3{font-size:14px;margin:20px 0 6px;font-weight:750;letter-spacing:0}
.information-modal h3:first-of-type{margin-top:0}
.information-modal p.modal-source{border-top:1px solid var(--line);margin-top:18px;padding-top:15px;color:#79727a;font-size:11px}
@media(max-width:760px){
  .embedded-planning .date-row{grid-template-columns:repeat(2,minmax(0,1fr))}
  .embedded-planning .pack-size-field{grid-column:1/-1}
}
@media(max-width:570px){
  .embedded-planning{margin-top:21px;padding-top:19px}
  .embedded-planning .date-row{grid-template-columns:1fr;gap:15px}
  .embedded-planning .pack-size-field{grid-column:1}
  .embedded-planning .box-grid{grid-template-columns:1fr;gap:11px}
}
@media print{
  .embedded-planning .date-row,.information-modal{display:none!important}
  .embedded-planning{break-inside:avoid}
}

/* Spanish DD/MM/YYYY text field with the browser-native date picker. */
.native-date-wrap{position:relative}
.native-date-wrap .date-text{padding-right:48px;font-variant-numeric:tabular-nums}
.native-date-wrap .date-text::placeholder{color:#969098;opacity:1}
.native-calendar-button{
  position:absolute;right:5px;top:5px;bottom:5px;width:42px;
  display:flex;align-items:center;justify-content:center;
  border:0;border-radius:9px;background:transparent;color:#6a626b;
  padding:0;cursor:pointer;
}
.native-calendar-button:hover{background:#f7eff2;color:var(--wine)}
.native-calendar-button .material-icons{font-size:21px;line-height:1}
/* The actual input remains rendered: showPicker() opens the native OS/browser calendar. */
.native-date-input{
  position:absolute;left:12px;top:50%;width:1px;height:1px;
  opacity:0;pointer-events:none;z-index:-1;border:0;padding:0;
}


/* Materialize globally sets button:focus to teal. Fully specify the colours
   for every interactive control in normal, hover, keyboard-focus and active
   states so mouse/touch focus cannot leak that library default into our UI. */
button.primary, button.primary:focus {background-color:var(--wine);color:#fff;border-color:var(--wine)}
button.primary:hover, button.primary:active {background-color:var(--wine-dark);color:#fff;border-color:var(--wine-dark)}
button.ghost, button.ghost:focus, button.ghost:active {background-color:#fff;color:#5d5960;border-color:#e0dbde}
button.ghost:hover {background-color:#fff8fa;color:var(--wine-dark);border-color:#bd9da6}
button.edit-button, button.edit-button:focus, button.edit-button:active {background-color:#fff;color:var(--wine);border-color:#ded6d9}
button.edit-button:hover {background-color:#fff7f9;color:var(--wine);border-color:var(--wine)}
button.info-button, button.info-button:focus, button.info-button:active {background-color:#fff;color:#8a7a82;border-color:#e6dfe1}
button.info-button:hover, button.info-button:focus-visible {background-color:var(--wine-soft);color:var(--wine);border-color:#e6b7c3}
button.modal-close, button.modal-close:focus, button.modal-close:active {background-color:#f6f2f4;color:#64585e}
button.modal-close:hover {background-color:#f0e6eb;color:var(--wine-dark)}
button.native-calendar-button, button.native-calendar-button:focus, button.native-calendar-button:active {background-color:transparent;color:#6a626b}
button.native-calendar-button:hover, button.native-calendar-button:focus-visible {background-color:#f7eff2;color:var(--wine)}
button.dose-tab, button.dose-tab:focus, button.dose-tab:active {background-color:#f3eff0;color:#81737a;border-color:#e3d9dc}
button.dose-tab:hover {background-color:#fdf7f9;color:var(--wine-dark)}
button.dose-tab.is-active, button.dose-tab.is-active:hover, button.dose-tab.is-active:focus, button.dose-tab.is-active:active {
  background-color:#fff;color:var(--wine-dark);border-color:#e3d9dc;border-bottom-color:#fff;
}
/* Respect keyboard accessibility while avoiding Materialize's teal outline. */
button:focus-visible {outline:3px solid rgba(169,41,74,.32);outline-offset:3px}
button.dose-tab:focus-visible {outline-offset:-3px}
/* The library's JS-created ripple should match the calculator palette too. */
.waves-effect:not(.waves-light) .waves-ripple {background-color:rgba(169,41,74,.13)}
.waves-effect.waves-light .waves-ripple {background-color:rgba(255,255,255,.30)}

/* Keep the amount and percentage together as legible units on narrow screens. */
.simulation-metric > strong.difference-up,
.simulation-metric > strong.difference-down,
.simulation-metric > strong.difference-zero {
  display:flex; flex-wrap:wrap; align-items:baseline; gap:2px 6px;
}
.difference-amount,.difference-percent{white-space:nowrap}
.difference-percent{font-size:.91em;font-weight:700}

/* Patient actions: new patient on the left, edit on the right. */
.toolbar{justify-content:space-between}
.new-patient-button{
  display:inline-flex;align-items:center;justify-content:center;gap:9px;
  min-height:44px;padding:9px 14px;border:1px solid #ded6d9;border-radius:12px;
  background:#fff;color:var(--wine-dark);font-size:13px;font-weight:700;
  line-height:1.3;box-shadow:0 5px 16px #22222208;
  transition:background .18s,border-color .18s,transform .18s;
}
.new-patient-button .material-icons{font-size:20px;line-height:1}
button.new-patient-button,button.new-patient-button:focus,button.new-patient-button:active{
  background-color:#fff;color:var(--wine-dark);border-color:#ded6d9;
}
button.new-patient-button:hover,button.new-patient-button:focus-visible{
  background-color:#fff7f9;color:var(--wine-dark);border-color:var(--wine);
}
.dialog-top h2{margin:0}
@media(max-width:520px){
  .new-patient-button{min-height:43px;padding:9px 12px;font-size:12px}
  .new-patient-button .material-icons{font-size:19px}
}
@media print{.new-patient-button{display:none!important}}

/* MySQL-backed patient workspace */
[hidden]{display:none!important}
.welcome-view{padding:38px 0 20px;animation:patient-arrive .45s ease both}
@keyframes patient-arrive{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}
.welcome-start{text-align:center;max-width:660px;margin:20px auto 62px}
.welcome-start h1{font-size:clamp(35px,5vw,50px);letter-spacing:-1.7px;margin:15px 0}
.welcome-start>p{color:var(--muted);font-size:16px;margin:0}
.welcome-actions{display:flex;justify-content:center;gap:13px;margin-top:34px;flex-wrap:wrap}
.welcome-actions button{display:inline-flex;align-items:center;justify-content:center;gap:10px;min-width:173px}
.welcome-actions .material-icons{font-size:20px;line-height:1}
.welcome-general{border-top:1px solid var(--line);padding-top:32px;max-width:960px;margin:auto}
.welcome-heading{display:flex;align-items:center;gap:12px}
.welcome-heading h2{margin:0;font-size:21px}
.welcome-general>p{font-size:14px;color:#645e66;max-width:820px;margin:12px 0 20px;line-height:1.65}
.welcome-facts{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:15px}
.welcome-facts>div{background:#fff;border:1px solid var(--line);border-radius:15px;padding:21px;display:flex;flex-direction:column;gap:5px}
.welcome-facts strong{font-size:17px;font-weight:750;color:var(--wine-dark)}
.welcome-facts span{font-size:13px;color:#726e74;line-height:1.5}
.welcome-general p.welcome-disclaimer{margin-top:22px;font-size:12px;color:#898189}
.patient-navigation{display:flex;flex-wrap:wrap;align-items:center;gap:9px}
.patient-key{display:inline-flex;align-items:center;gap:9px;border:1px solid #e1d8dc;border-radius:11px;background:#fff;padding:5px 6px 5px 12px;color:#77717a;font-size:12px}
.patient-key strong{color:#581b30;font-size:17px;letter-spacing:2px;font-variant-numeric:tabular-nums}
.patient-key button{display:inline-grid;place-items:center;width:30px;height:30px;border:0;border-radius:8px;padding:0;background:#fff1f4;color:var(--wine-dark)}
.patient-key button .material-icons{font-size:17px;line-height:1}
.patient-key button:hover,.patient-key button:focus,.patient-key button:active{background:#fce1e9;color:var(--wine-dark)}
.save-status{font-size:12px;text-align:right;color:#60806a;min-height:22px;margin:0 0 6px}
.save-status.has-error{color:#a5294a;font-weight:650}
.open-patient-modal{width:min(480px,calc(100vw - 28px));max-height:calc(100vh - 50px);border-radius:20px;padding:30px;border:1px solid #e6dee0;background:#fff;box-shadow:var(--shadow);color:var(--ink)}
.open-patient-modal::backdrop{background:rgba(33,24,31,.46);backdrop-filter:blur(3px)}
.open-patient-heading{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:26px}
.open-patient-heading h2{font-size:25px;margin:0}
.open-patient-heading .material-icons{font-size:20px;line-height:1}
.patient-code-input{text-align:center!important;text-transform:uppercase;letter-spacing:5px;font-size:25px!important;font-weight:750;max-height:58px}
.patient-code-input::placeholder{color:#c5bec4;letter-spacing:5px}
.patient-error{min-height:20px;margin:11px 0 14px;color:#a5294a;font-size:13px;font-weight:600}
.open-patient-actions{display:flex;justify-content:flex-end;gap:10px}
button:disabled{opacity:.65;cursor:wait}
@media(max-width:930px){
  .toolbar{align-items:flex-start;gap:9px}
  .patient-navigation{gap:7px}
  .patient-key{order:3;width:100%;max-width:220px}
}
@media(max-width:620px){
  .welcome-view{padding-top:15px}
  .welcome-start{margin:12px auto 46px}
  .welcome-start h1{font-size:35px}
  .welcome-actions{flex-direction:column;align-items:stretch}
  .welcome-actions button{width:100%}
  .welcome-facts{grid-template-columns:1fr;gap:9px}
  .welcome-facts>div{padding:15px}
  .toolbar{flex-direction:column;align-items:stretch}
  .patient-navigation{display:grid;grid-template-columns:1fr 1fr}
  .patient-key{grid-column:1 / -1;max-width:none;justify-content:space-between}
  .toolbar-actions{align-self:flex-end}
  .open-patient-actions button{padding:12px;min-height:45px}
  .open-patient-modal{padding:23px}
}
@media print{
  .welcome-view,.save-status,.patient-key,.open-patient-modal{display:none!important}
}
