/* =====================================================================
   e-BAST Banpem — antarmuka gaya dashboard admin modern
   Navbar putih (brand & pengguna) · sidebar berikon · kartu bersudut membulat
   badge lembut · mode gelap otomatis + tombol ganti tema.
   Warna utama tetap hijau tani (#1d5c3a). Lembar A4 & cetak tidak diubah.
   ===================================================================== */
:root {
    color-scheme: light dark;
    --page: light-dark(#f4f6f9,#0b1220);
    --bg: light-dark(#ffffff,#111a2b);
    --ink: light-dark(#0f172a,#e2e8f0);
    --mut: light-dark(#64748b,#94a3b8);
    --line: light-dark(#e2e8f0,#223049);
    --soft: light-dark(#f8fafc,#172236);
    --g: #1d5c3a;
    --gb: light-dark(#1d5c3a,#2a7a4e);
    --g2: light-dark(#1d5c3a,#6fc095);
    --ac: light-dark(#2f8f5b,#4fb584);
    --gsoft: light-dark(#e7f3ec,#173325);
    --red: light-dark(#c62828,#f87171);
    --amb: light-dark(#a15c00,#f0b45a);
    --blue: light-dark(#2563eb,#7aa7f7);
    --shadow: 0 1px 2px rgba(15,23,42,.05),0 1px 3px rgba(15,23,42,.06);
    --r: 12px
}
:root[data-theme=light] { color-scheme: light }
:root[data-theme=dark] { color-scheme: dark }

* { box-sizing: border-box; min-width: 0 }
body {
    margin: 0;
    background: var(--page);
    color: var(--ink);
    font: 15px/1.55 "Inter","Segoe UI",system-ui,-apple-system,sans-serif;
    overflow-x: clip;
    -webkit-font-smoothing: antialiased
}

/* ---------- ikon ---------- */
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round }

/* ---------- navbar atas: brand + pengguna ---------- */
header {
    background: var(--bg);
    color: var(--ink);
    border-bottom: 1px solid var(--line);
    padding: 8px max(3vw,16px);
    min-height: 64px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 40
}
header>div:not(.top) { display: none }
.top { flex: 1; display: flex; justify-content: space-between; align-items: center; gap: 12px }
.hd { display: flex; align-items: center; gap: 10px }
.brand { display: flex; align-items: center; gap: 12px; font-size: 17px; font-weight: 700; line-height: 1.15; letter-spacing: -.01em }
.brand .logo { flex: none; width: 38px; height: 38px; border-radius: 10px; background: var(--gb); color: #fff; display: grid; place-items: center; font-size: 19px; font-weight: 800 }
.brand small { display: block; margin-top: 2px; font-size: 12.5px; font-weight: 400; letter-spacing: 0; color: var(--mut) }
.who { display: flex; align-items: center; gap: 10px; font-size: 14px }
.ic {
    flex: none; width: 38px; height: 38px; padding: 0; border-radius: 10px;
    border: 1px solid var(--line); background: var(--bg); color: var(--mut);
    display: grid; place-items: center; cursor: pointer
}
.ic:hover { background: var(--soft); color: var(--ink) }
#burger { display: none }
#theme .sun { display: none }
:root[data-theme=dark] #theme .moon { display: none }
:root[data-theme=dark] #theme .sun { display: inline }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) #theme .moon { display: none }
    :root:not([data-theme]) #theme .sun { display: inline }
}
.av { flex: none; width: 38px; height: 38px; border-radius: 50%; background: var(--gsoft); color: var(--g2); display: grid; place-items: center; font-size: 14px; font-weight: 700 }
.wn { display: flex; flex-direction: column; line-height: 1.2 }
.wn b { font-size: 14px; font-weight: 600 }
.wn small { font-size: 12px; color: var(--mut) }
.who .out {
    display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 12px;
    border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink);
    font: inherit; font-weight: 500; cursor: pointer
}
.who .out:hover { background: var(--soft) }

/* ---------- tata letak: sidebar + konten ---------- */
.layout { display: flex; align-items: flex-start }
#side {
    position: sticky; top: var(--hh,64px); height: calc(100vh - var(--hh,64px));
    flex: none; width: 256px; overflow-y: auto; padding: 16px 12px;
    background: var(--bg); border-right: 1px solid var(--line); z-index: 30
}
.side-label { padding: 4px 12px 8px; font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--mut) }
#side nav { display: flex; flex-direction: column; gap: 2px }
#side nav a {
    display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 0 12px;
    border-radius: 8px; color: var(--mut); text-decoration: none; font-size: 14.5px; font-weight: 500
}
#side nav a:hover { background: var(--soft); color: var(--ink) }
#side nav a.on { background: var(--gsoft); color: var(--g2); font-weight: 600 }
#scrim { display: none }
main { padding: 24px max(3vw,16px) 70px; max-width: 1280px; margin: 0 auto }
.layout>main { flex: 1 1 0; min-width: 0 }

/* ---------- tipografi ---------- */
h1 { font-size: clamp(22px,2.4vw,26px); line-height: 1.2; font-weight: 700; letter-spacing: -.02em; margin: 0 0 4px }
h2 { font-size: 17px; font-weight: 600; margin: 26px 0 10px }
h3 { font-size: 15px; font-weight: 600; margin: 16px 0 6px }
.lead { color: var(--mut); margin: 0 0 18px; max-width: 75ch }
.note { font-size: 13.5px; color: var(--mut) }
a { color: var(--g2) }

/* ---------- formulir ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(min(100%,240px),1fr)); gap: 12px 16px }
label { display: block; font-size: 13px; font-weight: 500; color: var(--mut) }
input,select,textarea {
    width: 100%; font: 15px/1.4 inherit; font-family: inherit; color: var(--ink);
    background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
    padding: 8px 12px; min-height: 42px; margin-top: 4px
}
input[readonly],select:disabled { background: var(--soft); color: var(--mut) }
textarea { min-height: 90px }
input[type=checkbox] { width: 18px; height: 18px; min-height: 0; margin: 0; flex: none; accent-color: var(--gb) }
input:focus,select:focus,textarea:focus { outline: none; border-color: var(--g2); box-shadow: 0 0 0 3px color-mix(in srgb,var(--g2) 22%,transparent) }
button:focus-visible,a:focus-visible { outline: 3px solid color-mix(in srgb,var(--g2) 45%,transparent); outline-offset: 1px }

/* ---------- tombol ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    font: inherit; font-size: 14px; font-weight: 500; min-height: 40px; padding: 0 14px;
    border-radius: 8px; cursor: pointer; text-decoration: none;
    border: 1px solid var(--line); background: var(--bg); color: var(--ink); box-shadow: var(--shadow);
    transition: background .15s,border-color .15s,filter .15s
}
.btn:hover { background: var(--soft) }
.btn.pri { background: var(--gb); border-color: var(--gb); color: #fff }
.btn.pri:hover { background: var(--gb); filter: brightness(1.12) }
.btn.del { color: var(--red); border-color: color-mix(in srgb,var(--red) 40%,var(--line)) }
.btn.del:hover { background: color-mix(in srgb,var(--red) 10%,var(--bg)) }
.btn.sm { min-height: 34px; padding: 0 10px; font-size: 13px }
.btn:disabled { opacity: .45; cursor: not-allowed }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0 }

/* ---------- kartu, tabel ---------- */
.box, .funnel, .scroll { background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow) }
.box { padding: 16px 18px; margin: 14px 0 }
.scroll { overflow-x: auto }
table.data { border-collapse: collapse; width: 100%; font-size: 14px }
table.data th, table.data td { border-bottom: 1px solid var(--line); padding: 11px 14px; text-align: left; vertical-align: top }
table.data th { background: var(--soft); color: var(--mut); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap }
table.data td.n { text-align: right; white-space: nowrap }
table.data tr:last-child td { border-bottom: 0 }
table.data tr.click { cursor: pointer }
table.data tr.click:hover td { background: var(--soft) }

/* ---------- badge status ---------- */
.chip { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; background: color-mix(in srgb,var(--mut) 14%,transparent); color: var(--mut) }
.s0 { color: var(--mut) }
.s1, .s2 { color: var(--amb); background: color-mix(in srgb,var(--amb) 14%,transparent) }
.s3, .s4 { color: var(--blue); background: color-mix(in srgb,var(--blue) 14%,transparent) }
.s5 { color: var(--g2); background: color-mix(in srgb,var(--ac) 18%,transparent) }
.s6 { background: var(--gb); color: #fff }
.sx { color: var(--red); background: color-mix(in srgb,var(--red) 13%,transparent) }
.ok { color: var(--g2); font-weight: 600 }
.bad { color: var(--red); font-weight: 600 }
.warn { color: var(--amb); font-weight: 600 }

/* ---------- kartu statistik (dasbor) ---------- */
.kpi { display: grid; grid-template-columns: repeat(auto-fill,minmax(min(100%,200px),1fr)); gap: 14px; margin: 16px 0 }
.kpi div { position: relative; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px 70px 16px 18px }
.kpi b { display: block; font-size: 28px; line-height: 1.1; font-weight: 700; letter-spacing: -.02em }
.kpi span { display: block; margin-top: 4px; font-size: 13.5px; color: var(--mut) }
.kpi div::before { content: ""; position: absolute; right: 16px; top: 16px; width: 40px; height: 40px; border-radius: 10px; background: var(--gsoft) }
.kpi div::after { content: ""; position: absolute; right: 16px; top: 16px; width: 40px; height: 40px; background: var(--g2); -webkit-mask: var(--ic) center/20px no-repeat; mask: var(--ic) center/20px no-repeat }
.kpi div:nth-child(1){--ic:url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='black'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%3E%3Cpath%20d='M16%2021v-2a4%204%200%200%200-4-4H6a4%204%200%200%200-4%204v2'/%3E%3Ccircle%20cx='9'%20cy='7'%20r='4'/%3E%3Cpath%20d='M22%2021v-2a4%204%200%200%200-3-3.87'/%3E%3Cpath%20d='M16%203.13a4%204%200%200%201%200%207.75'/%3E%3C/svg%3E")}
.kpi div:nth-child(2){--ic:url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='black'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%3E%3Ccircle%20cx='12'%20cy='12'%20r='10'/%3E%3Cpath%20d='m9%2012%202%202%204-4'/%3E%3C/svg%3E")}
.kpi div:nth-child(3){--ic:url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='black'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%3E%3Cpath%20d='M14%2018V6a2%202%200%200%200-2-2H4a2%202%200%200%200-2%202v11a1%201%200%200%200%201%201h2'/%3E%3Cpath%20d='M15%2018H9'/%3E%3Cpath%20d='M19%2018h2a1%201%200%200%200%201-1v-3.65a1%201%200%200%200-.22-.624l-3.48-4.35A1%201%200%200%200%2017.52%208H14'/%3E%3Ccircle%20cx='17'%20cy='18'%20r='2'/%3E%3Ccircle%20cx='7'%20cy='18'%20r='2'/%3E%3C/svg%3E")}
.kpi div:nth-child(4){--ic:url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='black'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%3E%3Cpath%20d='M4%2014.9A7%207%200%201%201%2015.71%208h1.79a4.5%204.5%200%200%201%202.5%208.24'/%3E%3Cpath%20d='M12%2012v9'/%3E%3Cpath%20d='m16%2016-4-4-4%204'/%3E%3C/svg%3E")}
.kpi div:nth-child(5){--ic:url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='black'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%3E%3Cpath%20d='m21.73%2018-8-14a2%202%200%200%200-3.48%200l-8%2014A2%202%200%200%200%204%2021h16a2%202%200%200%200%201.73-3'/%3E%3Cpath%20d='M12%209v4'/%3E%3Cpath%20d='M12%2017h.01'/%3E%3C/svg%3E")}
.kpi .alert { border-color: color-mix(in srgb,var(--red) 50%,var(--line)) }
.kpi .alert b { color: var(--red) }
.kpi .alert::before { background: color-mix(in srgb,var(--red) 12%,transparent) }
.kpi .alert::after { background: var(--red) }

.funnel { display: grid; gap: 10px; margin: 10px 0 18px; padding: 16px 18px }
.funnel .r { display: grid; grid-template-columns: minmax(0,190px) minmax(0,1fr) 44px; gap: 12px; align-items: center; font-size: 14px }
.funnel .bar { height: 10px; background: var(--soft); border-radius: 99px; overflow: hidden }
.funnel .bar i { display: block; height: 100%; background: var(--ac); border-radius: 99px }
.funnel .r b { text-align: right }

.steps { display: flex; gap: 4px; flex-wrap: wrap; margin: 8px 0 16px }
.steps span { font-size: 12.5px; padding: 3px 10px; border-radius: 99px; border: 1px solid var(--line); color: var(--mut); background: var(--bg) }
.steps span.done { background: var(--gb); border-color: var(--gb); color: #fff }
.steps span.now { border-color: var(--g2); background: var(--gsoft); color: var(--g2); font-weight: 600 }

.checks { display: grid; grid-template-columns: repeat(auto-fill,minmax(min(100%,280px),1fr)); gap: 8px }
.checks label { display: flex; gap: 10px; align-items: center; color: var(--ink); font-size: 14.5px; font-weight: 400; min-height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; background: var(--bg) }
.photos { display: grid; grid-template-columns: repeat(auto-fill,minmax(min(100%,200px),1fr)); gap: 12px }
.ph { border: 1px dashed var(--line); border-radius: var(--r); padding: 8px; text-align: center; font-size: 14px; background: var(--bg) }
.ph img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 8px; display: block; margin-bottom: 6px; background: var(--soft) }
.ph .empty { aspect-ratio: 4/3; display: grid; place-items: center; color: var(--mut); background: var(--soft); border-radius: 8px; margin-bottom: 6px }

/* ---------- modal, login, toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: grid; place-items: center; z-index: 60; padding: 14px }
.modal>div { background: var(--bg); border: 1px solid var(--line); border-radius: 16px; padding: 22px; width: min(100%,460px); max-height: 90vh; overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.25) }
.login { max-width: 440px; margin: 6vh auto; background: var(--bg); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: 0 10px 30px rgba(15,23,42,.08) }
#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 10px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 70; max-width: 90vw; box-shadow: 0 8px 24px rgba(0,0,0,.25) }
#toast.on { opacity: 1 }

/* ---------- responsif ---------- */
@media (max-width: 899px) {
    #burger { display: grid }
    #side { position: fixed; top: var(--hh,64px); bottom: 0; left: 0; height: auto; width: 280px; transform: translateX(-100%); transition: transform .2s ease }
    #app.open #side { transform: none; box-shadow: 0 0 30px rgba(0,0,0,.3) }
    #app.open #scrim { display: block; position: fixed; top: var(--hh,64px); right: 0; bottom: 0; left: 0; background: rgba(15,23,42,.45); z-index: 25 }
}
@media (max-width: 640px) {
    .wn, .who .out span, .brand small { display: none }
    .who .out { width: 38px; padding: 0; justify-content: center }
    table.data { font-size: 13px }
    .funnel .r { grid-template-columns: 110px minmax(0,1fr) 34px }
}

/* ===== lembar A4 ===== */
#preview {
    background: light-dark(#94a3b8,#334155);
    padding: 20px 0;
    border-radius: 12px;
    margin-top: 16px
}
.page {
    width: 210mm;
    min-height: 297mm;
    margin: 0 auto 16px;
    background: #fff;
    color: #000;
    padding: 16mm 20mm 16mm 25mm;
    font: 12pt/1.35 "Times New Roman",Times,serif;
    position: relative;
    box-shadow: 0 2px 10px rgba(0,0,0,.25)
}
@media(max-width: 860px) {
    #preview {
        overflow-x:auto;
        padding: 12px
    }
    .page {
        margin: 0 0 12px
    }
}
.page p {
    margin: 0 0 6pt;
    text-align: justify
}
.page .c {
    text-align: center
}
.page .r {
    text-align: right
}
.page .b {
    font-weight: bold
}
.page .i {
    font-style: italic
}
.kop {
    text-align: center;
    font-weight: bold;
    line-height: 1.2
}
.kop .al {
    font-weight: normal;
    font-size: 11pt;
    border-bottom: 3px double #000;
    padding-bottom: 3pt;
    margin-bottom: 6pt
}
.page .jdl {
    text-align: center;
    font-weight: bold;
    margin: 4pt 0 0
}
.page .nom {
    text-align: center;
    margin: 0 0 8pt
}
.page.over {
    outline: 4px solid var(--red)
}
.fmt {
    position: absolute;
    top: 8mm;
    right: 22mm;
    font-style: italic;
    font-size: 11pt
}
.idb {
    position: absolute;
    bottom: 8mm;
    left: 25mm;
    right: 22mm;
    font-size: 9pt;
    color: #444;
    display: flex;
    justify-content: space-between;
    border-top: 1px solid #999;
    padding-top: 2pt
}
.isi {
    border-collapse: collapse;
    margin: 4pt 0 8pt
}
.isi td {
    padding: 0 4pt;
    vertical-align: top
}
.isi td:first-child {
    width: 52mm
}
.isi td:nth-child(2) {
    width: 4mm
}
.tb {
    border-collapse: collapse;
    width: 100%;
    margin: 4pt 0 8pt;
    font-size: 11pt
}
.tb th,.tb td {
    border: 1px solid #000;
    padding: 2pt 4pt;
    vertical-align: top
}
.tb th {
    background: #e3e3e3;
    text-align: center
}
.tb td.n {
    text-align: right;
    white-space: nowrap
}
.tb td.ct {
    text-align: center
}
.page ol {
    margin: 2pt 0 6pt;
    padding-left: 18pt
}
.page li {
    margin-bottom: 3pt;
    text-align: justify
}
.ttd {
    display: grid;
    gap: 8pt;
    margin-top: 8pt;
    text-align: center;
    break-inside: avoid
}
.ttd .sp {
    height: 17mm;
    display: flex;
    align-items: flex-end;
    justify-content: center
}
.ttd .mt {
    border: 1px dashed #777;
    font-size: 8pt;
    width: 22mm;
    height: 14mm;
    display: grid;
    place-items: center;
    color: #777;
    margin-bottom: 2pt
}
.ttd u {
    font-weight: bold
}
.stp {
    font-size: 8pt;
    color: #777
}
.foto {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6pt;
    margin: 6pt 0
}
.foto div {
    border: 1px solid #000;
    height: 62mm;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 4pt;
    font-size: 10pt;
    text-align: center
}
@page {
    size: A4;
    margin: 0
}
.qr {
    position: absolute;
    top: 7mm;
    left: 25mm;
    width: 16mm;
    height: 16mm
}
.qr svg {
    width: 100%;
    height: 100%
}
.foto .fimg {
    padding: 2pt;
    justify-content: flex-start
}
.foto .fimg img {
    width: 100%;
    height: 54mm;
    object-fit: cover
}
#preview .page.over {
    outline: 4px solid var(--red)
}
.hint {
    font-size: 7.5pt;
    color: #aaa;
    border: 1px dashed #ccc;
    padding: 1pt 8pt;
    margin-bottom: 2pt
}
.big {
    font-size: 20pt;
    font-weight: bold;
    text-align: center;
    margin: 6pt 0
}
.cut {
    border: 2px solid #000;
    padding: 6pt 8pt;
    margin: 8pt 0
}
@media print {
    body {
        background: #fff
    }
    header,main>*:not(#printArea),#toast {
        display: none!important
    }
    main {
        padding: 0;
        max-width: none
    }
    #printArea {
        display: block!important
    }
    #printArea>*:not(#preview) {
        display: none!important
    }
    #preview {
        background: none;
        padding: 0;
        margin: 0
    }
    .page {
        margin: 0;
        box-shadow: none;
        break-after: page;
        height: 297mm;
        overflow: hidden
    }
}

@media print {
    #side, #scrim { display: none !important }
    .layout { display: block }
}
