
:root{--red:#9d1111;--black:#111;--bg:#f4f4f6;--card:#fff;--line:#d8d8df}
*{box-sizing:border-box}
body{margin:0;font-family:Arial,Helvetica,sans-serif;background:var(--bg);color:#181818}
header{background:linear-gradient(135deg,var(--black),#250909 45%,var(--red));color:#fff;padding:18px;position:sticky;top:0;z-index:10}
.brand{display:flex;gap:14px;align-items:center}.logo{width:52px;height:52px;border-radius:50%;display:grid;place-items:center;font-weight:800;font-size:28px;background:radial-gradient(circle at 35% 35%, #ff6262 0%, #c61f1f 42%, #670b0b 100%);border:2px solid rgba(255,255,255,.65)}
.brand h1{margin:0;font-size:1.2rem}.brand p{margin:4px 0 0;color:#ffd7d7}
.loc{display:flex;gap:10px;margin-top:12px;flex-wrap:wrap}
.loc button,.tabs button,.subtabs button,.actions button,.auth-btn{border:none;border-radius:10px;padding:10px 14px;cursor:pointer;font-weight:700}
.loc button{background:rgba(255,255,255,.1);color:#fff;border:1px solid rgba(255,255,255,.35)}
.loc button.active{background:#fff;color:var(--red)}
.wrap{max-width:1450px;margin:0 auto;padding:18px}
.panel{background:var(--card);border:1px solid var(--line);border-radius:16px;padding:16px;margin-bottom:16px;box-shadow:0 4px 16px rgba(0,0,0,.05)}
.grid{display:grid;gap:14px}.grid.two{grid-template-columns:repeat(auto-fit,minmax(300px,1fr))}.grid.three{grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}.grid.four{grid-template-columns:repeat(auto-fit,minmax(180px,1fr))}
label{display:block;font-weight:700;margin:0 0 6px}
select,input,textarea{width:100%;padding:11px 12px;border:1px solid #cfd2d9;border-radius:10px;background:#fff;font-size:14px}
textarea{min-height:90px;resize:vertical}
.tabs,.subtabs,.actions{display:flex;gap:8px;flex-wrap:wrap}.tabs button,.subtabs button{background:#fff;color:#111;border:1px solid #cfcfd5}.tabs button.active,.subtabs button.active{background:var(--red);color:#fff;border-color:var(--red)}
.actions button,.auth-btn{background:var(--red);color:#fff}.actions .secondary{background:#2c2c2c}.actions .light{background:#ececef;color:#111}.actions .danger{background:#7b0e0e}
.hidden{display:none !important}
.daily-subtabs button{padding:8px 12px;font-size:13px}
.chart-meta-grid{align-items:end}
.chart-subpanel{background:#fafafb;border:1px solid #ececf0;border-radius:16px;padding:16px}
.chart-subpanel .grid > div{background:#fff;border:1px solid #ececf0;border-radius:12px;padding:14px;min-height:100%}
.chart-section-head{display:flex;justify-content:space-between;gap:12px;align-items:flex-end;flex-wrap:wrap;margin-bottom:12px}
.chart-section-head strong{font-size:15px}
.chart-field-card{box-shadow:inset 0 1px 0 rgba(255,255,255,.85)}
.chart-checkbox-card label{display:flex;align-items:center;gap:8px}
.chart-checkbox-card input[type="checkbox"]{width:auto;flex:0 0 auto}
.chart-full{grid-column:1 / -1}
.chart-inline-split{display:flex;align-items:center;gap:6px}
.chart-inline-split input{width:45%}
.chart-inline-actions{display:flex;gap:8px;align-items:center}
.chart-inline-actions button{white-space:nowrap}
.chart-subpanel > label{margin-top:12px}
.chart-subpanel > textarea{background:#fff}
.intake-grid > div textarea{min-height:78px}
.intake-water-card{display:flex;flex-direction:column;justify-content:flex-start}
.intake-water-card input{max-width:260px}
#caregiverPills,#residentPills{display:flex;flex-wrap:wrap;gap:8px;align-items:flex-start;margin-top:8px}
.pill{display:inline-block;padding:6px 10px;border-radius:999px;background:#111;color:#fff;font-size:12px;font-weight:700;margin:0;max-width:100%}
.thumb-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:14px;margin-top:14px}
.thumb-card{border:1px solid var(--line);border-radius:14px;padding:10px;background:#fff;cursor:pointer}
.thumb-preview{width:100%;height:180px;border-radius:10px;border:1px solid #e5e5ea;background:#fafafa;display:flex;align-items:center;justify-content:center;overflow:hidden}
.thumb-preview img{width:100%;height:100%;object-fit:cover}.pdf-preview{font-size:48px;font-weight:800;color:var(--red)}
.modal-bg{position:fixed;inset:0;background:rgba(0,0,0,.75);display:flex;align-items:center;justify-content:center;z-index:1000;padding:24px}.modal{background:#fff;border-radius:16px;width:min(1100px,100%);max-height:92vh;overflow:auto;padding:16px}.modal iframe,.modal img{width:100%;border:1px solid #ddd;border-radius:10px}.modal iframe{height:75vh}
.range-indicator{margin-top:6px;padding:6px 8px;border-radius:8px;font-size:12px;font-weight:700;display:inline-block}
.range-normal{background:#e8f6ea;color:#1f6b2a;border:1px solid #b7dfbf}
.range-caution{background:#fff5e6;color:#8a5a00;border:1px solid #f2d29b}
.range-alert{background:#fdeaea;color:#9d1111;border:1px solid #efb6b6}
.table-wrap{overflow:auto}
table{width:100%;border-collapse:collapse}
th,td{border-bottom:1px solid #ececf0;padding:10px;text-align:left;font-size:14px;vertical-align:top}
th{background:#fafafb}
.small{font-size:12px;color:#666}
.auth-shell{min-height:100vh;display:flex;align-items:center;justify-content:center;padding:24px;background:linear-gradient(135deg,#111,#250909 45%,#9d1111)}
.auth-card{background:#fff;border-radius:18px;padding:24px;max-width:520px;width:100%;box-shadow:0 10px 30px rgba(0,0,0,.25)}
.auth-title{margin:0 0 8px;font-size:1.35rem}.auth-sub{margin:0 0 18px;color:#555}.auth-note{font-size:12px;color:#666;margin-top:10px}
.top-status{display:flex;justify-content:space-between;gap:12px;align-items:center;flex-wrap:wrap;margin-bottom:16px}.badge{display:inline-block;padding:6px 10px;border-radius:999px;background:#111;color:#fff;font-size:12px;font-weight:700}
.alert-box{padding:10px 12px;border-radius:10px;background:#fdeaea;border:1px solid #efb6b6;color:#9d1111;font-weight:700}
.ok-box{padding:10px 12px;border-radius:10px;background:#e8f6ea;border:1px solid #b7dfbf;color:#1f6b2a;font-weight:700}
.email-green{background:#e8f6ea;border:1px solid #b7dfbf;color:#1f6b2a;padding:8px 10px;border-radius:8px;margin:6px 0;font-weight:700}
.email-yellow{background:#fff5e6;border:1px solid #f2d29b;color:#8a5a00;padding:8px 10px;border-radius:8px;margin:6px 0;font-weight:700}
.email-red{background:#fdeaea;border:1px solid #efb6b6;color:#9d1111;padding:8px 10px;border-radius:8px;margin:6px 0;font-weight:700}
.med-row{display:grid;grid-template-columns:120px 110px 120px 1fr;gap:10px;align-items:start;margin-bottom:10px;padding:10px;border:1px solid #ececf0;border-radius:12px;background:#fafafb}
.med-row-head{font-weight:700;font-size:12px;color:#555}
.required-note{border:2px solid #9d1111 !important;background:#fff5f5}
.conditional-wrap{display:none;margin-top:8px}
.conditional-wrap.show{display:block}
.prn-row{border:1px solid #ececf0;border-radius:12px;padding:12px;background:#fafafb;margin-top:10px}


/* Phase 3 alert UI */
.alert-card{border-left:5px solid #9d1111;}
.alert-card.acknowledged{border-left-color:#d6a300;background:#fff7cc !important;}
.alert-actions-row{display:flex;gap:6px;justify-content:flex-end;margin-top:8px;}
.small-alert-btn{font-size:11px;padding:3px 8px;line-height:1.2;}
#adminAlertsToolbar{justify-content:flex-end;}

.tch-toast{position:fixed;right:20px;bottom:20px;z-index:9999;background:#1f6b2a;color:#fff;padding:12px 16px;border-radius:10px;box-shadow:0 8px 20px rgba(0,0,0,.18);opacity:0;transform:translateY(12px);transition:opacity .2s ease, transform .2s ease;font-weight:700;pointer-events:none}.tch-toast.show{opacity:1;transform:translateY(0)}.tch-toast.error{background:#9d1111}.tch-toast.info{background:#1e3a8a}.small-alert-btn{font-size:11px;padding:3px 8px;line-height:1.2;border-radius:6px}.alert-actions-row{display:flex;gap:6px;margin-top:6px}.alert-card.active{background:#fdeaea !important;border-left:5px solid #cc2020}.alert-card.acknowledged{background:#fff7cc !important;border-left:5px solid #d6a300 !important}.alert-card.acknowledged .small{color:#7a5a00}.hidden{display:none}

.saved-history-shell{background:#fafafb;border:1px solid #ececf0;border-radius:14px;padding:14px}
.saved-history-head{display:flex;justify-content:space-between;gap:12px;align-items:center;flex-wrap:wrap;margin-bottom:10px}
.saved-history-mode{display:flex;gap:8px;flex-wrap:wrap}
.saved-history-mode button{border:1px solid #cfcfd5;border-radius:999px;padding:8px 12px;background:#fff;color:#111;font-weight:700;cursor:pointer}
.saved-history-mode button.active{background:var(--red);border-color:var(--red);color:#fff}
.saved-history-entity-label{font-weight:700;margin:12px 0 6px}
.saved-history-entity-list{display:flex;gap:8px;flex-wrap:wrap}
.saved-history-entity-list button{border:1px solid #d5d5db;border-radius:999px;padding:7px 12px;background:#fff;color:#111;font-weight:700;cursor:pointer}
.saved-history-entity-list button.active{background:#111;color:#fff;border-color:#111}
.saved-history-month{display:flex;justify-content:space-between;align-items:center;gap:10px;flex-wrap:wrap;margin:14px 0 10px}
.saved-history-month button{border:1px solid #cfcfd5;border-radius:10px;padding:8px 12px;background:#fff;color:#111;font-weight:700;cursor:pointer}
.saved-history-month-label{font-weight:700}
.saved-history-grid{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:8px}
.saved-history-weekday{font-size:12px;font-weight:700;color:#666;text-align:center;padding:4px 0}
.saved-history-day{min-height:76px;border:1px solid #e1e1e6;border-radius:12px;background:#fff;padding:8px;display:flex;flex-direction:column;gap:6px;cursor:pointer;text-align:left}
.saved-history-day.empty{background:transparent;border-style:dashed;cursor:default}
.saved-history-day.active{border-color:var(--red);box-shadow:0 0 0 2px rgba(157,17,17,.12)}
.saved-history-day.has-items{background:#fff8f2}
.saved-history-day-number{font-weight:700}
.saved-history-day-meta{font-size:11px;color:#666;line-height:1.3}
.saved-history-summary{font-size:12px;color:#555}
.saved-day-wrap{background:#fafafb;border:1px solid #ececf0;border-radius:16px;padding:16px}
.saved-day-meta{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:12px;margin-bottom:16px}
.saved-day-meta-card{background:#fff;border:1px solid #ececf0;border-radius:14px;padding:12px}
.saved-day-meta-label{font-size:12px;font-weight:700;color:#666;text-transform:uppercase;letter-spacing:.04em;margin-bottom:6px}
.saved-day-meta-value{font-weight:700;color:#181818}
.saved-day-pill-list{display:flex;gap:8px;flex-wrap:wrap}
.saved-day-pill{display:inline-flex;align-items:center;padding:6px 10px;border-radius:999px;background:#111;color:#fff;font-size:12px;font-weight:700}
.saved-day-section-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(320px,1fr));gap:14px}
.saved-day-section{background:#fff;border:1px solid #ececf0;border-radius:16px;padding:14px;min-height:100%}
.saved-day-section.is-alerts{background:#fffaf7}
.saved-day-section-title{font-size:14px;font-weight:800;margin-bottom:10px}
.saved-day-empty{margin-top:6px}
.saved-day-footnote{margin-top:14px}
@media (max-width: 720px){
  .chart-inline-actions{flex-wrap:wrap}
  .chart-inline-actions button{width:100%}
  .chart-inline-split input{width:calc(50% - 12px)}
  .saved-history-grid{gap:6px}
  .saved-history-day{min-height:64px;padding:6px}
  .saved-day-section-grid{grid-template-columns:1fr}
}
