:root {
  --navy: #0a1628;
  --navy-2: #11223d;
  --bg: #eef4f8;
  --card: #ffffff;
  --border: #dce5ef;
  --text: #0f172a;
  --muted: #64748b;
  --blue: #2563eb;
  --blue-strip: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
  --red: #dc2626;
  --red-strip: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
  --green: #16a34a;
  --green-strip: linear-gradient(180deg, #22c55e 0%, #15803d 100%);
  --cyan: #38bdf8;
  --shadow: 0 2px 6px rgba(15, 23, 42, 0.05), 0 8px 22px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* Topbar */
.topbar {
  background: var(--navy);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar-inner {
  max-width: 1520px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand-wrap { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff;
  font-weight: 900;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-eyebrow {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--cyan);
}
.brand-title {
  margin: 2px 0 0;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.env-chip {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.14);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.28);
}

/* Main container */
.container {
  max-width: 1520px;
  margin: 0 auto;
  padding: 20px 24px 44px;
}

/* Subheader */
.subheader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 16px;
}
.sub-left, .sub-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.page-title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 999px;
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #16a34a;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.22);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.65; transform: scale(0.9); }
}

.seg-tabs {
  display: inline-flex;
  background: #dce6f1;
  padding: 3px;
  border-radius: 10px;
  gap: 3px;
}
.seg-btn {
  border: none;
  background: transparent;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s;
}
.seg-btn.active {
  background: #fff;
  color: var(--navy);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.count-pill {
  font-size: 12.5px;
  font-weight: 700;
  color: #334155;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
}
.sync-time { font-size: 12px; color: var(--muted); }
.btn-refresh {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-refresh:hover { border-color: #94a3b8; background: #f8fafc; }
.btn-refresh.spinning svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Filter bar */
.filterbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}
.search-wrap {
  position: relative;
  flex: 1 1 210px;
  min-width: 190px;
}
.search-ico {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  pointer-events: none;
}
.search-wrap input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 13px;
  background: #f8fafc;
}
.search-wrap input:focus {
  outline: none;
  background: #fff;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.f-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}
.ms-wrap { position: relative; }
.ms-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.ms-pop {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 230px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
  padding: 8px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ms-pop label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.ms-pop label:hover { background: #f1f5f9; }

.btn-toggle {
  padding: 8px 14px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: #475569;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-toggle.active {
  background: #fef3c7;
  color: #b45309;
  border-color: #fcd34d;
}
.btn-filter {
  padding: 8px 18px;
  border-radius: 9px;
  border: none;
  background: var(--navy);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.btn-filter:hover { background: var(--navy-2); }

/* 4-column card grid */
.batch-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
@media (max-width: 1300px) { .batch-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 940px) { .batch-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .batch-grid { grid-template-columns: 1fr; } }

.bcard {
  display: flex;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.bcard:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.1), 0 12px 28px rgba(15, 23, 42, 0.08);
}

.bstrip {
  width: 72px;
  flex: none;
  background: var(--blue-strip);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 6px;
  text-align: center;
}
.bcard.is-break .bstrip { background: var(--red-strip); }
.bcard.is-done .bstrip { background: var(--green-strip); }

.bstrip-num {
  font-size: 26px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.02em;
}
.bstrip-lbl {
  font-size: 10.5px;
  font-weight: 700;
  opacity: 0.92;
  margin-top: 4px;
  text-transform: lowercase;
}

.bmain {
  flex: 1;
  min-width: 0;
  padding: 13px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.bhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.bname {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bpills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.pill-prog { background: #dbeafe; color: #1d4ed8; }
.pill-done { background: #dcfce7; color: #15803d; }
.pill-break {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  cursor: pointer;
}
.pill-break:hover { background: #fecaca; }
.pill-multi { background: #dcfce7; color: #15803d; }
.pill-manual { background: #e0f2fe; color: #0369a1; }
.pill-peso { background: #ffedd5; color: #c2410c; }
.pill-alim { background: #fef3c7; color: #b45309; }
.pill-chan { background: #f1f5f9; color: #334155; border: 1px solid #e2e8f0; }

.bmeta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-top: 1px dashed #e2e8f0;
  padding-top: 8px;
}
.bm-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
}
.bm-lbl { color: var(--muted); font-weight: 600; }
.bm-val {
  color: var(--text);
  font-weight: 700;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Inline Quiebre Odoo panel */
.break-panel {
  margin-top: 4px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 11.5px;
}
.break-panel-title {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #991b1b;
  margin-bottom: 6px;
}
.break-item {
  padding: 5px 0;
  border-top: 1px dashed #fca5a5;
}
.break-item:first-of-type { border-top: none; padding-top: 0; }
.break-so { font-weight: 800; color: #7f1d1d; }
.break-sku { font-family: ui-monospace, Consolas, monospace; color: #b91c1c; font-weight: 700; }
.break-msg { color: #991b1b; margin-top: 2px; }

.empty-state {
  grid-column: 1 / -1;
  background: #fff;
  border: 1px dashed var(--border);
  border-radius: 16px;
  padding: 46px 20px;
  text-align: center;
  color: var(--muted);
}
.empty-state h3 { margin: 0 0 6px; color: var(--text); }

/* Detail Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 22, 40, 0.56);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-dialog {
  width: 100%;
  max-width: 980px;
  max-height: 90vh;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(10, 22, 40, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-head {
  padding: 16px 22px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.modal-eyebrow {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--blue);
}
.modal-head h3 {
  margin: 2px 0 8px;
  font-size: 20px;
  font-weight: 900;
}
.modal-summary-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.msum-pill {
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--border);
  color: #334155;
}
.modal-x {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 20px;
  cursor: pointer;
  color: #64748b;
}
.modal-x:hover { background: #f1f5f9; color: var(--text); }

.modal-body {
  padding: 18px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pick-acc {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}
.pick-head {
  padding: 12px 14px;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  cursor: pointer;
}
.pick-head-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.pick-ids {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 800;
}
.copy-mini {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #334155;
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
}
.copy-mini:hover { background: #eff6ff; border-color: var(--blue); color: var(--blue); }
.pick-cust { font-size: 12px; color: var(--muted); }
.pick-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.ctrl-grp {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  color: #475569;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
}
.step-btn {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  font-weight: 800;
  cursor: pointer;
}
.step-btn:hover { background: #e2e8f0; }
.flag-btn {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #475569;
  border-radius: 6px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}
.flag-btn.on { background: #fef3c7; border-color: #f59e0b; color: #b45309; }

.pick-lines { padding: 12px 14px; border-top: 1px solid var(--border); }
.lines-tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.lines-tbl th {
  text-align: left;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 7px 8px;
  border-bottom: 1px solid var(--border);
}
.lines-tbl td {
  padding: 8px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.lines-tbl tr:last-child td { border-bottom: none; }
.mono { font-family: ui-monospace, Consolas, monospace; font-weight: 700; }

.add-sku-bar {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.add-sku-bar input {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12.5px;
}
.add-sku-hint { font-size: 11.5px; color: var(--muted); }

.modal-foot {
  padding: 14px 22px;
  background: #f8fafc;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.modal-warn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 10px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #b45309;
  font-size: 12.5px;
  font-weight: 600;
}
.modal-foot-btns {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.btn-warn {
  border: none;
  background: #ea580c;
  color: #fff;
  border-radius: 9px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.btn-dark {
  border: none;
  background: var(--navy);
  color: #fff;
  border-radius: 9px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 200;
  background: var(--navy);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 10px 28px rgba(10, 22, 40, 0.25);
}
