:root {
  --primary: #0b6fb8;
  --primary-dark: #0b4f83;
  --teal: #14a6a1;
  --navy: #123b5d;
  --bg: #f3f7fa;
  --surface: #ffffff;
  --text: #173042;
  --muted: #6d8190;
  --line: #dbe6ed;
  --danger: #c83e4d;
  --warning: #c77912;
  --success: #258a61;
  --shadow: 0 12px 35px rgba(18, 59, 93, .08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--text); background: var(--bg); font-family: Tahoma, "Noto Sans Thai", system-ui, sans-serif; font-size: 15px; line-height: 1.55; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
code { font-family: Consolas, monospace; font-size: .9em; color: var(--primary-dark); }

.topbar { position: sticky; top: 0; z-index: 50; min-height: 72px; display: flex; align-items: center; gap: 28px; padding: 10px clamp(18px, 4vw, 56px); background: rgba(255,255,255,.94); border-bottom: 1px solid rgba(219,230,237,.85); backdrop-filter: blur(16px); }
.brand { display: flex; align-items: center; gap: 12px; min-width: 245px; }
.brand-mark, .login-logo { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 13px; color: white; background: linear-gradient(135deg, var(--primary), var(--teal)); font-weight: 800; letter-spacing: .5px; box-shadow: 0 8px 18px rgba(11,111,184,.22); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; }
.brand small { color: var(--muted); font-size: 12px; }
.topnav { display: flex; align-items: center; gap: 6px; flex: 1; }
.topnav a { padding: 9px 13px; border-radius: 10px; color: var(--muted); font-weight: 700; }
.topnav a:hover, .topnav a.active { color: var(--primary); background: #eaf4fb; }
.user-area { display: flex; align-items: center; gap: 14px; }
.user-meta { text-align: right; }
.user-meta strong, .user-meta small { display: block; }
.user-meta small { color: var(--muted); font-size: 12px; }

.page-shell { width: min(1500px, calc(100% - 36px)); margin: 0 auto; padding: 34px 0 50px; }
.narrow-shell { width: min(850px, calc(100% - 36px)); }
.form-shell { width: min(1420px, calc(100% - 36px)); }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-heading h1 { margin: 4px 0 4px; font-size: clamp(26px, 3vw, 38px); line-height: 1.15; letter-spacing: -.4px; }
.page-heading p { margin: 0; color: var(--muted); }
.heading-with-actions { align-items: center; }
.heading-actions { display: flex; align-items: flex-end; justify-content: flex-end; gap: 12px; flex-wrap: wrap; }
.eyebrow { display: inline-block; color: var(--primary); font-size: 12px; font-weight: 800; letter-spacing: 1.2px; }
.back-link { display: block; width: fit-content; margin-bottom: 10px; color: var(--primary); font-weight: 700; }
.muted { color: var(--muted) !important; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 9px 16px; border: 1px solid transparent; border-radius: 11px; font-weight: 800; transition: .2s ease; }
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { color: #fff; background: linear-gradient(135deg, var(--primary), #0f86c9); box-shadow: 0 7px 16px rgba(11,111,184,.22); }
.btn-primary:hover { box-shadow: 0 10px 20px rgba(11,111,184,.28); }
.btn-secondary { color: var(--primary-dark); background: #eaf4fb; border-color: #cee5f4; }
.btn-ghost { color: var(--muted); background: transparent; border-color: var(--line); }
.btn-sm { min-height: 34px; padding: 6px 10px; font-size: 13px; }
.btn-block { width: 100%; }

.alert { margin: 0 0 20px; padding: 13px 16px; border-radius: 12px; border: 1px solid; }
.alert ul { margin: 8px 0 0; padding-left: 22px; }
.alert-success { color: #166545; background: #eaf8f2; border-color: #bfe7d5; }
.alert-info { color: #175b84; background: #eaf5fb; border-color: #c7e4f3; }
.alert-warning { color: #875513; background: #fff7e7; border-color: #f0d7aa; }
.alert-danger { color: #8f2d3a; background: #fff0f2; border-color: #f1c5cb; }

.panel { background: var(--surface); border: 1px solid rgba(219,230,237,.9); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 22px 12px; }
.panel-header h2 { margin: 0 0 2px; font-size: 18px; }
.panel-header p { margin: 0; color: var(--muted); font-size: 13px; }

.login-shell { min-height: calc(100vh - 52px); display: grid; grid-template-columns: minmax(380px, 1.15fr) minmax(420px, .85fr); }
.login-visual { position: relative; display: flex; align-items: flex-end; min-height: 680px; overflow: hidden; padding: 70px; color: white; background: linear-gradient(140deg, #0b4f83 0%, #0b6fb8 52%, #14a6a1 100%); }
.login-visual::before { content: ""; position: absolute; width: 520px; height: 520px; right: -150px; top: -120px; border: 90px solid rgba(255,255,255,.08); border-radius: 50%; }
.login-visual::after { content: "+"; position: absolute; right: 12%; bottom: 28%; font-size: 260px; line-height: 1; font-weight: 100; color: rgba(255,255,255,.08); }
.login-visual-content { position: relative; z-index: 1; max-width: 700px; }
.login-visual .eyebrow { color: #b9f1ee; }
.login-visual h1 { margin: 12px 0 18px; font-size: clamp(42px, 5vw, 70px); line-height: 1.12; }
.login-visual p { max-width: 620px; margin: 0 0 28px; font-size: 19px; color: rgba(255,255,255,.82); }
.login-points { display: flex; gap: 10px; flex-wrap: wrap; }
.login-points span { padding: 8px 12px; border: 1px solid rgba(255,255,255,.25); border-radius: 999px; background: rgba(255,255,255,.1); font-size: 13px; }
.login-panel { display: grid; place-items: center; padding: 38px; background: #f7fafc; }
.login-card { width: min(430px, 100%); padding: 38px; border-radius: 24px; background: white; box-shadow: 0 25px 70px rgba(18,59,93,.14); }
.login-logo { width: 58px; height: 58px; margin-bottom: 22px; border-radius: 17px; font-size: 20px; }
.login-card h2 { margin: 6px 0 4px; font-size: 30px; }
.login-card form { margin-top: 24px; }
.login-note { margin: 20px 0 0; color: var(--muted); font-size: 12px; text-align: center; }

.field { display: grid; gap: 7px; margin-bottom: 16px; }
.field > span { font-weight: 800; font-size: 13px; color: #345064; }
.field input, .field select, .filter-form select { width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid #cfdde5; border-radius: 11px; color: var(--text); background: white; outline: none; transition: .2s ease; }
.field input:focus, .field select:focus, .filter-form select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(11,111,184,.1); }
.field input[readonly] { color: #607786; background: #f2f6f8; }
.field small { color: var(--muted); }
.filter-form { display: flex; align-items: flex-end; gap: 10px; }
.filter-form label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; font-weight: 700; }
.filter-form select { min-width: 145px; min-height: 42px; }
.filter-form.inline { flex-wrap: wrap; }

.module-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.module-card { position: relative; display: flex; align-items: center; gap: 18px; min-height: 160px; padding: 24px; overflow: hidden; border: 1px solid var(--line); border-radius: 20px; background: white; box-shadow: var(--shadow); transition: .22s ease; }
.module-card:hover { transform: translateY(-3px); box-shadow: 0 20px 45px rgba(18,59,93,.14); }
.module-card::after { content: ""; position: absolute; right: -40px; bottom: -65px; width: 170px; height: 170px; border-radius: 50%; background: var(--card-accent, #0b6fb8); opacity: .07; }
.accent-blue { --card-accent: #0b6fb8; }.accent-indigo { --card-accent: #6657c7; }.accent-pink { --card-accent: #d84c83; }.accent-orange { --card-accent: #e4802c; }
.module-code { flex: 0 0 auto; width: 66px; height: 66px; display: grid; place-items: center; border-radius: 18px; color: white; background: var(--card-accent, var(--primary)); font-size: 18px; font-weight: 900; box-shadow: 0 10px 20px color-mix(in srgb, var(--card-accent, var(--primary)) 25%, transparent); }
.module-code.large { width: 90px; height: 90px; margin: 0 auto 20px; border-radius: 26px; font-size: 26px; }
.module-content { flex: 1; }
.module-content h2 { margin: 0; font-size: 20px; }
.module-content p { margin: 3px 0 12px; color: var(--muted); }
.module-arrow { position: relative; z-index: 1; color: var(--card-accent, var(--primary)); font-size: 28px; }
.status-pill { display: inline-block; padding: 5px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.status-live { color: #176748; background: #e6f7ef; }.status-preparing { color: #756021; background: #fff6d9; }
.info-banner { display: flex; align-items: center; gap: 18px; margin-top: 20px; padding: 16px 20px; border: 1px solid #cce5f2; border-radius: 14px; color: #31566c; background: #edf7fc; }
.info-banner strong { color: var(--primary-dark); }

.kpi-grid { display: grid; gap: 14px; margin-bottom: 18px; }
.kpi-grid.five { grid-template-columns: repeat(5, minmax(0,1fr)); }
.kpi-grid.six { grid-template-columns: repeat(6, minmax(0,1fr)); }
.kpi-card { position: relative; min-height: 128px; padding: 19px; overflow: hidden; border: 1px solid var(--line); border-radius: 17px; background: white; box-shadow: 0 8px 24px rgba(18,59,93,.06); }
.kpi-card::after { content: ""; position: absolute; width: 75px; height: 75px; right: -22px; bottom: -28px; border-radius: 50%; background: var(--primary); opacity: .06; }
.kpi-card span, .kpi-card small { display: block; color: var(--muted); }
.kpi-card span { min-height: 42px; font-size: 13px; font-weight: 700; }
.kpi-card strong { display: block; margin: 2px 0; color: var(--navy); font-size: clamp(22px, 2.2vw, 31px); line-height: 1.1; }
.kpi-card small { font-size: 12px; }
.kpi-card.featured { color: white; border-color: transparent; background: linear-gradient(135deg, var(--primary-dark), var(--primary)); }
.kpi-card.featured span, .kpi-card.featured small, .kpi-card.featured strong { color: white; }
.kpi-card.featured::after { background: white; opacity: .1; }
.warning-card { border-color: #efd9ae; background: #fffaf0; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(280px, .8fr); gap: 18px; margin-bottom: 18px; }
.chart-panel { min-height: 390px; }
.chart-wrap { position: relative; height: 310px; padding: 8px 18px 20px; }
.chart-wrap.large { height: 390px; }
.formula-panel { min-height: 390px; }
.formula-list { margin: 4px 22px 16px; }
.formula-list div, .calculation-list div { display: flex; justify-content: space-between; gap: 20px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.formula-list dt, .calculation-list dt { color: var(--muted); }
.formula-list dd, .calculation-list dd { margin: 0; color: var(--navy); font-weight: 800; }
.formula-note { margin: 12px 20px 20px; padding: 12px; border-radius: 11px; color: #526b7a; background: #f1f6f8; font-size: 12px; }
.summary-inline { color: var(--muted); }
.summary-inline strong { color: var(--primary-dark); }

.table-scroll { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; white-space: nowrap; }
.data-table th { padding: 12px 14px; color: #567080; background: #f5f9fb; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 12px; text-align: left; }
.data-table td { padding: 12px 14px; border-bottom: 1px solid #e8eff3; }
.data-table tbody tr:hover { background: #f8fbfd; }
.data-table.dense td, .data-table.dense th { padding: 10px 9px; font-size: 12px; }
.data-table .num { text-align: right; }
.table-link { color: var(--primary); font-weight: 800; }
.table-footnote { margin: 12px 18px 18px; color: var(--muted); font-size: 12px; }
.table-empty { padding: 30px; color: var(--muted); text-align: center; }
.ratio-badge { display: inline-block; min-width: 72px; padding: 5px 8px; border-radius: 999px; text-align: center; font-weight: 800; }
.ratio-neutral { color: #315d76; background: #eaf3f7; }
.ratio-good { color: #176748; background: #e4f6ed; }
.ratio-low { color: #9c3d3d; background: #ffebed; }
.ratio-high { color: #976113; background: #fff2d9; }
.day-badge { display: inline-block; max-width: 160px; overflow: hidden; padding: 5px 8px; border-radius: 999px; text-overflow: ellipsis; }
.day-badge.holiday { color: #9b3e4a; background: #fff0f2; }.day-badge.workday { color: #24704f; background: #e9f8f1; }

.entry-date-panel { margin-bottom: 18px; padding: 20px; }
.form-grid { display: grid; gap: 16px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0,1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0,1fr)); }
.date-grid { grid-template-columns: minmax(220px,.8fr) minmax(230px,1fr) minmax(300px,1.2fr); align-items: stretch; }
.day-status-card, .hours-card { display: flex; flex-direction: column; justify-content: center; padding: 13px 16px; border: 1px solid #d7e6ee; border-radius: 13px; background: #f7fbfd; }
.day-status-card span, .hours-card span { color: var(--muted); font-size: 12px; }
.day-status-card strong, .hours-card strong { margin: 3px 0; color: var(--navy); font-size: 17px; }
.day-status-card small, .hours-card small { color: var(--muted); font-size: 11px; }
.entry-layout { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 18px; align-items: start; }
.entry-inputs { display: grid; gap: 18px; }
.form-section { padding: 22px; }
.section-title { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.section-title h2 { margin: 0; font-size: 18px; }.section-title p { margin: 1px 0 0; color: var(--muted); font-size: 12px; }
.step { flex: 0 0 auto; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: white; background: var(--primary); font-weight: 900; }
.calculated-strip { display: flex; align-items: baseline; justify-content: flex-end; gap: 9px; margin-top: 4px; padding: 12px 14px; border-radius: 12px; background: #eef7fc; }
.calculated-strip span { margin-right: auto; color: #506c7d; font-weight: 700; }.calculated-strip strong { color: var(--primary-dark); font-size: 24px; }.calculated-strip small { color: var(--muted); }
.triage-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.triage { padding: 14px; border: 1px solid var(--line); border-radius: 14px; }
.triage.urgent { background: #fff5f5; }.triage.semi { background: #fffaf0; }.triage.non { background: #f2faf7; }
.validation-message { min-height: 42px; margin-top: 4px; padding: 10px 12px; border-radius: 10px; font-size: 12px; }
.validation-message.valid { color: #176748; background: #eaf8f1; }.validation-message.invalid { color: #933b48; background: #fff0f2; }
.calculation-panel { position: sticky; top: 92px; padding-bottom: 18px; }
.calculation-list { margin: 0 22px 14px; }
.calculation-list .total-line { color: var(--navy); border-bottom-style: solid; }
.calculation-list .total-line dt, .calculation-list .total-line dd { color: var(--navy); font-weight: 900; }
.ratio-result { margin: 12px 20px 18px; padding: 20px; border-radius: 16px; color: white; background: linear-gradient(145deg, var(--primary-dark), var(--primary), var(--teal)); text-align: center; }
.ratio-result span, .ratio-result small { display: block; opacity: .83; }.ratio-result strong { display: block; margin: 5px 0; font-size: 34px; }
.calculation-panel .btn, .save-note { width: calc(100% - 40px); margin-left: 20px; }
.save-note { color: var(--muted); font-size: 11px; text-align: center; }
.audit-panel { margin-top: 18px; }
.audit-list { padding: 0 22px 20px; }
.audit-item { display: grid; grid-template-columns: 70px 1fr auto; gap: 14px; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--line); }
.audit-action { padding: 5px 7px; border-radius: 8px; color: var(--primary-dark); background: #eaf4fb; font-size: 11px; font-weight: 900; text-align: center; }
.audit-item p { margin: 2px 0 0; color: var(--muted); }.audit-item time { color: var(--muted); font-size: 12px; }

.empty-state { margin: 70px 0; padding: 60px 30px; border: 1px solid var(--line); border-radius: 24px; background: white; box-shadow: var(--shadow); text-align: center; }
.empty-state h1 { margin: 8px 0; }.empty-state p { max-width: 600px; margin: 0 auto 24px; color: var(--muted); }
.error-code { margin: 0 auto 10px; color: var(--primary); font-size: 72px; font-weight: 900; }
.footer { display: flex; justify-content: space-between; gap: 20px; padding: 16px clamp(18px,4vw,56px); color: #7b8f9c; background: #eef4f7; border-top: 1px solid #dbe6ed; font-size: 11px; }

@media (max-width: 1180px) {
  .kpi-grid.five { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .kpi-grid.six { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .entry-layout { grid-template-columns: 1fr; }.calculation-panel { position: static; }
  .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 850px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }.brand { min-width: 0; flex: 1; }.topnav { order: 3; width: 100%; overflow-x: auto; }.user-meta { display: none; }
  .page-shell { width: min(100% - 24px, 1500px); padding-top: 22px; }.page-heading { align-items: stretch; flex-direction: column; }.heading-actions { justify-content: flex-start; }
  .module-grid { grid-template-columns: 1fr; }.login-shell { grid-template-columns: 1fr; }.login-visual { display: none; }.login-panel { min-height: calc(100vh - 52px); padding: 20px; }.login-card { padding: 28px 22px; }
  .date-grid, .form-grid.two, .form-grid.three, .triage-grid { grid-template-columns: 1fr; }
  .filter-form.inline { width: 100%; }.filter-form.inline label { flex: 1; min-width: 130px; }
}

@media (max-width: 620px) {
  .kpi-grid.five, .kpi-grid.six { grid-template-columns: repeat(2, minmax(0,1fr)); }.kpi-card { min-height: 112px; padding: 15px; }.kpi-card span { min-height: 36px; }
  .module-card { min-height: 135px; padding: 18px; }.module-code { width: 54px; height: 54px; border-radius: 15px; }.module-content h2 { font-size: 17px; }
  .form-section, .entry-date-panel { padding: 16px; }.panel-header { padding: 16px 16px 10px; }.chart-wrap, .chart-wrap.large { height: 300px; padding-left: 8px; padding-right: 8px; }
  .footer { flex-direction: column; gap: 3px; }.info-banner { align-items: flex-start; flex-direction: column; gap: 4px; }
  .audit-item { grid-template-columns: 62px 1fr; }.audit-item time { grid-column: 2; }
}

/* Historical import - additive module */
.import-safe-banner { margin-bottom: 18px; border-left: 4px solid var(--teal); }
.import-safe-banner strong { color: var(--primary-dark); }
.import-panel { max-width: 860px; margin: 0 auto; }
.import-form { padding: 4px 22px 24px; }
.upload-dropzone { min-height: 230px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; padding: 28px; border: 2px dashed #a9c8d9; border-radius: 20px; background: linear-gradient(145deg,#f8fcfe,#eef7fb); cursor: pointer; text-align: center; transition: .2s ease; }
.upload-dropzone:hover { border-color: var(--primary); background: #f2f9fd; transform: translateY(-1px); }
.upload-dropzone input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.upload-icon { width: 68px; height: 68px; display: grid; place-items: center; border-radius: 18px; color: white; background: linear-gradient(145deg,var(--primary-dark),var(--primary),var(--teal)); font-size: 18px; font-weight: 900; box-shadow: 0 12px 28px rgba(11,111,184,.2); }
.upload-dropzone strong { color: var(--navy); font-size: 20px; }
.upload-dropzone small { color: var(--muted); }
.import-actions { display: flex; justify-content: flex-end; margin-top: 18px; }
.import-actions .btn[disabled] { opacity: .5; cursor: not-allowed; }
.import-alert { margin: 0 22px 18px; }
.import-summary { margin-bottom: 18px; }
.import-confirm-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 18px 22px; border-top: 1px solid var(--line); background: #f8fbfd; }
.import-confirm-bar form { margin: 0; }
@media(max-width:700px){.import-confirm-bar{align-items:stretch;flex-direction:column}.import-confirm-bar .btn{width:100%}.import-confirm-bar form{width:100%}}

/* Login refinement v1.5.1 — isolated to login page */
.login-visual-content {
  font-family: "Leelawadee UI", "Noto Sans Thai", "Sarabun", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.login-visual-content h1 {
  font-family: "Leelawadee UI", "Noto Sans Thai", "Sarabun", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 800;
  letter-spacing: -1.25px;
  text-wrap: balance;
}
.login-visual-content p {
  font-weight: 450;
  letter-spacing: -.15px;
}
.connection-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 4px;
  padding: 11px 13px;
  border: 1px solid;
  border-radius: 13px;
  font-size: 13px;
  line-height: 1.35;
}
.connection-status strong {
  font-weight: 800;
}
.connection-icon {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
}
.connection-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.connection-status.is-connected {
  color: #176b4a;
  background: #ecf9f2;
  border-color: #bee8d3;
}
.connection-status.is-connected .connection-icon {
  color: #ffffff;
  background: #22a06b;
  box-shadow: 0 5px 12px rgba(34,160,107,.22);
}
.connection-status.is-disconnected {
  color: #a33242;
  background: #fff1f3;
  border-color: #f1c4cb;
}
.connection-status.is-disconnected .connection-icon {
  color: #ffffff;
  background: #d94b5b;
  box-shadow: 0 5px 12px rgba(217,75,91,.22);
}


/* IPD Productivity v1.6.0 - additive, scoped styles */
.ipd-date-grid { grid-template-columns: minmax(220px,.8fr) minmax(240px,1fr) minmax(300px,1.2fr); }
.ipd-shift-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:18px; align-items:start; }
.ipd-shift-card { overflow:hidden; border-top:4px solid var(--primary); }
.ipd-shift-card.shift-evening { border-top-color:#7c6bc9; }
.ipd-shift-card.shift-night { border-top-color:#37527d; }
.ipd-shift-head { display:flex; align-items:center; justify-content:space-between; padding:20px 20px 14px; border-bottom:1px solid var(--line); }
.ipd-shift-head>div { display:flex; align-items:center; gap:10px; }
.ipd-shift-head h2 { margin:0; color:var(--navy); font-size:20px; }
.shift-dot { width:12px; height:12px; border-radius:50%; background:var(--primary); box-shadow:0 0 0 5px rgba(11,111,184,.12); }
.shift-evening .shift-dot { background:#7c6bc9; box-shadow:0 0 0 5px rgba(124,107,201,.12); }
.shift-night .shift-dot { background:#37527d; box-shadow:0 0 0 5px rgba(55,82,125,.12); }
.shift-time { padding:5px 9px; border-radius:999px; color:var(--muted); background:#f1f6f9; font-size:11px; font-weight:800; }
.ipd-category-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; padding:16px 18px 4px; }
.category-field { margin:0; padding:12px; border:1px solid var(--line); border-radius:13px; background:#fbfdfe; }
.category-field span { min-height:38px; line-height:1.25; }
.category-field b { display:inline-grid; place-items:center; min-width:32px; margin-right:4px; padding:3px 6px; border-radius:8px; color:#fff; background:var(--primary); font-size:11px; }
.category-c4 b { background:#c44759; }.category-c3 b { background:#e18a34; }.category-c2 b { background:#3b8ebd; }.category-c1 b { background:#37936c; }
.category-field small { color:var(--muted); font-size:10px; }
.actual-staff-field { margin:14px 18px; padding:14px; border-radius:13px; background:#eef7fc; }
.shift-calculation { margin:0 18px 14px; }
.shift-calculation>div { display:flex; justify-content:space-between; gap:12px; padding:8px 2px; border-bottom:1px dashed var(--line); }
.shift-calculation dt { color:var(--muted); }.shift-calculation dd { margin:0; color:var(--navy); font-weight:900; }
.shift-productivity { margin:14px 18px 18px; padding:16px; border-radius:15px; color:#fff; background:linear-gradient(145deg,var(--primary-dark),var(--primary)); text-align:center; }
.shift-evening .shift-productivity { background:linear-gradient(145deg,#554589,#7c6bc9); }
.shift-night .shift-productivity { background:linear-gradient(145deg,#263a5b,#46658f); }
.shift-productivity span { display:block; opacity:.85; font-size:12px; }.shift-productivity strong { display:block; margin-top:5px; font-size:28px; }
.ipd-daily-result { display:flex; align-items:center; justify-content:space-between; gap:24px; margin-top:18px; padding:22px 26px; background:linear-gradient(135deg,#f7fbfd,#edf8f6); }
.ipd-daily-result>div:first-child span,.ipd-daily-result>div:first-child small { display:block; color:var(--muted); }
.ipd-daily-result>div:first-child strong { display:block; margin:4px 0; color:var(--primary-dark); font-size:40px; line-height:1; }
.ipd-submit-area { display:flex; align-items:flex-end; gap:14px; }.ipd-submit-area .field { min-width:320px; margin:0; }.ipd-submit-area .btn { min-width:180px; }
@media(max-width:1180px){.ipd-shift-grid{grid-template-columns:1fr}.ipd-shift-card{display:grid;grid-template-columns:1fr 1fr}.ipd-shift-head{grid-column:1/-1}.ipd-category-grid{grid-row:2/5}.actual-staff-field{align-self:start}.shift-productivity{align-self:end}}
@media(max-width:850px){.ipd-date-grid{grid-template-columns:1fr}.ipd-shift-card{display:block}.ipd-daily-result{align-items:stretch;flex-direction:column}.ipd-submit-area{align-items:stretch;flex-direction:column}.ipd-submit-area .field{min-width:0}.ipd-submit-area .btn{width:100%}}
@media(max-width:520px){.ipd-category-grid{grid-template-columns:1fr}.ipd-daily-result>div:first-child strong{font-size:34px}}


.kpi-grid.three { grid-template-columns: repeat(3, minmax(0,1fr)); }
@media(max-width:850px){.kpi-grid.three{grid-template-columns:1fr}}

/* IPD shift-by-shift workflow v2.1 */
.ipd-shift-save-grid { align-items: start; }
.ipd-shift-form { display: flex; flex-direction: column; gap: 14px; }
.ipd-shift-form.is-recorded { box-shadow: 0 18px 42px rgba(34, 139, 94, .10); }
.shift-status { display: inline-flex; align-items: center; min-height: 30px; padding: 6px 10px; border-radius: 999px; font-size: .78rem; font-weight: 800; }
.shift-status.recorded { background: #e7f8ef; color: #147a4a; }
.shift-status.pending { background: #fff5d9; color: #9a6700; }
.shift-record-meta { margin: -2px 18px 2px; padding: 10px 12px; border-radius: 12px; background: #f0f9f5; color: #426657; font-size: .82rem; display: grid; gap: 3px; }
.shift-change-reason em { color: #d13e50; font-style: normal; }
.shift-save-button { margin-top: auto; }
.ipd-daily-summary-card { margin-top: 22px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 24px 28px; }
.ipd-daily-summary-card h2 { margin: 5px 0; }
.ipd-daily-summary-card p { margin: 0; color: var(--muted); }
.daily-productivity-value { font-size: clamp(2rem, 4vw, 3.4rem); color: var(--primary); }
.shift-table-status { display: inline-flex; padding: 5px 9px; border-radius: 999px; font-size: .76rem; font-weight: 800; white-space: nowrap; }
.shift-table-status.done { background: #e7f8ef; color: #147a4a; }
.shift-table-status.waiting { background: #fff5d9; color: #9a6700; }
@media (max-width: 720px) {
  .ipd-daily-summary-card { align-items: flex-start; flex-direction: column; }
}


/* IPD historical import v2.2 */
.selected-file {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  margin-top: 4px;
  padding: 6px 11px;
  border-radius: 999px;
  color: var(--primary-dark);
  background: #e6f3fa;
  font-size: 12px;
  font-weight: 800;
}
.import-help-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 12px;
  margin-top: 16px;
}
.import-help-grid article {
  display: grid;
  gap: 4px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fbfd;
}
.import-help-grid strong { color: var(--navy); }
.import-help-grid span { color: var(--muted); font-size: 12px; }
.kpi-grid.four { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media(max-width:900px) {
  .import-help-grid, .kpi-grid.four { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media(max-width:560px) {
  .import-help-grid, .kpi-grid.four { grid-template-columns: 1fr; }
}

/* IPD executive heatmap v2.3.0 */
.ipd-executive-kpis { margin-bottom: 18px; }
.heat-kpi { position: relative; overflow: hidden; border: 1px solid transparent; }
.heat-kpi::after { content: ""; position: absolute; right: -22px; bottom: -28px; width: 94px; height: 94px; border-radius: 50%; background: currentColor; opacity: .07; }
.heat-kpi.heat-low { color: #176b4a; background: #f1fbf6; border-color: #ccebdc; }
.heat-kpi.heat-normal { color: #185b8f; background: #f1f8fd; border-color: #c9e0f0; }
.heat-kpi.heat-high { color: #9a5a08; background: #fff8e8; border-color: #f4ddb0; }
.heat-kpi.heat-critical { color: #a83245; background: #fff2f4; border-color: #efc3cb; }
.heat-kpi strong { color: inherit; }
.heat-kpi span,.heat-kpi small { color: color-mix(in srgb, currentColor 75%, #66788a); }

.heat-legend { display: flex; flex-wrap: wrap; gap: 7px; justify-content: flex-end; }
.heat-legend span { display: inline-flex; align-items: center; min-height: 28px; padding: 5px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; border: 1px solid transparent; }
.heat-legend .heat-low { color: #176b4a; background: #e7f8ef; border-color: #c7ead8; }
.heat-legend .heat-normal { color: #185b8f; background: #e8f4fb; border-color: #c5dfef; }
.heat-legend .heat-high { color: #9a5a08; background: #fff1cc; border-color: #f1d797; }
.heat-legend .heat-critical { color: #a83245; background: #ffe5e9; border-color: #efbdc6; }

.heatmap-grid { display: grid; grid-template-columns: minmax(180px,1.2fr) repeat(3,minmax(140px,1fr)); gap: 1px; padding: 0 22px 22px; background: var(--line); }
.heatmap-head { padding: 12px 14px; color: #567086; background: #eef5f9; font-size: 12px; font-weight: 900; text-align: center; }
.heatmap-month { display: flex; flex-direction: column; justify-content: center; gap: 3px; padding: 13px 15px; background: #fff; }
.heatmap-month strong { color: var(--navy); }
.heatmap-month small { color: var(--muted); }
.heatmap-cell { min-height: 66px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 10px; background: #fff; text-align: center; transition: .16s ease; }
.heatmap-cell strong { font-size: 17px; }
.heatmap-cell small { font-size: 10px; font-weight: 800; }
.heatmap-cell.heat-empty { color: #93a4b2; background: #f7fafc; }
.heatmap-cell.heat-low { color: #176b4a; background: #edf9f3; }
.heatmap-cell.heat-normal { color: #185b8f; background: #edf6fc; }
.heatmap-cell.heat-high { color: #9a5a08; background: #fff6df; }
.heatmap-cell.heat-critical,.heatmap-cell.heat-max { color: #fff; background: linear-gradient(145deg,#c73e55,#a9263d); box-shadow: inset 0 0 0 2px rgba(255,255,255,.26); }
.heatmap-cell:hover { transform: translateY(-1px); filter: brightness(.98); }

.productivity-heat { position: relative; font-weight: 800; text-align: center; }
.productivity-heat.heat-empty { color: #91a0ad; background: #f8fafb; }
.productivity-heat.heat-low { color: #176b4a; background: #edf9f3; }
.productivity-heat.heat-normal { color: #185b8f; background: #edf6fc; }
.productivity-heat.heat-high { color: #9a5a08; background: #fff6df; }
.productivity-heat.heat-critical { color: #a83245; background: #fff0f2; }
.productivity-heat.heat-max { color: #fff !important; background: #bd3048 !important; box-shadow: inset 0 0 0 2px #8f1f34; }
.ipd-productivity-table tbody tr:hover .productivity-heat { filter: brightness(.98); }

@media(max-width:1100px){.heatmap-grid{grid-template-columns:minmax(150px,1fr) repeat(3,minmax(110px,1fr))}.kpi-grid.five.ipd-executive-kpis{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:700px){.heat-legend{justify-content:flex-start}.heatmap-grid{display:block;background:transparent;padding:0 14px 18px}.heatmap-head{display:none}.heatmap-month{margin-top:12px;border:1px solid var(--line);border-radius:12px 12px 0 0}.heatmap-cell{min-height:54px;border:1px solid var(--line);border-top:0}.heatmap-cell:last-child{border-radius:0 0 12px 12px}.kpi-grid.five.ipd-executive-kpis{grid-template-columns:1fr}}


/* IPD heatmap refinement v2.3.1 - soft Smart Hospital palette */
.heat-legend .heat-max {
  color: #8a3f50;
  background: #f7e9ed;
  border-color: #e6c9d1;
}
.productivity-heat.heat-critical {
  color: #8f4254;
  background: #fbedf1;
}
.productivity-heat.heat-max {
  color: #7f3447 !important;
  background: #f4dfe5 !important;
  box-shadow: inset 0 0 0 1px #ddb9c3;
}
.heat-kpi.heat-critical {
  color: #8f4254;
  background: #fdf4f6;
  border-color: #e9cdd4;
}
.heat-legend .heat-critical {
  color: #8f4254;
  background: #f7e7eb;
  border-color: #e5c6ce;
}
.ipd-productivity-table .productivity-heat {
  transition: background-color .16s ease, color .16s ease, box-shadow .16s ease;
}
.ipd-productivity-table tbody tr:hover .productivity-heat.heat-max {
  background: #efd3db !important;
}

/* IPD highest-shift marker v2.3.2 */
.productivity-heat.heat-max {
  white-space: nowrap;
}
.productivity-heat.heat-max::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 8px;
  border-radius: 50%;
  background: #d94355;
  box-shadow: 0 0 0 3px rgba(217, 67, 85, .14);
  vertical-align: 1px;
}
.heat-legend .heat-max::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: #d94355;
  box-shadow: 0 0 0 3px rgba(217, 67, 85, .12);
}


/* IPD Heatmap threshold palette v2.3.4
   <90 = blue | 90–109.99 = green | 110–130 = yellow | >130 = soft red */
.heat-kpi.heat-low {
  color: #1f6598 !important;
  background: #eef7fd !important;
  border-color: #c9e2f2 !important;
}
.heat-kpi.heat-normal {
  color: #287a58 !important;
  background: #eff9f4 !important;
  border-color: #cce9da !important;
}
.heat-kpi.heat-high {
  color: #94620a !important;
  background: #fff8e6 !important;
  border-color: #f1ddb0 !important;
}
.heat-kpi.heat-critical {
  color: #93485a !important;
  background: #fdf2f5 !important;
  border-color: #e9cdd5 !important;
}

.heat-legend .heat-low {
  color: #1f6598 !important;
  background: #e9f4fb !important;
  border-color: #c5deed !important;
}
.heat-legend .heat-normal {
  color: #287a58 !important;
  background: #eaf7f0 !important;
  border-color: #c6e6d5 !important;
}
.heat-legend .heat-high {
  color: #94620a !important;
  background: #fff2cf !important;
  border-color: #efd797 !important;
}
.heat-legend .heat-critical {
  color: #93485a !important;
  background: #f8e9ed !important;
  border-color: #e6c7cf !important;
}

.productivity-heat.heat-low {
  color: #1f6598 !important;
  background: #edf6fc !important;
}
.productivity-heat.heat-normal {
  color: #287a58 !important;
  background: #edf8f2 !important;
}
.productivity-heat.heat-high {
  color: #94620a !important;
  background: #fff6df !important;
}
.productivity-heat.heat-critical {
  color: #93485a !important;
  background: #fbedf1 !important;
}

/* Maximum of each day/month: retain threshold color and add a red dot. */
.productivity-heat.heat-max {
  box-shadow: inset 0 0 0 1px rgba(217, 67, 85, .24) !important;
}
.productivity-heat.heat-max::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 8px;
  border-radius: 50%;
  vertical-align: 1px;
  background: #df4d60;
  box-shadow: 0 0 0 3px rgba(223, 77, 96, .14);
}
.productivity-heat.heat-low.heat-max {
  color: #1f6598 !important;
  background: #edf6fc !important;
}
.productivity-heat.heat-normal.heat-max {
  color: #287a58 !important;
  background: #edf8f2 !important;
}
.productivity-heat.heat-high.heat-max {
  color: #94620a !important;
  background: #fff6df !important;
}
.productivity-heat.heat-critical.heat-max {
  color: #93485a !important;
  background: #fbedf1 !important;
}

.heat-legend .heat-max::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: #df4d60;
  box-shadow: 0 0 0 3px rgba(223, 77, 96, .14);
}


/* OPD Product Ratio heatmap v2.3.5
   <90 = blue | 90–109.99 = green | 110–130 = yellow | >130 = soft red */
.opd-productivity-table .productivity-heat {
  min-width: 132px;
  transition: background-color .16s ease, color .16s ease, box-shadow .16s ease;
}
.opd-productivity-table tbody tr:hover .productivity-heat {
  filter: brightness(.985);
}
.opd-heat-legend {
  max-width: 100%;
}
.opd-daily-header-tools {
  display: grid;
  justify-items: end;
  gap: 8px;
}
@media (max-width: 900px) {
  .opd-daily-header-tools { justify-items: start; }
  .opd-heat-legend { justify-content: flex-start; }
}

/* OPD Product Ratio KPI contrast fix v2.3.6
   Override the legacy featured-card white text when a heatmap class is applied. */
.kpi-card.featured.heat-kpi,
.kpi-card.featured.heat-kpi span,
.kpi-card.featured.heat-kpi strong,
.kpi-card.featured.heat-kpi small {
  color: inherit !important;
}

.kpi-card.featured.heat-kpi span {
  opacity: .92;
}

.kpi-card.featured.heat-kpi small {
  opacity: .78;
}

.kpi-card.featured.heat-kpi::after {
  background: currentColor !important;
  opacity: .055 !important;
}


/* OPD target status and acuity colors v2.3.8 */
.target-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 118px;
  min-height: 30px;
  padding: 5px 11px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.target-status-low {
  color: #245f8f;
  background: #eaf4fb;
  border-color: #c9e1f1;
}
.target-status-in {
  color: #247052;
  background: #eaf7f0;
  border-color: #c9e7d6;
}
.target-status-watch {
  color: #94610d;
  background: #fff6df;
  border-color: #eedda9;
}
.target-status-empty {
  min-width: auto;
  color: var(--muted);
  background: #f4f7f9;
  border-color: #e1e8ed;
}

.opd-productivity-table .acuity-head {
  min-width: 74px;
  text-align: center;
}
.opd-productivity-table .acuity-head span {
  display: block;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
}
.opd-productivity-table .acuity-head small {
  display: block;
  margin-top: 4px;
  font-size: 9px;
  font-weight: 700;
  opacity: .78;
  white-space: nowrap;
}
.opd-productivity-table .acuity-cell {
  border-left: 1px solid rgba(15, 65, 96, .04);
  border-right: 1px solid rgba(15, 65, 96, .04);
  font-variant-numeric: tabular-nums;
}
.opd-productivity-table .acuity-cell strong {
  font-size: 14px;
  font-weight: 900;
}
.opd-productivity-table .acuity-urgent {
  color: #236995;
  background: #eaf5fb;
}
.opd-productivity-table .acuity-semi {
  color: #93600d;
  background: #fff6df;
}
.opd-productivity-table .acuity-non {
  color: #247052;
  background: #ebf7f0;
}
.opd-productivity-table tbody tr:hover .acuity-urgent {
  background: #dff0f9;
}
.opd-productivity-table tbody tr:hover .acuity-semi {
  background: #fff0c8;
}
.opd-productivity-table tbody tr:hover .acuity-non {
  background: #def1e7;
}

@media (max-width: 900px) {
  .target-status { min-width: 106px; }
  .opd-productivity-table .acuity-head small { display: none; }
  .opd-productivity-table .acuity-head { min-width: 48px; }
}


/* ER module v3.0.0 */
.kpi-grid.five { grid-template-columns: repeat(5,minmax(0,1fr)); }
.er-shift-grid { align-items: start; }
.er-input-section { margin: 14px 0; padding-top: 12px; border-top: 1px solid var(--line); }
.er-input-section h3 { margin: 0 0 10px; color: var(--navy); font-size: 13px; }
.er-input-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
.er-input-grid .field { margin:0; padding:11px; border:1px solid var(--line); border-radius:14px; background:#f9fbfd; }
.er-input-grid .field > span { display:flex; justify-content:space-between; gap:5px; }
.er-input-grid .field small { color:var(--muted); font-size:10px; }
.er-patient-field { border-left-width:4px!important; }
.er-emergent { border-left-color:#d65a6f!important; background:#fff5f7!important; }
.er-urgent { border-left-color:#e2a12d!important; background:#fff9ec!important; }
.er-non_urgent_acute { border-left-color:#438fc3!important; background:#f1f8fc!important; }
.er-non_urgent_non_acute { border-left-color:#45a177!important; background:#f0f9f4!important; }
@media(max-width:1100px){.kpi-grid.five{grid-template-columns:repeat(3,minmax(0,1fr));}.er-shift-grid{grid-template-columns:1fr;}}
@media(max-width:640px){.kpi-grid.five,.er-input-grid{grid-template-columns:1fr;}}


/* ER vertical shift workflow v3.0.1 */
.er-shift-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
  align-items: stretch;
}
.er-shift-grid .shift-card {
  width: 100%;
  overflow: hidden;
}
.er-shift-grid .shift-card > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}
.er-shift-grid .shift-card > header > div {
  display: flex;
  align-items: center;
  gap: 10px;
}
.er-shift-grid .shift-card > header h2 {
  margin: 0;
  color: var(--navy);
  font-size: 21px;
}
.er-shift-grid .shift-card form {
  padding: 0 20px 20px;
}
.er-shift-grid .er-input-section {
  margin: 18px 0 0;
  padding-top: 16px;
}
.er-shift-grid .er-input-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.er-shift-grid .er-input-grid .field {
  min-width: 0;
}
.er-shift-grid .er-input-grid .field input {
  width: 100%;
}
.er-shift-grid .btn-block {
  margin-top: 18px;
}

@media (max-width: 1180px) {
  .er-shift-grid .er-input-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 640px) {
  .er-shift-grid .shift-card > header {
    align-items: flex-start;
  }
  .er-shift-grid .shift-card form {
    padding: 0 14px 16px;
  }
  .er-shift-grid .er-input-grid {
    grid-template-columns: 1fr;
  }
}


/* ER IPD-style three-column workflow v3.0.2 */
.er-shift-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}
.er-shift-grid .shift-card {
  width: 100%;
  min-width: 0;
  overflow: hidden;
  border-top: 4px solid var(--primary);
}
.er-shift-grid .shift-card.shift-evening {
  border-top-color: #7c6bc9;
}
.er-shift-grid .shift-card.shift-night {
  border-top-color: #37527d;
}
.er-shift-grid .shift-card > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}
.er-shift-grid .shift-card > header > div {
  display: flex;
  align-items: center;
  gap: 10px;
}
.er-shift-grid .shift-card > header h2 {
  margin: 0;
  color: var(--navy);
  font-size: 20px;
}
.er-shift-grid .shift-card form {
  padding: 0 16px 18px;
}
.er-shift-grid .er-input-section {
  margin: 14px 0 0;
  padding-top: 14px;
}
.er-shift-grid .er-input-section h3 {
  margin-bottom: 10px;
}
.er-shift-grid .er-input-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.er-shift-grid .er-input-grid .field {
  min-width: 0;
  padding: 11px;
}
.er-shift-grid .er-input-grid .field > span {
  min-height: 34px;
  align-items: flex-start;
  line-height: 1.25;
}
.er-shift-grid .er-input-grid .field input {
  width: 100%;
}
.er-shift-grid .er-input-grid .field small {
  line-height: 1.25;
}
.er-shift-grid .btn-block {
  margin-top: 16px;
}

@media (max-width: 1180px) {
  .er-shift-grid {
    grid-template-columns: 1fr;
  }
  .er-shift-grid .er-input-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
@media (max-width: 820px) {
  .er-shift-grid .er-input-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 560px) {
  .er-shift-grid .er-input-grid {
    grid-template-columns: 1fr;
  }
  .er-shift-grid .shift-card form {
    padding: 0 12px 16px;
  }
}


/* ER calculated results and heatmap v3.0.3 */
.er-shift-result {
  margin: 18px 0 4px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.er-result-list {
  margin: 0;
  padding: 0;
}
.er-result-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 2px;
  border-bottom: 1px dashed #d8e3ea;
}
.er-result-list dt {
  color: var(--muted);
}
.er-result-list dd {
  margin: 0;
  color: var(--navy);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.er-productivity-result {
  display: grid;
  gap: 5px;
  place-items: center;
  margin-top: 16px;
  padding: 18px 14px;
  border: 1px solid transparent;
  border-radius: 15px;
  text-align: center;
}
.er-productivity-result span {
  font-size: 12px;
  font-weight: 800;
}
.er-productivity-result strong {
  font-size: 28px;
  line-height: 1.1;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.er-daily-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.er-daily-result > div {
  display: grid;
  gap: 4px;
}
.er-daily-result b {
  font-size: 24px;
  font-weight: 900;
  white-space: nowrap;
}
.er-productivity-result.heat-low,
.er-daily-result.heat-low {
  color: #245f8f;
  background: #eaf4fb;
  border-color: #c9e1f1;
}
.er-productivity-result.heat-normal,
.er-daily-result.heat-normal {
  color: #247052;
  background: #eaf7f0;
  border-color: #c9e7d6;
}
.er-productivity-result.heat-high,
.er-daily-result.heat-high {
  color: #94610d;
  background: #fff6df;
  border-color: #eedda9;
}
.er-productivity-result.heat-critical,
.er-daily-result.heat-critical {
  color: #a13b50;
  background: #fbecef;
  border-color: #ecc8d0;
}
.er-productivity-result.heat-empty,
.er-daily-result.heat-empty {
  color: var(--muted);
  background: #f4f7f9;
  border-color: #e1e8ed;
}
.er-heat-legend {
  flex-wrap: wrap;
}
@media (max-width: 640px) {
  .er-daily-result {
    align-items: flex-start;
    flex-direction: column;
  }
}


/* ER live productivity preview v3.0.4 */
.er-productivity-result {
  transition: background-color .18s ease, border-color .18s ease, color .18s ease;
}
.er-shift-result::before {
  content: "ผลคำนวณแบบทันที";
  display: inline-flex;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .04em;
}


/* ER historical import v3.1.0 */
.er-import-preview td { font-variant-numeric: tabular-nums; }


/* Unit identity headings and ER KPI heat cards v3.1.1 */
.unit-heading {
  position: relative;
  overflow: hidden;
  min-height: 132px;
  padding: 22px 24px;
  border: 1px solid transparent;
  border-radius: 20px;
  box-shadow: 0 12px 30px rgba(24, 58, 82, .07);
}
.unit-heading::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 6px;
  border-radius: 20px 0 0 20px;
  background: currentColor;
}
.unit-heading::after {
  content: "";
  position: absolute;
  right: -42px;
  bottom: -74px;
  width: 190px;
  height: 190px;
  border-radius: 50%;
  background: currentColor;
  opacity: .055;
  pointer-events: none;
}
.unit-heading > * {
  position: relative;
  z-index: 1;
}
.unit-heading h1 {
  color: inherit;
}
.unit-heading .eyebrow {
  color: inherit;
  opacity: .92;
}
.unit-heading p {
  color: color-mix(in srgb, currentColor 72%, #607284);
}
.unit-heading .back-link {
  color: inherit;
}
.unit-heading-opd {
  color: #9a6908;
  background: linear-gradient(135deg, #fffaf0, #fff5d9);
  border-color: #efdca9;
}
.unit-heading-ipd {
  color: #6651a8;
  background: linear-gradient(135deg, #f8f5ff, #eee9fb);
  border-color: #d8cef1;
}
.unit-heading-er {
  color: #a44958;
  background: linear-gradient(135deg, #fff7f8, #fae9ed);
  border-color: #ebcbd2;
}

/* ER average KPI cards use the same productivity thresholds as the heatmap. */
.kpi-card.heat-card {
  border: 1px solid transparent;
}
.kpi-card.heat-card::after {
  background: currentColor;
  opacity: .055;
}
.kpi-card.heat-card strong,
.kpi-card.heat-card span,
.kpi-card.heat-card small {
  color: inherit !important;
}
.kpi-card.heat-card.heat-low {
  color: #245f8f;
  background: #eaf4fb;
  border-color: #c9e1f1;
}
.kpi-card.heat-card.heat-normal {
  color: #247052;
  background: #eaf7f0;
  border-color: #c9e7d6;
}
.kpi-card.heat-card.heat-high {
  color: #94610d;
  background: #fff6df;
  border-color: #eedda9;
}
.kpi-card.heat-card.heat-critical {
  color: #a13b50;
  background: #fbecef;
  border-color: #ecc8d0;
}
.kpi-card.heat-card.heat-empty {
  color: var(--muted);
  background: #f4f7f9;
  border-color: #e1e8ed;
}

@media (max-width: 760px) {
  .unit-heading {
    align-items: flex-start;
    min-height: 0;
    padding: 19px 18px;
  }
}


/* ER five-level triage v3.2.0 */
.er-resuscitate {
  border-left-color: #cf4055 !important;
  background: #fff1f3 !important;
}
.er-emergent {
  border-left-color: #e8812b !important;
  background: #fff5e9 !important;
}
.er-urgent {
  border-left-color: #dfaa24 !important;
  background: #fff9e7 !important;
}
.er-non_urgent_acute {
  border-left-color: #438fc3 !important;
  background: #f1f8fc !important;
}
.er-non_urgent_non_acute {
  border-left-color: #45a177 !important;
  background: #f0f9f4 !important;
}
.er-shift-grid .er-input-section:first-of-type .er-input-grid .er-patient-field:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}


/* ER severity palette v3.2.1 */
.er-patient-field {
  position: relative;
  border: 2px solid transparent !important;
  border-left-width: 7px !important;
  box-shadow: 0 5px 14px rgba(31, 67, 91, .055);
}
.er-patient-field > span {
  display: flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  font-weight: 900;
}
.er-patient-field > span::before {
  content: "";
  width: 11px;
  height: 11px;
  flex: 0 0 11px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 4px rgba(255,255,255,.78);
}
.er-patient-field small {
  font-weight: 800;
}
.er-patient-field input {
  background: rgba(255,255,255,.94);
  border-color: color-mix(in srgb, currentColor 25%, #cfdbe5) !important;
}
.er-patient-field:focus-within {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px color-mix(in srgb, currentColor 15%, transparent);
}

/* 1. Resuscitate — red */
.er-resuscitate {
  color: #a9233a !important;
  background: #ffe8ec !important;
  border-color: #d53c55 !important;
}

/* 2. Emergency — pink */
.er-emergent {
  color: #a43b67 !important;
  background: #fdebf3 !important;
  border-color: #d85f91 !important;
}

/* 3. Urgent — yellow */
.er-urgent {
  color: #8b6205 !important;
  background: #fff5c9 !important;
  border-color: #e0ad22 !important;
}

/* 4. Semi Urgency — green */
.er-non_urgent_acute {
  color: #23724f !important;
  background: #e7f7ee !important;
  border-color: #49a87a !important;
}

/* 5. Non Urgency — white */
.er-non_urgent_non_acute {
  color: #465b6d !important;
  background: #ffffff !important;
  border-color: #bac9d4 !important;
}
