:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --line: #dee2ea;
  --text: #1f242e;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: #dbe7ff;
  --green: #178c4d;
  --green-soft: #dcf7e6;
  --amber: #b46e05;
  --amber-soft: #fff2d1;
  --red: #cc2626;
  --red-soft: #ffe3e3;
  --gray-soft: #e6e8ed;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0; font-weight: 700; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 240px; flex: none; background: var(--card); border-right: 1px solid var(--line); padding: 24px 16px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 0 8px 24px; }
.logo .dot { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; color: #fff; font-size: 14px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; color: var(--text); }
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a .ic { width: 16px; height: 16px; border-radius: 4px; background: var(--line); flex: none; }
.nav a.on .ic { background: var(--accent); }
.nav .count { margin-left: auto; font-size: 11px; background: var(--amber-soft); color: var(--amber); padding: 1px 7px; border-radius: 99px; font-weight: 600; }
.sidebar .spacer { flex: 1; }
.userbox { display: flex; align-items: center; gap: 10px; padding: 8px; }
.userbox .av { width: 32px; height: 32px; border-radius: 50%; background: var(--gray-soft); display: grid; place-items: center; font-weight: 600; color: var(--muted); }
.userbox form { margin-left: auto; }
.main { flex: 1; padding: 32px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }
.header { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.header .t { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 4px; }
.header .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mode-banner { background: var(--amber-soft); color: var(--amber); padding: 8px 14px; border-radius: 8px; font-size: 12px; }

/* Card & grid */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card.flush { padding: 0; overflow: hidden; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stat .n { font-size: 30px; font-weight: 700; margin: 4px 0; }
.c-accent { color: var(--accent); } .c-green { color: var(--green); } .c-amber { color: var(--amber); } .c-red { color: var(--red); }

/* Badge */
.badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge.gray { background: var(--gray-soft); color: var(--muted); }
.badge.blue { background: var(--accent-soft); color: var(--accent); }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }

/* Buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; background: var(--bg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1d4fd0; }
.btn.danger { color: var(--red); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.block { width: 100%; padding: 13px; font-size: 15px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); font-weight: 600; cursor: pointer; }
form.inline { display: inline; }
label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.field { margin-bottom: 14px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { min-height: 72px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 10px; font-size: 13px; }
.alert.ok { background: var(--green-soft); color: var(--green); }
.alert.warn { background: var(--amber-soft); color: var(--amber); }
.alert.error { background: var(--red-soft); color: var(--red); }

/* Table */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; background: var(--bg); padding: 11px 16px; }
td { padding: 12px 16px; border-top: 1px solid var(--line); vertical-align: middle; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #fafbfc; }
.table-wrap { overflow-x: auto; }
.empty { padding: 32px; text-align: center; color: var(--muted); }

/* Chips (filter) */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 7px 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-weight: 500; font-size: 13px; }
.chip:hover { text-decoration: none; background: var(--bg); }
.chip.on { background: var(--text); color: #fff; border-color: var(--text); }

/* Map */
.map { height: 380px; border-radius: 8px; background: var(--gray-soft); z-index: 0; }
.map.tall { height: 520px; }
.result { border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.result.tersedia { background: var(--green-soft); }
.result.port_penuh { background: var(--amber-soft); }
.result.tidak_tersedia { background: var(--red-soft); }
.result.none { background: var(--bg); }
.result.pop { animation: pop .5s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Timeline */
.timeline { display: flex; flex-direction: column; gap: 12px; max-height: 420px; overflow: auto; }
.timeline .ev { display: flex; gap: 10px; }
.timeline .ev::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 6px; flex: none; }
.kv { display: flex; flex-direction: column; gap: 12px; }
.kv .k { font-size: 12px; color: var(--muted); }
.kv .v { font-weight: 500; word-break: break-word; }

/* Antrian */
.board { display: grid; grid-template-columns: repeat(5, minmax(180px, 1fr)); gap: 12px; overflow-x: auto; }
.slot { background: #edf0f4; border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.job { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.job.dim { opacity: .7; border-style: dashed; }
.slot-empty { border: 1px dashed var(--line); border-radius: 10px; padding: 12px; text-align: center; color: var(--muted); font-size: 12px; }

/* Bars */
.bar-row { display: grid; grid-template-columns: 150px 1fr 40px; gap: 12px; align-items: center; margin-bottom: 10px; }
.bar { height: 14px; border-radius: 7px; background: var(--accent); transform-origin: left; animation: grow .8s ease-out; }
@keyframes grow { from { transform: scaleX(0); } }
.cap { width: 80px; height: 6px; border-radius: 3px; background: var(--gray-soft); overflow: hidden; display: inline-block; vertical-align: middle; }
.cap > i { display: block; height: 100%; }
.vbars { display: flex; gap: 32px; align-items: flex-end; height: 220px; padding-top: 10px; }
.vbars .grp { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.vbars .pair { display: flex; gap: 6px; align-items: flex-end; height: 190px; }
.vbars .b { width: 28px; border-radius: 4px 4px 0 0; transform-origin: bottom; animation: growY .8s ease-out; }
@keyframes growY { from { transform: scaleY(0); } }

/* WA bubble */
.bubble { background: #dcf8c6; border-radius: 10px; padding: 12px 14px; max-width: 560px; white-space: pre-wrap; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--accent); border-color: var(--accent); }

details summary { cursor: pointer; font-weight: 600; color: var(--accent); }
dialog { border: 0; border-radius: 12px; padding: 24px; width: min(440px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.2); }
dialog::backdrop { background: rgba(15, 20, 30, .4); }

/* Login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { width: min(380px, 100%); padding: 28px; }

/* Varian layout dua kolom */
.split.side-right { grid-template-columns: minmax(0, 1fr) 380px; }
.split.side-left-wide { grid-template-columns: 440px minmax(0, 1fr); }
.split.form-map { grid-template-columns: minmax(0, 520px) minmax(0, 1fr); }
.search-box { width: 260px; }

/* Top bar & laci menu (hanya tampil di HP) */
.topbar, .nav-overlay, .nav-close { display: none; }
.menu-btn, .nav-close { background: none; border: 1px solid var(--line); border-radius: 8px; width: 40px; height: 40px; font-size: 20px; line-height: 1; cursor: pointer; color: var(--text); }
.banner-detail { display: inline; }

/* Responsif: tablet */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split, .split.side-right, .split.side-left-wide, .split.form-map { grid-template-columns: minmax(0, 1fr); }
}

/* Responsif: HP */
@media (max-width: 800px) {
  body { font-size: 14px; }
  .app { display: block; }
  .topbar { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 900; background: var(--card); border-bottom: 1px solid var(--line); padding: 10px 16px; }
  .topbar .logo { padding: 0; font-size: 15px; }
  .topbar .logo .dot { width: 26px; height: 26px; font-size: 13px; }
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; height: 100%; width: 270px; max-width: 85vw; z-index: 1000; transform: translateX(-100%); transition: transform .25s ease; box-shadow: none; overflow-y: auto; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.25); }
  .nav-overlay { position: fixed; inset: 0; background: rgba(15, 20, 30, .4); z-index: 950; }
  body.nav-open .nav-overlay { display: block; }
  body.nav-open { overflow: hidden; }
  .nav-close { display: grid; place-items: center; position: absolute; top: 18px; right: 12px; width: 34px; height: 34px; font-size: 16px; }
  .nav a { padding: 12px; }

  .main { padding: 16px; gap: 16px; }
  .mode-banner { font-size: 11px; padding: 8px 12px; }
  .banner-detail { display: none; }
  h1 { font-size: 21px; }
  h2 { font-size: 15px; }
  .header { gap: 12px; }
  .header .t { min-width: 0; flex-basis: 100%; }
  .header .actions { width: 100%; }
  .header .actions > .btn, .header .actions > form > .btn { flex: 1 1 auto; }
  .card { padding: 16px; }
  .grid { gap: 12px; }
  .g2, .g3 { grid-template-columns: minmax(0, 1fr); }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: 14px; }
  .stat .n { font-size: 24px; margin: 2px 0; }
  .search-box { width: 100%; }
  .row.between > form[method=get] { flex: 1 1 100%; max-width: none !important; }

  /* Filter chip: satu baris, bisa digeser */
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
  .tabs { overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { flex: none; }

  /* Input 16px agar iPhone tidak zoom otomatis */
  input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], input[type=month], select, textarea { font-size: 16px; }

  /* Tabel menjadi kartu */
  .main table, .main thead, .main tbody, .main tr, .main td { display: block; width: 100%; }
  .main thead { display: none; }
  .main tr { padding: 12px 16px; border-top: 1px solid var(--line); }
  .main tbody tr:first-child { border-top: 0; }
  .main td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 4px 0; border: 0; text-align: right; min-height: 26px; }
  .main td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; flex: none; max-width: 45%; }
  .main td:first-child { font-size: 15px; font-weight: 600; text-align: left; justify-content: flex-start; padding-bottom: 6px; }
  .main td:first-child::before { display: none; }
  .main td:first-child > div { font-weight: 400; }
  .main td[data-label=""]::before { display: none; }
  .main td[data-label=""] { justify-content: flex-end; }
  .main td.empty, .main td[colspan] { justify-content: center; text-align: center; }
  .main td.empty::before, .main td[colspan]::before { display: none; }
  .main td > .row, .main td form.row { justify-content: flex-end; flex-wrap: wrap !important; }
  .main td input[type=text], .main td input[type=number], .main td select { width: auto; flex: 1; min-width: 0; max-width: 60%; }
  .main td .cap { width: 60px; }
  tr.click:hover td { background: none; }

  /* Peta */
  .map { height: 280px; }
  .map.tall { height: 340px; }

  /* Antrian: slot ditumpuk ke bawah */
  .board { grid-template-columns: minmax(0, 1fr); overflow: visible; }
  .header .actions input[type=date] { width: 100% !important; }
  .header .actions form { flex: 1 1 100%; }

  /* Grafik laporan bisa digeser */
  .vbars { gap: 18px; overflow-x: auto; }
  .bar-row { grid-template-columns: 110px 1fr 32px; gap: 8px; }

  .timeline { max-height: none; }
  .bubble { max-width: 100%; }
  dialog { padding: 20px; }
}

/* ===== E-Form (HP) ===== */
.ef { max-width: 480px; margin: 0 auto; min-height: 100vh; background: #fff; display: flex; flex-direction: column; }
.ef-top { padding: 28px 20px 12px; display: flex; flex-direction: column; gap: 10px; position: sticky; top: 0; background: #fff; z-index: 5; }
.ef-progress { height: 6px; background: var(--gray-soft); border-radius: 3px; overflow: hidden; }
.ef-progress i { display: block; height: 100%; background: var(--accent); width: 33%; transition: width .4s ease; }
.ef-body { padding: 8px 20px 24px; flex: 1; }
.ef-step { display: none; animation: slide .35s ease-out; }
.ef-step.on { display: block; }
@keyframes slide { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
.ef h1 { font-size: 22px; margin-bottom: 4px; }
.ef .lead-text { color: var(--muted); margin: 0 0 18px; }
.ef-foot { padding: 12px 20px 28px; display: flex; flex-direction: column; gap: 10px; }
.pkg { display: flex; gap: 12px; align-items: center; padding: 16px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 12px; cursor: pointer; font-weight: 400; }
.pkg input { width: 20px; height: 20px; accent-color: var(--accent); }
.pkg:has(input:checked) { border: 2px solid var(--accent); background: var(--accent-soft); padding: 15px; }
.pkg .nm { font-weight: 600; font-size: 16px; }
.ef .map { height: 220px; }
.slots { display: grid; grid-template-columns: 52px 1fr 1fr; gap: 8px; align-items: center; }
.slots .g { font-size: 12px; color: var(--muted); }
.slotbtn { position: relative; margin: 0; }
.slotbtn input { position: absolute; opacity: 0; }
.slotbtn span { display: flex; flex-direction: column; align-items: center; padding: 9px 4px; border: 1px solid var(--line); border-radius: 8px; font-weight: 500; font-size: 13px; cursor: pointer; }
.slotbtn input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.slotbtn input:disabled + span { background: var(--bg); color: var(--muted); cursor: not-allowed; }
.slotbtn small { color: var(--red); font-size: 10px; font-weight: 500; }
.ef-done { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; padding-top: 24px; }
.ok-ic { width: 72px; height: 72px; border-radius: 50%; background: var(--green-soft); color: var(--green); display: grid; place-items: center; font-size: 34px; font-weight: 700; animation: pop .5s ease-out; }
.va-card { width: 100%; text-align: left; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.va-num { font-size: 22px; font-weight: 700; letter-spacing: .5px; }

@media (max-width: 800px) {
  .row.between > .chips { flex: 1 1 100%; min-width: 0; }
  .row.between { gap: 10px; }
}
@media (max-width: 800px) {
  .row.between > form[method=get] { flex: 1 1 100% !important; }
  /* Sel tabel yang berisi form: label di atas, form selebar kartu */
  .main td:has(> form.row) { flex-direction: column; align-items: stretch; text-align: left; }
  .main td:has(> form.row)::before { max-width: none; }
  .main td > form.row { flex-wrap: wrap !important; justify-content: flex-start; }
  .main td > form.row select, .main td > form.row input[type=text] { flex: 1 1 140px; max-width: none; padding: 8px 10px !important; font-size: 16px !important; }
}
