:root {
  color-scheme: light;
  --ink: #111827;
  --muted: #6b7280;
  --line: rgba(203, 213, 225, .72);
  --rose: #f43f5e;
  --rose-dark: #e11d48;
  --rose-soft: #ffe4e6;
  --sky: #0ea5e9;
  --sky-soft: #e0f2fe;
  --emerald: #10b981;
  --emerald-soft: #d1fae5;
  --indigo: #6366f1;
  --amber: #d97706;
  --red: #dc2626;
  --glass: rgba(255, 255, 255, .86);
  --shadow: 0 18px 50px rgba(15, 23, 42, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; scroll-behavior: smooth; background: #f8fafc; }
body { min-width: 320px; min-height: 100vh; margin: 0; color: var(--ink); font: 16px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: 0; background: linear-gradient(155deg, #f8fafc 0%, #f0fdfa 36%, #eff6ff 68%, #fff1f2 100%); }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; }

.app-loading { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.boot-card { display: flex; align-items: center; gap: 14px; padding: 20px 24px; border: 1px solid rgba(255,255,255,.95); border-radius: 24px; background: var(--glass); box-shadow: var(--shadow), inset 0 1px 0 #fff; backdrop-filter: blur(20px) saturate(150%); }
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.shell-main { min-width: 0; min-height: calc(100vh - 64px); display: flex; flex: 1; flex-direction: column; }

.site-nav { position: sticky; top: 0; z-index: 40; height: 64px; border-bottom: 1px solid rgba(255,255,255,.7); background: rgba(255,255,255,.84); box-shadow: 0 8px 32px rgba(15,23,42,.07); backdrop-filter: blur(20px) saturate(150%); -webkit-backdrop-filter: blur(20px) saturate(150%); }
.nav-inner { width: min(1280px, 100%); height: 100%; margin: 0 auto; padding: 0 clamp(16px, 4vw, 32px); display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand-heart { width: 32px; height: 32px; display: inline-block; flex: 0 0 auto; color: var(--rose); background: currentColor; mask: url("../assets/icons/heartbeat.svg") center / contain no-repeat; -webkit-mask: url("../assets/icons/heartbeat.svg") center / contain no-repeat; }
.brand-heart-large { width: 40px; height: 40px; }
.brand-copy { display: grid; line-height: 1.08; }
.brand-copy strong { font-size: 19px; letter-spacing: 0; }
.brand-copy strong span, .footer-brand > span > span { color: var(--rose); }
.brand-copy small { color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; }
.desktop-nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.nav-link { min-height: 40px; padding: 9px 11px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: 999px; color: #4b5563; font-size: 13px; font-weight: 700; text-decoration: none; transition: color .2s ease, background .2s ease, transform .2s ease; }
.nav-link:hover { color: var(--rose-dark); background: rgba(255,228,230,.62); }
.nav-link.active { color: var(--rose-dark); background: var(--rose-soft); box-shadow: inset 0 0 0 1px rgba(244,63,94,.08); }
.nav-glyph { display: none; }
.pv-chip { min-width: 74px; padding: 8px 12px; border: 1px solid #bae6fd; border-radius: 999px; color: #0369a1; background: rgba(224,242,254,.86); font-size: 13px; font-weight: 850; text-align: center; text-decoration: none; box-shadow: 0 8px 18px rgba(14,165,233,.1); }

.topbar { width: min(1180px, calc(100% - 32px)); min-height: 68px; margin: 18px auto 0; padding: 11px 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border: 1px solid rgba(255,255,255,.92); border-radius: 18px; background: rgba(255,255,255,.68); box-shadow: 0 12px 34px rgba(15,23,42,.05), inset 0 1px 0 #fff; backdrop-filter: blur(18px) saturate(145%); }
.topbar h1 { margin: 0; font-size: 18px; line-height: 1.2; }
.status-line { color: var(--muted); font-size: 11px; font-weight: 700; }
.status-line.online { color: #059669; }
.local-badge { padding: 5px 9px; border-radius: 999px; color: #047857; background: var(--emerald-soft); font-size: 11px; font-weight: 800; }

#page-root { flex: 1; }
.page { width: min(1180px, 100%); margin: 0 auto; padding: 30px clamp(16px, 4vw, 32px) 72px; }
.page-enter { animation: page-enter .22s ease-out; }
@keyframes page-enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.page-head { position: relative; overflow: hidden; min-height: 150px; margin-bottom: 24px; padding: clamp(24px, 4vw, 36px); display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; border-radius: 24px; color: white; background: linear-gradient(135deg, #111827, #1e40af 56%, #0f766e); box-shadow: 0 20px 48px rgba(15,23,42,.16); }
.page-head::after { position: absolute; inset: 0; content: ""; opacity: .75; background-image: linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px); background-size: 40px 40px; pointer-events: none; }
.page-head > * { position: relative; z-index: 1; }
.page-head h2 { margin: 0 0 5px; font-size: clamp(28px, 4vw, 40px); line-height: 1.08; }
.page-head p { max-width: 660px; margin: 0; color: #dbeafe; }
.actions { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }

.btn { min-height: 46px; padding: 11px 17px; border: 1px solid #d1d5db; border-radius: 999px; color: #374151; background: rgba(255,255,255,.92); box-shadow: 0 7px 18px rgba(15,23,42,.06); font-size: 15px; font-weight: 800; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 7px; transition: transform .18s ease, border-color .18s ease, background .18s ease; }
.btn:hover { transform: translateY(-1px); border-color: #fb7185; color: var(--rose-dark); }
.btn.primary { color: white; border-color: var(--rose); background: var(--rose); box-shadow: 0 10px 24px rgba(244,63,94,.22); }
.btn.primary:hover { color: white; background: var(--rose-dark); }
.btn.danger { color: #b91c1c; border-color: #fecaca; background: #fff7f7; }
.btn.small { min-height: 38px; padding: 7px 13px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.icon-btn { width: 40px; height: 40px; padding: 0; border: 1px solid #e5e7eb; border-radius: 50%; color: #4b5563; background: #f3f4f6; font-size: 22px; }

.grid { display: grid; gap: 16px; }
.metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card, .metric, .panel { border: 1px solid rgba(255,255,255,.94); border-radius: 24px; background: var(--glass); box-shadow: var(--shadow), inset 0 1px 0 #fff; backdrop-filter: blur(16px) saturate(135%); -webkit-backdrop-filter: blur(16px) saturate(135%); }
.metric { position: relative; overflow: hidden; min-height: 132px; padding: 20px; }
.metric::before { position: absolute; inset: 0 auto 0 0; width: 4px; content: ""; background: var(--rose); }
.metric:nth-child(2)::before { background: var(--sky); }
.metric:nth-child(3)::before { background: var(--emerald); }
.metric:nth-child(4)::before { background: var(--indigo); }
.metric .label { color: var(--muted); font-size: 11px; font-weight: 850; letter-spacing: .06em; text-transform: uppercase; }
.metric strong { display: block; margin-top: 12px; color: var(--ink); font-size: clamp(22px, 3vw, 30px); line-height: 1; }
.metric small { display: block; margin-top: 11px; color: var(--muted); }
.panel { padding: clamp(18px, 3vw, 24px); }
.panel h3 { margin: 0 0 15px; color: var(--ink); font-size: 17px; }
.split { grid-template-columns: minmax(0, 1.5fr) minmax(280px, .8fr); margin-top: 16px; }
.stack { display: grid; gap: 12px; }
.record { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 14px; padding: 15px 2px; border-bottom: 1px solid #e5e7eb; }
.record:last-child { border-bottom: 0; }
.record h4, .record p { margin: 0; }
.record h4 { color: var(--ink); }
.record p, .record small { color: var(--muted); }
.amount { font-weight: 850; white-space: nowrap; }
.record-tools { display: grid; justify-items: end; gap: 8px; }
.positive { color: #059669; }
.negative { color: var(--red); }
.warning { color: var(--amber); }
.badge { display: inline-flex; align-items: center; min-height: 26px; padding: 3px 9px; border-radius: 999px; background: #f3f4f6; color: #4b5563; font-size: 11px; font-weight: 850; text-transform: capitalize; }
.badge.good, .badge.baseline { color: #047857; background: var(--emerald-soft); }
.badge.attention, .badge.improve, .badge.follow_up, .badge.limited { color: #92400e; background: #fef3c7; }
.badge.refer, .badge.urgent, .badge.emergency { color: #be123c; background: var(--rose-soft); }
.empty { padding: 38px 20px; color: var(--muted); border: 1px dashed #cbd5e1; border-radius: 18px; background: rgba(248,250,252,.55); text-align: center; }

.toolbar { display: flex; gap: 9px; margin-bottom: 15px; }
.search { flex: 1; }
.toolbar .search { width: 100%; min-height: 44px; padding: 10px 14px; border: 1px solid #d1d5db; border-radius: 999px; color: var(--ink); background: rgba(255,255,255,.9); outline: none; }
.toolbar .search:focus { border-color: var(--sky); box-shadow: 0 0 0 3px rgba(14,165,233,.12); }
.field { display: grid; gap: 6px; }
.field label, .field-label { color: #374151; font-size: 13px; font-weight: 800; }
.field input, .field select, .field textarea { width: 100%; min-height: 48px; padding: 11px 13px; border: 1px solid #d1d5db; border-radius: 12px; color: var(--ink); background: rgba(255,255,255,.94); outline: none; }
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--sky); box-shadow: 0 0 0 3px rgba(14,165,233,.12); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 15px; }
.form-grid .wide { grid-column: 1 / -1; }
.check-row { min-height: 42px; display: flex; align-items: flex-start; gap: 9px; padding: 9px 0; }
.check-row input { width: 18px; height: 18px; accent-color: var(--rose); flex: none; }
.notice { padding: 14px 15px; border: 1px solid #bae6fd; border-left: 4px solid var(--sky); border-radius: 14px; color: #075985; background: rgba(224,242,254,.84); }
.notice.warning { border-color: #fde68a; border-left-color: #f59e0b; color: #92400e; background: rgba(255,251,235,.9); }
.notice.danger { border-color: #fecdd3; border-left-color: var(--rose); color: #9f1239; background: rgba(255,241,242,.92); }
.progress { height: 9px; overflow: hidden; border-radius: 999px; background: #e5e7eb; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--emerald), var(--sky), var(--indigo)); }
.steps { display: grid; grid-template-columns: repeat(5, 1fr); margin: 0 0 18px; padding: 8px; border: 1px solid rgba(255,255,255,.92); border-radius: 999px; background: rgba(255,255,255,.74); box-shadow: 0 12px 34px rgba(15,23,42,.06); backdrop-filter: blur(18px); }
.step { padding: 9px 7px; border-radius: 999px; color: var(--muted); font-size: 11px; font-weight: 850; text-align: center; }
.step.active { color: white; background: linear-gradient(135deg, var(--rose), var(--indigo)); }
.result-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.result-card { min-height: 132px; padding: 16px; border: 1px solid rgba(255,255,255,.95); border-radius: 18px; background: rgba(255,255,255,.72); box-shadow: 0 8px 24px rgba(15,23,42,.05), inset 0 1px 0 #fff; }
.result-card h4 { margin: 8px 0 4px; }
.result-card p { margin: 0; color: var(--muted); font-size: 13px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 18px; background: rgba(15,23,42,.6); backdrop-filter: blur(10px); }
.modal { width: min(620px, 100%); max-height: min(88vh, 820px); overflow: auto; padding: 24px; border: 1px solid rgba(255,255,255,.88); border-radius: 28px; background: rgba(255,255,255,.96); box-shadow: 0 30px 90px rgba(15,23,42,.3); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 19px; }
.modal-head h2 { margin: 0; font-size: 22px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }
#toast-root { position: fixed; right: 18px; bottom: 22px; z-index: 80; display: grid; gap: 8px; }
.toast { max-width: 360px; padding: 13px 16px; border-radius: 16px; color: white; background: #111827; box-shadow: 0 12px 32px rgba(17,24,39,.24); }
.toast.error { background: #be123c; }

.site-footer { margin-top: auto; padding: 60px 0 30px; border-top: 1px solid #e5e7eb; background: rgba(243,244,246,.9); backdrop-filter: blur(16px); }
.footer-inner { width: min(1180px, 100%); margin: 0 auto; padding: 0 clamp(16px, 4vw, 32px); }
.footer-grid { display: grid; grid-template-columns: 1fr; align-items: start; gap: 32px; margin-bottom: 38px; }
.footer-brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: 24px; font-weight: 850; }
.footer-links { display: grid; gap: 9px; }
.footer-links a { color: #4b5563; font-weight: 700; text-decoration: none; }
.footer-links a:hover { color: var(--rose-dark); }
.footer-contact { min-width: 220px; padding: 15px 18px; display: flex; align-items: center; gap: 13px; border: 1px solid #e5e7eb; border-radius: 18px; background: white; box-shadow: 0 8px 22px rgba(15,23,42,.05); text-decoration: none; }
.contact-mark { width: 38px; height: 38px; display: block; flex: 0 0 38px; color: var(--sky); background: currentColor; mask: url("../assets/icons/phone-call.svg") center / contain no-repeat; -webkit-mask: url("../assets/icons/phone-call.svg") center / contain no-repeat; }
.footer-contact small { display: block; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.footer-contact strong { display: block; color: var(--ink); font-size: 19px; }
.footer-legal { padding-top: 28px; border-top: 1px solid #d1d5db; color: var(--muted); text-align: center; }
.footer-legal p { max-width: 820px; margin: 0 auto 10px; }
.footer-legal p:nth-child(2) { font-size: 13px; line-height: 1.65; }
.footer-legal p:last-child { margin-top: 14px; color: #9ca3af; font-size: 11px; }
.bottom-nav { display: none; }
.more-workspace { margin-bottom: 16px; }
.more-grid { margin-top: 0; }
.screen-only { display: initial; }

@media (max-width: 980px) {
  .desktop-nav { gap: 0; }
  .desktop-nav .nav-link { padding-inline: 8px; }
  .metrics { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .split { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  body { padding-bottom: 84px; font-size: 17px; line-height: 1.58; }
  .site-nav { height: 60px; }
  .desktop-nav { display: none; }
  .nav-inner { justify-content: space-between; }
  .brand-copy strong { font-size: 18px; }
  .pv-chip { margin-left: auto; }
  .topbar { width: calc(100% - 24px); min-height: 60px; margin-top: 12px; padding: 9px 14px; border-radius: 16px; }
  .topbar h1 { font-size: 18px; }
  .status-line, .local-badge { font-size: 12px; }
  .page { padding: 20px 14px 64px; }
  .page-head { min-height: 144px; align-items: stretch; flex-direction: column; justify-content: flex-end; border-radius: 22px; }
  .page-head .actions { width: 100%; }
  .page-head p { font-size: 16px; line-height: 1.55; }
  .page-head .btn { flex: 1; min-height: 50px; }
  .btn { min-height: 50px; padding: 12px 18px; font-size: 16px; }
  .btn.small { min-height: 44px; padding: 9px 14px; font-size: 14px; }
  .panel { padding: 20px; }
  .panel h3 { font-size: 19px; }
  .record { min-height: 68px; padding: 17px 2px; }
  .record h4 { font-size: 17px; }
  .record p, .record small { font-size: 14px; line-height: 1.5; }
  .bottom-nav { position: fixed; inset: auto 0 0; z-index: 50; display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); padding: 7px 10px max(8px, env(safe-area-inset-bottom)); border-top: 1px solid rgba(255,255,255,.8); background: rgba(255,255,255,.94); box-shadow: 0 -10px 32px rgba(15,23,42,.08); backdrop-filter: blur(20px) saturate(150%); }
  .bottom-nav .nav-link { min-width: 0; min-height: 62px; padding: 6px 4px; display: grid; gap: 2px; justify-items: center; align-content: center; border-radius: 16px; font-size: 12px; line-height: 1; }
  .bottom-nav .nav-link.active { color: var(--rose-dark); background: var(--rose-soft); }
  .bottom-nav .nav-glyph { display: block; min-height: 25px; color: var(--rose); font-size: 23px; line-height: 1; font-weight: 900; letter-spacing: .04em; }
  .site-footer { padding-bottom: 36px; }
  .footer-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .page-head h2 { font-size: 30px; }
  .metrics, .form-grid, .result-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .steps { grid-template-columns: repeat(5, minmax(88px,1fr)); overflow-x: auto; border-radius: 18px; }
  .record { align-items: start; }
  .record-tools { justify-items: end; }
  .record-tools .actions { justify-content: flex-end; }
  .modal { padding: 20px; border-radius: 22px; }
  .modal-actions .btn { flex: 1; }
  .toolbar .search { min-height: 50px; font-size: 16px; }
  .metric .label { font-size: 12px; }
  .metric strong { font-size: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

@media print {
  @page { margin: 14mm; }
  body { padding: 0; background: white; }
  .site-nav, .topbar, .bottom-nav, .actions, .screen-only { display: none !important; }
  .app-shell, .shell-main { display: block; min-height: 0; }
  .page { width: 100%; padding: 0 0 24px; }
  .page-head { min-height: auto; padding: 18px; color: #111827; border: 1px solid #d1d5db; background: white; box-shadow: none; }
  .page-head::after { display: none; }
  .page-head p { color: #4b5563; }
  .card, .panel, .metric, .result-card { background: white; box-shadow: none; backdrop-filter: none; border-color: #d1d5db; break-inside: avoid; }
  .site-footer { display: block; margin-top: 18px; padding: 24px 0 0; background: white; break-inside: avoid; }
  .footer-inner { width: 100%; padding: 0; }
  .footer-grid { margin-bottom: 18px; grid-template-columns: 1fr auto; }
  .footer-links, .footer-contact { display: none; }
  .footer-legal { padding-top: 16px; text-align: left; }
  .footer-legal p { max-width: none; }
}
