:root {
  --bg: #f2f3f6; --card: #fff; --ink: #1d1f22; --ink-2: #555a61; --ink-3: #8a8f96; --line: #e1e4ea;
  --side: #1c2433; --side-ink: #c9cfda; --accent: #24406b;
  --go: #1f7a4d; --go-bg: #e6f3ec; --pause: #b26b00; --pause-bg: #fff4e0; --red: #c62828; --red-bg: #fdecea;
  /* grafik (palet tervalidasi: seri biru, status warning/critical) */
  --series-1: #257de0; --track: #cce3fd; --warn: #fbb315; --crit: #dc3c3d; --grid: #e7e7e7; --base: #c2c2c2; --txt-2: #666;
  --radius: 10px;
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif; font-size: 14px; color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { display: flex; background: var(--bg); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--ink-3); }
.kecil-teks { font-size: 12px; }
.merah-teks { color: var(--red); }
small { font-size: 11px; color: var(--ink-3); }

/* ---------- sidebar ---------- */
.sidebar { width: 228px; flex-shrink: 0; background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; padding: 20px 14px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 22px; }
.brand-mark { width: 38px; height: 38px; }
.brand-name { color: #fff; font-weight: 600; }
.brand-sub { font-size: 12px; color: #8b93a3; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; background: none; border: 0; border-radius: 8px; color: var(--side-ink); cursor: pointer; text-align: left; }
.nav-item:hover { background: #263043; color: #fff; }
.nav-item.active { background: #2f3b52; color: #fff; }
.nav-icon { width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.i-kerja { background: #24533b; color: #9fe0bc; }
.i-papan { background: #263f66; color: #a9c6f2; }
.i-kendala { background: #5c2424; color: #f3a7a7; }
.i-lap { background: #4b3d14; color: #f5cf7a; }
.nav-badge { margin-left: auto; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 10px; }
.nav-item[data-page=kerja] .nav-badge { background: var(--go); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.clock { padding: 12px 10px; border-top: 1px solid #2f3b52; }
.clock-time { color: #fff; font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.clock-date { font-size: 12px; color: #8b93a3; }
.btn-ghost { background: none; border: 1px solid #36425a; color: var(--side-ink); border-radius: 8px; padding: 8px 10px; cursor: pointer; text-align: left; }
.btn-ghost:hover { color: #fff; border-color: #56627a; }
.btn-ghost:disabled { opacity: .5; }
.sync { font-size: 11px; color: #7d8696; padding: 4px 2px 0; }

/* ---------- main ---------- */
.main { flex: 1; min-width: 0; overflow-y: auto; padding: 24px 28px 60px; }
.banner { background: var(--red-bg); color: var(--red); border: 1px solid #f3b9b4; padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.page { display: none; }
.page.active { display: block; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin: 0 0 4px; font-size: 22px; }
.page-head p { margin: 0; color: var(--ink-2); max-width: 640px; }
.saya { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.saya select { min-width: 200px; font-weight: 600; }
.kosong-saya { background: #e8eefb; color: var(--accent); padding: 12px 16px; border-radius: 8px; margin-bottom: 14px; font-weight: 600; }
.grid-kerja { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.judul-sub { font-size: 14px; margin: 4px 0 10px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .4px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.card h2 { margin: 0 0 14px; font-size: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; margin-right: auto; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-weight: 600; font-size: 13px; }
input, select, textarea { border: 1px solid #cfd4dc; border-radius: 8px; padding: 9px 11px; background: #fff; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9db6e0; border-color: var(--accent); }
.row2, .row3 { display: grid; gap: 10px; }
.row2 { grid-template-columns: 1fr 1fr; }
.row3 { grid-template-columns: 1fr 1fr 1fr; }
.info-spk { font-size: 12px; color: var(--go); min-height: 16px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid #cfd4dc; background: #fff; border-radius: 20px; padding: 7px 12px; cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.on small { color: #c9d6ee; }
.chips.besar .chip { padding: 12px 16px; font-size: 15px; }

button { cursor: pointer; }
.btn-mulai, .btn-selesai, .btn-jeda, .btn-merah { border: 0; border-radius: 10px; padding: 12px 18px; font-weight: 700; font-size: 15px; color: #fff; }
.btn-mulai { background: var(--go); width: 100%; }
.btn-selesai { background: var(--accent); }
.btn-jeda { background: #fff; color: var(--pause); border: 2px solid #f0c674; }
.btn-merah { background: var(--red); width: 100%; }
.btn-mulai:disabled, .btn-selesai:disabled, .btn-merah:disabled { opacity: .6; cursor: wait; }
.btn-sekunder { background: #fff; border: 1px solid #cfd4dc; border-radius: 8px; padding: 8px 14px; font-weight: 600; }
.btn-sekunder:hover { border-color: var(--accent); }
.btn-teks { background: none; border: 0; padding: 10px 12px; font-weight: 600; color: var(--ink-2); }
.btn-teks.merah { color: var(--red); margin-right: auto; }
.btn-foto { border: 1px solid #cfd4dc; background: #fff; border-radius: 6px; padding: 2px 8px; font-size: 12px; }

.susulan { margin-top: 16px; border-top: 1px dashed var(--line); padding-top: 12px; }
.susulan summary { cursor: pointer; color: var(--ink-2); font-weight: 600; margin-bottom: 10px; }

/* kartu pekerjaan berjalan */
.kartu-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.kartu { background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--go); border-radius: var(--radius); padding: 14px 16px; }
.kartu.jeda { border-left-color: #f0a500; background: #fffbf2; }
.kartu.rusak { border-left-color: var(--red); background: #fff8f7; }
.kartu-atas { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.kartu-judul { font-weight: 600; font-size: 15px; }
.kartu-sub, .kartu-meta { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.kartu-meta { margin-top: 8px; }
.status-jeda { color: var(--pause); font-weight: 600; }
.timer { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--go); white-space: nowrap; }
.timer.diam { color: var(--pause); }
.kartu.rusak .timer { color: var(--red); font-size: 18px; }
.timer.kecil { font-size: 16px; }
.kartu-aksi { display: flex; gap: 8px; margin-top: 12px; }
.kartu-aksi > button { flex: 1; }
.kartu-aksi input { flex: 3; }
.kartu-list.kecil .kartu { padding: 10px 12px; }
.kartu-list.kecil .timer { font-size: 18px; }
.kosong { color: var(--ink-3); padding: 14px; text-align: center; background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); }
td.kosong { border: 0; }

.riwayat-list { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 18px; }
.riwayat-list > .kosong { border: 0; }
.riw { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.riw:last-child { border-bottom: 0; }
.riw-kanan { text-align: right; white-space: nowrap; }

/* foto */
.foto-pilih { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.thumb { position: relative; width: 64px; height: 64px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb button { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; line-height: 1; padding: 0; }

/* papan produksi */
.mesin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 18px; }
.mesin { background: var(--card); border: 1px solid var(--line); border-top: 4px solid #c9ced6; border-radius: var(--radius); padding: 12px 14px; }
.mesin.jalan { border-top-color: var(--go); }
.mesin.jeda { border-top-color: #f0a500; }
.mesin.rusak { border-top-color: var(--red); background: #fff8f7; }
.mesin-atas { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.mesin .st { font-size: 12px; font-weight: 700; color: var(--ink-3); white-space: nowrap; }
.mesin.jalan .st { color: var(--go); }
.mesin.jeda .st { color: var(--pause); }
.mesin.rusak .st { color: var(--red); }
.mesin-isi { font-size: 13px; padding: 6px 0; border-top: 1px dashed var(--line); }
.mesin-isi:first-of-type { border-top: 0; }

/* meter */
.meter-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 8px; }
.meter-lbl { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; margin-bottom: 4px; }
.meter-lbl:has(> span:first-child:empty) { justify-content: flex-end; }
.meter-val .pct { margin-left: 6px; }
.meter { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 4px; background: var(--series-1); }
.meter.waspada { background: #fde7b0; }
.meter.waspada i { background: var(--warn); }
.meter.krit { background: #f6c9c9; }
.meter.krit i { background: var(--crit); }
.meter.na { background: #eceef2; }
.meter-sub { font-size: 11px; margin-top: 3px; color: var(--txt-2); }
.meter-sub.waspada { color: #8a5a00; }
.meter-sub.krit { color: #a12626; }
td.meter-sel { min-width: 190px; }

/* laporan */
.filter { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.preset { display: flex; background: #fff; border: 1px solid #cfd4dc; border-radius: 8px; overflow: hidden; }
.preset button { border: 0; background: none; padding: 8px 12px; border-right: 1px solid var(--line); }
.preset button:last-child { border-right: 0; }
.preset button.on { background: var(--accent); color: #fff; font-weight: 600; }
.filter input[type=date] { width: 148px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile-lbl { font-size: 12px; color: var(--txt-2); }
.tile-val { font-size: 26px; font-weight: 700; margin: 2px 0; }
.tile-sub { font-size: 12px; color: var(--ink-3); }
.dua { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; }
.tabel td:first-child b { white-space: nowrap; }
.tabel-wrap { overflow-x: auto; }
.tabel { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabel th { text-align: left; font-size: 12px; color: var(--txt-2); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tabel td { padding: 9px 10px; border-bottom: 1px solid #eef0f3; vertical-align: top; }
.tabel .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tabel tbody tr:hover { background: #f8f9fb; }
.pill { display: inline-block; background: #eef2f8; border-radius: 10px; padding: 2px 8px; font-size: 12px; margin: 1px 0; }
#lCari { width: 240px; }

/* grafik */
.chart { position: relative; }
.chart-ket { font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .base { stroke: var(--base); stroke-width: 1; }
.chart .tick { fill: var(--txt-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--series-1); }
.chart .libur .tick { fill: #b5b9bf; }
.chart .hit { fill: transparent; }
.chart .bar-g.aktif .hit { fill: rgba(37, 125, 224, .07); }
.chart .kap { stroke: #191919; stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .kap-lbl { fill: #191919; font-size: 11px; font-weight: 600; paint-order: stroke; stroke: #fff; stroke-width: 3px; }
.tip { position: absolute; pointer-events: none; background: #fff; border: 1px solid rgba(11,11,11,.12); box-shadow: 0 4px 14px rgba(0,0,0,.12); border-radius: 8px; padding: 8px 10px; font-size: 12px; white-space: nowrap; z-index: 5; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(20, 26, 38, .55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-box { background: #fff; border-radius: 14px; padding: 20px; width: min(480px, 100%); max-height: 92vh; overflow: auto; }
.modal-box h2 { margin: 0 0 6px; font-size: 18px; }
.modal-aksi { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.modal-aksi .btn-mulai { width: auto; }
.foto-box { width: min(900px, 100%); }
.foto-box img { width: 100%; border-radius: 8px; min-height: 120px; background: #f0f0f0; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1d1f22; color: #fff; padding: 11px 18px; border-radius: 10px; z-index: 60; max-width: 92vw; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.err { background: var(--red); }

/* ---------- HP ---------- */
@media (max-width: 860px) {
  body { flex-direction: column; }
  .sidebar { order: 2; width: 100%; flex-direction: row; padding: 0; height: auto; padding-bottom: env(safe-area-inset-bottom); }
  .brand, .sidebar-foot { display: none; }
  .nav { flex-direction: row; width: 100%; gap: 0; }
  .nav-item { flex-direction: column; gap: 3px; padding: 8px 2px; font-size: 11px; border-radius: 0; align-items: center; position: relative; }
  .nav-txt { white-space: nowrap; }
  .nav-badge { position: absolute; top: 4px; left: 55%; margin: 0; }
  .main { order: 1; padding: 16px 14px 40px; }
  .grid-kerja, .dua { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 20px; }
  .saya { width: 100%; }
  .saya select { flex: 1; }
  .row3 { grid-template-columns: 1fr 1fr; }
  .filter input[type=date] { width: 130px; }
  .kartu-aksi { flex-wrap: wrap; }
  .kartu-aksi input { flex-basis: 100%; }
}
