:root {
  --navy: #0d1b3e;
  --navy2: #15305f;
  --blue: #0b5394;
  --blue2: #1f6fb2;
  --sky: #3fa7d6;
  --sky-l: #9fd3f0;
  --amber: #e3a21a;
  --yellow: #f6d860;
  --bg: #e6ecf3;
  --card: #ffffff;
  --ink: #1b2533;
  --ink2: #4a5868;
  --muted: #7c8a99;
  --line: #e2e8f0;
  --ok: #138a52;
  --ok-bg: #e3f6ec;
  --warn: #b26b00;
  --warn-bg: #fff3d6;
  --err: #c62828;
  --err-bg: #fde7e7;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(13, 27, 62, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); font-size: 14px; }
a { color: var(--blue2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; }
small, .muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px; flex-shrink: 0; color: #fff; padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: linear-gradient(180deg, #2a86cf 0%, #1767ab 45%, #0f4f8c 100%);
  box-shadow: inset -6px 0 12px rgba(0, 0, 0, .12);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 16px; border-bottom: 1px solid rgba(255, 255, 255, .2); margin-bottom: 12px; }
.brand .logo { width: 42px; height: 42px; border-radius: 10px; background: #fff; color: var(--blue); display: grid; place-items: center; font-weight: 800; font-size: 15px; letter-spacing: .5px; }
.brand b { font-size: 20px; letter-spacing: 2px; display: block; }
.brand span { font-size: 10.5px; opacity: .85; line-height: 1.2; display: block; }
.nav-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px; opacity: .7; margin: 14px 8px 6px; }
.nav a {
  display: flex; align-items: center; gap: 9px; color: #fff; padding: 8px 12px; margin: 4px 0; border-radius: 9px;
  background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .18); font-size: 13.5px; text-decoration: none;
  transition: background .15s;
}
.nav a:hover { background: rgba(255, 255, 255, .26); }
.nav a.active { background: var(--yellow); color: var(--navy); border-color: var(--yellow); font-weight: 600; }
.nav a .ic { width: 18px; text-align: center; }
.nav a .cnt { margin-left: auto; background: var(--err); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 7px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: linear-gradient(90deg, var(--navy) 0%, var(--navy2) 100%); color: #fff; padding: 12px 24px;
  display: flex; align-items: center; gap: 14px; position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 19px; font-weight: 600; }
.topbar .sub { font-size: 12px; opacity: .7; }
.topbar .spacer { flex: 1; }
.topbar .user { text-align: right; font-size: 12.5px; line-height: 1.3; }
.topbar .user b { display: block; font-size: 13.5px; }
.topbar button.ghost { color: #fff; border-color: rgba(255, 255, 255, .35); }
.burger { display: none; background: none; border: 0; color: #fff; font-size: 24px; cursor: pointer; }
.content { padding: 20px 24px 40px; }

/* ---------- Komponen ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.card h3 { font-size: 14.5px; margin-bottom: 10px; color: var(--ink); }
.card h3 small { font-weight: 400; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }

button, .btn {
  font: inherit; border: 1px solid var(--blue2); background: var(--blue2); color: #fff; border-radius: 9px; padding: 8px 14px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-weight: 500; text-decoration: none; white-space: nowrap;
}
button:hover, .btn:hover { filter: brightness(1.08); text-decoration: none; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.ghost, .btn.ghost { background: transparent; color: var(--blue2); }
button.ok { background: var(--ok); border-color: var(--ok); }
button.warn { background: var(--amber); border-color: var(--amber); color: var(--navy); }
button.danger { background: var(--err); border-color: var(--err); }
button.sm, .btn.sm { padding: 4px 10px; font-size: 12.5px; border-radius: 7px; }
button.lg { padding: 12px 20px; font-size: 16px; }

input, select, textarea {
  font: inherit; border: 1px solid #cbd5e1; border-radius: 8px; padding: 8px 10px; background: #fff; color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--sky); border-color: var(--sky); }
input[type=checkbox] { width: auto; }
label.f { display: block; font-size: 12px; color: var(--ink2); font-weight: 600; }
label.f > input, label.f > select, label.f > textarea { margin-top: 4px; font-weight: 400; }
.form { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.form .wide { grid-column: 1 / -1; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }

table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; background: #f1f5fa; color: var(--ink2); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; }
table.t td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #f5f9ff; }
table.t td.n, table.t th.n { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-wrap { overflow: auto; max-height: 68vh; border-radius: 10px; border: 1px solid var(--line); }
.empty { padding: 30px; text-align: center; color: var(--muted); }

.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; background: #e8eef6; color: var(--ink2); white-space: nowrap; }
.b-DRAFT { background: #eceff3; color: #5b6673; }
.b-CONFIRMED, .b-PLANNED, .b-LABELED, .b-OPEN { background: #e3effc; color: #1a5fa8; }
.b-RECEIVING, .b-RECEIVED, .b-LOADING, .b-LOADED, .b-WASPADA, .b-PACKING { background: var(--warn-bg); color: var(--warn); }
.b-IN_WAREHOUSE, .b-STORED, .b-CLOSED, .b-READY, .b-PACKED { background: #e6f4fb; color: #0f6f9a; }
.b-SHIPPED, .b-DEPARTED, .b-ARRIVED, .b-UNLOADING { background: #ece6fb; color: #5b3fb0; }
.b-DELIVERED, .b-COMPLETED, .b-NORMAL, .b-OK { background: var(--ok-bg); color: var(--ok); }
.b-CANCELLED, .b-KRITIS, .b-ERR { background: var(--err-bg); color: var(--err); }
.b-OVERSTOCK { background: #efe7fb; color: #6b3fb0; }
.mode { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 5px; color: #fff; }
.mode.TRUCK { background: #0b5394; }
.mode.SEA { background: #2b8fc0; }
.mode.AIR { background: #c98a08; }

.kpi { display: flex; flex-direction: column; gap: 2px; }
.kpi .v { font-size: 26px; font-weight: 700; color: var(--blue); font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 12px; color: var(--muted); }

/* toast */
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); max-width: 380px; animation: slide .2s; }
.toast.err { background: var(--err); }
.toast.ok { background: var(--ok); }
@keyframes slide { from { transform: translateY(10px); opacity: 0; } }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(13, 27, 62, .5); z-index: 500; display: grid; place-items: center; padding: 16px; }
.modal { background: #fff; border-radius: 16px; width: min(720px, 100%); max-height: 92vh; overflow: auto; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
.modal header { padding: 14px 18px; background: var(--navy); color: #fff; display: flex; justify-content: space-between; align-items: center; border-radius: 16px 16px 0 0; position: sticky; top: 0; z-index: 2; }
.modal header button { background: none; border: 0; font-size: 22px; padding: 0 4px; }
.modal .body { padding: 18px; }

/* ---------- Dashboard ---------- */
.dash { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; }
.hero {
  background: radial-gradient(ellipse at 70% 20%, #1f3c75 0%, var(--navy) 60%); color: #fff; border-radius: var(--radius); padding: 22px 24px;
  position: relative; overflow: hidden; min-height: 150px; display: flex; justify-content: space-between; gap: 16px;
}
.hero h2 { font-size: 26px; font-weight: 600; }
.hero p { margin: 4px 0 0; opacity: .8; font-size: 15px; }
.hero .routes { text-align: right; font-size: 13px; color: var(--sky-l); line-height: 1.75; z-index: 1; }
.hero svg.map { position: absolute; right: 240px; top: 0; height: 100%; opacity: .6; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { padding: 4px 11px; border-radius: 7px; background: #fff; border: 1px solid #c9d8ea; color: var(--blue2); font-size: 12px; cursor: pointer; font-weight: 600; }
.chip.on { background: var(--blue2); color: #fff; border-color: var(--blue2); }
.gauge-card { display: flex; align-items: center; gap: 14px; }
.gauge { width: 88px; height: 88px; position: relative; flex-shrink: 0; }
.gauge span { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: 15px; color: var(--ink2); }
.sign { border-radius: 12px; background: var(--blue); color: #fff; text-align: center; padding: 14px 10px; border: 3px solid #fff; outline: 2px solid var(--blue); }
.sign .v { font-size: 26px; font-weight: 700; }
.sign .l { font-size: 12px; opacity: .9; }
.side-panel { display: flex; flex-direction: column; gap: 16px; }
.hbar { display: grid; grid-template-columns: 110px 1fr auto; gap: 8px; align-items: center; font-size: 12.5px; margin: 7px 0; }
.hbar .track { background: #eef2f7; border-radius: 4px; height: 12px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--blue); border-radius: 0 4px 4px 0; }
.hbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--ink2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.alert-item { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.alert-item:last-child { border-bottom: 0; }

/* stepper */
.stepper { display: flex; gap: 0; overflow-x: auto; padding: 6px 0; }
.step { flex: 1; min-width: 92px; text-align: center; position: relative; font-size: 11.5px; color: var(--muted); }
.step::before { content: ''; position: absolute; top: 13px; left: -50%; width: 100%; height: 3px; background: #d6e0eb; z-index: 0; }
.step:first-child::before { display: none; }
.step .dot { width: 28px; height: 28px; border-radius: 50%; background: #d6e0eb; color: #fff; display: grid; place-items: center; margin: 0 auto 4px; position: relative; z-index: 1; font-weight: 700; font-size: 12px; }
.step.done { color: var(--ink); }
.step.done .dot, .step.done::before { background: var(--blue2); }
.step.cur .dot { background: var(--yellow); color: var(--navy); box-shadow: 0 0 0 4px rgba(246, 216, 96, .35); }

/* ---------- Scan station ---------- */
.station-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.station { border-radius: var(--radius); padding: 20px; color: #fff; text-decoration: none !important; display: block; box-shadow: var(--shadow); min-height: 130px; position: relative; }
.station .n { font-size: 34px; font-weight: 800; opacity: .35; position: absolute; right: 14px; top: 6px; }
.station b { font-size: 17px; display: block; margin-top: 30px; }
.station span { font-size: 12.5px; opacity: .9; }
.scan-wrap { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; }
.scan-input { font-size: 22px; padding: 14px 16px; border: 3px solid var(--blue2); border-radius: 12px; font-family: monospace; letter-spacing: 1px; }
.flash { border-radius: 14px; padding: 18px; font-size: 18px; font-weight: 600; min-height: 76px; display: flex; align-items: center; gap: 12px; background: #eef3f9; color: var(--ink2); }
.flash.ok { background: var(--ok); color: #fff; }
.flash.err { background: var(--err); color: #fff; animation: shake .3s; }
.flash .big { font-size: 32px; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.ctx { border: 2px dashed #b9cde3; border-radius: 12px; padding: 12px 14px; background: #f7faff; }
.ctx.set { border-style: solid; border-color: var(--ok); background: var(--ok-bg); }
.ctx b { font-size: 16px; }
#reader { width: 100%; border-radius: 12px; overflow: hidden; background: #000; }
#reader video { border-radius: 12px; }
.loglist { max-height: 340px; overflow: auto; font-size: 12.5px; }
.loglist div { padding: 6px 8px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; }
.loglist .x { color: var(--err); font-weight: 700; }
.loglist .v { color: var(--ok); font-weight: 700; }
.progress { height: 10px; background: #e6edf5; border-radius: 6px; overflow: hidden; }
.progress > div { height: 100%; background: var(--ok); }

/* ---------- Login ---------- */
.login-bg { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(ellipse at 30% 10%, #1f6fb2 0%, var(--navy) 65%); }
.login { width: min(400px, 100%); background: #fff; border-radius: 18px; padding: 30px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.login .brand { color: var(--navy); border-color: var(--line); }
.login .brand .logo { background: var(--blue); color: #fff; }

/* ---------- Responsif ---------- */
@media (max-width: 1100px) {
  .dash { grid-template-columns: 1fr; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero svg.map { display: none; }
}
@media (max-width: 820px) {
  .sidebar { position: fixed; left: -260px; z-index: 100; transition: left .2s; }
  .sidebar.open { left: 0; }
  .burger { display: block; }
  .content { padding: 14px; }
  .g2, .g3, .scan-wrap { grid-template-columns: 1fr; }
  .topbar { padding: 10px 14px; }
  .topbar .user span { display: none; }
}
@media print {
  .sidebar, .topbar, .noprint { display: none !important; }
  .content { padding: 0; }
  .card { box-shadow: none; }
}

/* perbaikan layout dashboard */
.dash > .grid { align-content: start; }
.dash .grid { align-items: stretch; }
.brand .logo { font-size: 11px; }
.gauge-card .v { white-space: nowrap; }
.gauge-card h3 { white-space: nowrap; }
.sign { display: flex; flex-direction: column; justify-content: center; }
.hero { max-height: 200px; }
.grid > * { min-width: 0; }
@media (max-width: 820px) {
  .topbar .sub, .topbar .user { display: none; }
  .topbar h1 { font-size: 17px; }
}
