:root{
  --bg:#fffdf6; --surface:#ffffff; --surface2:#fff8de; --line:#f1e8c4; --text:#1f1a05; --muted:#7a7355;
  --y:#ffc400; --y-strong:#f5b000; --y-soft:#fff1b8; --ink:#1a1400;
  --high:#d6362b; --high-bg:#fde8e6; --std:#b87900; --std-bg:#fff0c2; --low:#1f8a4c; --low-bg:#e2f5e9;
  --shadow:0 1px 2px rgba(60,45,0,.06),0 8px 24px rgba(60,45,0,.06);
  --r:14px; --r-sm:9px;
}
[data-theme=dark]{
  --bg:#14120a; --surface:#1d1a0e; --surface2:#27230f; --line:#3a3418; --text:#fbf6e0; --muted:#b0a77a;
  --y-soft:#3b3205; --high-bg:#3d1b18; --std-bg:#3b3005; --low-bg:#14301f; --shadow:0 8px 24px rgba(0,0,0,.4);
}
*{box-sizing:border-box}
html,body{height:100%}
body{margin:0;background:var(--bg);color:var(--text);font:15px/1.55 "Plus Jakarta Sans",system-ui,-apple-system,"Segoe UI",sans-serif;-webkit-font-smoothing:antialiased}
h1,h2,h3{line-height:1.2;margin:0;letter-spacing:-.01em}
.hidden{display:none!important}
.muted{color:var(--muted)}
small{color:var(--muted)}
:focus-visible{outline:3px solid var(--y);outline-offset:2px}
button{font:inherit;cursor:pointer}
input,select,textarea{font:inherit;color:var(--text);background:var(--surface);border:1.5px solid var(--line);border-radius:var(--r-sm);padding:.6rem .75rem;width:100%;transition:border-color .15s,box-shadow .15s}
input:focus,select:focus,textarea:focus{outline:none;border-color:var(--y-strong);box-shadow:0 0 0 4px var(--y-soft)}
label{display:flex;flex-direction:column;gap:.35rem;font-weight:600;font-size:.86rem}
textarea{min-height:84px;resize:vertical}

.btn{border:0;border-radius:var(--r-sm);padding:.65rem 1.1rem;font-weight:700;transition:transform .12s,background .15s,box-shadow .15s}
.btn:active{transform:translateY(1px)}
.btn.primary{background:var(--y);color:var(--ink);box-shadow:0 2px 0 var(--y-strong)}
.btn.primary:hover{background:var(--y-strong)}
.btn.soft{background:var(--y-soft);color:var(--text)}
.btn.soft:hover{background:var(--y)}
.btn.ghost{background:transparent;color:var(--muted);padding:.5rem .7rem}
.btn.ghost:hover{color:var(--text);background:var(--surface2)}
.btn.danger{background:var(--high-bg);color:var(--high)}
.btn.sm{padding:.35rem .7rem;font-size:.82rem}

/* ---------- Login ---------- */
.login{min-height:100vh;display:grid;grid-template-columns:1.1fr 1fr}
.login-art{background:var(--y);color:var(--ink);padding:clamp(2rem,6vw,5rem);display:flex;flex-direction:column;justify-content:center;gap:1.4rem}
.login-art h1{font-size:clamp(1.8rem,3.6vw,3rem);font-weight:800;max-width:16ch}
.login-art p{max-width:46ch;font-size:1.05rem}
.meter{width:min(280px,60%)}
.meter line{transform-origin:100px 100px;animation:needle 1.6s cubic-bezier(.2,.9,.3,1.2) both}
@keyframes needle{from{transform:rotate(-70deg)}to{transform:rotate(0)}}
.login-card{align-self:center;justify-self:center;width:min(400px,90%);display:flex;flex-direction:column;gap:1rem;padding:2rem}
.login-card h2{font-size:1.8rem;font-weight:800}
.pw{position:relative;display:block}
.pw button{position:absolute;right:.3rem;top:50%;transform:translateY(-50%)}
.err{min-height:1.2em;color:var(--high);font-size:.86rem;font-weight:600}

/* ---------- Shell ---------- */
.app{display:grid;grid-template-columns:250px 1fr;min-height:100vh}
.side{background:var(--surface);border-right:1px solid var(--line);padding:1.1rem;display:flex;flex-direction:column;gap:1.2rem;position:sticky;top:0;height:100vh}
.brand{display:flex;gap:.7rem;align-items:center}
.brand small{display:block;font-size:.76rem}
.logo{width:40px;height:40px;border-radius:12px;background:var(--y);color:var(--ink);display:grid;place-items:center;font-weight:800;font-size:1.2rem}
#nav{display:flex;flex-direction:column;gap:.2rem;flex:1}
#nav a{display:flex;align-items:center;gap:.7rem;padding:.65rem .8rem;border-radius:var(--r-sm);color:var(--muted);text-decoration:none;font-weight:600}
#nav a:hover{background:var(--surface2);color:var(--text)}
#nav a.on{background:var(--y);color:var(--ink)}
#nav svg{width:19px;height:19px;flex:none}
.side-foot{display:flex;flex-direction:column;gap:.6rem}
.me{display:flex;gap:.6rem;align-items:center;padding:.5rem;border-radius:var(--r-sm);background:var(--surface2)}
.me small{display:block;font-size:.75rem}
.avatar{width:36px;height:36px;border-radius:50%;background:var(--y);color:var(--ink);display:grid;place-items:center;font-weight:800;flex:none}
.main{min-width:0}
.top{display:flex;align-items:center;gap:1rem;padding:1.1rem clamp(1rem,3vw,2rem);border-bottom:1px solid var(--line);background:color-mix(in srgb,var(--bg) 85%,transparent);backdrop-filter:blur(10px);position:sticky;top:0;z-index:5}
.top h1{font-size:1.35rem;font-weight:800;flex:1}
.menu-btn{display:none}
.search{border:1.5px solid var(--line);background:var(--surface);color:var(--muted);border-radius:99px;padding:.5rem 1rem;display:flex;gap:.8rem;align-items:center}
.search:hover{border-color:var(--y-strong)}
kbd{background:var(--surface2);border:1px solid var(--line);border-radius:6px;padding:.05rem .4rem;font:600 .72rem inherit;color:var(--muted)}
.view{padding:clamp(1rem,3vw,2rem);max-width:1280px}

/* ---------- Komponen ---------- */
.card{background:var(--surface);border:1px solid var(--line);border-radius:var(--r);box-shadow:var(--shadow);padding:1.25rem}
.card h3{font-size:1rem;font-weight:700;margin-bottom:.9rem}
.grid{display:grid;gap:1rem}
.kpis{grid-template-columns:repeat(auto-fit,minmax(190px,1fr))}
.kpi strong{display:block;font-size:2rem;font-weight:800;line-height:1.1}
.kpi span{color:var(--muted);font-weight:600;font-size:.86rem}
.kpi.hero{background:var(--y);border-color:var(--y-strong);color:var(--ink)}
.kpi.hero span{color:rgba(26,20,0,.7)}
.two{grid-template-columns:minmax(0,1.2fr) minmax(0,1fr)}
.badge{display:inline-flex;align-items:center;gap:.35rem;border-radius:99px;padding:.15rem .7rem;font-weight:700;font-size:.8rem}
.badge.High{background:var(--high-bg);color:var(--high)}
.badge.Standard{background:var(--std-bg);color:var(--std)}
.badge.Low{background:var(--low-bg);color:var(--low)}
.badge.on{background:var(--low-bg);color:var(--low)}
.badge.off{background:var(--surface2);color:var(--muted)}
.donut{width:150px;height:150px;border-radius:50%;display:grid;place-items:center;flex:none}
.donut div{width:98px;height:98px;border-radius:50%;background:var(--surface);display:grid;place-items:center;text-align:center;font-weight:800;font-size:1.5rem;line-height:1.1}
.donut small{display:block;font-size:.7rem;font-weight:600}
.legend{display:flex;flex-direction:column;gap:.5rem;font-weight:600}
.dot{display:inline-block;width:10px;height:10px;border-radius:50%;margin-right:.5rem}
.bars{display:flex;flex-direction:column;gap:.7rem}
.bar{display:grid;grid-template-columns:110px 1fr 44px;gap:.7rem;align-items:center;font-size:.86rem;font-weight:600}
.track{height:12px;background:var(--surface2);border-radius:99px;overflow:hidden}
.fill{height:100%;border-radius:99px;transition:width .8s cubic-bezier(.2,.8,.2,1)}
table{width:100%;border-collapse:collapse}
th,td{text-align:left;padding:.7rem .6rem;border-bottom:1px solid var(--line);vertical-align:middle}
th{font-size:.8rem;color:var(--muted);font-weight:700}
tr:last-child td{border-bottom:0}
tbody tr:hover{background:var(--surface2)}
.table-wrap{overflow-x:auto}
.toolbar{display:flex;gap:.7rem;flex-wrap:wrap;margin-bottom:1rem;align-items:center}
.toolbar input,.toolbar select{width:auto;min-width:200px}
.empty{padding:2.5rem 1rem;text-align:center;color:var(--muted)}
.empty strong{display:block;color:var(--text);font-size:1.05rem;margin-bottom:.3rem}

/* Form bertahap */
.steps{display:flex;gap:.4rem;margin-bottom:1.2rem;flex-wrap:wrap}
.step{border:1.5px solid var(--line);background:var(--surface);border-radius:99px;padding:.45rem 1rem;font-weight:700;color:var(--muted)}
.step.on{background:var(--y);border-color:var(--y-strong);color:var(--ink)}
.step.done{color:var(--text)}
.fields{display:grid;grid-template-columns:repeat(auto-fill,minmax(250px,1fr));gap:1rem}
.fields .wide{grid-column:1/-1}
.hint{font-weight:500;color:var(--muted);font-size:.78rem}
.actions{display:flex;gap:.7rem;justify-content:space-between;margin-top:1.4rem;flex-wrap:wrap}

/* Hasil justifikasi */
.result{display:grid;grid-template-columns:260px 1fr;gap:1.4rem}
.gauge{text-align:center}
.gauge svg{width:100%;max-width:240px}
.gauge .score{font-size:2.6rem;font-weight:800;line-height:1}
.gauge .lv{margin-top:.6rem;display:inline-block}
.ai-text{display:flex;flex-direction:column;gap:.8rem}
.ai-text p{margin:0;max-width:72ch}
.ai-head{display:flex;align-items:center;gap:.6rem;font-weight:700;margin-bottom:.4rem}
.spark{width:26px;height:26px;border-radius:8px;background:var(--y);display:grid;place-items:center;color:var(--ink);font-size:.9rem}
.caret::after{content:"";display:inline-block;width:2px;height:1em;background:var(--y-strong);margin-left:2px;vertical-align:-.15em;animation:blink 1s steps(1) infinite}
@keyframes blink{50%{opacity:0}}
.flag{display:flex;gap:.6rem;padding:.55rem .75rem;border-radius:var(--r-sm);font-size:.88rem;border-left:4px solid}
.flag.high{background:var(--high-bg);border-color:var(--high)}
.flag.med{background:var(--std-bg);border-color:var(--y-strong)}
.flag.low{background:var(--surface2);border-color:var(--line)}
.flag.good{background:var(--low-bg);border-color:var(--low)}
.meter-scale{display:grid;grid-template-columns:repeat(3,1fr);gap:.4rem;margin-top:1rem}
.meter-scale div{padding:.5rem;border-radius:var(--r-sm);text-align:center;font-weight:700;font-size:.82rem;opacity:.45}
.meter-scale div.on{opacity:1;outline:2px solid currentColor}
.meter-scale .High{background:var(--high-bg);color:var(--high)}
.meter-scale .Standard{background:var(--std-bg);color:var(--std)}
.meter-scale .Low{background:var(--low-bg);color:var(--low)}

/* Overlay */
.overlay{position:fixed;inset:0;background:rgba(20,15,0,.45);backdrop-filter:blur(3px);display:flex;align-items:flex-start;justify-content:center;padding:8vh 1rem;z-index:50;overflow:auto}
.cmd-box,.modal{background:var(--surface);border-radius:var(--r);box-shadow:0 20px 60px rgba(0,0,0,.3);width:min(560px,100%);animation:pop .18s ease-out}
.modal{padding:1.4rem;width:min(780px,100%)}
.modal.narrow{width:min(460px,100%)}
@keyframes pop{from{opacity:0;transform:scale(.97) translateY(6px)}}
#cmdInput{border:0;border-bottom:1px solid var(--line);border-radius:var(--r) var(--r) 0 0;padding:1rem 1.1rem;font-size:1.05rem}
#cmdInput:focus{box-shadow:none}
#cmdList{list-style:none;margin:0;padding:.4rem;max-height:50vh;overflow:auto}
#cmdList li{padding:.6rem .8rem;border-radius:var(--r-sm);cursor:pointer;display:flex;justify-content:space-between;gap:1rem}
#cmdList li.on,#cmdList li:hover{background:var(--y-soft)}
.toasts{position:fixed;right:1rem;bottom:1rem;display:flex;flex-direction:column;gap:.5rem;z-index:80}
.toast{background:var(--ink);color:#fff8d6;padding:.7rem 1rem;border-radius:var(--r-sm);box-shadow:var(--shadow);font-weight:600;animation:pop .2s}
.toast.err{background:var(--high);color:#fff}

@media (max-width:900px){
  .login{grid-template-columns:1fr}
  .login-art{padding:2rem}
  .app{grid-template-columns:1fr}
  .side{position:fixed;left:0;top:0;z-index:40;width:260px;transform:translateX(-100%);transition:transform .2s}
  .side.open{transform:none;box-shadow:0 0 0 100vmax rgba(20,15,0,.4)}
  .menu-btn{display:block}
  .two,.result{grid-template-columns:1fr}
  .search kbd,.search span{display:none}
}
@media (prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}
@media print{
  .side,.top,.actions,.toolbar,.toasts{display:none!important}
  .app{display:block}.view{padding:0}body{background:#fff;color:#000}
  .overlay{position:static;background:none;padding:0}.modal{box-shadow:none;width:100%}
}
