/* OPdb RKH – mobile-first */
:root {
  --bg: #f4f5f1; --card: #fff; --ink: #1d2620; --muted: #66706a; --line: #dfe3dc;
  --green: #1f4d2c; --green-2: #2f7a45; --green-soft: #e3f0e6;
  --panen: #3f9a5a; --lanjut: #2f6fb0; --sebagian: #a7c957; --geser: #d9822b; --none: #e7e9e4;
  --warn: #b5482b; --warn-soft: #fbe9e3; --amber-soft: #fdf1df;
  --r: 12px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 1px 8px rgba(0,0,0,.04);
  font-size: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink);
       line-height: 1.4; -webkit-text-size-adjust: 100%; padding-bottom: 84px; }
h1 { font-size: 1.3rem; margin: .2rem 0 .4rem; }
h2 { font-size: 1.02rem; margin: 0; }
h3 { font-size: .95rem; margin: 0 0 .4rem; }
a { color: var(--green-2); }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.fine { font-size: .75rem; color: var(--muted); margin-top: 1rem; }
[hidden] { display: none !important; }
main { max-width: 1180px; margin: 0 auto; }

/* header */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .6rem; padding: .55rem .9rem;
       background: var(--green); color: #fff; }
.brand { color: #fff; text-decoration: none; font-weight: 700; letter-spacing: .02em; }
.brand span { font-weight: 400; opacity: .8; }
.who { flex: 1; font-size: .82rem; opacity: .9; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout { margin: 0; }
.top .btn-ghost { color: #fff; border-color: rgba(255,255,255,.4); padding: .3rem .7rem; min-height: 34px; }

/* buttons */
button, .btn-primary, .btn-secondary, .btn-ghost { font: inherit; cursor: pointer; border-radius: 10px; min-height: 44px;
  padding: .55rem 1rem; border: 1px solid transparent; text-decoration: none; display: inline-flex; align-items: center;
  justify-content: center; gap: .3rem; }
.btn-primary { background: var(--green-2); color: #fff; font-weight: 600; }
.btn-primary:disabled { opacity: .45; cursor: default; }
.btn-secondary { background: var(--green-soft); color: var(--green); border-color: #bcd9c3; font-weight: 600; }
.btn-secondary:disabled { opacity: .5; cursor: default; }
.btn-ghost { background: transparent; color: var(--green); border-color: var(--line); }
.btn-small { min-height: 34px; padding: .25rem .6rem; font-size: .85rem; }
.wide { width: 100%; }
.btn-warn { background: transparent; color: var(--warn); border: 1px solid #efc2b5; }

/* login */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 1rem; background: linear-gradient(160deg, #1f4d2c, #2f7a45); }
.login-card { background: var(--card); border-radius: 16px; padding: 1.6rem 1.3rem; width: min(380px, 100%); box-shadow: 0 8px 30px rgba(0,0,0,.2); }
.login-brand { font-size: 1.6rem; font-weight: 800; color: var(--green); }
.login-brand span { font-weight: 400; }
.login-card label { display: block; font-size: .85rem; color: var(--muted); margin: .9rem 0 .2rem; }
.login-card input { width: 100%; font-size: 1rem; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: 10px; margin-top: .25rem; }
.login-card .btn-primary { margin-top: 1.2rem; }
.alert { background: var(--warn-soft); color: var(--warn); padding: .6rem .8rem; border-radius: 10px; margin-top: .8rem; font-size: .9rem; }

/* list */
.page { padding: 1rem .9rem; }
.rkh-list { list-style: none; padding: 0; margin: .8rem 0; display: grid; gap: .6rem; }
.rkh-list a { display: grid; grid-template-columns: 1fr auto; gap: .1rem .6rem; background: var(--card); border-radius: var(--r);
  padding: .85rem 1rem; color: var(--ink); text-decoration: none; box-shadow: var(--shadow); }
.rl-date { font-weight: 600; }
.rl-sub { color: var(--muted); font-size: .85rem; grid-column: 1; }
.rkh-list .chip { grid-row: 1 / span 2; grid-column: 2; align-self: center; }

/* chips */
.chip { display: inline-block; font-size: .78rem; font-weight: 600; padding: .2rem .6rem; border-radius: 999px; background: var(--none); color: var(--ink); }
.st-draft { background: var(--amber-soft); color: #8a5a12; }
.st-menunggu_askep { background: #e3ecf7; color: #234f80; }
.st-disetujui { background: var(--green-soft); color: var(--green); }
.st-ditolak { background: var(--warn-soft); color: var(--warn); }

/* day header */
.dayhead { background: var(--card); padding: .7rem .9rem .6rem; border-bottom: 1px solid var(--line); }
.dh-nav { display: flex; align-items: center; gap: .5rem; }
.dh-title { flex: 1; text-align: center; }
.dh-date { font-weight: 700; font-size: 1.05rem; }
.dh-sub { color: var(--muted); font-size: .82rem; }
.navbtn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: var(--green-soft);
  color: var(--green); text-decoration: none; font-size: 1.6rem; line-height: 1; }
.navbtn.off { opacity: .3; }
.dh-status { display: flex; justify-content: center; gap: .6rem; align-items: center; margin-top: .45rem; }

/* layout */
.layout { display: grid; gap: .9rem; padding: .9rem; }
.col-a, .col-b { display: grid; gap: .9rem; align-content: start; min-width: 0; }
.card { background: var(--card); border-radius: var(--r); padding: .9rem; box-shadow: var(--shadow); }
.card-h, .sec-h { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; margin-bottom: .55rem; }
.sec-h { margin: .2rem .1rem .55rem; }

/* KPI */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.kpi { background: var(--card); border-radius: var(--r); padding: .7rem .8rem; box-shadow: var(--shadow); min-width: 0; }
.kpi .k-label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.kpi .k-val { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: .1rem; }
.kpi .k-val small { font-size: .8rem; font-weight: 500; color: var(--muted); }
.kpi .k-sub { font-size: .78rem; color: var(--muted); }
.kpi.over { background: var(--warn-soft); }
.kpi.over .k-val { color: var(--warn); }
.bar { height: 6px; background: var(--none); border-radius: 3px; margin-top: .4rem; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--green-2); border-radius: 3px; }
.kpi.over .bar > i { background: var(--warn); }

/* gap */
.gap-row { display: flex; align-items: center; gap: .7rem; }
.gap-big { font-size: 1.6rem; font-weight: 800; color: #8a5a12; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gap-text { font-size: .86rem; }
.gap-scale { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .5rem; margin-top: .7rem; font-size: .8rem; color: var(--muted); }
.gap-track { position: relative; height: 8px; background: var(--none); border-radius: 4px; }
.gap-track i { position: absolute; top: -4px; width: 16px; height: 16px; border-radius: 50%; transform: translateX(-50%); border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.15); }
.gap-track .now { background: var(--geser); }
.gap-track .tgt { background: var(--green-2); }

/* map */
.map-wrap { background: #f9faf7; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
#map { width: 100%; height: auto; display: block; touch-action: manipulation; }
#map path { stroke: #fff; stroke-width: 1.2; vector-effect: non-scaling-stroke; cursor: pointer; }
#map path.sel { stroke: var(--ink); stroke-width: 2.5; }
#map text { fill: #1d2620; pointer-events: none; font-weight: 600; paint-order: stroke; stroke: rgba(255,255,255,.85); }
.legend { display: flex; flex-wrap: wrap; gap: .3rem .9rem; font-size: .78rem; color: var(--muted); margin-top: .55rem; }
.lg { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: .3rem; vertical-align: -1px; }
.lg-panen { background: var(--panen); } .lg-lanjut { background: var(--lanjut); } .lg-sebagian { background: var(--sebagian); }
.lg-geser { background: var(--geser); } .lg-none { background: var(--none); border: 1px solid #cfd3cc; }
.blockinfo { margin-top: .6rem; padding: .6rem .7rem; background: var(--bg); border-radius: 10px; font-size: .88rem;
  display: flex; justify-content: space-between; align-items: center; gap: .6rem; }

/* block cards */
.bcard { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: .8rem .85rem; margin-bottom: .6rem; border-left: 5px solid var(--panen); }
.bcard.lanjutan { border-left-color: var(--lanjut); }
.bcard.sebagian { border-left-color: var(--sebagian); }
.bcard.geser { border-left-color: var(--geser); opacity: .95; }
.bcard.flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 3px var(--green-2); } 100% { box-shadow: var(--shadow); } }
.b-top { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.b-name { font-weight: 700; font-size: 1.08rem; }
.b-tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .2rem; }
.tag { font-size: .72rem; padding: .1rem .45rem; border-radius: 6px; background: var(--bg); color: var(--muted); }
.tag.t-lanjutan { background: #e3ecf7; color: #234f80; }
.tag.t-sebagian { background: #eef5dc; color: #4d6b12; }
.tag.t-geseran, .tag.t-geser { background: var(--amber-soft); color: #8a5a12; }
.tag.t-tambahan { background: #efe6f6; color: #5d3a80; }
.tag.t-edit { background: var(--amber-soft); color: #8a5a12; }
.b-kg { text-align: right; }
.b-kg .v { font-weight: 700; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.b-kg .u { font-size: .75rem; color: var(--muted); }
.formula { font-size: .8rem; color: var(--muted); margin: .45rem 0 .6rem; font-variant-numeric: tabular-nums; }
.fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.fields label { font-size: .72rem; color: var(--muted); display: grid; gap: .15rem; }
.fields input, .fields select, .lain-grid input, .lain-grid select, #dlg input, #dlg select {
  width: 100%; font: inherit; font-size: 1rem; padding: .5rem .55rem; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; min-height: 42px; font-variant-numeric: tabular-nums; }
.fields input:disabled, .fields select:disabled, .lain-grid input:disabled { background: var(--bg); color: var(--ink); border-color: transparent; }
.hk-row { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: .55rem; }
.stepper { display: grid; grid-template-columns: 42px 1fr 42px; align-items: stretch; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stepper button { min-height: 42px; border: 0; background: var(--green-soft); color: var(--green); font-size: 1.2rem; font-weight: 700; border-radius: 0; padding: 0; }
.stepper input { border: 0 !important; text-align: center; border-radius: 0 !important; min-height: 42px; }
.stepper.ro button { display: none; }
.stepper.ro { grid-template-columns: 1fr; }
.hk-lbl { font-size: .72rem; color: var(--muted); margin-bottom: .15rem; }
.hk-need { display: flex; justify-content: space-between; align-items: center; font-size: .82rem; margin-top: .5rem; padding: .4rem .55rem;
  background: var(--bg); border-radius: 8px; }
.hk-need.short { background: var(--warn-soft); color: var(--warn); }
.hk-need .fill { border: 0; background: transparent; color: var(--green-2); text-decoration: underline; min-height: 30px; padding: 0 .2rem; font-size: .82rem; }
.b-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: .55rem; }
.empty { background: var(--card); border-radius: var(--r); padding: .8rem; color: var(--muted); font-size: .88rem; box-shadow: var(--shadow); margin-bottom: .6rem; }

/* lain */
.lain-card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: .7rem .8rem; margin-bottom: .6rem; }
.lain-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .45rem; }
.lain-grid label { font-size: .72rem; color: var(--muted); display: grid; gap: .15rem; }
.lain-grid .full { grid-column: 1 / -1; }

.note p { font-size: .84rem; margin: .3rem 0; color: var(--muted); }

/* action bar */
.actionbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; gap: .5rem; padding: .6rem .8rem calc(.6rem + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.97); border-top: 1px solid var(--line); box-shadow: 0 -2px 10px rgba(0,0,0,.05); }
.actionbar > * { flex: 1; }
.actionbar .btn-ghost { flex: .6; }
.ro .edit-only { display: none !important; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 84px; z-index: 40; background: var(--ink); color: #fff;
  padding: .6rem 1rem; border-radius: 10px; font-size: .9rem; max-width: 92vw; box-shadow: 0 4px 16px rgba(0,0,0,.2); }
.toast.err { background: var(--warn); }

dialog { border: 0; border-radius: 14px; padding: 1.1rem; width: min(420px, 94vw); box-shadow: 0 10px 40px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(0,0,0,.35); }
#dlg-body { font-size: .92rem; display: grid; gap: .55rem; margin: .5rem 0 .9rem; }
#dlg-body label { font-size: .78rem; color: var(--muted); display: grid; gap: .15rem; }
.dlg-actions { display: flex; gap: .5rem; justify-content: flex-end; }
.dlg-sum { display: grid; grid-template-columns: 1fr auto; gap: .25rem .8rem; font-variant-numeric: tabular-nums; }
.dlg-warn { background: var(--warn-soft); color: var(--warn); padding: .5rem .6rem; border-radius: 8px; font-size: .85rem; }

/* laptop */
@media (min-width: 900px) {
  body { padding-bottom: 76px; }
  .layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); padding: 1.1rem; gap: 1.1rem; }
  .col-a { position: sticky; top: 64px; }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .actionbar { justify-content: flex-end; padding-right: max(1rem, calc((100vw - 1180px) / 2 + 1rem)); }
  .actionbar > * { flex: 0 0 auto; min-width: 130px; }
  .dayhead { padding: .9rem 1.1rem .7rem; }
  .dh-nav { max-width: 560px; margin: 0 auto; }
}
