/* =========================================================
   CycleCounter — Incoming Control
   ========================================================= */

:root {
  --navy-900: #0a1c30;
  --navy-800: #0f2742;
  --navy-700: #153a5f;
  --navy-600: #1b4b77;
  --ink: #102033;
  --ink-2: #33475f;
  --muted: #64748b;
  --muted-2: #8b9bb0;
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --line: #dbe3ec;
  --line-soft: #e9eef5;
  --amber: #f59e0b;
  --amber-600: #d97706;
  --amber-soft: #fff5e2;
  --green: #0f9d72;
  --green-600: #0b7f5c;
  --green-soft: #e5f8f1;
  --red: #dc2626;
  --red-soft: #feecec;
  --blue: #2563eb;
  --blue-soft: #eaf0ff;
  --violet: #7c3aed;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow-sm: 0 1px 2px rgba(15, 39, 66, .05), 0 1px 3px rgba(15, 39, 66, .06);
  --shadow: 0 10px 30px -12px rgba(15, 39, 66, .18), 0 2px 8px rgba(15, 39, 66, .05);
  --shadow-lg: 0 28px 70px -20px rgba(10, 28, 48, .4);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Mono", "Cascadia Code", Consolas, "SFMono-Regular", "Roboto Mono", monospace;
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 90% -10%, rgba(245, 158, 11, .07), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, rgba(37, 99, 235, .05), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
code, .mono { font-family: var(--mono); }
::selection { background: rgba(245, 158, 11, .3); }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic-sm { width: 15px; height: 15px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-variant-ligatures: none; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ============ App shell ============ */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 236px;
  flex: none;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 14px 18px;
  color: #e9f0f8;
  background:
    radial-gradient(500px 300px at 20% 0%, rgba(245, 158, 11, .12), transparent 65%),
    linear-gradient(178deg, #102c4b 0%, var(--navy-900) 72%);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, .06);
  z-index: 40;
}
.sidebar::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .35;
  background-image: radial-gradient(rgba(255, 255, 255, .12) .6px, transparent .6px);
  background-size: 18px 18px;
  mask-image: linear-gradient(180deg, #000, transparent 55%);
}
.brand { position: relative; display: flex; align-items: center; gap: 11px; padding: 4px 8px 22px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  color: var(--navy-900);
  background: linear-gradient(150deg, #ffce6b, var(--amber));
  box-shadow: 0 6px 18px -6px rgba(245, 158, 11, .75), inset 0 1px 0 rgba(255, 255, 255, .5);
}
.brand-mark svg { width: 24px; height: 24px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-family: var(--font-display); font-size: 16.5px; letter-spacing: -.2px; }
.brand-text span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .13em; color: rgba(255, 255, 255, .5); margin-top: 3px; }

.nav { position: relative; display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  width: 100%; padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: rgba(233, 240, 248, .72);
  font-size: 13.5px; font-weight: 500;
  text-align: left;
  transition: background .16s ease, color .16s ease, transform .16s ease;
}
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(245, 158, 11, .2), rgba(245, 158, 11, .06));
  border-color: rgba(245, 158, 11, .28);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--amber);
}
.nav-item .ic { opacity: .9; }
.nav-badge {
  margin-left: auto; font-style: normal;
  min-width: 22px; height: 20px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; font-size: 11px; font-weight: 700;
  background: var(--amber); color: #422006;
}
.sidebar-foot { position: relative; margin-top: auto; padding: 16px 8px 0; }
.save-pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11.5px; color: rgba(233, 240, 248, .72);
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .08);
  padding: 6px 10px; border-radius: 999px;
}
.save-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, .15); }
.save-pill.saving .dot { background: var(--amber); box-shadow: 0 0 0 3px rgba(245, 158, 11, .18); }
.sidebar-note { font-size: 10.5px; line-height: 1.55; color: rgba(233, 240, 248, .38); margin-top: 10px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 17px 28px 16px;
  background: rgba(238, 242, 247, .86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(219, 227, 236, .8);
}
.topbar-title h1 { font-family: var(--font-display); font-size: 22px; font-weight: 700; letter-spacing: -.35px; }
.topbar-title p { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.clock-box { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.clock-time { font-family: var(--mono); font-size: 17px; font-weight: 600; letter-spacing: .02em; }
.clock-date { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .09em; margin-top: 2px; }
.status-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 11px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; color: #0b7f5c;
  background: var(--green-soft); border: 1px solid #c6f0e1;
  white-space: nowrap;
}
.status-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: #10b981; }
.status-chip.off { color: var(--red); background: var(--red-soft); border-color: #fbd5d5; }
.status-chip.off .dot { background: var(--red); }

.content { padding: 22px 28px 56px; width: 100%; max-width: 1560px; margin: 0 auto; }
.page { display: none; animation: pageIn .22s ease both; }
.page.active { display: block; }
@keyframes pageIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

/* ============ Generic card ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}
.card + .card { margin-top: 16px; }
.card-title { font-family: var(--font-display); font-size: 15.5px; font-weight: 700; letter-spacing: -.15px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.card-head .muted { font-size: 12px; margin-top: 2px; }
.head-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.section-title { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line-soft); }
.settings-desc { font-size: 12.5px; margin-top: 3px; margin-bottom: 10px; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 13px; font-weight: 600; line-height: 1.2;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .1s ease;
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn .ic { width: 16px; height: 16px; }
.btn-primary { background: var(--navy-800); color: #fff; box-shadow: 0 4px 12px -4px rgba(15, 39, 66, .4); }
.btn-primary:hover { background: var(--navy-700); }
.btn-accent { background: linear-gradient(160deg, #ffc24b, var(--amber)); color: #3d2500; box-shadow: 0 5px 14px -5px rgba(245, 158, 11, .65); }
.btn-accent:hover { filter: brightness(1.03); }
.btn-quiet { background: #fff; border-color: var(--line); color: var(--ink-2); }
.btn-quiet:hover { background: var(--surface-2); border-color: #c9d5e2; }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: rgba(15, 39, 66, .05); }
.btn-danger-soft { background: var(--red-soft); color: #b91c1c; border-color: #f7c9c9; }
.btn-danger-soft:hover { background: #fde0e0; }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: var(--green-600); }
.btn-sm { padding: 7px 10px; font-size: 12px; border-radius: 9px; }
.btn-sm .ic { width: 14px; height: 14px; }
.btn-lg { padding: 12px 18px; font-size: 14px; border-radius: 11px; }
.btn-icon { padding: 8px; width: 34px; height: 34px; }
.btn-icon .ic { width: 16px; height: 16px; }
.btn-on-dark { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .18); color: #fff; }
.btn-on-dark:hover { background: rgba(255, 255, 255, .17); }
.btn-danger-on-dark { background: rgba(220, 38, 38, .22); border-color: rgba(248, 113, 113, .4); color: #fecaca; }
.btn-danger-on-dark:hover { background: rgba(220, 38, 38, .32); }
.link-btn { border: 0; background: none; color: var(--blue); font-weight: 600; padding: 0; font-size: inherit; }
.link-btn:hover { text-decoration: underline; }

/* ============ Forms ============ */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .field > label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.input, select.input, textarea.input {
  width: 100%;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13.5px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(245, 158, 11, .18); }
.input-sm { padding: 8px 10px; font-size: 13px; }
.input.mono { font-family: var(--mono); letter-spacing: .02em; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.field-hint { font-size: 11.5px; color: var(--muted); }
.field-error { font-size: 11.5px; color: var(--red); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.search-box {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 10px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 9px;
  color: var(--muted);
}
.search-box:focus-within { border-color: var(--amber); background: #fff; box-shadow: 0 0 0 3px rgba(245, 158, 11, .14); }
.search-box .ic { width: 15px; height: 15px; }
.search-box input { border: 0; outline: none; background: transparent; width: 190px; font-size: 12.5px; color: var(--ink); }
.field-inline { display: flex; align-items: center; gap: 7px; }
.field-inline > span { font-size: 11.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.field-inline .input { width: auto; min-width: 120px; }
.field-inline.grow { flex: 1; min-width: 160px; }
.field-inline.grow .input { width: 100%; }

/* switch */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: #cbd5e1; transition: .18s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; background: #fff; top: 3px; left: 3px; box-shadow: 0 1px 4px rgba(0, 0, 0, .2); transition: .18s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::before { transform: translateX(18px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px rgba(15, 157, 114, .25); }

/* ============ Scan layout ============ */
.scan-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.scan-main, .scan-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.scan-main > .card + .card, .scan-side > * + * { margin-top: 0; }
.scan-side { position: sticky; top: 96px; max-height: calc(100vh - 112px); overflow-y: auto; padding-right: 2px; scrollbar-width: thin; }
.scan-side::-webkit-scrollbar { width: 6px; }
.scan-side::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }
.scan-side > div:empty { display: none; }

/* Active pallet dark card */
.pallet-card { padding: 22px; transition: background .2s ease; }
.pallet-card.is-active {
  color: #f5f9ff;
  border-color: transparent;
  background:
    radial-gradient(600px 240px at 100% 0%, rgba(245, 158, 11, .16), transparent 60%),
    linear-gradient(135deg, #0e2742 0%, #123c60 58%, #174b76 100%);
  box-shadow: 0 22px 45px -24px rgba(10, 28, 48, .65), inset 0 1px 0 rgba(255, 255, 255, .07);
}
.eyebrow { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.pallet-card.is-active .eyebrow { color: rgba(255, 255, 255, .5); }
.pallet-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.pallet-id { font-family: var(--mono); font-size: clamp(22px, 3vw, 31px); font-weight: 700; letter-spacing: .01em; line-height: 1.15; margin-top: 5px; word-break: break-all; }
.pallet-id .id-accent { color: #ffce6b; }
.pallet-sup { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 9px; font-size: 13.5px; color: rgba(255, 255, 255, .88); }
.pallet-sup .code-chip { font-family: var(--mono); font-size: 10.5px; font-weight: 600; padding: 2px 7px; border-radius: 6px; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .14); color: #ffd98f; }
.pallet-sup .ic { width: 16px; height: 16px; color: rgba(255, 255, 255, .5); }
.pallet-timer { text-align: right; flex: none; }
.pallet-timer .timer { font-family: var(--mono); font-size: clamp(26px, 3.4vw, 38px); font-weight: 700; letter-spacing: .02em; line-height: 1.05; color: #fff; margin-top: 4px; }
.pallet-timer .timer-sub { font-size: 11px; color: rgba(255, 255, 255, .48); margin-top: 4px; }
.pallet-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin-top: 20px; }
.pstat { padding: 10px 12px; border-radius: 11px; background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .08); min-width: 0; }
.pstat .k { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: rgba(255, 255, 255, .45); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pstat .v { display: block; font-family: var(--mono); font-size: 18px; font-weight: 700; margin-top: 3px; white-space: nowrap; }
.pstat .v small { font-family: var(--font); font-size: 10.5px; font-weight: 500; color: rgba(255, 255, 255, .5); margin-left: 2px; }
.pallet-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px solid rgba(255, 255, 255, .1); }
.pallet-actions .btn { font-size: 12.5px; padding: 8px 12px; }

/* Empty hero */
.empty-hero { display: flex; gap: 20px; align-items: flex-start; position: relative; overflow: hidden; }
.empty-hero::after {
  content: ""; position: absolute; right: -40px; top: -50px; width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 158, 11, .16), transparent 68%);
  pointer-events: none;
}
.empty-icon {
  width: 62px; height: 62px; flex: none; border-radius: 16px;
  display: grid; place-items: center;
  background: linear-gradient(150deg, var(--navy-800), var(--navy-600));
  color: #ffce6b; box-shadow: 0 10px 24px -10px rgba(15, 39, 66, .5);
}
.empty-icon .ic { width: 30px; height: 30px; }
.empty-body { min-width: 0; flex: 1; }
.empty-body h2 { font-family: var(--font-display); font-size: 21px; margin-top: 3px; letter-spacing: -.3px; }
.empty-body p { color: var(--muted); font-size: 13px; margin-top: 5px; max-width: 520px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 15px; }
.hero-steps { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 17px; }
.hero-step { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 999px; padding: 5px 10px; }
.hero-step b { width: 17px; height: 17px; display: inline-grid; place-items: center; border-radius: 50%; background: #e3ebf5; color: var(--navy-700); font-size: 10px; }

/* Scan panel */
.scan-panel { padding: 18px 20px 16px; }
.scan-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.scan-panel-head .muted { font-size: 12px; margin-top: 2px; }
.seg { display: inline-flex; padding: 3px; background: #eef2f7; border: 1px solid var(--line); border-radius: 10px; flex: none; }
.seg button {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; background: transparent; color: var(--muted);
  padding: 6px 11px; border-radius: 7px; font-size: 12px; font-weight: 600;
  transition: .15s;
}
.seg button .ic { width: 14px; height: 14px; }
.seg button.active { background: #fff; color: var(--navy-800); box-shadow: 0 1px 4px rgba(15, 39, 66, .14); }
.seg button:disabled { opacity: .4; cursor: not-allowed; }

.scan-bar {
  display: flex; align-items: stretch; gap: 8px;
  background: #fff;
  border: 2px solid var(--navy-800);
  border-radius: 13px;
  padding: 5px;
  transition: border-color .15s, box-shadow .15s;
}
.scan-bar:focus-within { border-color: var(--amber-600); box-shadow: 0 0 0 4px rgba(245, 158, 11, .18); }
.scan-bar:has(input:disabled) { border-color: var(--line); background: var(--surface-2); box-shadow: none; }
.scan-bar-icon { display: grid; place-items: center; width: 38px; color: var(--navy-700); }
.scan-bar-icon .ic { width: 21px; height: 21px; }
.scan-bar input {
  flex: 1; min-width: 0; border: 0; outline: none; background: transparent;
  font-family: var(--mono); font-size: 16px; font-weight: 600; letter-spacing: .02em;
  padding: 8px 2px;
}
.scan-bar input::placeholder { font-family: var(--font); font-weight: 400; color: var(--muted-2); font-size: 14px; letter-spacing: 0; }
.scan-bar .btn { border-radius: 9px; padding: 9px 13px; }
.scan-bar .btn-quiet { border-color: transparent; background: var(--surface-2); }
.scan-subbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.scan-context { font-size: 11.5px; color: var(--muted); margin-left: 2px; }
.scan-context strong { color: var(--ink-2); font-weight: 600; }
.active-box-bar {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11.5px; font-weight: 600; color: #92400e;
  background: var(--amber-soft); border: 1px solid #fde4b3;
  padding: 4px 6px 4px 9px; border-radius: 8px;
}
.active-box-bar .ic { width: 14px; height: 14px; }

/* Palette for scan last */
.scan-last { display: inline-flex; align-items: center; gap: 6px; }
.scan-last .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }

/* ============ Tables ============ */
.table-wrap { overflow: auto; border-radius: 10px; border: 1px solid var(--line-soft); }
.table-wrap.flush { border: 0; border-radius: 0; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  position: sticky; top: 0; z-index: 1;
  text-align: left; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); background: #f6f8fb;
  padding: 9px 12px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: #fafcff; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .mono { font-size: 12px; }
table.data .strong { font-weight: 700; }
table.data .row-actions { display: flex; gap: 4px; justify-content: flex-end; }
table.data .row-actions .btn { padding: 5px; width: 28px; height: 28px; border-radius: 7px; }
table.data .row-actions .ic { width: 14px; height: 14px; }
.empty-table { padding: 34px 18px; text-align: center; color: var(--muted); font-size: 12.5px; }
.empty-table .ic { width: 28px; height: 28px; color: #b8c5d5; margin-bottom: 7px; }
.empty-table strong { display: block; color: var(--ink-2); font-size: 13px; margin-bottom: 2px; }

.code-cell { display: flex; flex-direction: column; gap: 1px; min-width: 130px; }
.code-cell .code { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--ink); word-break: break-all; }
.code-cell .sub { font-size: 10.5px; color: var(--muted); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .01em; white-space: nowrap; }
.badge-gray { background: #eef2f7; color: #475569; }
.badge-amber { background: var(--amber-soft); color: #92400e; }
.badge-green { background: var(--green-soft); color: #0b7f5c; }
.badge-blue { background: var(--blue-soft); color: #1d4ed8; }
.badge-red { background: var(--red-soft); color: #b91c1c; }
.badge-navy { background: #e8eef7; color: var(--navy-700); }
.badge .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.cycle-val { font-family: var(--mono); font-weight: 700; font-size: 13px; }
.cycle-val small { font-family: var(--font); font-weight: 500; color: var(--muted); font-size: 10px; }
.delta { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }

tr.row-new td { animation: rowFlash 1.6s ease both; }
@keyframes rowFlash { 0% { background: #fff4d8; } 100% { background: transparent; } }

/* ============ Side stats ============ */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.stat { padding: 12px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--line-soft); min-width: 0; }
.stat .k { display: block; font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.stat .v { display: block; font-family: var(--mono); font-size: 21px; font-weight: 700; line-height: 1.2; margin-top: 3px; white-space: nowrap; }
.stat .v small { font-family: var(--font); font-size: 10px; color: var(--muted); font-weight: 500; }
.stat.hero { background: linear-gradient(150deg, #fff8e8, #fff3d8); border-color: #fbe3b0; }
.stat.hero .v { color: #92400e; }
.stat.green .v { color: var(--green-600); }
.stat.blue .v { color: var(--blue); }
.stat.navy .v { color: var(--navy-700); }
.card .card-title + .stat-grid { margin-top: 11px; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.side-head .hint { font-size: 10.5px; color: var(--muted); }

.chart-wrap { width: 100%; overflow: hidden; }
.chart-wrap svg { width: 100%; height: auto; display: block; }
.chart-legend { display: flex; gap: 14px; margin-top: 8px; font-size: 10.5px; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.chart-legend i { width: 8px; height: 8px; border-radius: 2px; background: var(--amber); }
.chart-legend i.avg { width: 14px; height: 0; border-top: 2px dashed var(--navy-600); border-radius: 0; background: none; }
.chart-empty { padding: 26px 10px; text-align: center; color: var(--muted); font-size: 12px; }

.part-list { display: flex; flex-direction: column; gap: 0; margin: 0 -4px; }
.part-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 4px; border-bottom: 1px solid var(--line-soft); }
.part-row:last-child { border-bottom: 0; }
.part-row .pname { min-width: 0; }
.part-row .pname strong { display: block; font-family: var(--mono); font-size: 11.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 190px; }
.part-row .pname span { font-size: 10px; color: var(--muted); }
.part-row .pval { text-align: right; flex: none; }
.part-row .pval strong { font-family: var(--mono); font-size: 11.5px; }
.part-row .pval span { display: block; font-size: 10px; color: var(--muted); }

.open-list { display: flex; flex-direction: column; gap: 6px; }
.open-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  text-align: left; padding: 9px 10px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--line-soft);
  transition: .15s;
}
.open-item:hover { background: #f1f6fc; border-color: #cddbeb; }
.open-item.active { background: #fff9ec; border-color: #f8d99b; }
.open-item .oi-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); flex: none; box-shadow: 0 0 0 3px rgba(245, 158, 11, .16); }
.open-item .oi-main { min-width: 0; flex: 1; }
.open-item .oi-id { font-family: var(--mono); font-size: 11px; font-weight: 700; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.open-item .oi-sub { font-size: 10px; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.open-item .oi-val { font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--ink-2); flex: none; }
.side-empty { padding: 18px 8px; text-align: center; font-size: 11.5px; color: var(--muted); }

.today-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.today-item { background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 10px; padding: 9px 11px; }
.today-item .k { font-size: 10px; color: var(--muted); display: block; }
.today-item .v { font-family: var(--mono); font-size: 17px; font-weight: 700; margin-top: 1px; }

/* ============ Labels ============ */
.label-layout, .supplier-layout, .settings-grid { display: grid; gap: 16px; align-items: start; }
.label-layout { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.supplier-layout { grid-template-columns: minmax(0, 5fr) minmax(0, 3fr); }
.settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
/* Kartu grid harus sejajar atas; aturan .card + .card hanya untuk kartu bertumpuk. */
.label-layout > .card + .card,
.supplier-layout > .card + .card,
.settings-grid > .card + .card { margin-top: 0; }
.guide-card { background: linear-gradient(180deg, #fff, #fafcff); }
.steps { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-direction: column; gap: 13px; }
.steps li { display: flex; gap: 10px; align-items: flex-start; }
.steps li > span {
  width: 24px; height: 24px; flex: none; border-radius: 8px;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: var(--navy-700);
  background: #e9f0f8; border: 1px solid #d5e2f0;
}
.steps li strong { display: block; font-size: 12.5px; }
.steps li p { font-size: 11.5px; color: var(--muted); margin-top: 1px; line-height: 1.45; }
.callout {
  display: flex; gap: 9px; align-items: flex-start;
  margin-top: 16px; padding: 11px 12px;
  background: var(--blue-soft); border: 1px solid #d5e3ff; border-radius: 10px;
  font-size: 11.5px; color: #1e40af; line-height: 1.5;
}
.callout .ic { width: 15px; height: 15px; flex: none; margin-top: 1px; }
.callout.warn { background: var(--amber-soft); border-color: #fbe3b0; color: #92400e; }
.callout.danger { background: var(--red-soft); border-color: #f7c9c9; color: #991b1b; }
.callout strong { font-weight: 700; }

.generator-actions { display: flex; gap: 8px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.generator-actions .spacer { flex: 1; }
.gen-note { font-size: 11px; color: var(--muted); margin-top: 10px; }
.label-preview-wrap { margin-top: 16px; }
.preview-sheet {
  display: flex; flex-wrap: wrap; gap: 10px;
  padding: 16px; background: #f1f5f9; border: 1px dashed #cbd5e1; border-radius: 12px;
  max-height: 620px; overflow: auto;
}
.plabel-scaler { flex: none; }
.plabel {
  --lw: 100mm; --lh: 50mm;
  width: var(--lw); height: var(--lh);
  padding: 3mm 3.5mm;
  background: #fff; color: #000;
  border: 1px dashed #c2ccd8;
  display: flex; flex-direction: column; overflow: hidden;
  font-family: var(--font);
}
.plabel-previews .plabel { transform-origin: top left; }
.plabel-top { display: flex; align-items: center; justify-content: space-between; gap: 5mm; flex: none; }
.plabel-brand { font-size: 6.5pt; font-weight: 800; letter-spacing: .1em; color: #0f2742; }
.plabel-date { font-size: 6pt; color: #333; white-space: nowrap; }
.plabel-sup {
  font-size: 8.5pt; font-weight: 700; line-height: 1.15;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-bottom: .35mm solid #000; padding-bottom: .7mm; margin-top: 1mm; flex: none;
}
.plabel-barcode { width: 100%; flex: 1; min-height: 0; margin: .7mm 0; }
.plabel-barcode svg, .plabel-barcode img { width: 100%; height: 100%; display: block; }
.plabel-id { font-family: var(--mono); font-weight: 700; font-size: 10pt; letter-spacing: .03em; text-align: center; white-space: nowrap; overflow: hidden; flex: none; }
.plabel-foot { display: flex; align-items: center; justify-content: space-between; gap: 4mm; font-size: 5.5pt; color: #333; margin-top: .6mm; flex: none; }
.plabel-foot .po { font-weight: 700; letter-spacing: .05em; }
.plabel[data-size="75x50"] { padding: 2.5mm 3mm; }
.plabel[data-size="75x50"] .plabel-sup { font-size: 8pt; }
.plabel[data-size="75x50"] .plabel-id { font-size: 9pt; }
.plabel[data-size="50x30"] { padding: 1.8mm 2.2mm; --lw: 50mm; --lh: 30mm; }
.plabel[data-size="50x30"] .plabel-top { display: none; }
.plabel[data-size="50x30"] .plabel-sup { font-size: 6pt; margin-top: 0; border-bottom-width: .25mm; padding-bottom: .4mm; }
.plabel[data-size="50x30"] .plabel-id { font-size: 7pt; }
.plabel[data-size="50x30"] .plabel-foot { font-size: 4.5pt; margin-top: .2mm; }
.plabel[data-size="50x30"] .plabel-barcode { margin: .3mm 0; }
.plabel[data-size="100x75"] .plabel-sup { font-size: 10pt; }
.plabel[data-size="100x75"] .plabel-id { font-size: 12pt; }
.plabel[data-size="100x75"] .plabel-foot { font-size: 6pt; }

.label-list-card { margin-top: 16px; }
.label-search { width: 180px; }
.label-preview-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.label-preview-actions .muted { font-size: 12px; }
.label-preview-actions .spacer { flex: 1; }

/* ============ History ============ */
.filter-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; padding-bottom: 14px; margin-bottom: 4px; border-bottom: 1px solid var(--line-soft); }
.summary-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.summary-card { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: #fff; border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow-sm); }
.summary-card .si { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: #eef3f9; color: var(--navy-700); flex: none; }
.summary-card .si .ic { width: 19px; height: 19px; }
.summary-card .sk { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.summary-card .sv { display: block; font-family: var(--mono); font-size: 20px; font-weight: 700; line-height: 1.2; }
.summary-card .sv small { font-family: var(--font); font-size: 10px; color: var(--muted); }
.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(--blue-soft); color: var(--blue); }

/* ============ Suppliers ============ */
.code-examples { display: flex; flex-direction: column; gap: 7px; margin-top: 12px; }
.code-examples div { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.code-examples code { background: #eef2f7; border: 1px solid var(--line); padding: 3px 7px; border-radius: 6px; font-weight: 600; min-width: 64px; text-align: center; }
.code-examples span { color: var(--muted); }

/* ============ Settings ============ */
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 13px 0; border-bottom: 1px solid var(--line-soft); }
.setting-row:last-child { border-bottom: 0; }
.setting-row strong { font-size: 13px; font-weight: 600; }
.setting-row p { font-size: 11.5px; color: var(--muted); margin-top: 2px; max-width: 380px; }
.setting-row .input-sm { width: 120px; flex: none; }
.setting-row select.input-sm { width: auto; min-width: 130px; }
.storage-box { margin-top: 12px; padding: 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line-soft); }
.storage-head { display: flex; align-items: center; justify-content: space-between; font-size: 12px; }
.storage-head strong { font-weight: 600; }
.storage-head span { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.storage-track { height: 8px; border-radius: 99px; background: #e2e9f2; overflow: hidden; margin: 9px 0 7px; }
.storage-track span { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, #34d399, #10b981); transition: width .3s; }
.storage-track span.warn { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.storage-track span.danger { background: linear-gradient(90deg, #f87171, #dc2626); }
.data-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.danger-zone { margin-top: 22px; padding: 14px; border: 1px dashed #f3b7b7; border-radius: 12px; background: #fffafa; }
.danger-zone h3 { font-size: 12.5px; color: #b91c1c; }
.danger-zone p { font-size: 11.5px; margin-top: 3px; }
.danger-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 11px; }
.about-list { display: flex; flex-direction: column; gap: 0; margin-top: 8px; }
.about-list div { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); font-size: 12px; }
.about-list div:last-child { border-bottom: 0; }
.about-list span { color: var(--muted); }
.about-list strong { font-weight: 600; }

/* ============ Toast ============ */
.toast-stack { position: fixed; right: 18px; bottom: 18px; z-index: 5000; display: flex; flex-direction: column; gap: 8px; pointer-events: none; width: min(360px, calc(100vw - 28px)); }
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 13px;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--navy-700);
  border-radius: 11px;
  box-shadow: var(--shadow-lg);
  font-size: 12.5px;
  animation: toastIn .22s cubic-bezier(.2, .9, .3, 1.2) both;
}
.toast .ic { width: 17px; height: 17px; flex: none; margin-top: 1px; }
.toast .t-main { min-width: 0; }
.toast .t-title { font-weight: 700; font-size: 12.5px; }
.toast .t-sub { color: var(--muted); font-size: 11.5px; margin-top: 1px; line-height: 1.4; word-break: break-word; }
.toast.success { border-left-color: var(--green); }
.toast.success .ic { color: var(--green); }
.toast.error { border-left-color: var(--red); }
.toast.error .ic { color: var(--red); }
.toast.warn { border-left-color: var(--amber); }
.toast.warn .ic { color: var(--amber-600); }
.toast.info { border-left-color: var(--blue); }
.toast.info .ic { color: var(--blue); }
.toast.out { animation: toastOut .2s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px); } }

/* ============ Modal ============ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 4000;
  background: rgba(10, 22, 38, .55);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
  animation: fadeIn .15s ease both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 520px; max-height: calc(100vh - 36px);
  background: #fff; border-radius: 18px;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  animation: modalIn .2s cubic-bezier(.2, .9, .3, 1.1) both;
  overflow: hidden;
}
.modal.sm { max-width: 420px; }
.modal.lg { max-width: 760px; }
.modal.xl { max-width: 1080px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 19px 21px 14px; border-bottom: 1px solid var(--line-soft); }
.modal-head h2 { font-family: var(--font-display); font-size: 17px; letter-spacing: -.2px; }
.modal-head p { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.modal-x { width: 30px; height: 30px; border-radius: 8px; border: 0; background: var(--surface-2); color: var(--muted); display: grid; place-items: center; flex: none; }
.modal-x:hover { background: #e9eef5; color: var(--ink); }
.modal-x .ic { width: 16px; height: 16px; }
.modal-body { padding: 18px 21px; overflow-y: auto; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px 21px 18px; border-top: 1px solid var(--line-soft); background: #fbfcfe; }
.modal-foot .spacer { flex: 1; }
.modal-foot .left { margin-right: auto; }
.modal-section + .modal-section { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.modal .form-grid { gap: 12px; }
.modal-note { font-size: 11.5px; color: var(--muted); margin-top: 8px; line-height: 1.5; }
.confirm-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--amber-soft); color: var(--amber-600); margin-bottom: 10px; }
.confirm-icon.danger { background: var(--red-soft); color: var(--red); }
.confirm-icon .ic { width: 21px; height: 21px; }
.detail-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.detail-stat { background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 10px; padding: 10px 11px; }
.detail-stat .k { font-size: 9.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); display: block; }
.detail-stat .v { font-family: var(--mono); font-size: 16px; font-weight: 700; display: block; margin-top: 2px; }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.detail-head .pid { font-family: var(--mono); font-size: 18px; font-weight: 700; word-break: break-all; }
.detail-head .psup { font-size: 12px; color: var(--muted); margin-top: 2px; }
.detail-toolbar { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; margin: 14px 0 10px; }
.detail-toolbar .spacer { flex: 1; }
.modal .table-wrap { max-height: 42vh; }
.kanban-detail-chart { margin-top: 14px; }

/* ============ Camera ============ */
.camera-overlay {
  position: fixed; inset: 0; z-index: 4500;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(4, 13, 24, .94);
  animation: fadeIn .18s ease both;
}
.camera-shell { width: min(780px, 100%); max-height: calc(100vh - 24px); display: flex; flex-direction: column; gap: 12px; }
.camera-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #fff; }
.camera-top h2 { font-family: var(--font-display); font-size: 16px; }
.camera-top p { font-size: 11.5px; color: rgba(255, 255, 255, .55); margin-top: 2px; }
.camera-video-wrap {
  position: relative; border-radius: 16px; overflow: hidden;
  background: #000; aspect-ratio: 16 / 10;
  border: 1px solid rgba(255, 255, 255, .14);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .8);
}
.camera-video-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-frame {
  position: absolute; inset: 16% 10%;
  border: 2px solid rgba(255, 255, 255, .25);
  border-radius: 14px;
  pointer-events: none;
  transition: border-color .2s;
}
.cam-frame::before, .cam-frame::after {
  content: ""; position: absolute; width: 34px; height: 34px; border: 3px solid var(--amber); border-radius: 6px;
}
.cam-frame::before { left: -3px; top: -3px; border-right: 0; border-bottom: 0; border-top-left-radius: 14px; }
.cam-frame::after { right: -3px; bottom: -3px; border-left: 0; border-top: 0; border-bottom-right-radius: 14px; }
.cam-frame.ok { border-color: rgba(52, 211, 153, .7); }
.cam-frame.ok::before, .cam-frame.ok::after { border-color: #34d399; }
.cam-laser {
  position: absolute; left: 12%; right: 12%; height: 2px; top: 50%;
  background: linear-gradient(90deg, transparent, rgba(245, 158, 11, .8), transparent);
  filter: blur(.4px);
  animation: laser 2.4s ease-in-out infinite;
}
@keyframes laser { 0%, 100% { top: 32%; opacity: .5; } 50% { top: 68%; opacity: 1; } }
.cam-status { position: absolute; left: 12px; bottom: 12px; right: 12px; display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.cam-last {
  min-width: 0; max-width: 70%; padding: 7px 10px; border-radius: 9px;
  background: rgba(0, 0, 0, .55); backdrop-filter: blur(8px);
  color: #fff; font-size: 11px; border: 1px solid rgba(255, 255, 255, .12);
}
.cam-last strong { display: block; font-family: var(--mono); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cam-last span { color: rgba(255, 255, 255, .6); font-size: 10px; }
.cam-count { flex: none; padding: 7px 10px; border-radius: 9px; background: rgba(15, 157, 114, .85); color: #fff; font-size: 11px; font-weight: 700; white-space: nowrap; }
.cam-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .11); }
.cam-controls select {
  background: rgba(255, 255, 255, .08); color: #fff; border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 8px; padding: 7px 9px; font-size: 11.5px; max-width: 200px; outline: none;
}
.cam-controls select option { color: #111; }
.cam-controls .cam-toggle { display: inline-flex; align-items: center; gap: 7px; color: rgba(255, 255, 255, .78); font-size: 11.5px; margin-left: auto; }
.cam-controls .cam-toggle input { accent-color: var(--amber); width: 15px; height: 15px; }
.cam-controls .btn { color: #fff; border-color: rgba(255, 255, 255, .16); background: rgba(255, 255, 255, .08); }
.cam-controls .btn:hover { background: rgba(255, 255, 255, .15); }
.cam-error { display: none; padding: 10px 12px; border-radius: 10px; background: rgba(220, 38, 38, .16); border: 1px solid rgba(248, 113, 113, .3); color: #fecaca; font-size: 12px; line-height: 1.5; }
.cam-error.show { display: block; }
.cam-help { color: rgba(255, 255, 255, .42); font-size: 10.5px; text-align: center; }
.camera-overlay .modal { display: none; }

/* ============ Print ============ */
#printArea { display: none; }
.print-sheet { display: flex; flex-wrap: wrap; gap: 2mm; align-items: flex-start; }
.print-sheet .plabel { break-inside: avoid; page-break-inside: avoid; border: .2mm dashed #d8dee6; }
@media print {
  @page { size: A4; margin: 5mm; }
  html, body { background: #fff !important; }
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: block !important; }
  #printArea .plabel { box-shadow: none; border: 0 !important; }
  .print-sheet { gap: 2mm; }
}

/* ============ Responsive ============ */
@media (max-width: 1320px) {
  .scan-grid { grid-template-columns: minmax(0, 1fr) 336px; }
}
@media (max-width: 1180px) {
  .scan-grid { grid-template-columns: 1fr; }
  .scan-side {
    position: static; max-height: none; overflow: visible;
    display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding-right: 0;
  }
  .scan-side > * { margin: 0 !important; }
  .scan-side > #cycleChart, .scan-side > #openPallets { grid-column: span 1; }
  .label-layout, .settings-grid, .supplier-layout { grid-template-columns: 1fr; }
  .summary-strip { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 980px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    position: sticky; top: 0; width: 100%; height: auto; flex-direction: row; align-items: center;
    gap: 8px; padding: 9px 12px; overflow: visible;
  }
  .brand { padding: 0 8px 0 2px; flex: none; }
  .brand-mark { width: 34px; height: 34px; border-radius: 9px; }
  .brand-mark svg { width: 20px; height: 20px; }
  .brand-text strong { font-size: 14.5px; }
  .brand-text span { display: none; }
  .nav { flex-direction: row; margin: 0; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; }
  .nav::-webkit-scrollbar { display: none; }
  .nav-item { width: auto; padding: 8px 10px; font-size: 12px; gap: 7px; border-radius: 8px; white-space: nowrap; }
  .nav-item.active { box-shadow: inset 0 -2px 0 var(--amber); background: rgba(245, 158, 11, .12); }
  .nav-badge { min-width: 18px; height: 17px; font-size: 9.5px; padding: 0 4px; }
  .sidebar-foot { display: none; }
  .topbar { top: 53px; padding: 13px 18px; }
  .topbar-title h1 { font-size: 19px; }
  .topbar-title p { display: none; }
  .clock-time { font-size: 15px; }
  .clock-date { display: none; }
  .status-chip { display: none; }
  .content { padding: 16px 18px 44px; }
  .scan-side { grid-template-columns: 1fr 1fr; }
  .summary-strip { grid-template-columns: 1fr 1fr; }
  .detail-stats { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .scan-side { grid-template-columns: 1fr; }
  .pallet-top { flex-direction: column; gap: 12px; }
  .pallet-timer { text-align: left; display: flex; align-items: baseline; gap: 10px; }
  .pallet-timer .eyebrow { order: 2; }
  .pallet-timer .timer { font-size: 30px; margin: 0; order: 1; }
  .pallet-timer .timer-sub { order: 3; }
  .pallet-stats { grid-template-columns: 1fr 1fr; }
  .empty-hero { flex-direction: column; }
  .scan-panel-head { flex-direction: column; align-items: flex-start; }
  .scan-bar { flex-wrap: wrap; }
  .scan-bar input { flex: 1 1 calc(100% - 50px); }
  .scan-bar .btn:not(.btn-quiet) { flex: 1; }
  .scan-bar-icon { width: 32px; }
  .summary-strip { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .filter-bar .field-inline { flex: 1 1 140px; }
  .filter-bar .field-inline.grow { flex-basis: 100%; }
  .card { padding: 16px; border-radius: 14px; }
  .topbar { padding: 11px 14px; }
  .content { padding: 14px; }
  .clock-box { display: none; }
  .field-inline .input { min-width: 0; width: 100%; }
  .search-box input { width: 130px; }
  .modal-backdrop { padding: 8px; }
  .modal { max-height: calc(100vh - 16px); border-radius: 15px; }
  .modal-head, .modal-body, .modal-foot { padding-left: 16px; padding-right: 16px; }
  .detail-stats { grid-template-columns: 1fr 1fr; }
  .cam-controls .cam-toggle { margin-left: 0; }
  .camera-video-wrap { aspect-ratio: 4 / 3; }
  .cam-frame { inset: 12% 7%; }
  .preview-sheet { padding: 10px; }
}
@media (max-width: 520px) {
  .nav-item span { display: none; }
  .nav-item { padding: 8px 11px; }
  .nav-item .ic { width: 19px; height: 19px; }
  .brand-text { display: none; }
  .pallet-card { padding: 17px; }
  .pallet-id { font-size: 20px; }
  .hero-steps { display: none; }
  .scan-bar .btn span { display: none; }
  .scan-bar .btn { flex: 0; min-width: 42px; }
  .scan-bar input { flex: 1 1 160px; }
  .summary-card { padding: 11px 12px; }
  .summary-card .sv { font-size: 17px; }
  .stat-grid { gap: 7px; }
}

/* reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* ============ Tambahan komponen ============ */
[hidden] { display: none !important; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.no-scroll { overflow: hidden; }
.pallet-main { min-width: 0; }
.stat-note { display: block; font-size: 10px; color: var(--muted); margin-top: 3px; }
.summary-meta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 11px; font-size: 11px; color: var(--muted); }
.summary-meta b { color: var(--ink-2); font-weight: 600; font-family: var(--mono); font-size: 11px; }
.modal .summary-meta { padding: 9px 11px; background: var(--surface-2); border-radius: 9px; border: 1px solid var(--line-soft); }
.table-note { padding: 8px 12px; font-size: 10.5px; color: var(--muted); border-top: 1px solid var(--line-soft); background: #fbfcfe; }
.code-sub { font-size: 10px; color: var(--muted); margin-top: 1px; }
.table-card .table-wrap { max-height: 540px; }
.inline-add { display: flex; gap: 7px; align-items: stretch; }
.inline-add select { flex: 1; min-width: 0; }
.checkline { display: flex; align-items: center; font-size: 12.5px; }
.checkline label { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.checkline input { width: 16px; height: 16px; accent-color: var(--green); }
.code-readonly { padding: 10px 12px; background: var(--surface-2); border: 1px dashed var(--line); border-radius: 9px; }
.code-readonly span { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.code-readonly code { display: block; font-size: 12px; margin-top: 2px; word-break: break-all; }
.barcode-missing { font-size: 7pt; color: #991b1b; text-align: center; padding: 4mm 0; }
.export-choice {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px; border: 1px solid var(--line); border-radius: 11px;
  cursor: pointer; transition: .15s; background: #fff;
}
.export-choice:hover { border-color: var(--amber); background: var(--amber-soft); }
.export-choice > .ic { color: var(--navy-700); width: 20px; height: 20px; }
.export-choice > .ic:last-child { color: var(--muted); margin-left: auto; width: 16px; height: 16px; }
.export-choice div { flex: 1; min-width: 0; }
.export-choice strong { display: block; font-size: 13px; }
.export-choice span { display: block; font-size: 11.5px; color: var(--muted); margin-top: 1px; line-height: 1.4; }
.detail-table { margin-top: 2px; }
.detail-table .table-wrap { border: 1px solid var(--line-soft); }
.cam-controls .btn.active { background: var(--amber); border-color: var(--amber); color: #3d2500; }
.cam-controls .btn.active .ic { color: #3d2500; }
.cam-controls .btn[hidden] { display: none; }
.plabel-barcode svg { width: 100%; height: 100%; }

/* ============ Box cycle ============ */
.pallet-timer .timer.timer-waiting { color: rgba(255, 255, 255, .35); }
.pstat .v small { margin-left: 4px; }
.box-live-clock,
.live-cycle { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.box-live-clock { color: inherit; font-weight: 700; }
table.data .live-cycle { color: var(--amber-600); font-weight: 700; }
table.data .box-row td {
  background: #f8fafd;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line-soft);
}
table.data .box-row:first-child td { border-top: 1px solid var(--line-soft); }
table.data .box-row.active td { background: #fff9ec; }
table.data .box-row:hover td { background: #f4f8fd; }
table.data .box-row.active:hover td { background: #fff4dc; }
table.data .box-row .strong { font-size: 13px; }
table.data .kb-row td { background: #fff; }
table.data .kb-row:hover td { background: #fafcff; }
table.data .kb-row .kb-seq { display: inline-block; font-family: var(--mono); font-size: 11px; color: var(--muted); padding-left: 8px; }
table.data .kb-row .code { font-size: 11.5px; }
table.data .kb-row .code-sub { margin-top: 1px; }
table.data .kb-row.kb-empty td { color: var(--muted); font-size: 11.5px; padding-left: 24px; font-style: italic; }
table.data .legacy-row td { background: #f5f7fa; }
table.data .legacy-kb .kb-seq { color: var(--muted-2); }
.box-list-row.active { background: #fff9ec; border-color: #f8d99b; border-radius: 8px; padding-left: 8px; padding-right: 8px; }
.box-list-row.active .pname strong { color: #92400e; }
.active-box-bar .box-finish {
  display: inline-flex; align-items: center; gap: 4px;
  border: 0; background: rgba(146, 64, 14, .12); color: #92400e;
  padding: 3px 7px; border-radius: 6px; font-size: 10.5px; font-weight: 700;
}
.active-box-bar .box-finish:hover { background: rgba(146, 64, 14, .22); }
.active-box-bar .box-finish .ic { width: 12px; height: 12px; }
.detail-section-title {
  font-size: 10px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); margin: 18px 0 7px;
}
.detail-section-title:first-of-type { margin-top: 12px; }
.box-detail-table .box-row td { background: #f8fafd; }
.box-detail-table .box-row.active td { background: #fff9ec; }

@media (max-width: 720px) {
  .active-box-bar { max-width: 100%; }
  .active-box-bar > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .active-box-bar .box-finish span { display: none; }
  .detail-section-title { margin-top: 15px; }
  table.data .kb-row .kb-seq { padding-left: 2px; }
}

