:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #102a2b;
  --muted: #5d7475;
  --line: #d9e7e5;
  --paper: #ffffff;
  --wash: #eef8f6;
  --teal: #087f73;
  --teal-dark: #04564f;
  --teal-light: #d9f4ef;
  --navy: #092144;
  --green: #16835b;
  --green-bg: #dff6e9;
  --yellow: #7a5a00;
  --yellow-bg: #fff1b8;
  --red: #a5212a;
  --red-bg: #fee3e5;
  --shadow: 0 18px 48px rgba(4, 62, 57, .12);
}

.portal-admin{display:flex;align-items:center;justify-content:space-between;gap:18px;margin-top:18px;padding:18px;border:1px solid rgba(8,127,115,.2);border-radius:18px;background:rgba(255,255,255,.82);box-shadow:0 10px 30px rgba(13,54,49,.07)}
.portal-admin h2{margin:2px 0 6px;font-size:18px}.portal-admin p{margin:0;color:#66736f;font-size:13px}.portal-admin-actions{display:flex;align-items:center;justify-content:flex-end;gap:9px;flex-wrap:wrap}
.portal-admin button,.portal-admin a{border:0;border-radius:999px;padding:10px 14px;background:#087f73;color:#fff;font:inherit;font-weight:700;text-decoration:none;cursor:pointer}.portal-admin button.secondary{background:#e7efed;color:#31534e}
@media(max-width:640px){.portal-admin{align-items:flex-start;flex-direction:column}.portal-admin-actions{justify-content:flex-start}}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100svh; color: var(--ink); background: #f4faf9; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.portal-body {
  color: #f4fffc;
  background: radial-gradient(circle at 50% 0%, #26b7a4 0, #087f73 38%, #033f3a 100%);
  padding: max(26px, env(safe-area-inset-top)) 18px max(26px, env(safe-area-inset-bottom));
}
.portal-shell { width: min(100%, 520px); margin: 0 auto; }
.portal-header { text-align: center; }
.portal-logo { width: 132px; height: 132px; border-radius: 30px; box-shadow: 0 20px 42px rgba(0, 20, 18, .35); }
.eyebrow { margin: 24px 0 5px; font-size: .78rem; font-weight: 900; letter-spacing: .15em; text-transform: uppercase; opacity: .78; }
.portal-header h1 { margin: 0; font-size: clamp(1.8rem, 7vw, 2.35rem); letter-spacing: .025em; }
.portal-header > p:last-child { margin: 8px 0 24px; color: #d5fbf5; }
.portal-grid { display: grid; gap: 14px; }
.portal-card { display: grid; grid-template-columns: 50px 1fr 24px; align-items: center; gap: 14px; min-height: 108px; padding: 18px; color: var(--ink); background: rgba(255,255,255,.97); border: 1px solid rgba(255,255,255,.75); border-radius: 22px; text-decoration: none; box-shadow: 0 14px 32px rgba(0, 30, 27, .24); }
.portal-card:active { transform: translateY(1px); }
.portal-card-icon { display: grid; place-items: center; width: 50px; height: 50px; color: white; background: var(--teal); border-radius: 16px; font-size: 1.55rem; font-weight: 900; }
.portal-card-asthma .portal-card-icon { background: var(--navy); }
.portal-card-phc .portal-card-icon { padding: 0; background: #fff; overflow: hidden; }
.portal-card-amo .portal-card-icon,
.portal-card-asthma .portal-card-icon { padding: 0; background: #fff; overflow: hidden; }
.portal-card-amo .portal-card-icon img,
.portal-card-asthma .portal-card-icon img { width: 100%; height: 100%; object-fit: contain; display: block; }
.portal-card-phc .portal-card-icon img { width: 100%; height: 100%; object-fit: contain; display: block; }
.portal-card-girn .portal-card-icon { background: #153e3a; }
.portal-card-radio { position: relative; overflow: visible; }
.portal-card-radio img {
  width: 34px;
  height: 43px;
  border-radius: 7px;
  object-fit: cover;
  object-position: center;
}
.portal-card-radio i,
.portal-card-radio::before,
.portal-card-radio::after {
  position: absolute;
  top: 7px;
  left: 39px;
  width: 8px;
  height: 8px;
  border: 2px solid #7ce5c5;
  border-bottom-color: transparent;
  border-left-color: transparent;
  border-radius: 50%;
  content: "";
  transform: rotate(45deg);
  animation: portal-signal 1.8s ease-out infinite;
}
.portal-card-radio::before { width: 13px; height: 13px; animation-delay: .2s; }
.portal-card-radio::after { width: 18px; height: 18px; animation-delay: .4s; }
@keyframes portal-signal {
  0%, 35% { opacity: 0; transform: rotate(45deg) scale(.75); }
  55%, 80% { opacity: 1; }
  100% { opacity: 0; transform: rotate(45deg) scale(1.08); }
}
.portal-card strong { display: block; font-size: 1.03rem; line-height: 1.3; }
.portal-card small { display: block; margin-top: 6px; color: var(--muted); line-height: 1.35; }
.portal-arrow { color: var(--teal); font-size: 2rem; line-height: 1; }
.portal-note { margin: 18px 12px 0; text-align: center; color: #c8eee8; font-size: .78rem; line-height: 1.45; }

@media (max-width: 520px) {
  .portal-card { min-height: 123px; }
}

.app-header { position: sticky; top: 0; z-index: 20; color: white; background: rgba(5, 91, 83, .97); backdrop-filter: blur(12px); box-shadow: 0 5px 20px rgba(0, 50, 45, .15); }
.app-header-inner { display: flex; align-items: center; gap: 12px; width: min(100%, 900px); min-height: 66px; margin: 0 auto; padding: max(10px, env(safe-area-inset-top)) 16px 10px; }
.back-link { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid rgba(255,255,255,.25); border-radius: 13px; color: white; text-decoration: none; font-size: 1.45rem; }
.app-title { min-width: 0; }
.app-title strong { display: block; font-size: 1rem; }
.app-title small { display: block; margin-top: 2px; color: #c9f1eb; }
.app-mark { width: 42px; height: 42px; margin-left: auto; border-radius: 12px; }

.app-shell { width: min(100%, 900px); margin: 0 auto; padding: 18px 14px calc(92px + env(safe-area-inset-bottom)); }
.notice { margin-bottom: 16px; padding: 13px 15px; color: #4f5f61; background: #eef4f5; border-left: 4px solid #789295; border-radius: 10px; font-size: .82rem; line-height: 1.45; }
.sync-notice { border-left-color: #c7860a; background: #fff7df; color: #654d14; }
.view { display: none; }
.view.is-active { display: block; }
.section-heading { margin: 0 0 15px; }
.section-heading h1, .section-heading h2 { margin: 0; }
.section-heading p { margin: 6px 0 0; color: var(--muted); line-height: 1.45; }

.card { margin-bottom: 14px; padding: 18px; background: var(--paper); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 8px 24px rgba(4, 62, 57, .06); }
.card h2 { display: flex; align-items: center; gap: 9px; margin: 0 0 16px; font-size: 1.05rem; }
.step { display: grid; place-items: center; width: 28px; height: 28px; color: white; background: var(--teal); border-radius: 50%; font-size: .78rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label, .fieldset-label { color: #344f50; font-size: .83rem; font-weight: 800; }
.field input, .field select { width: 100%; min-height: 48px; padding: 0 13px; color: var(--ink); background: #fbfdfd; border: 1px solid #c9dedd; border-radius: 12px; outline: none; }
.field input:focus, .field select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8,127,115,.13); }
.field input:disabled, .field select:disabled { background: #eef3f3; color: #718181; }
.field small { color: var(--muted); line-height: 1.35; }
.unit-field { position: relative; }
.unit-field input { padding-right: 62px; }
.unit { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .78rem; font-weight: 700; pointer-events: none; }
.segmented { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.segmented.three { grid-template-columns: repeat(3, 1fr); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; }
.segmented span { display: grid; place-items: center; min-height: 48px; padding: 8px; text-align: center; color: #446060; background: #f2f7f6; border: 1px solid #d4e5e3; border-radius: 12px; font-size: .86rem; font-weight: 800; }
.segmented input:checked + span { color: white; background: var(--teal); border-color: var(--teal); box-shadow: 0 7px 16px rgba(8,127,115,.2); }
.segmented input:disabled + span { opacity: .48; }
.checkbox-row { display: flex; align-items: flex-start; gap: 12px; padding: 14px; background: #f3f8f7; border: 1px solid #d2e4e1; border-radius: 14px; cursor: pointer; }
.checkbox-row input { width: 21px; height: 21px; margin: 1px 0 0; accent-color: var(--teal); }
.checkbox-row span { display: grid; gap: 4px; }
.checkbox-row small { color: var(--muted); line-height: 1.35; }
.option-list { display: grid; gap: 8px; }
.option-list label { position: relative; }
.option-list input { position: absolute; opacity: 0; }
.option-list span { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 10px 12px; color: #3f5859; background: #f7faf9; border: 1px solid #d4e5e3; border-radius: 12px; font-size: .84rem; font-weight: 750; }
.option-list span b { display: grid; flex: 0 0 28px; place-items: center; width: 28px; height: 28px; color: white; background: #789493; border-radius: 9px; }
.option-list span small { color: inherit; font-weight: 650; }
.option-list input:checked + span { color: var(--teal-dark); background: var(--teal-light); border-color: var(--teal); }
.option-list input:checked + span b { background: var(--teal); }

.ideal-card { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 14px; padding: 16px; background: linear-gradient(135deg, #e4f8f3, #f8fffd); border: 1px solid #b9e4db; border-radius: 16px; }
.ideal-card small { display: block; color: var(--muted); }
.ideal-card strong { display: block; margin-top: 3px; color: var(--teal-dark); font-size: 1.8rem; }
.ideal-method { max-width: 29ch; text-align: right; color: var(--muted); font-size: .72rem; line-height: 1.35; }
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.result-card { min-height: 150px; padding: 16px; border: 1px solid var(--line); border-radius: 17px; background: #f7faf9; }
.result-card > small { color: var(--muted); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.result-value { margin: 8px 0 9px; font-size: 1.75rem; font-weight: 900; }
.category-badge { display: inline-flex; align-items: center; min-height: 34px; padding: 6px 10px; border-radius: 10px; font-size: .8rem; font-weight: 900; }
.category-mild { color: var(--green); background: var(--green-bg); }
.category-moderate { color: var(--yellow); background: var(--yellow-bg); }
.category-severe { color: var(--red); background: var(--red-bg); }
.category-empty { color: var(--muted); background: #e8eeee; }
.uptriage-card[hidden], .summary-card[hidden] { display: none; }

.summary-list { display: grid; gap: 10px; margin: 0; }
.summary-row { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.summary-row:last-child { padding-bottom: 0; border: 0; }
.summary-row dt { color: var(--muted); }
.summary-row dd { margin: 0; text-align: right; font-weight: 850; }
.actions { display: grid; grid-template-columns: 1fr 1.5fr; gap: 10px; margin-top: 18px; }
.btn { min-height: 50px; padding: 10px 16px; border: 0; border-radius: 13px; font-weight: 900; cursor: pointer; }
.btn-primary { color: white; background: var(--teal); box-shadow: 0 9px 18px rgba(8,127,115,.22); }
.btn-secondary { color: var(--teal-dark); background: #e8f4f2; }
.btn-danger { color: var(--red); background: var(--red-bg); }
.btn:disabled { opacity: .48; cursor: not-allowed; }

.empty-state { padding: 30px 18px; text-align: center; color: var(--muted); background: white; border: 1px dashed #bfd4d1; border-radius: 18px; }
.record-list { display: grid; gap: 12px; }
.record-card { padding: 16px; background: white; border: 1px solid var(--line); border-radius: 17px; box-shadow: 0 7px 20px rgba(4,62,57,.05); }
.record-top { display: flex; justify-content: space-between; gap: 12px; }
.record-top strong { font-size: .96rem; }
.record-top small { color: var(--muted); }
.pending-label { display: inline-block; margin-left: .35rem; padding: .18rem .45rem; border-radius: 999px; background: #fff3cd; color: #8a5700; font-weight: 800; font-size: .7rem; }
.record-flow { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin-top: 14px; }
.record-flow > div { min-width: 0; }
.record-flow b { display: block; margin-bottom: 6px; }
.record-flow .arrow { color: var(--teal); font-size: 1.35rem; }
.record-footer { display: flex; justify-content: space-between; gap: 10px; margin-top: 13px; padding-top: 11px; border-top: 1px solid var(--line); color: var(--muted); font-size: .78rem; }

.filter-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-bottom: 14px; }
.record-search-row { grid-template-columns: minmax(0, 1fr) auto auto; }
.filter-row input, .filter-row select { min-height: 46px; padding: 0 12px; border: 1px solid #c9dedd; border-radius: 12px; background: white; }
@media (max-width: 430px) {
  .record-search-row { grid-template-columns: minmax(0, 1fr) auto; }
  .record-search-row #refreshRecords { grid-column: 1 / -1; }
}
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.stat-card { padding: 15px; background: white; border: 1px solid var(--line); border-radius: 16px; }
.stat-card small { color: var(--muted); }
.stat-card strong { display: block; margin-top: 5px; font-size: 1.65rem; }
.stat-section h3 { margin: 0 0 12px; }
.bar-row { display: grid; grid-template-columns: 90px 1fr 32px; align-items: center; gap: 9px; margin: 10px 0; font-size: .8rem; }
.bar-track { height: 11px; overflow: hidden; background: #e7efee; border-radius: 99px; }
.bar { height: 100%; min-width: 0; border-radius: 99px; }
.bar-mild { background: #35aa79; }
.bar-moderate { background: #e0b126; }
.bar-severe { background: #d84953; }

.reference-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.reference-card { overflow: hidden; padding: 0; text-align: left; background: white; border: 1px solid var(--line); border-radius: 17px; cursor: pointer; }
.reference-card img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.reference-card strong { display: block; padding: 12px 12px 4px; }
.reference-card small { display: block; padding: 0 12px 13px; color: var(--muted); }
.reference-dialog { width: min(96vw, 980px); max-height: 94svh; padding: 0; border: 0; border-radius: 18px; box-shadow: var(--shadow); }
.reference-dialog::backdrop { background: rgba(0,20,20,.8); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.dialog-head strong { font-size: .95rem; }
.dialog-close { width: 42px; height: 42px; border: 0; border-radius: 12px; background: #edf4f3; font-size: 1.25rem; }
.dialog-image-wrap { max-height: calc(94svh - 68px); overflow: auto; background: #172524; }
.dialog-image-wrap img { display: block; width: 100%; min-width: min(760px, 100%); height: auto; margin: auto; }

.bottom-nav { position: fixed; z-index: 30; left: 50%; bottom: 0; transform: translateX(-50%); display: grid; grid-template-columns: repeat(5, 1fr); width: min(100%, 900px); padding: 7px 8px calc(7px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.97); border-top: 1px solid var(--line); box-shadow: 0 -8px 28px rgba(0,45,42,.1); backdrop-filter: blur(12px); }
.nav-button { min-height: 53px; padding: 5px 3px; color: #6a7e7e; background: transparent; border: 0; border-radius: 11px; font-size: .68rem; font-weight: 800; }
.nav-button span { display: block; margin-bottom: 3px; font-size: 1.15rem; }
.nav-button.is-active { color: var(--teal); background: var(--teal-light); }
.lookup-privacy-note { margin: -4px 0 14px; color: var(--muted); font-size: .78rem; }
.patient-lookup-card { padding: 18px; background: white; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 7px 20px rgba(4,62,57,.05); }
.patient-lookup-card h3 { margin: 0; font-size: 1.12rem; }
.patient-lookup-card > small { display: block; margin-top: 4px; color: var(--muted); }
.patient-detail-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 16px 0 0; }
.patient-detail-list div { padding: 12px; background: #f2f8f7; border-radius: 13px; }
.patient-detail-list dt { color: var(--muted); font-size: .76rem; }
.patient-detail-list dd { margin: 5px 0 0; font-weight: 850; }
.lookup-warning { margin: 14px 0 0; padding: 11px 12px; color: #6d5200; background: #fff8d8; border-radius: 12px; font-size: .8rem; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: calc(82px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); width: min(calc(100% - 28px), 480px); padding: 13px 16px; color: white; background: #173f3d; border-radius: 13px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .22s ease; }
.toast.is-visible { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 640px) {
  .form-grid, .result-grid { grid-template-columns: 1fr; }
  .reference-grid { grid-template-columns: 1fr; }
  .reference-card { display: grid; grid-template-columns: 105px 1fr; }
  .reference-card img { grid-row: 1 / 3; height: 100%; aspect-ratio: auto; }
  .reference-card small { padding-bottom: 12px; }
  .ideal-card { grid-template-columns: 1fr; }
  .ideal-method { text-align: left; }
  .patient-detail-list { grid-template-columns: 1fr; }
}

@media (max-width: 390px) {
  .segmented.three { grid-template-columns: 1fr; }
  .actions { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* Label versi modul + bar kemas kini (portal) */
.portal-version { margin: 8px 12px 0; text-align: center; color: #9fded5; font-size: .72rem; letter-spacing: .01em; }
.update-bar { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); width: min(calc(100% - 24px), 520px); display: flex; align-items: center; gap: 11px; background: #fff; border-radius: 16px; padding: 12px 14px; box-shadow: 0 12px 30px rgba(0,20,18,.32); z-index: 90; animation: updatebar-pop .35s ease; }
.update-bar[hidden] { display: none; }
@keyframes updatebar-pop { from { transform: translate(-50%, 12px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.update-bar-icon { width: 38px; height: 38px; flex: 0 0 auto; border-radius: 12px; background: var(--teal-light); color: var(--teal-dark); display: grid; place-items: center; font-size: 20px; }
.update-bar-text { flex: 1; min-width: 0; }
.update-bar-text strong { display: block; font-size: .84rem; color: var(--ink); }
.update-bar-text small { font-size: .72rem; color: var(--muted); }
.update-bar button { flex: 0 0 auto; border: 0; background: var(--teal); color: #fff; font-weight: 800; font-size: .78rem; padding: 10px 15px; border-radius: 11px; cursor: pointer; }
.update-bar button:disabled { opacity: .6; }
@media (max-width: 390px) { .update-bar-text strong { font-size: .8rem; } .update-bar-text small { font-size: .68rem; } }

/* Pilihan tarikh penilaian Asthma (Hari ini / Tarikh lain) */
.datetime-toggle { display: flex; gap: 8px; margin-bottom: 8px; }
.datetime-toggle .dt-opt { flex: 1; border: 1px solid var(--line); background: #fff; color: var(--muted); font-weight: 700; font-size: .82rem; padding: 9px 10px; border-radius: 10px; cursor: pointer; }
.datetime-toggle .dt-opt.active { background: var(--teal); border-color: var(--teal); color: #fff; }
.datetime-auto { display: flex; gap: 8px; }
.datetime-auto input { flex: 1; }
.datetime-custom { display: flex; flex-wrap: wrap; gap: 8px; }
.datetime-custom input[type="date"], .datetime-custom input[type="time"] { flex: 1 1 130px; }
.datetime-custom .dt-note { flex: 1 1 100%; color: var(--muted); font-size: .72rem; margin-top: 2px; }

/* Asthma v1.1 - Laporan PEFR A4 */
.eyebrow-inline { margin: 0 0 4px; color: var(--teal); font-size: .7rem; font-weight: 900; letter-spacing: .13em; }
.report-builder-head { display: flex; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.report-builder-head h3 { margin: 0; font-size: 1.1rem; }
.report-builder-head p:last-child { margin: 5px 0 0; color: var(--muted); font-size: .8rem; line-height: 1.4; }
.report-version { align-self: start; flex: 0 0 auto; padding: 6px 9px; color: var(--teal-dark); background: var(--teal-light); border-radius: 999px; font-size: .72rem; font-weight: 900; }
.report-filter-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.report-generate { width: 100%; margin-top: 15px; }
.report-load-status { min-height: 18px; margin: 9px 0 0; color: var(--muted); font-size: .78rem; text-align: center; }
.pefr-preview-shell { margin-top: 18px; }
.preview-toolbar { position: sticky; top: 76px; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; padding: 12px; background: rgba(255,255,255,.97); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 8px 24px rgba(4,62,57,.12); }
.preview-toolbar strong, .preview-toolbar small { display: block; }
.preview-toolbar small { margin-top: 3px; color: var(--muted); font-size: .72rem; }
.preview-toolbar .btn { min-height: 42px; }
.pefr-print-report { width: 297mm; min-height: 210mm; margin: 0 auto; padding: 9mm; overflow: visible; color: #173b38; background: white; border: 1px solid #aebfbc; box-shadow: 0 8px 24px rgba(0,0,0,.13); font-family: Arial, sans-serif; font-size: 9px; }
.print-report-head { display: flex; align-items: center; gap: 11px; padding-bottom: 8px; border-bottom: 3px solid #117d75; }
.print-mark { display: grid; place-items: center; flex: 0 0 auto; width: 48px; height: 48px; color: white; background: #117d75; border-radius: 9px; font-weight: 900; }
.print-report-head small { color: #117d75; font-size: 7px; font-weight: 900; letter-spacing: .1em; }
.print-report-head h2 { margin: 3px 0; font-size: 17px; }
.print-report-head p { margin: 0; color: #68817e; }
.print-report-head dl { display: grid; grid-template-columns: auto auto; gap: 3px 8px; margin: 0 0 0 auto; text-align: right; }
.print-report-head dt { color: #68817e; }
.print-report-head dd { margin: 0; font-weight: 800; }
.print-kpi-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-top: 8px; }
.print-kpi { padding: 7px; border: 1px solid #cddedb; border-top: 3px solid #117d75; border-radius: 6px; }
.print-kpi.good { border-top-color: #23986b; }.print-kpi.warn { border-top-color: #d99718; }.print-kpi.bad { border-top-color: #ce5656; }
.print-kpi span, .print-kpi small { display: block; color: #68817e; }.print-kpi span { font-size: 7px; text-transform: uppercase; }.print-kpi strong { display: block; margin: 2px 0; font-size: 17px; }
.print-analysis, .print-detail { margin-top: 9px; }
.print-analysis h3, .print-detail h3, .print-summary h3 { margin: 0 0 5px; padding-bottom: 4px; color: #075b56; border-bottom: 1px solid #cddedb; font-size: 9px; text-transform: uppercase; letter-spacing: .07em; }
.print-analysis-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.print-analysis-card { padding: 7px; background: #edf6f4; border: 1px solid #cddedb; border-radius: 6px; line-height: 1.5; }
.print-analysis-card strong { font-size: 12px; }.print-analysis-card b { color: #117d75; }
.print-table-wrap { overflow: visible; }
.pefr-print-report table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.pefr-print-report th, .pefr-print-report td { padding: 4px 3px; border: 1px solid #c5d5d2; vertical-align: top; line-height: 1.25; overflow-wrap: anywhere; }
.pefr-print-report th { color: white; background: #117d75; font-size: 7px; }
.pefr-print-report td { font-size: 7px; }.pefr-print-report tbody tr:nth-child(even) { background: #edf6f4; }
.pefr-print-report th:nth-child(1){width:8%}.pefr-print-report th:nth-child(2){width:7%}.pefr-print-report th:nth-child(3){width:9%}.pefr-print-report th:nth-child(4){width:7%}.pefr-print-report th:nth-child(5){width:12%}.pefr-print-report th:nth-child(6){width:6%}.pefr-print-report th:nth-child(7),.pefr-print-report th:nth-child(8){width:9%}.pefr-print-report th:nth-child(9){width:7%}.pefr-print-report th:nth-child(10){width:16%}.pefr-print-report th:nth-child(11){width:10%}
.print-summary { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; margin-top: 10px; break-inside: avoid; }
.print-summary p { margin: 0; line-height: 1.45; }.print-signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding-top: 20px; }.print-signatures p { border-top: 1px solid #777; padding-top: 4px; }
.pefr-print-report footer { margin-top: 9px; color: #68817e; text-align: center; font-size: 7px; }

@media (max-width: 900px) {
  .pefr-preview-shell { overflow: hidden; }
  .pefr-print-report { transform: scale(.72); transform-origin: top left; margin-bottom: -59mm; }
}
@media (max-width: 640px) {
  .report-filter-grid { grid-template-columns: 1fr; }
  .preview-toolbar { top: 70px; align-items: flex-start; }
  .preview-toolbar .btn { padding: 8px 10px; font-size: .78rem; }
  .pefr-print-report { transform: scale(.34); margin-bottom: -138mm; }
}

.draft-manager{margin-bottom:16px;padding:15px}.draft-manager-head{display:flex;align-items:center;justify-content:space-between;gap:12px}.draft-manager-head small{color:var(--primary);font-size:10px;font-weight:800;letter-spacing:.12em}.draft-manager-head h2{margin:3px 0 0;font-size:16px}.draft-manager-head .btn{width:auto}.draft-list{display:grid;gap:8px;margin-top:12px}.draft-item{display:flex;align-items:center;gap:9px;padding:10px;border:1px solid var(--border);border-radius:12px;background:var(--surface-soft)}.draft-item.active{border-color:var(--primary)}.draft-copy{min-width:0;flex:1}.draft-copy strong,.draft-copy small{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.draft-copy small{margin-top:2px;color:var(--text-muted)}.draft-item button{padding:7px 9px;border:0;border-radius:8px;font:inherit;font-size:12px;font-weight:700}.draft-open{background:var(--primary);color:#fff}.draft-delete{background:#f7e8e8;color:#a23838}.draft-empty{margin:0;color:var(--text-muted);font-size:13px}@media(max-width:520px){.draft-manager-head{align-items:flex-start;flex-direction:column}.draft-manager-head .btn{width:100%}}

@media print {
  @page { size: A4 landscape; margin: 8mm; }
  body { background: white; }
  body > :not(main), .app-shell > :not(#statsView), #statsView > :not(#pefrReportPreview), .no-print { display: none !important; }
  .app-shell, #statsView, #pefrReportPreview { display: block !important; width: auto; margin: 0; padding: 0; }
  .pefr-preview-shell { margin: 0; overflow: visible; }
  .pefr-print-report { width: auto; min-height: 0; margin: 0; padding: 0; border: 0; box-shadow: none; transform: none; }
  .print-report-head, .print-kpi-grid, .print-analysis-grid, .print-summary { break-inside: avoid; page-break-inside: avoid; }
  .pefr-print-report thead { display: table-header-group; }
  .pefr-print-report tr { break-inside: avoid; page-break-inside: avoid; }
}
