:root {
  --bg: #F7F3EC; --card: #FFFFFF; --ink: #1E2A26; --muted: #6B756F; --line: #E7E1D6;
  --pri: #2F5D50; --pri-2: #3F7A69; --pri-soft: #E4EDE7; --acc: #E2A04A; --acc-soft: #FBEBD3;
  --warn: #C2533F; --warn-soft: #F8E1DC; --ok: #3E8A5B;
  --r: 18px; --r-sm: 12px; --shadow: 0 1px 2px rgba(30,42,38,.06), 0 6px 18px rgba(30,42,38,.06);
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink); background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { min-height: 100vh; font-size: 16px; line-height: 1.45; }
body.noscroll { overflow: hidden; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.55rem; letter-spacing: -.01em; }
h2 { font-size: 1.25rem; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: .87rem; }
.center { text-align: center; }
[hidden] { display: none !important; }

/* ---------- tombol ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .8rem 1.1rem; border-radius: 999px; font-weight: 600; text-decoration: none; min-height: 46px; transition: transform .08s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--pri); color: #fff; }
.btn.soft { background: var(--pri-soft); color: var(--pri); }
.btn.ghost { background: transparent; color: var(--pri); }
.btn.danger { color: var(--warn); }
.btn.sm { padding: .5rem .9rem; min-height: 38px; font-size: .92rem; }
.btn.block { display: flex; width: 100%; margin-top: .6rem; }
.btn.grow { flex: 1; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; font-size: 1.2rem; }

/* ---------- layout ---------- */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; padding: .6rem 1rem; padding-top: max(.6rem, env(safe-area-inset-top)); background: rgba(247,243,236,.92); backdrop-filter: blur(10px); }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--pri); }
.brand img { border-radius: 8px; }
.view { max-width: 620px; margin: 0 auto; padding: .4rem 1rem calc(96px + var(--safe-b)); }
.nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: grid; grid-template-columns: repeat(5, 1fr); background: #fff; border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.nav button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .5rem 0 .55rem; font-size: .72rem; color: var(--muted); font-weight: 600; }
.nav button span { font-size: 1.25rem; filter: grayscale(1) opacity(.6); transition: filter .15s; }
.nav button.on { color: var(--pri); }
.nav button.on span { filter: none; }
.head-row { display: flex; align-items: center; justify-content: space-between; margin: .5rem 0 .6rem; }
.sec { margin: 1.3rem 0 .5rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.sec small { font-weight: 400; }
.sec.warn { color: var(--warn); }
.card { background: var(--card); border-radius: var(--r); padding: 1rem; box-shadow: var(--shadow); margin: .8rem 0; }
.card h3 { margin-bottom: .5rem; font-size: 1rem; }
.row-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .9rem; }
.row-actions .btn { flex: 1 1 auto; }

/* ---------- hari ini ---------- */
.hello { margin: .4rem 0 .2rem; }
.datenav { display: flex; align-items: center; gap: .4rem; }
.datenav > button:not(.chip) { width: 34px; height: 34px; border-radius: 50%; background: #fff; box-shadow: var(--shadow); font-size: 1.2rem; color: var(--pri); }
.progress-card { display: flex; align-items: center; gap: 1rem; }
.progress-card p { margin: .2rem 0 0; }
.ring { --p: 0; flex: none; width: 70px; height: 70px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--pri) calc(var(--p) * 1%), var(--pri-soft) 0); }
.ring span { width: 54px; height: 54px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-weight: 700; font-size: .95rem; }
.banner { display: flex; align-items: center; gap: .8rem; width: 100%; text-align: left; background: var(--acc-soft); border-radius: var(--r); padding: .8rem 1rem; margin: .6rem 0; }
.banner > span:first-child { font-size: 1.5rem; }
.banner b { display: block; }
.banner small { color: var(--muted); }
.banner.alt { background: var(--pri-soft); }

.chips { display: flex; gap: .4rem; overflow-x: auto; padding: .3rem 0; scrollbar-width: none; flex-wrap: nowrap; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: .45rem .9rem; border-radius: 999px; background: #fff; border: 1px solid var(--line); font-size: .9rem; font-weight: 600; white-space: nowrap; }
.chip.on { background: var(--pri); color: #fff; border-color: var(--pri); }

.tasks { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.task { display: flex; align-items: stretch; background: var(--card); border-radius: var(--r-sm); box-shadow: var(--shadow); overflow: hidden; }
.task .check { flex: none; width: 54px; display: grid; place-items: center; font-weight: 800; color: #fff; position: relative; }
.task .check::before { content: ""; position: absolute; width: 28px; height: 28px; border-radius: 9px; border: 2.5px solid #C9C2B4; transition: all .15s; }
.task.done .check::before { background: var(--ok); border-color: var(--ok); }
.task .check { isolation: isolate; font-size: 1.05rem; }
.task .check::before { z-index: -1; }
.task .task-body { flex: 1; display: flex; align-items: center; gap: .7rem; padding: .75rem .9rem .75rem 0; text-align: left; min-width: 0; }
.tasks.plain .task-body { padding-left: .9rem; }
.ic { flex: none; width: 40px; height: 40px; border-radius: 12px; background: var(--pri-soft); display: grid; place-items: center; font-size: 1.3rem; }
.ic.xl { width: 58px; height: 58px; font-size: 1.9rem; border-radius: 16px; }
.tt { min-width: 0; flex: 1; }
.tt b { display: block; font-weight: 600; }
.tt small { color: var(--muted); font-size: .82rem; }
.task.done .tt b { text-decoration: line-through; color: var(--muted); }
.task.paused { opacity: .5; }
.next { flex: none; font-size: .78rem; color: var(--pri); font-weight: 600; }
.empty { text-align: center; padding: 2.2rem 1rem; color: var(--muted); }
.empty > div { font-size: 2.4rem; }
.stock-alert { display: flex; align-items: center; gap: .8rem; width: 100%; text-align: left; }
.stock-alert > span:nth-child(2) { flex: 1; } .stock-alert b { display: block; } .stock-alert small { color: var(--muted); }

/* ---------- segmen ---------- */
.seg { display: flex; background: #ECE6DA; border-radius: 999px; padding: 3px; margin: .4rem 0; }
.seg button { flex: 1; padding: .5rem .6rem; border-radius: 999px; font-size: .88rem; font-weight: 600; color: var(--muted); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.seg.wrap { flex-wrap: wrap; border-radius: 16px; }
.seg.wrap button { flex: 1 0 30%; }

/* ---------- stok ---------- */
.stock-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; }
.stock { display: flex; flex-direction: column; align-items: flex-start; gap: .35rem; background: #fff; border-radius: var(--r-sm); padding: .75rem; text-align: left; box-shadow: var(--shadow); border: 2px solid transparent; font-weight: 600; min-height: 74px; }
.stock.tipis { border-color: var(--acc); }
.stock.habis { border-color: var(--warn); background: var(--warn-soft); }
.pill { display: inline-block; font-size: .72rem; padding: .15rem .55rem; border-radius: 999px; font-weight: 700; }
.pill.ada { background: var(--pri-soft); color: var(--pri); }
.pill.tipis { background: var(--acc-soft); color: #9A6418; }
.pill.habis { background: var(--warn); color: #fff; }
.sticky-actions { position: sticky; bottom: calc(64px + var(--safe-b)); display: flex; gap: .4rem; padding: .7rem 0; margin-top: .8rem; background: linear-gradient(transparent, var(--bg) 30%); }
.sticky-actions .btn { flex: 1 1 auto; padding-inline: .7rem; font-size: .9rem; box-shadow: var(--shadow); white-space: nowrap; }
.sticky-actions .btn.primary { flex: 2 1 auto; }

/* ---------- SOP ---------- */
.sop-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; margin: .8rem 0; }
.sop-card { background: #fff; border-radius: var(--r); padding: 1rem; display: flex; flex-direction: column; align-items: flex-start; gap: .4rem; text-align: left; box-shadow: var(--shadow); }
.sop-card small { color: var(--muted); }
.steps { padding-left: 1.3rem; margin: .6rem 0; }
.steps li { margin: .35rem 0; }
.steps.big li { margin: .6rem 0; font-size: 1.02rem; }
.note { background: var(--acc-soft); padding: .7rem .9rem; border-radius: var(--r-sm); margin: .6rem 0; }
.soft-card { background: var(--pri-soft); box-shadow: none; }

/* ---------- cetak ---------- */
.print-card { display: flex; gap: .8rem; background: #fff; border-radius: var(--r); padding: 1rem; margin: .6rem 0; box-shadow: var(--shadow); }
.print-card > div { flex: 1; min-width: 0; }
.print-card b { display: block; } .print-card small { color: var(--muted); display: block; margin-top: .15rem; }
.pc-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; align-items: center; }
.pc-actions select { padding: .45rem .6rem; border-radius: 10px; border: 1px solid var(--line); background: #fff; max-width: 150px; }

/* ---------- pengaturan ---------- */
.people { list-style: none; padding: 0; margin: 0 0 .6rem; }
.people li { display: flex; justify-content: space-between; align-items: center; padding: .4rem 0; border-bottom: 1px solid var(--line); }

/* ---------- sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet-bg { position: absolute; inset: 0; background: rgba(20,28,25,.45); animation: fade .2s; }
.sheet-card { position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow: auto; background: var(--bg); border-radius: 24px 24px 0 0; padding: .6rem 1.1rem calc(1.2rem + var(--safe-b)); animation: up .25s cubic-bezier(.2,.8,.2,1); max-width: 620px; margin: 0 auto; }
.grab { width: 44px; height: 5px; border-radius: 9px; background: #D3CCBE; margin: 0 auto .8rem; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.detail-head { display: flex; gap: .9rem; align-items: flex-start; margin-bottom: .4rem; }
.detail-head p { margin: .25rem 0 0; }
.field { display: block; margin: .8rem 0; }
.field > span { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: .3rem; }
.field input, .field select, .field textarea { width: 100%; padding: .75rem .85rem; border-radius: var(--r-sm); border: 1.5px solid var(--line); background: #fff; font-size: 16px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--pri); }
.field.inset { margin-left: 3.4rem; margin-top: .2rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.grid2 .field { margin: .4rem 0; }
.icon-pick { display: flex; gap: .35rem; overflow-x: auto; padding: .3rem 0 .5rem; scrollbar-width: none; }
.icon-pick button { flex: none; width: 44px; height: 44px; border-radius: 12px; background: #fff; font-size: 1.35rem; border: 2px solid transparent; }
.icon-pick button.on { border-color: var(--pri); background: var(--pri-soft); }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: .3rem; }
.days button { padding: .6rem 0; border-radius: 10px; background: #fff; font-weight: 600; font-size: .85rem; border: 1.5px solid var(--line); }
.days button.on { background: var(--pri); color: #fff; border-color: var(--pri); }

/* ---------- toggle ---------- */
.toggle-row { display: flex; align-items: center; gap: .8rem; margin: .9rem 0 .3rem; font-weight: 600; }
.switch { position: relative; flex: none; width: 50px; height: 30px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; background: #D3CCBE; border-radius: 99px; transition: .2s; }
.switch i::after { content: ""; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + i { background: var(--pri); }
.switch input:checked + i::after { transform: translateX(20px); }

/* ---------- onboarding ---------- */
.onboarding { min-height: 100vh; display: flex; justify-content: center; padding: max(1.2rem, env(safe-area-inset-top)) 1rem calc(1.5rem + var(--safe-b)); background: linear-gradient(180deg, #EAF1EC 0%, var(--bg) 45%); }
.ob-card { width: 100%; max-width: 520px; position: relative; }
.ob-card h2 { font-size: 1.45rem; margin: .4rem 0 .3rem; }
.ob-back { position: absolute; left: -.3rem; top: -.2rem; font-size: 1.8rem; width: 40px; height: 40px; color: var(--pri); }
.ob-dots { display: flex; justify-content: center; gap: 6px; margin: .3rem 0 1rem; }
.ob-dots i { width: 7px; height: 7px; border-radius: 9px; background: #CFC8BA; transition: .2s; }
.ob-dots i.on { width: 22px; background: var(--pri); }
.ob-hero h1 { font-size: 2rem; line-height: 1.12; margin: 1rem 0 .8rem; letter-spacing: -.02em; }
.ob-hero h1 em { font-style: normal; color: var(--warn); }
.ob-hero p { font-size: 1.04rem; color: #3C4843; }
.ob-strong { font-weight: 600; color: var(--pri) !important; }
.ob-tabs { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .4rem; }
.ob-tabs span { font-size: .78rem; padding: .3rem .6rem; background: #fff; border: 1px solid var(--line); border-radius: 8px 8px 2px 2px; box-shadow: var(--shadow); animation: pop .4s backwards; animation-delay: calc(var(--i) * 70ms); }
@keyframes pop { from { transform: translateY(8px) scale(.9); opacity: 0; } }
.pain-list { display: grid; gap: .5rem; margin: 1rem 0; }
.pain { display: flex; align-items: center; gap: .7rem; padding: .85rem 1rem; background: #fff; border-radius: var(--r-sm); text-align: left; border: 2px solid transparent; box-shadow: var(--shadow); font-weight: 500; }
.pain span { font-size: 1.3rem; }
.pain.on { border-color: var(--pri); background: var(--pri-soft); }
.ob-tasklist { display: grid; gap: .4rem; margin: .8rem 0; max-height: 55vh; overflow: auto; }
.ob-task { display: flex; align-items: center; gap: .7rem; background: #fff; border-radius: var(--r-sm); padding: .6rem .8rem; box-shadow: var(--shadow); }
.ob-task input { width: 22px; height: 22px; accent-color: var(--pri); flex: none; }
.ob-task b { display: block; font-weight: 600; font-size: .95rem; }
.ob-task small { color: var(--muted); font-size: .8rem; }
.ob-done { text-align: center; padding: 1.5rem 0 1rem; }
.big-num { font-size: 4.5rem; font-weight: 800; color: var(--pri); line-height: 1; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: calc(150px + var(--safe-b)); transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: .7rem 1.1rem; border-radius: 999px; font-size: .92rem; opacity: 0; pointer-events: none; transition: .25s; z-index: 30; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ================= PRATINJAU & CETAK A4 ================= */
#print-root { position: fixed; inset: 0; z-index: 40; background: #5B635F; overflow: auto; padding-bottom: 2rem; }
.preview-bar { position: sticky; top: 0; display: flex; justify-content: space-between; gap: .5rem; padding: .6rem .8rem; padding-top: max(.6rem, env(safe-area-inset-top)); background: var(--bg); z-index: 1; }
#print-pages { padding: 1rem .6rem; display: grid; gap: 1rem; justify-items: center; }
.p-page { width: 210mm; min-height: 297mm; max-width: 100%; background: #fff; color: #111; padding: 14mm 14mm 18mm; position: relative; box-shadow: 0 4px 20px rgba(0,0,0,.25); font-size: 11pt; }
@media screen and (max-width: 800px) { .p-page { width: 100%; min-height: auto; aspect-ratio: auto; padding: 6vw 5vw 12vw; font-size: 3.2vw; } }
.p-head { border-bottom: 3px solid var(--pri); padding-bottom: 3mm; margin-bottom: 5mm; }
.p-brand { font-size: .8em; color: var(--pri); font-weight: 700; letter-spacing: .04em; }
.p-head h1 { font-size: 1.7em; margin-top: 1mm; }
.p-sub { color: #555; margin-top: 1mm; }
.p-foot { position: absolute; left: 14mm; right: 14mm; bottom: 8mm; font-size: .75em; color: #888; border-top: 1px solid #ddd; padding-top: 2mm; }
@media screen and (max-width: 800px) { .p-foot { position: static; margin-top: 6mm; } }
.p-table { width: 100%; border-collapse: collapse; }
.p-table th, .p-table td { border: 1px solid #BBB; padding: 2.2mm 1.6mm; text-align: center; vertical-align: middle; }
.p-table th { background: #EEF3F0; font-size: .85em; }
.p-table td.c-task { text-align: left; font-weight: 600; }
.p-table td.c-task small { display: block; font-weight: 400; color: #666; font-size: .82em; }
.p-table td.c-time { font-variant-numeric: tabular-nums; width: 13mm; }
.p-table tfoot td { height: 11mm; font-weight: 600; text-align: left; background: #FAFAFA; }
.p-table.maint td { font-size: .9em; }
.p-table.grid30 td { height: 7.2mm; padding: 0 2mm; }
.p-table.grid30 td:nth-child(3) { width: 45%; }
.box { display: inline-block; width: 5mm; height: 5mm; border: 1.6px solid #333; border-radius: 1.2mm; vertical-align: middle; }
.box.big { width: 7mm; height: 7mm; flex: none; }
.box.sm { width: 3.6mm; height: 3.6mm; margin-left: 1.5mm; }
.na { color: #CCC; }
.p-check { list-style: none; padding: 0; margin: 0; }
.p-check li { display: flex; align-items: center; gap: 4mm; padding: 3.2mm 0; border-bottom: 1px dashed #CCC; }
.p-check .t-time { width: 14mm; font-weight: 700; font-variant-numeric: tabular-nums; }
.p-check .t-title { flex: 1; font-size: 1.08em; }
.p-check .t-title small { display: block; color: #666; font-size: .8em; }
.p-check .qty { color: #888; font-size: .9em; }
.p-page h2 { font-size: 1.1em; margin: 5mm 0 1mm; color: var(--pri); }
.tag-habis { color: #fff; background: #C2533F; padding: 0 1.5mm; border-radius: 1mm; font-size: .75em; }
.tag-tipis { color: #9A6418; font-size: .8em; font-weight: 600; }
.p-note { margin-top: 7mm; }
.p-note .lines { height: 30mm; background: repeating-linear-gradient(#fff 0 9mm, #CCC 9mm calc(9mm + 1px)); }
.sop .sop-icon { font-size: 3em; position: absolute; right: 14mm; top: 12mm; }
.p-steps { font-size: 1.3em; padding-left: 9mm; }
.p-steps li { margin: 4mm 0; padding-left: 2mm; }
.p-standard { margin-top: 7mm; padding: 4mm 5mm; border: 2px solid var(--pri); border-radius: 3mm; font-weight: 700; font-size: 1.1em; }

@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { position: static; display: block !important; background: #fff; overflow: visible; padding: 0; }
  .preview-bar { display: none; }
  #print-pages { display: block; padding: 0; }
  .p-page { width: 210mm; box-shadow: none; page-break-after: always; break-after: page; min-height: 297mm; height: auto; padding: 14mm 14mm 18mm; font-size: 11pt; }
  .p-page:last-child { page-break-after: auto; break-after: auto; }
  .p-foot { position: absolute; margin: 0; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
@media screen and (max-width: 800px) { .p-table td.c-task { min-width: 30vw; } .p-table th, .p-table td { padding: 1.6vw 1vw; } }
