:root {
  --sidebar-width: 240px;
  --sidebar-collapsed-width: 50px;
  --bg-main: #f4f6f9;
  --bg-sidebar: #111827;
  --bg-sidebar-hover: #1f2937;
  --text-sidebar-muted: #9ca3af;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
}

body {
  background-color: var(--bg-main);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  overflow: hidden;
  height: 100vh;
}

#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  margin: 0;
  padding: 0;
  background-color: var(--bg-sidebar);
  color: #ffffff;
  transition: transform 0.25s ease, width 0.25s ease;
  z-index: 1050;
  overflow-y: auto;
  overflow-x: hidden;
}

#sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar-brand {
  padding: 20px 15px;
  margin-top: 0 !important;
  font-size: 1.1rem;
  font-weight: 700;
  white-space: nowrap;
  border-top: 0 !important;
  border-bottom: 1px solid #1f2937;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#sidebar.collapsed .sidebar-brand {
  justify-content: center;
  padding: 20px 0;
}

#sidebar.collapsed .sidebar-brand span {
  display: none;
}

.sidebar-menu {
  list-style: none;
  padding: 0;
  margin: 20px 0;
}

.sidebar-menu li a {
  display: flex;
  align-items: center;
  padding: 14px 22px;
  color: var(--text-sidebar-muted);
  text-decoration: none;
  transition: background-color 0.2s, color 0.2s;
  white-space: nowrap;
  cursor: pointer;
}

.sidebar-menu li a:hover,
.sidebar-menu li.active a {
  background-color: var(--bg-sidebar-hover);
  color: #ffffff;
}

.sidebar-menu li a i {
  font-size: 1.25rem;
  min-width: 35px;
  text-align: center;
}

#sidebar.collapsed .sidebar-menu li a {
  justify-content: center;
  padding: 14px 0;
}

#sidebar.collapsed .sidebar-menu li a span {
  display: none;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1040;
}

#mainContentWrapper {
  margin-left: var(--sidebar-width);
  transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  height: 100vh;
  display: flex;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

#sidebar.collapsed ~ #mainContentWrapper {
  margin-left: var(--sidebar-collapsed-width);
}

.module-workspace {
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

.module-workspace.d-none {
  display: none !important;
}

.workspace-container {
  width: 100%;
  max-width: 1400px;
  padding: 15px 25px;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  margin: 0 auto;
}

.workspace-sticky-top {
  flex: 0 0 auto;
  background-color: var(--bg-main);
  z-index: 10;
}

.workspace-header {
  position: relative !important;
  background: #ffffff;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  margin-bottom: 10px;
}

.workspace-scrollable-content {
  flex: 1 1 auto;
  overflow-y: auto;
  padding-right: 5px;
  padding-bottom: 20px;
}

.card-order {
  background: #ffffff;
  border: none;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}

.komponen-block {
  background-color: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px 14px !important;
  margin-bottom: 12px;
}

.teknis-item-row {
  background-color: #f9fafb;
  border-left: 4px solid #3b82f6;
  border-radius: 0 6px 6px 0;
  padding: 4px 8px !important;
  margin-top: 4px;
  margin-bottom: 4px;
}

.teknis-item-row.manual-mode {
  border-left-color: #f59e0b;
}

.teknis-flex-row {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 18px;
}

.col-teknis {
  min-width: 220px;
}

.col-target {
  min-width: 90px;
  width: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}

.col-target label {
  width: 65px;
  display: block;
  text-align: center;
  margin-bottom: 2px !important;
  line-height: 1;
}

.col-target .input-target-qty {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.col-operator {
  flex: 1;
  min-width: 320px;
}

.input-target-qty,
.input-operator-qty {
  width: 65px !important;
  height: 30px !important;
  padding: 3px 5px !important;
  font-size: 0.85rem !important;
  box-sizing: border-box;
}

.select-operator-name {
  width: 125px !important;
  height: 30px !important;
  padding: 3px 3px !important;
  font-size: 0.85rem !important;
  box-sizing: border-box;
}

.teknis-action-row {
  width: 100%;
  min-height: 20px;
  gap: 16px;
  margin-bottom: 5px;
}

.teknis-action-row .btn {
  line-height: 1;
  white-space: nowrap;
}

[id^="crewContainer"],
[id^="operatorContainerHC_"] {
  width: 100%;
}

.crew-input-row {
  background: #ffffff;
  padding: 3px 6px;
  border-radius: 4px;
  border: 1px solid #e5e7eb;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.local-loader-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 8px;
  z-index: 20;
}

.module-placeholder {
  width: 100%;
  max-width: 900px;
  margin: 40px auto;
}

@media (max-width: 991.98px) {
  body {
    overflow: hidden;
    height: 100vh;
  }

  #sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width) !important;
  }

  #sidebar.show-mobile {
    transform: translateX(0);
    width: var(--sidebar-width) !important;
  }

  .sidebar-backdrop.show-mobile {
    display: block;
  }

  #sidebar.show-mobile .sidebar-brand {
    justify-content: space-between !important;
    padding: 20px 15px !important;
  }

  #sidebar.show-mobile .sidebar-brand span,
  #sidebar.show-mobile .sidebar-menu li a span {
    display: inline !important;
  }

  #sidebar.show-mobile .sidebar-menu li a {
    justify-content: flex-start !important;
    padding: 14px 22px !important;
  }

  #mainContentWrapper,
  #sidebar.collapsed ~ #mainContentWrapper {
    margin-left: 0 !important;
  }

  .workspace-container {
    padding: 8px;
    height: 100vh;
  }

  .workspace-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 6px;
    padding: 8px 8px 8px 28px !important;
    margin-bottom: 6px;
    position: relative !important;
    min-height: 48px;
  }

  #mobileSidebarBtn {
    position: fixed !important;
    top: 17px !important;
    left: 6px !important;
    width: 26px !important;
    height: 30px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 1035;
    border-radius: 6px !important;
    font-size: 0.72rem !important;
    line-height: 1 !important;
  }

  .workspace-header .ps-4,
  .workspace-header .ps-lg-0 {
    padding-left: 0 !important;
    min-width: 0;
    flex: 1;
  }

  .workspace-header h4 {
    font-size: 1rem !important;
    margin-bottom: 0 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .workspace-header p {
    display: none !important;
  }

  .workspace-header .d-flex {
    flex-shrink: 0;
    width: auto !important;
    margin-top: 0 !important;
  }

  .input-no-order-mobile {
    width: 100px !important;
    height: 28px !important;
    font-size: 0.74rem !important;
  }

  .workspace-header .btn-dark {
    height: 28px !important;
    padding: 0 7px !important;
    font-size: 0.72rem !important;
  }

  .workspace-scrollable-content {
    overflow-x: hidden;
    padding-right: 0;
  }

  .card-order,
  .komponen-block,
  .teknis-item-row {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }

  .komponen-block {
    padding: 6px 6px !important;
    margin-bottom: 8px;
  }

  .komponen-block > .d-flex {
    gap: 6px;
  }

  .komponen-block > .d-flex > div:first-child {
    min-width: 0;
    flex: 1;
  }

  .komponen-block strong {
    display: inline-block;
    max-width: 135px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
  }

  .komponen-block .btn-outline-secondary {
    font-size: 0.65rem !important;
    padding: 1px 4px !important;
    white-space: nowrap;
  }

  .teknis-item-row {
    padding: 5px 6px !important;
    margin-top: 4px;
    margin-bottom: 4px;
  }

  .teknis-flex-row {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 72px;
    column-gap: 8px !important;
    row-gap: 4px !important;
    align-items: start !important;
    width: 100%;
    max-width: 100%;
  }

  .col-teknis,
  .col-target,
  .col-operator {
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .col-teknis {
    grid-column: 1 / 2;
  }

  .col-target {
    grid-column: 2 / 3;
    width: 72px !important;
    align-items: center;
  }

  .col-operator {
    grid-column: 1 / -1;
    padding-top: 0 !important;
  }

  .select-teknis-value {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .col-target label {
    display: block !important;
    width: 65px;
    text-align: center;
    font-size: 0.62rem !important;
    margin-bottom: 1px !important;
    line-height: 1;
  }

  .input-target-qty {
    width: 58px !important;
    height: 24px !important;
    font-size: 0.78rem !important;
  }

  .teknis-action-row {
    display: flex !important;
    justify-content: flex-start;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px !important;
    margin-bottom: 4px;
    min-height: 18px;
  }

  .teknis-action-row .btn {
    font-size: 0.68rem !important;
  }

  [id^="crewContainer"],
  [id^="operatorContainerHC_"] {
    display: flex !important;
    flex-wrap: wrap;
    gap: 4px !important;
    width: 100%;
    max-width: 100%;
  }

  .crew-input-row {
    padding: 2px 4px;
    gap: 3px;
    max-width: 100%;
  }

  .select-operator-name {
    width: 118px !important;
    height: 24px !important;
    font-size: 0.78rem !important;
  }

  .input-operator-qty {
    width: 58px !important;
    height: 24px !important;
    font-size: 0.78rem !important;
  }
}

/* === V0.8.0: dialog pemindai kamera yang ringkas & mobile-friendly === */
.btn-scan-order { white-space: nowrap; min-width: 60px; flex-shrink: 0; }
.produksi-overlay {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: none;
  justify-content: center;
  align-items: center;
  padding: 18px;
  background: rgba(5, 12, 28, .76);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}
.produksi-overlay.is-visible { display: flex; }
.scan-dialog {
  width: min(100%, 440px);
  max-height: min(90dvh, 740px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border-radius: 23px;
  border: 1px solid rgba(226, 232, 240, .82);
  box-shadow: 0 28px 76px rgba(0, 0, 0, .4), 0 2px 9px rgba(0, 0, 0, .12);
  animation: scan-dialog-in 170ms ease-out both;
}
@keyframes scan-dialog-in {
  from { opacity: 0; transform: translateY(9px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.scan-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 17px 18px;
  background: #fff;
}
.scan-head-group { display: flex; align-items: center; gap: 12px; min-width: 0; }
.scan-head-icon {
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: #eaf2ff;
  color: #2164cc;
  font-size: 1.14rem;
}
.scan-head-copy { min-width: 0; }
.scan-head-copy h2 { font-size: 1.02rem; font-weight: 780; line-height: 1.25; margin: 0 0 3px; color: #172a48; }
.scan-head-copy p { font-size: .77rem; line-height: 1.3; margin: 0; color: #65758c; }
.scan-dialog-close {
  display: grid;
  place-items: center;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: #f1f5f9;
  color: #435671;
  cursor: pointer;
  font-size: .92rem;
  transition: background 150ms, color 150ms;
}
.scan-dialog-close:hover, .scan-dialog-close:focus-visible { background: #e2e8f0; color: #1d3355; }
.scan-dialog-close:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.scan-camera-shell {
  position: relative;
  background: #081423;
  min-height: 310px;
  height: min(54dvh, 385px);
  isolation: isolate;
  overflow: hidden;
}
.scan-reader { position: absolute; inset: 0; background: #0b1729; color: #fff; overflow: hidden; }
.scan-reader video {
  width: 100% !important;
  height: 100% !important;
  max-height: none !important;
  object-fit: contain;
}
.scan-reader #scanOrderReader__scan_region {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 100%;
}
.scan-reader #scanOrderReader__dashboard { background: transparent !important; }
.scan-viewfinder { position: absolute; inset: 0; z-index: 2; pointer-events: none; display: grid; place-items: center; }
.scan-viewfinder::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(2, 13, 27, .26), transparent 28%, transparent 72%, rgba(2, 13, 27, .38));
}
.scan-focus-frame {
  position: relative;
  width: min(78%, 302px);
  height: min(58%, 206px);
  min-height: 140px;
  filter: drop-shadow(0 0 6px rgba(11, 24, 43, .35));
}
.scan-corner { position: absolute; width: 32px; height: 32px; border-color: #66f6d1; border-style: solid; border-width: 0; }
.scan-corner-tl { top: 0; left: 0; border-top-width: 4px; border-left-width: 4px; border-top-left-radius: 13px; }
.scan-corner-tr { top: 0; right: 0; border-top-width: 4px; border-right-width: 4px; border-top-right-radius: 13px; }
.scan-corner-bl { bottom: 0; left: 0; border-bottom-width: 4px; border-left-width: 4px; border-bottom-left-radius: 13px; }
.scan-corner-br { bottom: 0; right: 0; border-bottom-width: 4px; border-right-width: 4px; border-bottom-right-radius: 13px; }
.scan-sweep-line {
  position: absolute;
  top: 16%;
  left: 11%;
  right: 11%;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, #6fffe0 25%, #6fffe0 75%, transparent);
  box-shadow: 0 0 12px rgba(77, 255, 208, .75);
  opacity: 0;
}
.scan-overlay[data-scan-state="ready"] .scan-sweep-line { animation: scan-sweep 2.9s ease-in-out infinite alternate; opacity: .9; }
@keyframes scan-sweep { from { top: 13%; } to { top: 85%; } }
.scan-status-badge {
  position: absolute;
  z-index: 3;
  bottom: 15px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100% - 32px);
  min-height: 34px;
  padding: 8px 13px;
  border-radius: 999px;
  background: rgba(9, 24, 42, .88);
  color: #f1f5fb;
  border: 1px solid rgba(255, 255, 255, .2);
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  text-align: center;
}
.scan-status { font-size: .75rem; font-weight: 550; line-height: 1.25; color: inherit; overflow-wrap: anywhere; }
.scan-status-dot { flex: 0 0 7px; width: 7px; height: 7px; background: #ffcb70; border-radius: 50%; }
.scan-overlay[data-scan-state="loading"] .scan-status-dot { animation: scan-dot-pulse 1.3s ease-in-out infinite; }
.scan-overlay[data-scan-state="ready"] .scan-status-dot { background: #6ff7c0; box-shadow: 0 0 8px rgba(108, 247, 192, .65); }
.scan-overlay[data-scan-state="error"] .scan-status-badge { border-color: rgba(251, 113, 133, .5); background: rgba(83, 26, 39, .94); }
.scan-overlay[data-scan-state="error"] .scan-status-dot { background: #fda4af; }
.scan-overlay[data-scan-state="success"] .scan-status-dot { background: #6ff7c0; }
@keyframes scan-dot-pulse { 50% { opacity: .32; transform: scale(.75); } }
@media (prefers-reduced-motion: reduce) {
  .scan-dialog, .scan-sweep-line, .scan-status-dot { animation: none !important; }
}
/* V0.7.9 — satu input searchable, tanpa dropdown dan tombol pencarian dobel. */
.teknis-item-row select.teknis-native-value-hidden { display: none !important; }
.teknis-inline-combo {
  position: relative;
  width: min(100%, 245px);
  min-width: 165px;
  max-width: 100%;
}
.teknis-inline-input {
  height: 31px;
  min-height: 31px;
  width: 100%;
  border: 1px solid #d6a04b;
  border-radius: 6px;
  background: #fffcf5;
  color: #233047;
  padding: 5px 27px 5px 9px;
  font-size: .78rem;
  font-weight: 600;
  text-overflow: ellipsis;
  box-shadow: none;
}
.teknis-inline-input:focus {
  background: #fff;
  border-color: #4381de;
  outline: 0;
  box-shadow: 0 0 0 2px rgba(67,129,222,.16);
}
.teknis-inline-input:invalid:not(:placeholder-shown) { border-color: #d38a18; }
.teknis-inline-input::placeholder { color: #8b909d; opacity: 1; font-weight: 400; }
.teknis-inline-icon { pointer-events: none; position: absolute; right: 8px; top: 50%; transform: translateY(-50%); color: #8b7586; font-size: .71rem; }
.teknis-inline-suggestions {
  position: fixed;
  z-index: 3500;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid #d7e0ee;
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 9px 30px rgba(17, 33, 58, .22);
  padding: 4px;
  font-size: .78rem;
}
.teknis-inline-suggestions[hidden] { display: none !important; }
.teknis-inline-result-count { padding: 6px 9px; color: #63738c; font-size: .72rem; border-bottom: 1px solid #edf1f6; }
.teknis-inline-option {
  display: block;
  width: 100%;
  background: #fff;
  text-align: left;
  border: none;
  border-radius: 5px;
  padding: 9px 10px;
  color: #21334c;
  font-size: .8rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
  cursor: pointer;
}
.teknis-inline-option:hover, .teknis-inline-option:focus-visible, .teknis-inline-option.is-active { background: #eaf3ff; color: #174a95; outline: none; }
.teknis-inline-no-result { padding: 12px 10px; color: #7a8595; }
@media (max-width: 600px) {
  .btn-scan-order {min-width: 34px; padding-inline: 8px;}
  .scan-button-label {display: none;}
  .scan-overlay {align-items: center; padding: 12px;}
  .scan-dialog {width: 100%; max-height: min(89dvh, 670px); border-radius: 21px;}
  .scan-dialog-head {padding: 14px 15px;}
  .scan-camera-shell {min-height: 255px; height: min(55dvh, 390px);}
  .scan-focus-frame {width: min(80%, 290px); height: min(55%, 190px); min-height: 125px;}
  .teknis-inline-combo { width: 100%; min-width: 0; }
  .teknis-item-row .col-teknis > .d-flex { flex-wrap: wrap; gap: 5px !important; }

}

@media (max-height: 470px) and (orientation: landscape) {
  .scan-dialog-head { padding: 9px 14px; }
  .scan-camera-shell { height: 57dvh; min-height: 180px; }
  .scan-focus-frame { height: 58%; min-height: 105px; }
}
