/* =========================================================
   CycleCounter — theme.css (v1.3)
   Dimuat SETELAH app.css. Hapus link-nya untuk kembali ke tampilan lama.
   Arah: tegas, rapi, dewasa. Grafit + satu aksen kobalt.
   Amber hanya untuk status "sedang berjalan". Satu blok gelap: pallet aktif.
   ========================================================= */

:root {
  --navy-900: #0d1117;
  --navy-800: #151b23;
  --navy-700: #2a3340;
  --navy-600: #435061;
  --ink: #12171d;
  --ink-2: #394350;
  --muted: #66717e;
  --muted-2: #8b95a1;
  --bg: #f1f3f5;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --line: #d6dbe1;
  --line-soft: #e6e9ed;
  --accent: #2457f5;
  --accent-600: #1a43cc;
  --accent-soft: #e9efff;
  --amber: #f2a900;
  --amber-600: #b57600;
  --amber-soft: #fff3d1;
  --green: #1a8a54;
  --green-600: #14703f;
  --green-soft: #e2f4ea;
  --red: #c62d2d;
  --red-soft: #fdeaea;
  --blue: #2457f5;
  --blue-soft: #e9efff;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(13, 17, 23, .05);
  --shadow: 0 8px 24px -12px rgba(13, 17, 23, .22);
  --shadow-lg: 0 24px 60px -16px rgba(13, 17, 23, .38);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, "Roboto Mono", monospace;
}

body { background: var(--bg); font-size: 14px; }
::selection { background: rgba(36, 87, 245, .22); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.scan-bar input:focus-visible, .input:focus-visible, .search-box input:focus-visible { outline: 0; }

/* Label sentence case, angka rata (tabular) */
.eyebrow, table.data th, .clock-date, .brand-text span, .pstat .k, .stat .k,
.summary-card .sk, .detail-stat .k, .detail-section-title, .code-readonly span {
  text-transform: none; letter-spacing: 0;
}
.eyebrow { font-size: 12px; font-weight: 600; }
.mono, .cycle-val, .stat .v, .pstat .v, .timer, .clock-time, table.data td { font-variant-numeric: tabular-nums; }

/* ============ Sidebar: rata penuh, dipisah garis ============ */
.sidebar {
  width: 228px; margin: 0; top: 0; height: 100vh;
  padding: 18px 12px 16px;
  color: var(--ink); background: var(--surface);
  border-radius: 0; border-right: 1px solid var(--line); box-shadow: none;
}
.sidebar::before { display: none; }
.brand { padding: 2px 8px 20px; border-bottom: 1px solid var(--line-soft); margin-bottom: 14px; }
.brand-mark { width: 38px; height: 38px; border-radius: 8px; background: var(--navy-800); color: #fff; box-shadow: none; }
.brand-mark svg { width: 22px; height: 22px; }
.brand-text strong { font-size: 16px; font-weight: 700; letter-spacing: -.2px; }
.brand-text span { font-size: 12px; color: var(--muted); margin-top: 1px; }
.nav { gap: 2px; margin-top: 0; }
.nav-item {
  padding: 10px 12px; border-radius: 8px; font-size: 14px; font-weight: 600;
  color: var(--ink-2); border: 0;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-600); box-shadow: inset 3px 0 0 var(--accent); border: 0; }
.nav-badge { background: var(--amber); color: #2b1c00; border-radius: 6px; }
.save-pill { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line-soft); border-radius: 6px; padding: 6px 9px; }
.save-pill .dot { background: var(--green); box-shadow: none; }
.save-pill.saving .dot { background: var(--amber); box-shadow: none; }
.sidebar-note { color: var(--muted-2); }

/* ============ Topbar ============ */
.topbar {
  background: var(--surface); backdrop-filter: none;
  border-bottom: 1px solid var(--line); padding: 14px 28px;
}
.topbar-title h1 { font-size: 21px; font-weight: 700; letter-spacing: -.3px; }
.topbar-title p { font-size: 13px; color: var(--muted); }
.clock-box { flex-direction: row; align-items: baseline; gap: 10px; padding-left: 16px; border-left: 1px solid var(--line); }
.clock-time { font-size: 18px; font-weight: 700; }
.clock-date { margin: 0; font-size: 12.5px; }
.status-chip { border-radius: 6px; padding: 6px 10px; background: var(--green-soft); border: 0; color: var(--green-600); }
.status-chip .dot { background: var(--green); }
.status-chip.off { background: var(--red-soft); color: var(--red); }
.status-chip.off .dot { background: var(--red); }
.status-chip.sync { background: var(--amber-soft); color: #7a5200; }
.status-chip.sync .dot { background: var(--amber); }
.status-chip.error { background: var(--red-soft); color: var(--red); }
.status-chip.error .dot { background: var(--red); }
.sync-chip { border: 1px solid var(--line); }
.content { padding: 24px 28px 56px; }

/* ============ Kartu ============ */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: none; padding: 20px; }
.card-title { font-size: 15px; font-weight: 700; letter-spacing: -.1px; }
.card-head { margin-bottom: 16px; }
.scan-grid { gap: 20px; }
.scan-main, .scan-side { gap: 16px; }
.guide-card { background: var(--surface); }
.section-title { border-top-color: var(--line-soft); }

/* ============ Tombol ============ */
.btn { border-radius: 8px; padding: 9px 15px; font-size: 13.5px; font-weight: 600; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 7px; }
.btn-lg { border-radius: 9px; }
.btn-icon { border-radius: 8px; }
.btn-primary { background: var(--navy-800); color: #fff; box-shadow: none; }
.btn-primary:hover { background: var(--navy-700); }
.btn-accent { background: var(--accent); color: #fff; box-shadow: none; }
.btn-accent:hover { background: var(--accent-600); filter: none; }
.btn-quiet { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-quiet:hover { background: var(--surface-2); border-color: #bcc4ce; }
.btn-danger-soft { background: #fff; color: var(--red); border-color: #efbcbc; }
.btn-danger-soft:hover { background: var(--red-soft); }
.btn-on-dark { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .22); }
.btn-on-dark:hover { background: rgba(255, 255, 255, .16); }
.link-btn { color: var(--accent); }
table.data .row-actions .btn { border-radius: 7px; background: transparent; border-color: transparent; }
table.data .row-actions .btn:hover { background: var(--surface-2); border-color: var(--line); }

/* ============ Form ============ */
.input, select.input, textarea.input { border: 1px solid #c3cad3; border-radius: 8px; background: #fff; padding: 10px 12px; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(36, 87, 245, .16); }
.field > span, .field > label { color: var(--ink); }
.search-box { border-radius: 8px; background: #fff; border-color: #c3cad3; }
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(36, 87, 245, .14); }
.filter-bar { border-bottom-color: var(--line-soft); }
.switch span { background: #bcc4ce; }
.switch input:checked + span { background: var(--accent); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px rgba(36, 87, 245, .25); }
.setting-row strong { font-weight: 700; }

/* ============ Pallet aktif: satu-satunya blok gelap ============ */
.pallet-card { border-radius: 12px; padding: 24px; }
.pallet-card.is-active {
  background: var(--navy-900); color: #fff;
  border: 0; border-top: 4px solid var(--amber);
  box-shadow: 0 18px 36px -22px rgba(13, 17, 23, .7);
}
.pallet-card.is-active .eyebrow { color: rgba(255, 255, 255, .6); }
.pallet-id { font-weight: 700; letter-spacing: 0; }
.pallet-id .id-accent { color: var(--amber); }
.pallet-sup { color: rgba(255, 255, 255, .9); }
.pallet-sup .code-chip { background: transparent; border: 1px solid rgba(255, 255, 255, .28); color: #fff; border-radius: 5px; padding: 2px 7px; }
.pallet-timer .timer { font-size: clamp(32px, 4vw, 46px); font-weight: 700; color: #fff; }
.pallet-timer .timer-sub { color: rgba(255, 255, 255, .55); }
.pallet-stats { gap: 8px; margin-top: 22px; }
.pstat { background: #181f29; border: 1px solid #2a3340; border-radius: 8px; padding: 12px 14px; }
.pstat .k { font-size: 12px; color: rgba(255, 255, 255, .55); }
.pstat .v { font-size: 20px; font-weight: 700; }
.pallet-actions { border-top-color: #2a3340; }

/* Kondisi kosong */
.empty-hero::after { display: none; }
.empty-icon { width: 56px; height: 56px; border-radius: 10px; background: var(--navy-800); color: #fff; box-shadow: none; }
.empty-body h2 { font-size: 21px; font-weight: 700; }
.hero-step { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; }
.hero-step b { background: var(--navy-800); color: #fff; border-radius: 4px; }

/* ============ Panel scan ============ */
.scan-panel { padding: 20px; }
.seg { background: #e8ebef; border: 0; border-radius: 9px; padding: 3px; }
.seg button { border-radius: 7px; padding: 7px 14px; font-size: 13px; color: var(--ink-2); }
.seg button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(13, 17, 23, .18); }
.scan-bar {
  min-height: 60px; padding: 6px; gap: 6px;
  background: #fff; border: 2px solid var(--navy-800); border-radius: 10px;
}
.scan-bar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(36, 87, 245, .16); }
.scan-bar:has(input:disabled) { border-color: var(--line); background: var(--surface-2); }
.scan-bar-icon { width: 42px; color: var(--navy-800); }
.scan-bar input { font-size: 17px; font-weight: 700; }
.scan-bar input::placeholder { font-size: 14.5px; color: var(--muted-2); }
.scan-bar .btn { border-radius: 7px; padding: 0 18px; }
.scan-bar .btn-quiet { background: var(--surface-2); border-color: var(--line-soft); }
.active-box-bar { background: var(--amber-soft); border: 1px solid #f1d78f; border-radius: 6px; color: #6b4600; }
.active-box-bar .box-finish { border-radius: 5px; background: rgba(107, 70, 0, .14); color: #6b4600; }

/* ============ Tabel ============ */
.table-wrap { border: 1px solid var(--line); border-radius: 8px; }
table.data th { background: var(--surface-2); color: var(--ink-2); font-size: 12px; font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--line); }
table.data td { padding: 11px 14px; border-bottom-color: var(--line-soft); }
table.data tbody tr:hover td { background: #f9fafc; }
table.data .box-row td { background: #f3f5f8; border-top: 1px solid var(--line); border-bottom-color: var(--line-soft); }
table.data .box-row.active td { background: var(--amber-soft); }
table.data .box-row:hover td { background: #edf0f5; }
table.data .box-row.active:hover td { background: #ffecb8; }
table.data .legacy-row td { background: var(--surface-2); }
table.data .live-cycle { color: var(--amber-600); }
.table-note { background: var(--surface-2); }
.empty-table .ic { color: #b5bec9; }
.badge { border-radius: 5px; padding: 2px 8px; font-size: 11.5px; font-weight: 700; }
.badge-gray { background: #e8ebef; color: #46515e; }
.badge-navy { background: #e1e6ee; color: var(--navy-700); }
.badge-amber { background: var(--amber-soft); color: #6b4600; }
.badge-blue { background: var(--accent-soft); color: var(--accent-600); }
tr.row-new td { animation-name: rowFlashSoft; }
@keyframes rowFlashSoft { 0% { background: #dfe8ff; } 100% { background: transparent; } }

/* ============ Sisi kanan ============ */
.stat { border: 1px solid var(--line-soft); border-radius: 8px; background: var(--surface-2); padding: 12px 14px; }
.stat .k { font-size: 12px; font-weight: 600; }
.stat .v { font-size: 22px; font-weight: 700; }
.stat.hero { background: var(--navy-800); border-color: var(--navy-800); }
.stat.hero .k { color: rgba(255, 255, 255, .6); }
.stat.hero .v { color: #fff; }
.open-item { border: 1px solid var(--line-soft); border-radius: 8px; background: #fff; }
.open-item:hover { background: var(--surface-2); border-color: var(--line); }
.open-item.active { background: var(--amber-soft); border-color: #f1d78f; }
.open-item .oi-dot { box-shadow: none; }
.today-item { border-radius: 8px; border-color: var(--line-soft); }
.summary-card { border: 1px solid var(--line); border-radius: 10px; box-shadow: none; }
.summary-card .si { border-radius: 8px; background: #e8ebef; color: var(--navy-700); }
.summary-card.amber .si { background: var(--amber-soft); color: var(--amber-600); }
.summary-card.green .si { background: var(--green-soft); color: var(--green-600); }
.summary-card.blue .si { background: var(--accent-soft); color: var(--accent); }
.box-list-row.active { background: var(--amber-soft); border-radius: 6px; }
.box-list-row.active .pname strong { color: #6b4600; }

/* ============ Panduan, callout, pengaturan ============ */
.steps li > span { border-radius: 6px; background: var(--navy-800); color: #fff; border: 0; }
.callout { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; color: var(--ink-2); }
.callout .ic { color: var(--accent); }
.callout.warn { background: var(--amber-soft); border-color: #f1d78f; color: #6b4600; }
.callout.danger { background: var(--red-soft); border-color: #efbcbc; color: #8e1f1f; }
.storage-box { border-radius: 8px; background: var(--surface-2); }
.storage-track { background: #dfe4ea; }
.storage-track span { background: var(--accent); }
.danger-zone { border: 1px solid #efbcbc; border-radius: 8px; background: #fff; }

/* Sinkronisasi data bersama */
.sync-box { padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.sync-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sync-head strong { font-size: 13.5px; }
.sync-fields { display: grid; gap: 10px; margin-top: 12px; }
.sync-fields .field > span { font-size: 11.5px; font-weight: 600; }
.sync-fields .input { width: 100%; font-size: 12px; padding: 9px 10px; }
.sync-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.sync-note { margin-top: 10px; font-size: 11.5px; }
.sync-warning { margin-top: 12px; }
.sync-warning p { font-size: 11.5px; }
.code-examples code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; }
.preview-sheet { background: var(--surface-2); border: 1px dashed #b8c1cc; border-radius: 8px; }
.export-choice { border-radius: 8px; }
.export-choice:hover { border-color: var(--accent); background: var(--accent-soft); }

/* ============ Toast ============ */
.toast { border: 1px solid var(--line); border-radius: 10px; border-left-width: 1px; padding: 12px 14px; box-shadow: var(--shadow); }
.toast .t-title { font-weight: 700; font-size: 13.5px; }
.toast .ic { width: 19px; height: 19px; }
.toast.info .ic { color: var(--accent); }

/* ============ Modal ============ */
.modal-backdrop { background: rgba(13, 17, 23, .55); backdrop-filter: none; }
.modal { border-radius: 14px; }
.modal-head { padding: 20px 24px 16px; border-bottom: 1px solid var(--line-soft); }
.modal-head h2 { font-size: 18px; font-weight: 700; }
.modal-body { padding: 20px 24px; }
.modal-foot { background: var(--surface-2); border-top: 1px solid var(--line-soft); padding: 14px 24px; }
.modal-x { border-radius: 8px; background: transparent; }
.modal-x:hover { background: var(--surface-2); }
.confirm-icon { border-radius: 10px; }
.detail-stat { border-radius: 8px; }

/* ============ Kamera ============ */
.camera-overlay { background: rgba(8, 11, 15, .95); }
.camera-video-wrap { border-radius: 12px; }
.cam-frame { border-radius: 8px; }
.cam-frame::before, .cam-frame::after { border-color: #fff; }
.cam-frame::before { border-top-left-radius: 8px; }
.cam-frame::after { border-bottom-right-radius: 8px; }
.cam-laser { background: linear-gradient(90deg, transparent, rgba(255, 70, 70, .9), transparent); }
.cam-controls { border-radius: 10px; }
.cam-controls select { border-radius: 7px; }
.cam-last, .cam-count { border-radius: 7px; }
.cam-count { background: var(--green); }
.cam-controls .btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.cam-controls .btn.active .ic { color: #fff; }

/* ============ Responsif ============ */
@media (max-width: 980px) {
  .app-shell { flex-direction: column; }
  /* Navigasi bar bawah, penuh lebar */
  .sidebar {
    position: fixed; top: auto; left: 0; right: 0; bottom: 0;
    width: auto; height: auto; margin: 0;
    padding: 0 6px env(safe-area-inset-bottom, 0px);
    border-right: 0; border-top: 1px solid var(--line); border-radius: 0;
    box-shadow: 0 -8px 24px -16px rgba(13, 17, 23, .25); z-index: 60;
  }
  .brand, .sidebar-foot { display: none; }
  .nav { width: 100%; flex-direction: row; justify-content: space-between; gap: 0; overflow: visible; }
  .nav-item {
    flex: 1; flex-direction: column; justify-content: center; gap: 3px;
    padding: 9px 2px 8px; border-radius: 0; font-size: 11px; font-weight: 600; color: var(--muted);
  }
  .nav-item span { display: inline; }
  .nav-item .ic { width: 22px; height: 22px; }
  .nav-item.active { background: transparent; color: var(--accent-600); box-shadow: inset 0 3px 0 var(--accent); }
  .nav-badge { position: absolute; top: 5px; left: 55%; margin: 0; min-width: 18px; height: 18px; font-size: 10px; }

  .topbar { top: 0; padding: 12px 18px; }
  .topbar-title h1 { font-size: 19px; }
  .content { padding: 16px 18px calc(92px + env(safe-area-inset-bottom, 0px)); }
  .toast-stack { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); left: 14px; right: 14px; width: auto; }
}

@media (max-width: 760px) {
  .card { padding: 16px; border-radius: 10px; }
  .pallet-card { padding: 18px; }
  .scan-bar { border-radius: 10px; }
  .scan-bar .btn { padding: 11px 16px; }
  .topbar { padding: 11px 14px; }
  .content { padding-left: 14px; padding-right: 14px; }

  /* Modal menjadi bottom sheet */
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal {
    max-width: 100%; max-height: 92vh; border-radius: 14px 14px 0 0;
    animation: sheetUp .22s cubic-bezier(.2, .9, .3, 1) both;
  }
  .modal-head, .modal-body, .modal-foot { padding-left: 18px; padding-right: 18px; }
  .modal-foot { padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
}
@keyframes sheetUp { from { transform: translateY(32px); opacity: .7; } to { transform: none; opacity: 1; } }

@media (max-width: 520px) {
  .nav-item span { display: inline; }
  .nav-item { padding: 9px 2px 8px; }
  .scan-bar .btn span { display: none; }
}

@media print {
  .sidebar, .toast-stack { display: none !important; }
}
