:root {
  --bg: #FFF9F0; --pri: #0B6152; --pri-d: #084A3E; --teal: #4E9A94; --sage: #7D9B76; --terra: #D08C60; --ink: #2E2A26;
  --muted: #6E665E; --card: #fff; --line: #EFE5D6; --soft: #EAF3F1; --sage-soft: #EEF3EC; --terra-soft: #FBEDE2;
  --ok: #2F7D4F; --bad: #B83A2E; --warn: #8A5A12;
  --r: 20px; --sh: 0 1px 2px rgba(46,42,38,.05), 0 8px 24px rgba(46,42,38,.06);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 'Plus Jakarta Sans', system-ui, sans-serif; overflow-x: hidden; }
input, select, textarea, button { font: inherit; color: inherit; }
a { color: var(--pri); }
h1, h2, h3, .brand, .hero-h { font-family: Poppins, 'Plus Jakarta Sans', sans-serif; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; font-weight: 600; margin: 1.5rem 0 .75rem; line-height: 1.3; }
h3 { font-size: 1rem; font-weight: 600; margin: 0 0 .75rem; }
.m0 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.r { text-align: right; }
.ok { color: var(--ok); font-weight: 700; }
.bad { color: var(--bad); }
.svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- kerangka ---------- */
#app main { padding: 0 16px 108px; max-width: 880px; margin: 0 auto; }
.topbar { position: sticky; top: 0; z-index: 5; background: var(--bg); display: flex; align-items: center; gap: 8px; padding: 12px 0 8px; }
.topbar h1 { font-size: 1.25rem; font-weight: 600; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { min-width: 44px; min-height: 44px; border: 0; border-radius: 14px; background: #fff; box-shadow: var(--sh); color: var(--pri); font-size: 1.6rem; line-height: 1; cursor: pointer; }
body[data-route="dashboard"] .topbar { display: none; }

.brand { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--pri); font-weight: 700; font-size: 1.3rem; }
.brand img { border-radius: 12px; }

.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(255,255,255,.96); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); border-radius: 22px 22px 0 0; }
.nav .brand, .nav .more { display: none; }
.nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 64px;
  color: #9A9088; text-decoration: none; font-size: .72rem; font-weight: 600; }
.nav a.active { color: var(--pri); }
.nav a.active .svg { stroke-width: 2.2; }

@media (min-width: 960px) {
  #app { padding-left: 240px; }
  #app main { padding-bottom: 40px; }
  .nav { top: 0; right: auto; width: 240px; display: flex; flex-direction: column; gap: 2px; padding: 20px 14px; border: 0; border-right: 1px solid var(--line); border-radius: 0; overflow-y: auto; }
  .nav .brand { display: flex; justify-content: flex-start; margin: 0 8px 18px; }
  .nav .more { display: flex; }
  .nav .mobile { display: none; }
  .nav a { flex-direction: row; justify-content: flex-start; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 12px; font-size: .92rem; color: var(--muted); }
  .nav a.active { background: var(--soft); color: var(--pri); }
}

/* ---------- komponen ---------- */
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--sh); padding: 16px; margin-bottom: 12px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 14px;
  border: 1px solid var(--line); background: #fff; color: var(--ink); font-weight: 700; font-size: .95rem; text-decoration: none; cursor: pointer; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--pri); border-color: var(--pri); color: #fff; }
.btn-wa { background: #1E8E50; border-color: #1E8E50; color: #fff; }
.btn-danger { color: var(--bad); border-color: #F1CFC9; }
.btn-sm { padding: 0 12px; font-size: .875rem; }
.btn-big { width: 100%; min-height: 54px; font-size: 1.02rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .92rem; min-width: 0; }
input, select, textarea { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid #E2D6C4; border-radius: 12px; background: #fff; font-size: 16px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--teal); outline-offset: 1px; border-color: var(--pri); }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; }
.check input { width: 22px; height: 22px; min-height: 0; accent-color: var(--pri); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 420px) { .grid3 { grid-template-columns: 1fr 1fr; } }
fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
legend { font-family: Poppins, sans-serif; font-weight: 600; padding: 0; margin-bottom: 8px; }

.toolbar { display: flex; gap: 8px; margin-bottom: 12px; }
.toolbar input, .toolbar select { flex: 1; min-width: 0; }
.list { display: flex; flex-direction: column; gap: 8px; }
.row { display: block; background: #fff; border-radius: 16px; box-shadow: var(--sh); padding: 12px 14px; color: inherit; text-decoration: none; }
.row-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.row-top b { min-width: 0; overflow-wrap: anywhere; }
.row-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 4px; font-size: .85rem; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 20px 8px; }
.note { background: var(--terra-soft); border-left: 3px solid var(--terra); padding: 8px 12px; border-radius: 8px; margin: 8px 0; white-space: pre-wrap; }
.alergi { background: #FDE8E4; color: #8E2A1F; border: 1px solid #F3C2B9; padding: 10px 12px; border-radius: 12px; font-weight: 700; margin: 8px 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.section-head h2 { margin-bottom: .6rem; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .72rem; font-weight: 700; white-space: nowrap; background: #EEE9E2; color: #5A524A; }
.b-teal { background: var(--soft); color: var(--pri-d); }
.b-sage { background: var(--sage-soft); color: #4B6545; }
.b-terra { background: var(--terra-soft); color: #9A5A30; }
.b-ok { background: #E3F2E8; color: var(--ok); }
.b-bad { background: #FBE3DF; color: var(--bad); }
.b-warn { background: #FFF1D6; color: var(--warn); }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; overflow-x: auto; scrollbar-width: none; }
.tab { flex: none; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-weight: 600; font-size: .85rem; cursor: pointer; }
.tab.active { background: var(--pri); border-color: var(--pri); color: #fff; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 8px 0 0; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .875rem; }
.tbl th, .tbl td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { font-size: .7rem; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
.tbl .r { text-align: right; white-space: nowrap; }

.pay { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; }
.pay b { text-align: right; }
.pay .big { font-size: 1.25rem; color: var(--pri); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; padding-left: 14px; border-radius: 999px; background: var(--soft); font-weight: 600; font-size: .9rem; }
.chip button { min-width: 44px; min-height: 44px; border: 0; background: none; color: var(--pri); font-size: 1.2rem; cursor: pointer; }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { min-height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-size: .82rem; font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--pri); border-color: var(--pri); color: #fff; }

/* ---------- dashboard (mengikuti gaya kartu besar & ikon lembut) ---------- */
.hero { position: relative; overflow: hidden; margin: 0 -16px; padding: 20px 16px 18px; background: linear-gradient(180deg, #EAF3F1, var(--bg)); }
.hero-top { display: flex; justify-content: space-between; align-items: center; }
.hero-top a { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: #fff; box-shadow: var(--sh); color: var(--ink); }
.hero-body { display: grid; grid-template-columns: 1fr 120px; align-items: center; gap: 8px; margin-top: 10px; }
.hero-body p { margin: 0; color: var(--muted); }
.hero-h { margin: 2px 0 0; font-size: clamp(1.5rem, 6.5vw, 2rem); font-weight: 700; line-height: 1.18; }
.hero-h span { color: var(--pri); }
.hero-art { width: 120px; height: 120px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, #CFE4E0); display: grid; place-items: center; }
.hero-art svg { width: 64px; height: 64px; fill: var(--pri); }
.search { display: flex; gap: 8px; margin-top: 16px; }
.search label { flex: 1; display: flex; align-items: center; gap: 8px; padding: 0 14px; background: #fff; border-radius: 999px; box-shadow: var(--sh); color: var(--muted); }
.search input { border: 0; min-height: 50px; padding: 0; background: none; }
.search input:focus { outline: 0; }
.search label:focus-within { outline: 2px solid var(--teal); }

.banner { position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; margin: 14px 0 0; padding: 18px; border-radius: 22px;
  background: linear-gradient(135deg, #0B6152, #7FAA84); color: #fff; text-decoration: none; }
.banner b { font-family: Poppins, sans-serif; font-size: 1.15rem; font-weight: 600; }
.banner small { opacity: .9; max-width: 62%; }
.banner span.btn { margin-top: 10px; min-height: 40px; background: #fff; border: 0; color: var(--pri); }
.banner::after { content: ''; position: absolute; right: -30px; bottom: -40px; width: 160px; height: 160px; border-radius: 50%; background: rgba(255,255,255,.14); }
.banner .svg { position: absolute; right: 22px; top: 22px; width: 64px; height: 64px; stroke-width: 1.3; opacity: .95; }

.services { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.svc { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 12px 4px; border-radius: 18px; background: #fff; box-shadow: var(--sh);
  color: var(--ink); text-decoration: none; font-size: .78rem; font-weight: 700; line-height: 1.2; min-height: 104px; }
.svc i { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: var(--soft); color: var(--pri); }
.svc:nth-child(2) i { background: var(--terra-soft); color: #A5603A; }
.svc:nth-child(3) i { background: var(--sage-soft); color: #4B6545; }
.svc:nth-child(4) i { background: #F2EEF8; color: #6B5A93; }
.svc small { font-weight: 500; color: var(--muted); font-size: .68rem; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { display: flex; flex-direction: column; padding: 12px 14px; border-radius: 18px; background: #fff; box-shadow: var(--sh); text-decoration: none; color: var(--ink); min-width: 0; }
.stat span { font-size: .78rem; color: var(--muted); }
.stat b { font-family: Poppins, sans-serif; font-size: clamp(1.05rem, 4.8vw, 1.35rem); font-weight: 600; overflow-wrap: anywhere; }
.stat.wide { grid-column: span 2; background: var(--pri); color: #fff; }
.stat.wide span { color: rgba(255,255,255,.85); }

.alert { display: flex; gap: 10px; align-items: center; }
.alert i { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--terra); }
.alert.hot i { background: var(--bad); }

/* ---------- kunjungan & antrean ---------- */
.q { display: grid; grid-template-columns: 52px 1fr; gap: 12px; align-items: start; }
.q-n { display: grid; place-items: center; height: 52px; border-radius: 16px; background: var(--soft); color: var(--pri); font-family: Poppins, sans-serif; font-weight: 700; font-size: 1.2rem; }
.q-n.on { background: var(--pri); color: #fff; }
.q-n.done { background: #EEE9E2; color: #8A8178; }
.pick-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.pick { min-height: 48px; padding: 8px 12px; text-align: left; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; }
.picked { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 14px; background: var(--soft); }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .85rem; }
.or::before, .or::after { content: ''; flex: 1; border-top: 1px solid var(--line); }

/* rekam medis */
.rows { display: flex; flex-direction: column; gap: 8px; }
.rx { display: grid; grid-template-columns: 1fr 1fr 44px; gap: 6px; padding: 10px; border: 1px solid var(--line); border-radius: 14px; }
.rx .full { grid-column: 1 / 3; }
.rx button { grid-row: 1; grid-column: 3; }
.tx { display: grid; grid-template-columns: 1fr 44px; gap: 6px; }

/* garis waktu pasien */
.tl { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--line); }
.tl li { position: relative; margin: 0 0 12px; }
.tl li::before { content: ''; position: absolute; left: -25px; top: 16px; width: 12px; height: 12px; border-radius: 50%; background: var(--teal); border: 2px solid var(--bg); }
.tl li.t-order::before { background: var(--terra); }
.tl li.t-inap::before { background: var(--sage); }
.tl li.t-ingat::before { background: #9B86C9; }
.tl .row { box-shadow: none; border: 1px solid var(--line); }

/* order */
.oi { padding: 12px 0; border-bottom: 1px solid var(--line); }
.oi:last-child { border-bottom: 0; }
.oi-top { display: flex; justify-content: space-between; gap: 8px; }
.oi-num { display: grid; grid-template-columns: 70px 1fr 1fr 44px; gap: 6px; margin-top: 8px; align-items: end; }
.oi-num .field { font-size: .75rem; font-weight: 600; color: var(--muted); }
.oi-num input { min-height: 40px; padding: 6px 8px; }
.oi-work { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.oi-work select { width: auto; min-height: 38px; padding: 4px 8px; font-size: .85rem; }
.add-item { display: grid; grid-template-columns: 1fr 80px; gap: 8px; }
.add-item .btn { grid-column: 1 / -1; }
.total-line { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; padding-top: 10px; border-top: 2px solid var(--line); }
.total-line b { font-family: Poppins, sans-serif; font-size: 1.3rem; color: var(--pri); }

.stepper { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; list-style: none; padding: 0; margin: 0; }
.stepper li { text-align: center; padding: 8px 4px; border-radius: 12px; background: #F4EFE7; font-size: .82rem; font-weight: 600; color: var(--muted); }
.stepper li.done { background: var(--soft); color: var(--pri); }
.stepper li.now { background: var(--pri); color: #fff; }

/* menu */
.menu { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.menu a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 96px; padding: 10px 6px; border-radius: 18px;
  background: #fff; box-shadow: var(--sh); text-decoration: none; color: var(--ink); font-size: .8rem; font-weight: 700; text-align: center; }
.menu a .svg { color: var(--pri); width: 26px; height: 26px; }

/* ---------- invoice / dokumen ---------- */
.inv-head { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 10px; margin-bottom: 12px; border-bottom: 2px solid #0B6152; }
.inv-head h2 { margin: 0; color: #0B6152; }
.inv-head h3 { margin: 0; color: #D08C60; letter-spacing: .12em; }
.inv-head p { margin: 4px 0 0; font-size: .85rem; }
.inv-head img { max-height: 48px; max-width: 120px; display: block; margin-bottom: 6px; }
.inv-pay { max-width: 320px; margin: 12px 0 0 auto; }
.ttd { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 32px; text-align: center; font-size: .9rem; }
.ttd div { padding-top: 64px; border-bottom: 1px solid #2E2A26; }
.doc h3 { margin: 16px 0 4px; }
.doc p { margin: 0 0 6px; white-space: pre-wrap; }

/* lembar kwitansi untuk html2canvas: di luar layar, hanya warna hex */
.sheet-stage { position: fixed; left: -10000px; top: 0; }
.sheet { width: 760px; padding: 36px; background: #ffffff; color: #2E2A26; font-size: 15px; }
.sheet .tbl th, .sheet .tbl td { border-bottom: 1px solid #EFE5D6; }
.sheet .tbl th { color: #6E665E; }
.sheet .ok { color: #2F7D4F; }
.sheet-struk { width: 384px; padding: 16px; background: #ffffff; color: #000000; font-size: 18px; line-height: 1.35; }
.sheet-struk[data-lebar="80"] { width: 576px; }

.modal { position: fixed; inset: 0; z-index: 30; background: rgba(46,42,38,.55); display: grid; place-items: center; padding: 16px; }
.modal-box { background: #fff; border-radius: 20px; padding: 16px; max-width: 520px; width: 100%; max-height: 92vh; overflow: auto; }
.modal-box img { width: 100%; margin-top: 10px; border: 1px solid var(--line); border-radius: 8px; }

/* ---------- login & toast ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(180deg, #EAF3F1, var(--bg)); }
.login form { width: 100%; max-width: 380px; }
#login-msg:empty { display: none; }
#toast { position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%); z-index: 40; max-width: 90vw; padding: 10px 18px; border-radius: 12px;
  background: var(--ink); color: #fff; text-align: center; opacity: 0; pointer-events: none; transition: opacity .15s; }
#toast.show { opacity: 1; }

.install { position: fixed; left: 12px; right: 12px; bottom: calc(78px + env(safe-area-inset-bottom)); z-index: 15; display: flex; align-items: center; gap: 10px;
  padding: 10px 6px 10px 12px; border-radius: 18px; background: #fff; box-shadow: 0 10px 30px rgba(46,42,38,.2); border: 1px solid var(--line); }
.install img { border-radius: 12px; flex: none; }
.install div { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.install small { color: var(--muted); font-size: .8rem; }
.install-x { min-width: 44px; min-height: 44px; border: 0; background: none; color: var(--muted); font-size: 1.4rem; cursor: pointer; }
#app[hidden] ~ .install { bottom: 16px; }
@media (min-width: 960px) { .install { left: auto; right: 20px; bottom: 20px; width: 380px; } }

/* ---------- struk printer termal: hitam saja, area cetak 48 mm (kertas 58) / 72 mm (kertas 80) ---------- */
#struk { position: absolute; left: -10000px; top: 0; width: 48mm; padding: 2mm 0; background: #fff; color: #000; font-size: 9pt; line-height: 1.35; }
#struk[data-lebar="80"] { width: 72mm; font-size: 10.5pt; }
.s-c { text-align: center; }
.s-b { font-weight: 800; }
.s-big { font-size: 1.25em; }
.s-row { display: flex; justify-content: space-between; gap: 2mm; }
.s-row span:last-child { text-align: right; }
.s-hr { border-top: 1px dashed #000; margin: 1.5mm 0; }

@media print {
  body.struk-mode { background: #fff; }
  body.struk-mode > :not(#struk) { display: none !important; }
  body.struk-mode #struk { position: static; margin: 0 auto; }
}
@media print {
  @page { size: A5; margin: 10mm; }
  body { background: #fff; font-size: 10.5pt; }
  .nav, .topbar, .no-print, #toast, .install { display: none !important; }
  #app { padding: 0 !important; }
  #app main { padding: 0; max-width: none; }
  .card { box-shadow: none; padding: 0; margin: 0; }
  .tbl-wrap { overflow: visible; }
}
