/* System UI — ERP mật độ cao. Ghi đè legacy Offline (style/dispatch). */
@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap");

:root {
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --bg: #eef1f6;
  --panel: #ffffff;
  --rail: 200px;
  --accent: #c41e3a;
  --accent-ink: #fff;
  --focus: #2563eb;
  --ok: #059669;
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --ctrl-h: 28px;
  --radius: 6px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0 !important;
  min-height: 100%;
  background: var(--bg) !important;
  color: var(--ink) !important;
  font: 12.5px/1.4 var(--font) !important;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea,
label {
  font: inherit !important;
  font-size: 12.5px !important;
  line-height: 1.35 !important;
  min-height: 0 !important;
  color: inherit;
}

button {
  cursor: pointer;
  border: 1px solid var(--line-2);
  background: var(--panel);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 5px 10px;
  font-weight: 550 !important;
  height: var(--ctrl-h);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
}
button:hover {
  background: #f8fafc;
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
button.primary {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: var(--accent-ink) !important;
}
button.primary:hover {
  filter: brightness(1.06);
}
button.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
button.ghost:hover {
  background: #f1f5f9;
  color: var(--ink);
}

input:not([type="checkbox"]):not([type="file"]),
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-2) !important;
  border-radius: 4px !important;
  background: #fff !important;
  color: var(--ink) !important;
  padding: 4px 7px !important;
  height: var(--ctrl-h);
  font-weight: 450 !important;
}
textarea {
  height: auto;
  min-height: 56px;
  resize: vertical;
}
input[readonly] {
  background: #f1f5f9 !important;
  font-weight: 600 !important;
  font-family: var(--mono) !important;
}
input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--focus) 45%, transparent);
  outline-offset: 1px;
}

/* —— Kill legacy Offline chrome —— */
header:not(.dispatch-company),
.top,
.steps,
.eyebrow,
footer,
.paste-hint,
.num,
.formtitle,
.attachment-hint,
.notice,
.confirm,
#history-save-status,
.dock {
  display: none !important;
}

/* —— Sidebar —— */
aside {
  position: fixed !important;
  inset: 0 auto 0 0;
  width: var(--rail) !important;
  height: 100vh !important;
  background: #0b1220 !important;
  color: #e2e8f0 !important;
  padding: 12px 10px !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 8px !important;
  z-index: 30;
  border-right: 1px solid #1e293b;
  overflow: hidden;
}
.brand {
  display: flex !important;
  align-items: center;
  gap: 8px;
  padding: 2px 4px 10px !important;
  margin: 0 !important;
  border-bottom: 1px solid #1e293b;
  font-size: inherit !important;
  font-style: normal !important;
  font-weight: 400 !important;
  letter-spacing: 0 !important;
}
.brand .app-logo {
  width: 32px !important;
  height: 32px !important;
  object-fit: contain;
  background: #fff;
  border-radius: 7px;
  padding: 2px;
  flex-shrink: 0;
}
.brand-mark {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 0;
}
.brand-mark strong {
  font-size: 14px !important;
  font-weight: 700 !important;
  color: #fff !important;
  letter-spacing: -0.02em;
}
.brand-mark span {
  font-size: 9.5px !important;
  color: #94a3b8 !important;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
aside > small {
  display: none !important;
}
aside nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
aside nav button {
  width: 100%;
  height: auto !important;
  min-height: 0 !important;
  text-align: left;
  border: 0 !important;
  background: transparent !important;
  color: #94a3b8 !important;
  margin: 0 !important;
  padding: 8px 9px !important;
  border-radius: 6px;
  font-size: 12px !important;
  font-weight: 500 !important;
  justify-content: flex-start;
}
aside nav button:hover {
  background: #1e293b !important;
  color: #fff !important;
}
aside nav button.active {
  background: #1e293b !important;
  color: #fff !important;
  box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar-history {
  flex: 1;
  min-height: 0;
  overflow: auto;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid #1e293b;
}
.sidebar-history-empty {
  color: #64748b !important;
  font-size: 11px !important;
  padding: 6px;
  margin: 0;
}
.history-item {
  width: 100%;
  height: auto !important;
  text-align: left;
  background: #111827 !important;
  color: #e2e8f0 !important;
  border: 1px solid #1f2937 !important;
  border-radius: 6px;
  padding: 6px 8px !important;
  margin: 0 0 4px !important;
  display: block;
}
.history-item b {
  display: block;
  font-size: 12px !important;
  font-weight: 600 !important;
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-item small {
  font-size: 10px !important;
  color: #94a3b8 !important;
}
.aside-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding-top: 6px;
}
.aside-tools button,
.aside-tools label {
  height: 26px !important;
  font-size: 11px !important;
  padding: 0 4px !important;
  border-radius: 5px;
  border: 1px solid #334155 !important;
  background: #111827 !important;
  color: #cbd5e1 !important;
  text-align: center;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
}
.asidefoot {
  position: static !important;
  margin-top: auto !important;
  padding-top: 8px;
  border-top: 1px solid #1e293b;
  font-size: 10.5px !important;
  color: #94a3b8 !important;
  line-height: 1.35 !important;
}
.asidefoot span {
  color: #64748b !important;
  font-size: 10px !important;
}

/* —— Main —— */
main {
  margin-left: var(--rail) !important;
  min-height: 100vh;
  padding: 0 !important;
  background: var(--bg) !important;
}

.sys-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  background: rgba(238, 241, 246, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.sys-topbar h1 {
  margin: 0 !important;
  font-size: 15px !important;
  font-weight: 650 !important;
  letter-spacing: -0.02em;
  line-height: 1.2 !important;
  color: var(--ink) !important;
}
.sys-topbar .sub {
  margin: 1px 0 0 !important;
  font-size: 11px !important;
  color: var(--muted) !important;
  line-height: 1.25 !important;
}
.sys-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: flex-end;
}

.sys-status {
  margin: 8px 16px 0 !important;
  padding: 5px 10px !important;
  font-size: 11.5px !important;
  color: #334155 !important;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  border-left: 3px solid var(--focus);
}

/* —— Workbench —— */
.workbench {
  display: grid !important;
  grid-template-columns: 220px minmax(0, 1fr) !important;
  gap: 10px;
  padding: 10px 16px 20px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}
.panel-head h2 {
  margin: 0 !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #475569 !important;
}
.panel-body {
  padding: 10px;
}
.panel-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.chip {
  display: inline-flex !important;
  align-items: center;
  gap: 5px;
  height: var(--ctrl-h);
  padding: 0 8px !important;
  border: 1px solid var(--line) !important;
  border-radius: var(--radius);
  background: #fff !important;
  font-size: 11.5px !important;
  color: #475569 !important;
  cursor: pointer;
  margin: 0 !important;
  font-weight: 500 !important;
}
.chip input {
  width: auto !important;
  height: auto !important;
  margin: 0 !important;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 64px;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius);
  background: #f8fafc;
  cursor: pointer;
  padding: 8px;
  margin: 8px 0;
  text-align: center;
}
.dropzone strong {
  font-size: 16px;
  color: #94a3b8;
  font-weight: 500;
}
.dropzone b {
  font-size: 12px;
  font-weight: 600;
}
.dropzone span {
  font-size: 10.5px !important;
  color: var(--muted) !important;
}
.dropzone input {
  display: none !important;
}

#photo {
  width: 100%;
  max-height: 180px !important;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #0b1220;
  display: block;
}

.ocr-details {
  margin-top: 8px;
  border-top: 1px solid var(--line);
  padding-top: 6px;
}
.ocr-details summary {
  cursor: pointer;
  font-size: 11.5px !important;
  font-weight: 600;
  color: #475569;
  list-style: none;
}
.ocr-details summary::-webkit-details-marker {
  display: none;
}
#raw {
  margin-top: 6px;
  font-family: var(--mono) !important;
  font-size: 11px !important;
  min-height: 72px;
}

.badge {
  display: inline-flex !important;
  align-items: center;
  height: 20px;
  padding: 0 7px !important;
  border-radius: 999px;
  background: #e2e8f0 !important;
  color: #334155 !important;
  font-size: 10.5px !important;
  font-weight: 650 !important;
  letter-spacing: 0 !important;
}

/* Spreadsheet */
.sheet-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  max-height: min(52vh, 560px);
  background: #fff;
}
table.sheet {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px !important;
}
table.sheet th {
  text-align: left;
  background: #f1f5f9 !important;
  color: #475569 !important;
  font-weight: 650 !important;
  font-size: 10.5px !important;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 6px 6px !important;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
}
table.sheet td {
  padding: 3px 4px !important;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle !important;
  background: #fff;
}
table.sheet tr:hover td {
  background: #f8fafc;
}
table.sheet td input,
table.sheet td select {
  height: 26px !important;
  padding: 2px 5px !important;
  font-size: 12px !important;
  border-radius: 3px !important;
}
table.sheet .col-idx {
  width: 28px;
  text-align: center;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}
table.sheet .col-qty,
table.sheet .col-unit {
  width: 52px;
}
table.sheet .col-lot {
  width: 64px;
}
table.sheet .col-mode {
  width: 72px;
}
table.sheet .col-kg {
  width: 88px;
}
table.sheet .col-kg input {
  font-family: var(--mono) !important;
  font-weight: 600 !important;
  text-align: right;
}
table.sheet .col-del {
  width: 32px;
  text-align: center;
}
table.sheet .col-del button {
  width: 24px;
  height: 24px !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  color: #94a3b8;
  font-size: 14px !important;
}
table.sheet .col-del button:hover {
  color: var(--accent);
  background: #fef2f2 !important;
}

.row-actions {
  display: flex;
  gap: 6px;
  padding: 8px 0 0;
}
.row-actions button {
  border-style: dashed;
  background: #f8fafc;
}

.bar-scale,
.bar-meta {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: #fafbfc;
}
.bar-scale {
  grid-template-columns: 160px 1fr auto auto;
  align-items: end;
}
.bar-meta {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}
.field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 0 !important;
  font-size: 10.5px !important;
  font-weight: 650 !important;
  color: #64748b !important;
}
.field input,
.field select,
.field textarea {
  font-weight: 450 !important;
  color: var(--ink) !important;
}
.muted {
  margin: 0;
  font-size: 11px !important;
  color: var(--muted) !important;
}
.bar-extras {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 8px 10px 10px;
  border-top: 1px solid var(--line);
}
.weigh-upload {
  height: var(--ctrl-h);
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  font-size: 12px !important;
}
.weigh-upload input {
  display: none !important;
}
#weigh-photo {
  max-height: 100px;
  max-width: 160px;
  border-radius: 4px;
  border: 1px solid var(--line);
}

/* Batch */
#batch-panel {
  margin: 10px 16px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.batch-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}
.batch-heading h1 {
  margin: 0 !important;
  font-size: 14px !important;
}
.batch-heading p {
  margin: 1px 0 0 !important;
  font-size: 11px !important;
  color: var(--muted) !important;
}
.batch-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 8px 12px;
}
.batch-upload {
  height: var(--ctrl-h);
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1e40af;
  border-radius: var(--radius);
  font-weight: 600 !important;
  cursor: pointer;
  font-size: 12px !important;
}
.batch-upload input {
  display: none !important;
}
#batch-images {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 12px 8px;
}
#batch-images figure {
  margin: 0;
  width: 72px;
}
#batch-images img {
  width: 100%;
  border-radius: 4px;
  border: 1px solid var(--line);
  display: block;
}
#batch-images figcaption {
  font-size: 10px;
  color: var(--muted);
  text-align: center;
}
.batch-table-wrap {
  margin: 0 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  max-height: min(55vh, 520px);
}
.batch-total-bar,
.batch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
  padding: 10px 12px;
}
.batch-total-bar {
  border-top: 1px solid var(--line);
  background: #fafbfc;
}
.batch-total-bar label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 10.5px !important;
  font-weight: 650 !important;
  color: #64748b !important;
  min-width: 200px;
}

/* Modal */
dialog#modal {
  border: 0;
  border-radius: 10px;
  max-width: min(960px, 96vw);
  width: 960px;
  padding: 16px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
}
dialog#modal::backdrop {
  background: rgba(15, 23, 42, 0.55);
}
#close {
  float: right;
  margin-bottom: 8px;
}

@media (max-width: 1100px) {
  .workbench {
    grid-template-columns: 1fr !important;
  }
  .bar-scale {
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 820px) {
  aside {
    position: relative !important;
    width: 100% !important;
    height: auto !important;
  }
  main {
    margin-left: 0 !important;
  }
}

/* Neutralize dispatch.css form pollution */
#dispatch-fields{border:0!important;margin:0!important;padding:0!important}
#dispatch-fields select{font-size:12.5px!important;padding:4px 7px!important;margin:0!important}
.item-note-input{min-height:0!important;font-size:12.5px!important}

