:root {
  color-scheme: light;
  --navy-950: #0a223d;
  --navy-900: #0f2f53;
  --navy-800: #174a79;
  --blue-700: #1768ac;
  --blue-100: #eaf3fb;
  --green-700: #17764b;
  --green-100: #e5f5ed;
  --orange-700: #b85b0d;
  --orange-100: #fff0df;
  --red-700: #b43d3d;
  --red-100: #fbe9e8;
  --yellow-100: #fff8d9;
  --ink: #162231;
  --muted: #647386;
  --line: #dce4ec;
  --line-strong: #c6d2de;
  --surface: #ffffff;
  --surface-soft: #f4f7fa;
  --canvas: #edf2f6;
  --shadow: 0 8px 24px rgba(25, 48, 75, .09);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-size: 14px;
  letter-spacing: 0;
}

button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

h1, h2, h3, h4, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: 26px; line-height: 1.25; }
h2 { margin-bottom: 4px; font-size: 20px; line-height: 1.35; }
h3 { margin-bottom: 8px; font-size: 16px; line-height: 1.4; }
p { margin-bottom: 0; }

.eyebrow {
  margin-bottom: 5px;
  color: var(--blue-700);
  font-size: 12px;
  font-weight: 700;
}

.muted { color: var(--muted); }
.danger-text { color: var(--red-700); }
.success-text { color: var(--green-700); }
.strong { font-weight: 700; }

.button {
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--navy-800);
  color: #fff;
  font-weight: 700;
}

.button:hover { background: var(--navy-900); }
.button.secondary { border-color: var(--line-strong); background: #fff; color: var(--ink); }
.button.secondary:hover { border-color: var(--navy-800); color: var(--navy-800); }
.button.success { background: var(--green-700); }
.button.warning { background: var(--orange-700); }
.button.danger { background: var(--red-700); }
.button.full { width: 100%; }
.button.small { min-height: 32px; padding: 5px 10px; font-size: 13px; }

.icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 22px;
}

.icon-button:hover { border-color: var(--blue-700); color: var(--blue-700); }

.demo-switch {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: flex;
  gap: 4px;
  padding: 5px;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 8px;
  background: var(--navy-950);
  box-shadow: 0 10px 28px rgba(0,0,0,.24);
}

.demo-switch a {
  min-width: 70px;
  padding: 7px 9px;
  border-radius: 5px;
  color: #d8e6f4;
  text-align: center;
  font-size: 11px;
}

.demo-switch a.active { background: #fff; color: var(--navy-900); }
.switch-icon { display: block; margin-bottom: 2px; font-size: 17px; }

.badge, .status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.green, .badge.green { background: var(--green-100); color: var(--green-700); }
.status.blue, .badge.blue { background: var(--blue-100); color: var(--blue-700); }
.status.orange, .badge.orange { background: var(--orange-100); color: var(--orange-700); }
.status.red, .badge.red { background: var(--red-100); color: var(--red-700); }
.status.gray, .badge.gray { background: #eef1f4; color: #596676; }

.admin-app { min-height: 100vh; display: grid; grid-template-columns: 230px minmax(0, 1fr); }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--navy-950);
  color: #fff;
}

.brand {
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}

.brand img { width: 43px; height: 43px; border-radius: 7px; object-fit: cover; }
.brand strong { display: block; font-size: 17px; }
.brand span { color: #9eb5cb; font-size: 11px; }

.side-nav { flex: 1; overflow-y: auto; padding: 12px 9px 100px; }
.nav-label { padding: 13px 10px 6px; color: #718ca5; font-size: 11px; font-weight: 700; }

.nav-item {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #cbd9e7;
  text-align: left;
}

.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: #1768ac; color: #fff; }
.nav-icon { width: 20px; color: #8fb0cb; text-align: center; font-size: 16px; }
.nav-item.active .nav-icon { color: #fff; }
.nav-count { margin-left: auto; min-width: 22px; padding: 2px 6px; border-radius: 9px; background: var(--orange-700); color: #fff; text-align: center; font-size: 11px; }

.sidebar-user {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 15px;
  border-top: 1px solid rgba(255,255,255,.12);
  background: var(--navy-950);
}

.avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #ee7c24;
  color: #fff;
  font-weight: 800;
}

.sidebar-user strong { display: block; }
.sidebar-user span { color: #98aec2; font-size: 12px; }

.admin-main { min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.97);
}

.mobile-menu { display: none; }
.breadcrumb { min-width: 190px; color: var(--muted); font-size: 13px; }

.global-search {
  flex: 1;
  max-width: 620px;
  height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.global-search input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.role-select { height: 38px; padding: 0 30px 0 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); }

.workspace { padding: 22px 24px 90px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.page-head p { color: var(--muted); }
.page-actions { display: flex; gap: 8px; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }

.kpi {
  min-height: 116px;
  padding: 16px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--blue-700);
  border-radius: 7px;
  background: var(--surface);
}

.kpi.green { border-top-color: var(--green-700); }
.kpi.orange { border-top-color: var(--orange-700); }
.kpi.red { border-top-color: var(--red-700); }
.kpi-label { color: var(--muted); font-size: 12px; }
.kpi-value { margin: 8px 0 4px; font-size: 27px; font-weight: 800; }
.kpi-note { color: var(--muted); font-size: 12px; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, .8fr); gap: 14px; margin-bottom: 14px; }
.grid-equal { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.panel-head { min-height: 55px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 15px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; }
.panel-body { padding: 15px; }
.panel-body.flush { padding: 0; }

.chain { display: grid; grid-template-columns: repeat(7, minmax(90px, 1fr)); overflow-x: auto; }
.chain-step { position: relative; min-width: 100px; padding: 18px 10px 15px; border-right: 1px solid var(--line); text-align: center; }
.chain-step:last-child { border-right: 0; }
.chain-step::after { content: "›"; position: absolute; right: -6px; top: 35px; z-index: 1; color: #9cafc0; font-size: 23px; }
.chain-step:last-child::after { display: none; }
.chain-number { width: 30px; height: 30px; display: grid; place-items: center; margin: 0 auto 9px; border-radius: 50%; background: var(--blue-100); color: var(--blue-700); font-weight: 800; }
.chain-step.done .chain-number { background: var(--green-100); color: var(--green-700); }
.chain-step.alert .chain-number { background: var(--orange-100); color: var(--orange-700); }
.chain-step strong { display: block; margin-bottom: 5px; font-size: 13px; }
.chain-step small { color: var(--muted); }

.task-list { display: grid; gap: 9px; }
.task-item { display: flex; align-items: flex-start; gap: 10px; padding-bottom: 9px; border-bottom: 1px solid var(--line); }
.task-item:last-child { padding-bottom: 0; border-bottom: 0; }
.task-mark { width: 9px; height: 9px; flex: 0 0 auto; margin-top: 6px; border-radius: 50%; background: var(--orange-700); }
.task-item strong { display: block; margin-bottom: 3px; font-size: 13px; }
.task-item p { color: var(--muted); font-size: 12px; line-height: 1.5; }

.table-toolbar { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.filter-input, .filter-select { height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 5px; background: #fff; color: var(--ink); }
.filter-input { min-width: 220px; }

.table-wrap { width: 100%; max-width: 100%; min-width: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; white-space: nowrap; }
th { background: #f5f8fa; color: #506176; font-size: 12px; font-weight: 700; }
td { font-size: 13px; }
tbody tr:hover { background: #f8fbfd; }
.table-product { display: flex; align-items: center; gap: 9px; min-width: 210px; white-space: normal; }
.table-product img { width: 42px; height: 42px; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 5px; object-fit: cover; }
.table-product strong { display: block; margin-bottom: 3px; }
.table-product span { color: var(--muted); font-size: 11px; }

.business-table-wrap {
  position: relative;
  scrollbar-color: #aebdca #eef3f6;
  scrollbar-width: thin;
  overscroll-behavior-inline: contain;
  transition: box-shadow .16s ease;
}
.business-table-wrap::-webkit-scrollbar { width: 8px; height: 8px; }
.business-table-wrap::-webkit-scrollbar-track { background: #eef3f6; }
.business-table-wrap::-webkit-scrollbar-thumb { border: 2px solid #eef3f6; border-radius: 8px; background: #aebdca; }
.business-table-wrap:focus { outline: 0; }
.business-table-wrap:focus-visible { outline: 2px solid rgba(23, 101, 171, .32); outline-offset: -2px; }
.business-table-wrap.can-scroll:not(.scrolled-end) { box-shadow: inset -14px 0 12px -14px rgba(20, 48, 73, .48); }
.business-table-wrap.can-scroll.scrolled-start:not(.scrolled-end) { box-shadow: inset 14px 0 12px -14px rgba(20, 48, 73, .48), inset -14px 0 12px -14px rgba(20, 48, 73, .48); }
.business-table-wrap.can-scroll.scrolled-start.scrolled-end { box-shadow: inset 14px 0 12px -14px rgba(20, 48, 73, .48); }
.business-table { min-width: 100%; }
.business-table th {
  position: sticky;
  top: 0;
  z-index: 4;
  box-shadow: inset 0 -1px 0 var(--line);
}
.business-table tbody tr { --table-row-bg: #fff; }
.business-table tbody tr:nth-child(even) { --table-row-bg: #fbfcfd; }
.business-table tbody tr:hover { --table-row-bg: #f4f8fb; }
.business-table tbody td { background: var(--table-row-bg); }
.business-table .table-key,
.business-table .table-actions { background: var(--table-row-bg, #fff); }
.business-table.table-wide .table-key {
  position: sticky;
  left: 0;
  z-index: 2;
  box-shadow: 1px 0 0 var(--line), 7px 0 10px -10px rgba(20, 48, 73, .72);
}
.business-table.table-wide thead .table-key {
  z-index: 6;
  background: #f5f8fa;
}
.business-table.table-wide .table-actions {
  position: sticky;
  right: 0;
  z-index: 2;
  min-width: 116px;
  box-shadow: -1px 0 0 var(--line), -7px 0 10px -10px rgba(20, 48, 73, .72);
  white-space: nowrap;
}
.business-table.table-wide td.table-actions-multi { min-width: 196px; }
.business-table.table-wide thead .table-actions {
  z-index: 6;
  background: #f5f8fa;
}
.business-table .table-numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.business-table .table-date { font-variant-numeric: tabular-nums; }
.business-table td.table-status { min-width: 88px; }
.business-table td.table-actions .button {
  min-height: 30px;
  margin: 2px 3px 2px 0;
}
.business-table .table-wide-message {
  padding: 24px 16px;
  color: var(--muted);
  text-align: center;
  white-space: normal;
}

.business-table-page {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}
.business-table-tabs {
  display: flex;
  gap: 0;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: #f5f8fa;
  scrollbar-width: thin;
}
.business-table-tabs button {
  min-width: 116px;
  height: 46px;
  padding: 0 16px;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 3px solid transparent;
  background: transparent;
  color: #52667a;
  font: inherit;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.business-table-tabs button:hover { background: #eef4f8; color: var(--blue-700); }
.business-table-tabs button.active {
  border-bottom-color: var(--blue-700);
  background: #fff;
  color: var(--blue-700);
}
.business-table-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.business-table-filters,
.business-table-actions {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 8px;
}
.business-table-filters { min-width: 0; }
.business-table-filters .field.compact { min-width: 130px; margin: 0; }
.business-table-filters .field.compact > span { margin-bottom: 4px; font-size: 11px; }
.business-table-filters .field.compact input,
.business-table-filters .field.compact select { height: 35px; min-height: 35px; padding: 0 9px; }
.business-table-filters .table-search-field { flex: 1 1 220px; }
.business-table-actions { flex: 0 0 auto; }
.business-table-help {
  display: grid;
  grid-template-columns: minmax(170px, auto) minmax(280px, 1fr);
  gap: 6px 16px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  background: #f8fbfd;
}
.business-table-help strong { color: #163d5d; }
.business-table-help span { color: #4f6274; line-height: 1.55; }
.business-table-help em {
  grid-column: 2;
  color: #687b8e;
  font-size: 12px;
  font-style: normal;
}
.business-table-help.workflow { border-left: 4px solid var(--orange-700); }
.business-table-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.business-data-table { min-width: max-content; }
.business-data-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  box-shadow: inset 0 -1px 0 var(--line);
}
.business-data-table td { max-width: 360px; }
.business-data-table td:last-child { white-space: normal; }
.modal.business-table-modal { width: min(1180px, 100%); }
.business-table-modal .modal-body { overflow-x: auto; }
.business-table-print {
  min-width: 270mm;
  padding: 8mm;
  color: #000;
  background: #fff;
}
.business-table-print header { margin-bottom: 5mm; text-align: center; }
.business-table-print header h2 { margin: 0 0 2mm; font-size: 20px; }
.business-table-print header p,
.business-table-print footer { margin: 0; font-size: 11px; }
.business-table-print table { table-layout: auto; }
.business-table-print th,
.business-table-print td {
  padding: 2mm;
  border: 1px solid #333;
  color: #000;
  font-size: 9px;
  white-space: normal;
}
.business-table-print footer { margin-top: 4mm; text-align: right; }

.progress { width: 100px; height: 7px; overflow: hidden; border-radius: 4px; background: #e7edf2; }
.progress span { display: block; height: 100%; background: var(--green-700); }
.progress.orange span { background: var(--orange-700); }

.schedule-list { display: grid; gap: 10px; }
.schedule-item { display: grid; grid-template-columns: 55px 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.schedule-item:last-child { border-bottom: 0; }
.schedule-time { color: var(--blue-700); font-weight: 800; }
.schedule-item strong { display: block; margin-bottom: 3px; }
.schedule-item small { color: var(--muted); }

.stock-split { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stock-box { padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-soft); }
.stock-box span { display: block; color: var(--muted); font-size: 12px; }
.stock-box strong { display: block; margin-top: 6px; font-size: 19px; }

.product-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.product-item { display: flex; gap: 12px; padding: 11px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.product-item img { width: 76px; height: 76px; flex: 0 0 auto; border-radius: 5px; object-fit: cover; }
.product-item strong { display: block; margin-bottom: 4px; }
.product-item p { color: var(--muted); font-size: 12px; line-height: 1.5; }

.machine-board { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); gap: 10px; }
.machine-card { min-height: 120px; padding: 12px; border: 1px solid var(--line); border-left: 4px solid var(--green-700); border-radius: 6px; background: #fff; }
.machine-card[data-action] { cursor: pointer; transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease; }
.machine-card[data-action]:hover { border-color: #8db2d2; box-shadow: 0 3px 10px rgba(10, 48, 82, .1); transform: translateY(-1px); }
.machine-card[data-action]:focus-visible { outline: 3px solid rgba(21, 105, 174, .28); outline-offset: 2px; }
.machine-card.warning { border-left-color: var(--orange-700); }
.machine-card.stopped { border-left-color: #8795a4; }
.machine-card header { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 13px; }
.machine-card strong { font-size: 15px; }
.machine-card p { margin-bottom: 5px; color: var(--muted); font-size: 12px; }
.machine-card b { font-size: 18px; }

.ai-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, .6fr);
  gap: 14px;
  height: clamp(480px, calc(100dvh - 272px), 820px);
  min-height: 0;
  align-items: start;
}
.ai-chat {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  background: #f5f8fb;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-color: #a8b8c8 transparent;
  scrollbar-width: thin;
}
.chat-messages::-webkit-scrollbar { width: 8px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb {
  background: #a8b8c8;
  border: 2px solid #f5f8fb;
  border-radius: 8px;
}
.message { max-width: 78%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 7px; background: #fff; line-height: 1.65; }
.message.user { align-self: flex-end; border-color: #bdd5eb; background: var(--blue-100); }
.message strong { display: block; margin-bottom: 4px; }
.message.operation-guide { width: min(92%, 880px); max-width: 92%; padding: 0; overflow: hidden; }
.ai-answer-title { padding: 14px 16px 10px; font-size: 15px; }
.ai-answer-body {
  margin-top: 10px;
  line-height: 1.8;
  overflow-wrap: anywhere;
}
.operation-guide .ai-answer-body { margin-top: 0; }
.ai-answer-text { white-space: normal; }
.ai-guide { border-top: 1px solid var(--line); }
.ai-guide-section { padding: 13px 16px; }
.ai-guide-section + .ai-guide-section { border-top: 1px solid var(--line); }
.ai-guide-section h4 { margin: 0 0 7px; color: var(--navy-800); font-size: 13px; }
.ai-guide-copy { color: #25364a; }
.ai-guide-copy p { margin: 0; }
.ai-guide-copy p + p { margin-top: 4px; }
.ai-guide-path { background: #f1f7fc; }
.ai-path-list { display: flex; flex-wrap: wrap; gap: 7px 20px; margin: 0; padding: 0; list-style: none; counter-reset: ai-path; }
.ai-path-list li { position: relative; padding-left: 24px; color: #163f67; font-weight: 700; counter-increment: ai-path; }
.ai-path-list li::before { position: absolute; left: 0; top: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--blue-700); color: #fff; content: counter(ai-path); font-size: 11px; line-height: 18px; text-align: center; }
.ai-path-list li:not(:last-child)::after { position: absolute; right: -14px; color: #83a5c2; content: "›"; }
.ai-step-list { margin: 0; padding-left: 23px; }
.ai-step-list li { padding-left: 3px; }
.ai-step-list li + li { margin-top: 5px; }
.source-list { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 14px; margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--line); color: var(--blue-700); font-size: 12px; }
.operation-guide .source-list { margin: 0; padding: 10px 16px; background: #fafcfe; }
.chat-compose {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: #fff;
}
.chat-compose textarea { flex: 1; min-height: 45px; max-height: 120px; padding: 10px; border: 1px solid var(--line); border-radius: 6px; resize: vertical; }
.ai-prompt-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 18px 14px; background: #f5f8fb; }
.ai-prompt { min-height: 36px; padding: 7px 11px; border: 1px solid #bfd3e5; border-radius: 5px; background: #fff; color: var(--blue-800); font: inherit; cursor: pointer; }
.ai-prompt:hover { border-color: var(--blue-700); background: var(--blue-100); }
.message.ai-action-message { width: min(100%, 960px); max-width: 100%; padding: 0; overflow: hidden; align-self: flex-start; }
.ai-draft-form { display: grid; gap: 14px; padding: 16px; }
.ai-draft-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.ai-draft-head h4 { margin: 0 0 4px; font-size: 18px; }
.ai-draft-head p { margin: 0; color: var(--muted); }
.ai-draft-summary { padding: 12px 14px; border-left: 3px solid var(--blue-700); background: var(--blue-100); line-height: 1.7; }
.ai-draft-facts { display: flex; flex-wrap: wrap; gap: 7px; }
.ai-draft-facts span { padding: 5px 8px; border: 1px solid var(--line); border-radius: 4px; background: #f8fafc; color: #405268; font-size: 12px; }
.ai-draft-notice,
.ai-draft-ready,
.ai-draft-result { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border-radius: 5px; line-height: 1.65; }
.ai-draft-notice { border: 1px solid #f0c48d; background: #fff6e8; color: #7d470b; }
.ai-draft-ready { border: 1px solid #a9d8bf; background: #edf9f2; color: #14633c; }
.ai-draft-result { border: 1px solid #a9d8bf; background: #edf9f2; color: #14633c; }
.ai-draft-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ai-draft-field { display: grid; align-content: start; gap: 6px; min-width: 0; }
.ai-draft-field > span { color: #48586d; font-size: 12px; font-weight: 700; }
.ai-draft-field input,
.ai-draft-field select,
.ai-draft-field textarea { width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 5px; background: #fff; color: var(--ink); font: inherit; outline: 0; }
.ai-draft-field textarea { min-height: 76px; resize: vertical; }
.ai-draft-field input:focus,
.ai-draft-field select:focus,
.ai-draft-field textarea:focus { border-color: var(--blue-700); box-shadow: 0 0 0 2px rgba(23,104,172,.12); }
.required-mark { color: var(--red); }
.ai-draft-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.ai-draft-actions .button[disabled] { cursor: not-allowed; opacity: .5; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: grid; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { color: #536174; font-size: 12px; font-weight: 700; }
.field input, .field select, .field textarea { width: 100%; min-height: 42px; padding: 9px 10px; border: 1px solid var(--line-strong); border-radius: 5px; background: #fff; color: var(--ink); outline: 0; }
.field textarea { min-height: 86px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue-700); box-shadow: 0 0 0 2px rgba(23,104,172,.12); }
.field.compact { min-width: 150px; }
.field.compact span { color: var(--muted); font-size: 11px; font-weight: 700; }
.field.compact input, .field.compact select { min-height: 36px; }
.form-note { padding: 10px 12px; border-left: 3px solid var(--orange-700); background: var(--orange-100); color: #75430f; line-height: 1.55; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.camera-capture {
  min-height: 112px;
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 16px;
  border: 2px dashed #9eb6ca;
  border-radius: 7px;
  background: #f4f9fd;
  color: var(--navy-800);
  text-align: center;
  cursor: pointer;
}

.camera-capture:hover { border-color: var(--blue-700); background: var(--blue-100); }
.camera-capture input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.camera-symbol { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: var(--navy-800); color: #fff; font-size: 18px; font-weight: 800; }
.camera-capture strong { display: block; font-size: 15px; }
.camera-capture small { display: block; color: var(--muted); }
.camera-preview { width: 100%; max-height: 260px; margin-top: 10px; border: 1px solid var(--line); border-radius: 6px; object-fit: contain; background: #eef2f5; }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(6,22,38,.56); }
.modal { width: min(720px, 100%); max-height: calc(100vh - 40px); overflow: auto; border-radius: 8px; background: #fff; box-shadow: 0 22px 60px rgba(0,0,0,.25); }
.modal-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); background: #fff; }
.modal-head h2 { margin: 0; }
.modal-body { padding: 18px; }
.inventory-summary-modal { width: min(1180px, 100%); }
.inventory-summary-toolbar { display: grid; grid-template-columns: 160px 160px 150px minmax(240px, 1fr); gap: 10px; }
.inventory-summary-toolbar .field { margin: 0; }
.inventory-summary-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.inventory-summary-table { min-width: 1040px; }
.inventory-summary-table th:nth-child(4),
.inventory-summary-table td:nth-child(4) { min-width: 240px; }
.inventory-record-modal { width: min(1220px, 100%); }
.inventory-record-toolbar { align-items: center; }
.inventory-record-toolbar .filter-input { flex: 1; }
.inventory-record-table { min-width: 1180px; }
.filter-result-note { padding: 8px 14px; color: var(--muted); font-size: 12px; background: #f8fafc; border-bottom: 1px solid var(--line); }
.pre-inbound-modal { width: min(1280px, 100%); }
.pre-inbound-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.pre-inbound-table { min-width: 1220px; }
.pre-inbound-panel table { min-width: 1040px; }
.row-actions { display: flex; align-items: center; gap: 6px; min-width: max-content; }
.warning-note { color: #714411; }

.slip-modal { width: min(980px, 100%); }
.slip-stage { overflow-x: auto; padding: 8px; background: #e7ebef; }
.slip-preview {
  width: 100%;
  min-width: 760px;
  aspect-ratio: 240 / var(--slip-height, 93);
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
  border: 1px solid #222;
  background: #fff;
  color: #111;
  font-family: SimSun, "Microsoft YaHei", sans-serif;
}
.slip-title { margin-bottom: 4px; text-align: center; font-size: 19px; font-weight: 700; }
.slip-meta { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 12px; margin-bottom: 5px; font-size: 12px; }
.slip-preview table { table-layout: fixed; flex: 1; border: 1px solid #222; }
.slip-preview th, .slip-preview td { height: 25px; padding: 3px 5px; border: 1px solid #222; color: #111; text-align: center; font-size: 11px; white-space: normal; }
.slip-preview th { background: #fff; }
.slip-total { display: flex; justify-content: space-between; gap: 15px; padding: 4px 1px 0; font-size: 11px; }
.slip-signatures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 5px; font-size: 11px; }
.document-bundle-list { display: grid; gap: 10px; margin-top: 14px; }
.bundle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 14px; border: 1px solid var(--line); background: #f8fafb; }
.bundle-row p { margin-top: 3px; color: var(--muted); font-size: 12px; }

.report-modal { width: min(1120px, 100%); }
.report-stage { overflow-x: auto; padding: 8px; background: #e7ebef; }
.inspection-report-preview {
  width: 100%;
  min-width: 860px;
  aspect-ratio: 241 / 140;
  display: flex;
  flex-direction: column;
  padding: 18px 22px;
  border: 1px solid #222;
  background: #fff;
  color: #111;
  font-family: SimSun, "Microsoft YaHei", sans-serif;
}
.report-company { text-align: center; font-size: 17px; font-weight: 700; }
.report-title { margin: 3px 0 8px; text-align: center; font-size: 23px; font-weight: 800; }
.report-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px 14px; margin-bottom: 8px; font-size: 12px; }
.inspection-report-preview table { table-layout: fixed; flex: 1; border: 1px solid #222; }
.inspection-report-preview th, .inspection-report-preview td { height: 31px; padding: 4px 6px; border: 1px solid #222; color: #111; text-align: center; font-size: 12px; white-space: normal; }
.inspection-report-preview th { background: #fff; }
.report-conclusion { min-height: 38px; padding: 7px 3px 2px; font-size: 12px; }
.report-signatures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; padding-top: 5px; font-size: 12px; }
.special-delivery .report-meta { grid-template-columns: repeat(2, 1fr); }

.special-delivery-modal { width: min(1220px, 100%); }
.special-delivery-stage { overflow-x: auto; }
.special-delivery-note {
  width: 100%;
  min-width: 1000px;
  aspect-ratio: 297 / 210;
  padding: 24px 28px;
  background: #fff;
  color: #245989;
  font-family: SimSun, "Microsoft YaHei", sans-serif;
}
.special-delivery-note table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  border: 2px solid #245989;
}
.special-delivery-note th,
.special-delivery-note td {
  padding: 4px 7px;
  border: 1.5px solid #245989;
  background: #fff;
  color: #245989;
  font-size: 13px;
  line-height: 1.1;
  text-align: left;
  white-space: normal;
}
.special-delivery-note th { font-weight: 700; }
.special-delivery-meta col:nth-child(1) { width: 10%; }
.special-delivery-meta col:nth-child(2) { width: 12%; }
.special-delivery-meta col:nth-child(3) { width: 10%; }
.special-delivery-meta col:nth-child(4) { width: 13%; }
.special-delivery-meta col:nth-child(5) { width: 9%; }
.special-delivery-meta col:nth-child(6) { width: 10%; }
.special-delivery-meta col:nth-child(7) { width: 10%; }
.special-delivery-meta col:nth-child(8) { width: 10%; }
.special-delivery-meta col:nth-child(9) { width: 7%; }
.special-delivery-meta col:nth-child(10) { width: 9%; }
.special-delivery-meta tr { height: 29px; }
.special-delivery-meta .delivery-main-title { height: 38px; }
.special-delivery-meta .delivery-main-title th {
  text-align: center;
  font-size: 23px;
  letter-spacing: 0;
}
.special-delivery-items { margin-top: 34px; }
.special-delivery-items .delivery-company { height: 45px; }
.special-delivery-items .delivery-company th { text-align: center; font-size: 23px; }
.special-delivery-items thead tr:last-child { height: 36px; }
.special-delivery-items thead tr:last-child th { text-align: center; font-size: 14px; }
.special-delivery-items tbody tr { height: 40px; }
.special-delivery-items tbody td { text-align: center; font-size: 13px; font-weight: 700; }
.special-delivery-signatures {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 30px;
  padding: 10px 10px 0;
  color: #245989;
  font-size: 15px;
  font-weight: 700;
}

.factory-inspection-report {
  display: block;
  padding: 15px 22px 13px;
  font-family: SimSun, "Microsoft YaHei", sans-serif;
}
.factory-report-header { padding: 0 15px; }
.factory-inspection-report .report-company { font-size: 21px; line-height: 1.2; }
.factory-inspection-report .report-title { margin: 8px 0 5px; font-size: 25px; line-height: 1.1; }
.factory-report-number {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: end;
  gap: 20px;
  font-size: 13px;
  line-height: 1.2;
}
.factory-report-number span:nth-child(2) { text-align: center; }
.factory-report-number span:nth-child(3) { text-align: right; }
.factory-inspection-report table {
  width: 100%;
  border-collapse: collapse;
  border: 1.2px solid #111;
}
.factory-inspection-report th,
.factory-inspection-report td {
  height: auto;
  padding: 3px 6px;
  border: 1px solid #111;
  background: #fff;
  color: #111;
  text-align: center;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.12;
  white-space: normal;
}
.factory-inspection-report th { text-align: left; }
.inspection-basic-table { margin-top: 3px; table-layout: fixed; }
.inspection-basic-table tr { height: 23px; }
.inspection-basic-table .label-col { width: 12%; }
.inspection-basic-table .value-col { width: 23%; }
.inspection-basic-table .short-value-col { width: 12%; }
.inspection-table-spacer {
  height: 18px;
  border-right: 1.2px solid #111;
  border-left: 1.2px solid #111;
}
.inspection-result-table { table-layout: fixed; }
.inspection-result-table .item-col { width: 14%; }
.inspection-result-table .requirement-col { width: 25%; }
.inspection-result-table .result-col { width: 43%; }
.inspection-result-table .decision-col { width: 18%; }
.inspection-result-table thead tr { height: 22px; }
.inspection-result-table tbody tr { height: 20px; }
.inspection-result-table thead th { text-align: center; font-size: 13px; }
.inspection-result-table tbody td:first-child,
.inspection-result-table .conclusion-row td { text-align: left; }
.inspection-result-table .conclusion-row { height: 25px; }
.factory-report-signatures {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr 1.2fr;
  gap: 16px;
  padding: 9px 18px 0;
  font-size: 13px;
  line-height: 1.2;
}

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 200; max-width: min(520px, calc(100vw - 32px)); padding: 12px 18px; border-radius: 6px; background: var(--navy-950); color: #fff; box-shadow: var(--shadow); transform: translateX(-50%); text-align: center; font-weight: 700; }

/* Factory Pad */
.pad-app { min-height: 100vh; background: #edf2f5; }
.pad-topbar { min-height: 70px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 18px; padding: 10px 20px; background: var(--navy-950); color: #fff; }
.pad-brand { display: flex; align-items: center; gap: 10px; }
.pad-brand img { width: 43px; height: 43px; border-radius: 6px; object-fit: cover; }
.pad-brand strong { display: block; font-size: 17px; }
.pad-brand span { color: #a9bfd4; font-size: 11px; }
.shift-banner { justify-self: center; display: flex; align-items: center; gap: 18px; color: #dce8f2; }
.shift-banner b { color: #fff; }
.identity-select { min-height: 44px; padding: 0 12px; border: 1px solid rgba(255,255,255,.24); border-radius: 6px; background: #163b61; color: #fff; }
.pad-content { max-width: 1500px; margin: 0 auto; padding: 16px 18px 90px; }
.pad-alert { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; padding: 12px 14px; border: 1px solid #f3c899; border-left: 5px solid var(--orange-700); border-radius: 7px; background: var(--orange-100); }
.pad-alert strong { display: block; margin-bottom: 3px; }
.pad-alert p { color: #80521e; }
.pad-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr); gap: 14px; }
.pad-panel { border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.pad-panel-head { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 15px; border-bottom: 1px solid var(--line); }
.pad-panel-head h2 { margin: 0; }
.pad-panel-body { padding: 14px; }
.pad-section-title { display: flex; align-items: center; gap: 8px; margin: 6px 0 10px; font-size: 14px; }
.line-label { min-width: 40px; padding: 4px 7px; border-radius: 4px; background: var(--blue-100); color: var(--blue-700); text-align: center; }
.line-label.pet { background: var(--green-100); color: var(--green-700); }
.pad-machine-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin-bottom: 16px; }
.pad-machine { min-height: 116px; display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 11px; border: 2px solid #6db68f; border-radius: 7px; background: #f8fffb; text-align: left; }
.pad-machine.warning { border-color: #e8a458; background: #fffaf4; }
.pad-machine.off { border-color: #c5cdd5; background: #f4f6f8; }
.pad-machine strong { display: block; margin-bottom: 5px; font-size: 16px; }
.pad-machine p { margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.pad-machine .machine-rate { align-self: end; color: var(--green-700); font-weight: 800; }
.pad-machine.warning .machine-rate { color: var(--orange-700); }
.quick-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.quick-action { min-height: 94px; display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--line-strong); border-radius: 7px; background: #fff; color: var(--ink); text-align: left; }
.quick-action:hover { border-color: var(--blue-700); background: #f5faff; }
.quick-action.alert { border-color: #e5a1a1; background: #fff8f8; }
.quick-symbol { width: 43px; height: 43px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 6px; background: var(--blue-100); color: var(--blue-700); font-size: 22px; font-weight: 800; }
.quick-action.alert .quick-symbol { background: var(--red-100); color: var(--red-700); }
.quick-action strong { display: block; margin-bottom: 4px; font-size: 15px; }
.quick-action span { color: var(--muted); font-size: 12px; }
.pad-task-list { display: grid; gap: 9px; }
.pad-task { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 11px; border: 1px solid var(--line); border-radius: 6px; }
.pad-task-time { width: 48px; color: var(--blue-700); font-size: 16px; font-weight: 800; }
.pad-task strong { display: block; margin-bottom: 3px; }
.pad-task span { color: var(--muted); font-size: 12px; }
.pad-task-end { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.pad-task-end .button { white-space: nowrap; }
.encouragement { margin-top: 12px; padding: 15px; border-left: 4px solid var(--green-700); border-radius: 6px; background: var(--green-100); color: #18593c; line-height: 1.7; }

/* Driver phone */
.driver-app { min-height: 100vh; display: grid; place-items: start center; padding: 18px 14px 90px; background: #dfe7ed; }
.driver-shell { width: min(480px, 100%); min-height: calc(100vh - 36px); overflow: hidden; border-radius: 8px; background: #f3f6f8; box-shadow: 0 12px 36px rgba(22,39,57,.17); }
.driver-header { padding: 16px; background: var(--navy-950); color: #fff; }
.driver-header-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 17px; }
.driver-header h1 { margin: 0; font-size: 22px; }
.driver-user { display: flex; align-items: center; gap: 9px; }
.driver-user .avatar { width: 34px; height: 34px; }
.driver-date { color: #b7cbdd; font-size: 12px; }
.driver-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.driver-summary div { padding: 8px; border: 1px solid rgba(255,255,255,.14); border-radius: 6px; background: rgba(255,255,255,.07); }
.driver-summary span { display: block; color: #a9bfd4; font-size: 11px; }
.driver-summary strong { display: block; margin-top: 4px; font-size: 17px; }
.driver-content { padding: 13px 13px 22px; }
.driver-date-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.driver-date-tabs button { min-height: 44px; border: 1px solid var(--line-strong); border-radius: 7px; background: #fff; color: var(--ink); font-weight: 700; }
.driver-date-tabs button.active { border-color: var(--blue-700); background: var(--navy-950); color: #fff; }
.driver-date-tabs strong { margin-left: 4px; }
.route-card { margin-bottom: 12px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.driver-active-route { border-color: #9ab3c9; box-shadow: 0 5px 18px rgba(23, 56, 84, .08); }
.driver-route-choice { width: 100%; padding: 0; color: inherit; text-align: left; cursor: pointer; }
.driver-route-choice:hover { border-color: var(--blue-700); }
.route-head { display: flex; justify-content: space-between; gap: 12px; padding: 13px; border-bottom: 1px solid var(--line); }
.route-head strong { display: block; margin-bottom: 3px; font-size: 16px; }
.route-head span { color: var(--muted); font-size: 12px; }
.route-body { padding: 13px; }
.route-line { display: grid; grid-template-columns: 64px 1fr; gap: 8px; padding: 7px 0; }
.route-line > span { color: var(--muted); }
.cargo-list { margin: 6px 0 10px; padding: 10px; border-radius: 6px; background: var(--surface-soft); }
.cargo-list div { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; }
.driver-odometer-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 12px 0; }
.driver-odometer-summary div { padding: 8px 6px; border-radius: 6px; background: #edf3f7; text-align: center; }
.driver-odometer-summary span { display: block; color: var(--muted); font-size: 11px; }
.driver-odometer-summary strong { display: block; margin-top: 3px; font-size: 13px; }
.driver-timeline { display: grid; grid-template-columns: repeat(5, 1fr); margin: 18px 0; }
.driver-step { position: relative; text-align: center; color: var(--muted); font-size: 11px; }
.driver-step::before { content: ""; position: absolute; left: -50%; right: 50%; top: 11px; height: 2px; background: #d5dde4; }
.driver-step:first-child::before { display: none; }
.driver-step-dot { position: relative; z-index: 1; width: 24px; height: 24px; display: grid; place-items: center; margin: 0 auto 6px; border-radius: 50%; background: #dfe5ea; color: #7a8998; font-size: 11px; font-weight: 800; }
.driver-step.done::before, .driver-step.active::before { background: var(--green-700); }
.driver-step.done .driver-step-dot { background: var(--green-700); color: #fff; }
.driver-step.active .driver-step-dot { outline: 3px solid #b9ddcb; background: var(--green-700); color: #fff; }
.driver-step.active { color: var(--ink); font-weight: 700; }
.driver-primary {
  width: 100%;
  min-height: 82px;
  border: 0;
  border-radius: 7px;
  background: var(--green-700);
  color: #fff;
  font-size: 24px;
  font-weight: 800;
  box-shadow: 0 5px 0 #0c5634;
  touch-action: manipulation;
}
.driver-primary:active { transform: translateY(3px); box-shadow: 0 2px 0 #0c5634; }
.driver-primary:disabled { background: #8798a8; box-shadow: 0 5px 0 #667583; cursor: not-allowed; opacity: .9; }
.driver-primary.complete { background: var(--navy-800); box-shadow: 0 5px 0 var(--navy-950); }
.driver-hint { margin-top: 10px; color: var(--muted); text-align: center; font-size: 12px; }
.driver-secondary { width: 100%; min-height: 46px; margin-top: 10px; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; color: var(--ink); font-weight: 700; }
.driver-secondary:disabled { color: #8a98a5; background: #eef2f5; cursor: not-allowed; }
.driver-ocr-status { margin-top: 8px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.driver-ocr-status.loading { color: var(--blue-700); }
.driver-ocr-status.success { color: var(--green-700); font-weight: 700; }
.driver-ocr-status.warning { color: var(--orange-700); font-weight: 700; }
.driver-log { margin-top: 12px; }
.driver-log h3 { margin-bottom: 8px; }
.log-row { display: grid; grid-template-columns: 64px 1fr; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.log-row time { color: var(--blue-700); font-weight: 700; }
.log-row p { color: var(--muted); font-size: 12px; line-height: 1.5; }

@media (max-width: 1180px) {
  .admin-app { grid-template-columns: 82px minmax(0, 1fr); }
  .brand { justify-content: center; padding: 12px 8px; }
  .brand div, .nav-item span:not(.nav-icon):not(.nav-count), .nav-label, .sidebar-user div { display: none; }
  .nav-item { justify-content: center; }
  .nav-icon { font-size: 19px; }
  .nav-count { position: absolute; margin: -22px 0 0 28px; }
  .sidebar-user { justify-content: center; padding: 14px 8px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .machine-board { grid-template-columns: repeat(3, minmax(130px, 1fr)); }
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pad-machine-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inventory-summary-toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pre-inbound-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .admin-app { display: block; }
  .sidebar { position: fixed; left: -245px; z-index: 80; width: 230px; transition: left .2s ease; box-shadow: var(--shadow); }
  .admin-app.menu-open .sidebar { left: 0; }
  .brand { justify-content: flex-start; padding: 14px 16px; }
  .brand div, .nav-item span:not(.nav-icon):not(.nav-count), .nav-label, .sidebar-user div { display: block; }
  .nav-item { justify-content: flex-start; }
  .nav-count { position: static; margin: 0 0 0 auto; }
  .sidebar-user { justify-content: flex-start; padding: 14px 15px; }
  .topbar { height: 58px; padding: 0 12px; gap: 8px; }
  .mobile-menu { display: inline-grid; }
  .breadcrumb { display: none; }
  .global-search { max-width: none; }
  .role-select { max-width: 116px; }
  .workspace { padding: 16px 12px 88px; }
  .page-head { align-items: stretch; flex-direction: column; }
  .page-actions { overflow-x: auto; }
  .admin-main { max-width: 100vw; overflow-x: hidden; }
  .business-table th { top: 0; }
  .business-table-toolbar { align-items: stretch; flex-direction: column; }
  .business-table-filters,
  .business-table-actions { width: 100%; }
  .business-table-actions { justify-content: flex-end; }
  .business-table-help { grid-template-columns: 1fr; }
  .business-table-help em { grid-column: 1; }
  .grid-2, .grid-equal, .ai-layout { grid-template-columns: minmax(0, 1fr); }
  .grid-2 > *, .grid-equal > *, .ai-layout > * { min-width: 0; }
  .ai-layout { height: auto; }
  .ai-chat { height: clamp(520px, calc(100dvh - 150px), 760px); }
  .chain { grid-template-columns: repeat(7, 118px); }
  .machine-board { grid-template-columns: repeat(2, minmax(125px, 1fr)); }
  .product-grid { grid-template-columns: 1fr; }
  .form-grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pad-topbar { grid-template-columns: 1fr auto; }
  .shift-banner { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; justify-content: space-between; padding-top: 8px; border-top: 1px solid rgba(255,255,255,.13); }
  .pad-content { padding: 12px 12px 88px; }
  .pad-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  body { font-size: 13px; }
  h1 { font-size: 22px; }
  .demo-switch { left: 10px; right: 10px; bottom: 8px; justify-content: stretch; }
  .demo-switch a { flex: 1; min-width: 0; padding: 6px 4px; }
  .switch-icon { display: inline; margin: 0 4px 0 0; }
  .top-actions .icon-button { display: none; }
  .global-search { min-width: 0; }
  .role-select { width: 105px; max-width: 105px; padding-left: 7px; }
  .ai-prompt-row { display: grid; padding: 0 12px 12px; }
  .ai-prompt { width: 100%; text-align: left; }
  .message.ai-action-message { width: 100%; }
  .ai-draft-form { padding: 12px; }
  .ai-draft-head { display: grid; }
  .ai-draft-grid { grid-template-columns: minmax(0, 1fr); }
  .ai-draft-actions { display: grid; }
  .ai-draft-actions .button { width: 100%; justify-content: center; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { min-height: 104px; padding: 12px; }
  .kpi-value { font-size: 22px; }
  .page-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: visible; }
  .page-actions .button { width: 100%; min-width: 0; white-space: normal; }
  .table-toolbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table-toolbar .filter-input,
  .table-toolbar .filter-select {
    width: 100%;
    min-width: 0;
  }
  .business-table-filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .business-table-filters .field.compact { min-width: 0; }
  .business-table-filters .table-search-field { grid-column: 1 / -1; }
  .business-table-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .business-table-actions .button { width: 100%; min-width: 0; white-space: normal; }
  .business-table-help { padding: 10px 12px; }
  .business-data-table { min-width: max-content; }
  .table-toolbar .filter-input { grid-column: 1 / -1; }
  .business-table-wrap {
    overflow-x: visible;
    box-shadow: none !important;
  }
  .business-table {
    display: block;
    min-width: 0 !important;
    width: 100%;
  }
  .business-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .business-table tbody,
  .business-table tr { display: block; width: 100%; }
  .business-table tbody tr {
    padding: 7px 0;
    border-bottom: 1px solid var(--line);
    background: var(--table-row-bg);
  }
  .business-table tbody tr:last-child { border-bottom: 0; }
  .business-table tbody td,
  .business-table.table-wide tbody td {
    position: static;
    display: grid;
    grid-template-columns: minmax(92px, 34%) minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    width: 100%;
    min-width: 0;
    padding: 7px 12px;
    border: 0;
    box-shadow: none;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .business-table tbody td::before {
    content: attr(data-label);
    color: #607286;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.45;
  }
  .business-table tbody td.table-key {
    display: block;
    padding-top: 10px;
    color: #133858;
    font-size: 14px;
    font-weight: 800;
  }
  .business-table tbody td.table-key::before { display: none; }
  .business-table tbody td.table-actions {
    grid-template-columns: 92px minmax(0, 1fr);
    padding-bottom: 10px;
    white-space: normal;
  }
  .business-table tbody td.table-actions .button { width: auto; }
  .business-table tbody td.table-wide-message {
    display: block;
    padding: 24px 14px;
    text-align: center;
  }
  .business-table tbody td.table-wide-message::before { display: none; }
  .business-table .table-product { min-width: 0; }
  .business-table .progress { max-width: 100%; }
  .machine-board { grid-template-columns: 1fr; }
  .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .button { width: 100%; }
  .stock-split { grid-template-columns: 1fr; }
  .inventory-summary-toolbar { grid-template-columns: 1fr; }
  .inventory-summary-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pre-inbound-summary { grid-template-columns: 1fr; }
  .ai-chat { height: calc(100dvh - 130px); min-height: 480px; max-height: 720px; }
  .chat-messages { padding: 12px; }
  .message { max-width: 92%; }
  .message.operation-guide { width: 100%; max-width: 100%; }
  .ai-path-list { display: grid; gap: 8px; }
  .ai-path-list li:not(:last-child)::after { display: none; }
  .chat-compose { position: static; }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal { max-height: 92vh; border-radius: 8px 8px 0 0; }
  .pad-topbar { padding: 10px 12px; }
  .pad-brand span { display: none; }
  .identity-select { max-width: 145px; }
  .shift-banner { gap: 8px; font-size: 12px; }
  .pad-alert { align-items: flex-start; flex-direction: column; }
  .pad-alert .button { width: 100%; }
  .pad-machine-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .pad-machine { min-height: 108px; padding: 9px; }
  .pad-machine strong { font-size: 14px; }
  .quick-actions { grid-template-columns: 1fr; }
  .quick-action { min-height: 75px; }
  .driver-app { padding: 0 0 72px; background: #f3f6f8; }
  .driver-shell { min-height: 100vh; border-radius: 0; box-shadow: none; }
  .driver-header { padding-top: max(16px, env(safe-area-inset-top)); }
}

@media (max-width: 420px) {
  .pad-machine-grid { grid-template-columns: minmax(0, 1fr); }
  .pad-machine { min-height: 98px; }
}

@media print {
  .sidebar, .topbar, .demo-switch, .page-actions, .table-toolbar { display: none !important; }
  .business-table-wrap { overflow: visible !important; box-shadow: none !important; }
  .business-table { display: table !important; min-width: 0 !important; }
  .business-table thead { display: table-header-group !important; position: static !important; width: auto !important; height: auto !important; clip: auto !important; clip-path: none !important; }
  .business-table tbody { display: table-row-group !important; }
  .business-table tr { display: table-row !important; }
  .business-table th,
  .business-table td { position: static !important; display: table-cell !important; box-shadow: none !important; }
  .business-table td::before { display: none !important; }
  .admin-app { display: block; }
  .workspace { padding: 0; }
  .panel { border: 0; }
  body { background: #fff; }

  body.printing-business-table #app,
  body.printing-business-table .demo-switch,
  body.printing-business-table .modal-head,
  body.printing-business-table .form-actions { display: none !important; }
  body.printing-business-table .modal-backdrop { position: static; display: block !important; padding: 0; background: #fff; }
  body.printing-business-table .modal { width: 297mm; max-height: none; overflow: visible; border-radius: 0; box-shadow: none; }
  body.printing-business-table .modal-body { padding: 0; }
  body.printing-business-table .business-table-print { width: 297mm; min-width: 297mm; padding: 7mm; }

  body.printing-slip #app,
  body.printing-slip .demo-switch,
  body.printing-slip .modal-head,
  body.printing-slip .form-actions { display: none !important; }
  body.printing-slip .no-print { display: none !important; }
  body.printing-slip .modal-backdrop { position: static; display: block !important; padding: 0; background: #fff; }
  body.printing-slip .modal { width: 240mm; max-height: none; overflow: visible; border-radius: 0; box-shadow: none; }
  body.printing-slip .modal-body { padding: 0; }
  body.printing-slip .slip-stage { overflow: visible; padding: 0; background: #fff; }
  body.printing-slip .slip-preview { width: 240mm; min-width: 240mm; height: 93mm; min-height: 93mm; aspect-ratio: auto; padding: 4mm 5mm; }
  body.printing-slip.slip-height-92 .slip-preview { height: 92mm; min-height: 92mm; }
  body.printing-slip.slip-height-94 .slip-preview { height: 94mm; min-height: 94mm; }

  body.printing-inspection #app,
  body.printing-inspection .demo-switch,
  body.printing-inspection .modal-head,
  body.printing-inspection .form-actions { display: none !important; }
  body.printing-inspection .modal-backdrop { position: static; display: block !important; padding: 0; background: #fff; }
  body.printing-inspection .modal { width: 241mm; max-height: none; overflow: visible; border-radius: 0; box-shadow: none; }
  body.printing-inspection .modal-body { padding: 0; }
  body.printing-inspection .report-stage { overflow: visible; padding: 0; background: #fff; }
  body.printing-inspection .inspection-report-preview { width: 241mm; min-width: 241mm; height: 140mm; min-height: 140mm; aspect-ratio: auto; padding: 7mm 8mm; }
  body.printing-inspection .factory-inspection-report { padding: 4mm 7mm 3mm; }

  body.printing-special-delivery #app,
  body.printing-special-delivery .demo-switch,
  body.printing-special-delivery .modal-head,
  body.printing-special-delivery .form-note,
  body.printing-special-delivery .form-actions { display: none !important; }
  body.printing-special-delivery .modal-backdrop { position: static; display: block !important; padding: 0; background: #fff; }
  body.printing-special-delivery .modal { width: 297mm; max-height: none; overflow: visible; border-radius: 0; box-shadow: none; }
  body.printing-special-delivery .modal-body { padding: 0; }
  body.printing-special-delivery .report-stage { overflow: visible; padding: 0; background: #fff; }
  body.printing-special-delivery .special-delivery-note {
    width: 297mm;
    min-width: 297mm;
    height: 210mm;
    min-height: 210mm;
    aspect-ratio: auto;
    padding: 10mm 12mm 8mm;
  }
}

.production-mode .demo-switch {
  display: none !important;
}

.auth-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #0f2f53;
}

.auth-card {
  width: min(420px, 100%);
  padding: 30px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 22px 60px rgba(5, 25, 48, 0.28);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 22px;
  border-bottom: 1px solid #dfe7ef;
}

.auth-brand img,
.auth-card > img {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
}

.auth-brand strong,
.auth-brand span {
  display: block;
}

.auth-brand strong {
  color: #0f2f53;
  font-size: 18px;
}

.auth-brand span {
  margin-top: 3px;
  color: #64748b;
  font-size: 13px;
}

.auth-heading {
  margin: 24px 0 20px;
}

.auth-heading h1 {
  margin: 3px 0 8px;
  color: #102a43;
  font-size: 27px;
  letter-spacing: 0;
}

.auth-heading p:last-child {
  margin: 0;
  color: #64748b;
  font-size: 14px;
}

.auth-form {
  display: grid;
  gap: 15px;
}

.auth-form label {
  display: grid;
  gap: 7px;
  color: #243b53;
  font-size: 14px;
  font-weight: 600;
}

.auth-form input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid #cbd8e6;
  border-radius: 6px;
  background: #fff;
  color: #102a43;
  font: inherit;
}

.auth-form input:focus {
  border-color: #1c64a6;
  outline: 3px solid rgba(28, 100, 166, 0.12);
}

.auth-form .button {
  min-height: 46px;
  margin-top: 3px;
  justify-content: center;
}

.auth-error {
  margin: 0;
  padding: 10px 12px;
  border-left: 3px solid #c0392b;
  background: #fff2f0;
  color: #9f2d22;
  font-size: 13px;
}

.signed-user {
  max-width: 180px;
  overflow: hidden;
  color: #334e68;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 600px) {
  .auth-screen {
    align-items: end;
    padding: 0;
  }

  .auth-card {
    width: 100%;
    padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
    border: 0;
    border-radius: 8px 8px 0 0;
  }

  .auth-heading h1 {
    font-size: 24px;
  }

  .signed-user {
    display: none;
  }
}

.panel-actions,
.table-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.replenishment-flow {
  display: grid;
  grid-template-columns: repeat(7, auto);
  align-items: center;
  justify-content: start;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid #e1e9f1;
  border-bottom: 1px solid #e1e9f1;
  background: #f7fafc;
  color: #334e68;
  font-size: 13px;
  font-weight: 600;
}

.replenishment-flow i {
  color: #8aa4bd;
  font-style: normal;
}

.panel-subhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 0 16px;
  border-top: 1px solid #e1e9f1;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 10px;
  margin: 10px 0 18px;
}

.photo-thumb {
  display: grid;
  grid-template-rows: 104px auto;
  min-width: 0;
  overflow: hidden;
  border: 1px solid #d7e2ec;
  border-radius: 6px;
  background: #fff;
  color: #334e68;
  text-decoration: none;
}

.photo-thumb img {
  width: 100%;
  height: 104px;
  object-fit: cover;
}

.photo-thumb span {
  overflow: hidden;
  padding: 7px 8px;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-thumb.missing {
  place-items: center;
  min-height: 104px;
  background: #f4f7fa;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.detail-grid > div {
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid #dfe7ef;
  border-radius: 6px;
  background: #f8fafc;
}

.detail-grid span,
.detail-grid strong {
  display: block;
}

.detail-grid span {
  margin-bottom: 5px;
  color: #627d98;
  font-size: 12px;
}

.detail-grid strong {
  overflow-wrap: anywhere;
  color: #102a43;
  font-size: 14px;
}

.check-list {
  display: grid;
  gap: 8px;
  margin: 12px 0 16px;
}

.check-list label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #d7e2ec;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.check-list label:has(input:checked) {
  border-color: #1d6fa8;
  background: #edf6fc;
}

.check-list input {
  margin-top: 3px;
}

.check-list span,
.check-list small {
  display: block;
}

.check-list small {
  margin-top: 3px;
  color: #627d98;
}

.timeline-list {
  display: grid;
  gap: 0;
  margin: 10px 0 18px;
  border-left: 2px solid #cbdbe9;
}

.timeline-list > div {
  position: relative;
  padding: 2px 0 14px 18px;
}

.timeline-list > div::before {
  position: absolute;
  top: 5px;
  left: -6px;
  width: 10px;
  height: 10px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #1d6fa8;
  content: "";
}

.timeline-list time,
.timeline-list strong,
.timeline-list p {
  display: block;
  margin: 0;
}

.timeline-list time {
  color: #627d98;
  font-size: 12px;
}

.timeline-list strong {
  margin: 2px 0;
  color: #102a43;
}

.document-sheet {
  width: 100%;
  padding: 18px;
  border: 1px solid #52697f;
  background: #fff;
  color: #111;
}

.document-sheet > header {
  margin-bottom: 14px;
  text-align: center;
}

.document-sheet > header h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.document-sheet > header p {
  margin: 5px 0 0;
  color: #52606d;
  font-size: 12px;
}

.document-sheet table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
}

.document-sheet th,
.document-sheet td {
  min-height: 34px;
  padding: 7px 6px;
  border: 1px solid #222;
  text-align: center;
  overflow-wrap: anywhere;
}

.document-sheet th {
  background: #f0f3f5;
  color: #111;
}

.document-meta,
.document-signatures {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 8px 0 12px;
  font-size: 12px;
}

.document-signatures {
  margin-top: 16px;
}

.document-note {
  margin: 12px 0;
  padding: 10px 12px;
  border-left: 3px solid #1d6fa8;
  background: #f5f8fb;
  line-height: 1.7;
}

.document-note p {
  margin: 4px 0 0;
}

.document-annex {
  margin-top: 20px;
  break-before: page;
}

.document-annex h3,
.document-annex h4 {
  letter-spacing: 0;
}

@media (max-width: 760px) {
  .replenishment-panel .panel-head {
    align-items: stretch;
  }

  .replenishment-panel .panel-actions .button {
    flex: 1 1 calc(50% - 4px);
    justify-content: center;
  }

  .replenishment-flow {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .replenishment-flow i {
    display: none;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .replenishment-document-modal {
    width: calc(100vw - 16px);
  }

  .document-sheet {
    min-width: 760px;
  }

  .replenishment-document-modal .modal-body {
    overflow-x: auto;
  }
}

@media print {
  body.printing-replenishment-document #app,
  body.printing-replenishment-document .demo-switch,
  body.printing-replenishment-document .modal-head,
  body.printing-replenishment-document .no-print,
  body.printing-replenishment-document .form-actions {
    display: none !important;
  }

  body.printing-replenishment-document .modal-backdrop {
    position: static;
    display: block !important;
    padding: 0;
    background: #fff;
  }

  body.printing-replenishment-document .modal {
    width: 297mm;
    max-height: none;
    overflow: visible;
    border-radius: 0;
    box-shadow: none;
  }

  body.printing-replenishment-document .modal-body {
    padding: 8mm;
    overflow: visible;
  }

  body.printing-replenishment-document .document-sheet {
    width: 100%;
    min-width: 0;
    border: 0;
    padding: 0;
  }

body.printing-replenishment-document .photo-thumb {
    break-inside: avoid;
  }
}

/* Product master images */
.product-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.product-summary article {
  min-width: 0;
  min-height: 112px;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--blue-700);
  border-radius: 7px;
  background: #fff;
}

.product-summary span,
.product-summary small,
.product-summary strong {
  display: block;
}

.product-summary span,
.product-summary small {
  color: var(--muted);
}

.product-summary strong {
  margin: 7px 0 4px;
  color: var(--navy-950);
  font-size: 28px;
}

.product-catalog-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 150px 150px auto;
  align-items: end;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.product-catalog-toolbar .field {
  margin: 0;
}

.product-catalog-result {
  align-self: center;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.product-catalog-table td {
  vertical-align: middle;
}

.product-old-name {
  display: block;
  max-width: 340px;
  margin-top: 4px;
  color: var(--muted);
  font-weight: 400;
  line-height: 1.45;
  white-space: normal;
}

.product-image-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  overflow: hidden;
  padding: 0;
  border: 1px solid #cddbe7;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.product-image-button:hover {
  border-color: var(--blue-700);
  box-shadow: 0 0 0 2px rgba(29, 111, 168, .12);
}

.product-image-button.thumb,
.product-image-placeholder.thumb {
  width: 54px;
  height: 54px;
}

.product-image-button.large,
.product-image-placeholder.large {
  width: min(100%, 420px);
  height: 420px;
}

.product-image-button img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.product-image-placeholder {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px dashed #b9c9d8;
  border-radius: 6px;
  background: #f3f7fa;
  color: #6b7f92;
  text-align: center;
}

.product-image-placeholder span {
  padding: 4px;
  font-size: 11px;
  line-height: 1.3;
}

.product-select-preview {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid #d6e3ee;
  border-radius: 6px;
  background: #f7fafc;
}

.product-select-preview strong,
.product-select-preview small {
  display: block;
  overflow-wrap: anywhere;
}

.product-select-preview strong {
  color: var(--navy-950);
  font-size: 13px;
  line-height: 1.4;
}

.product-select-preview small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.product-select-preview.empty {
  border-style: dashed;
}

.product-detail-layout {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(320px, 1fr);
  gap: 22px;
  align-items: start;
}

.product-detail-image {
  display: grid;
  place-items: center;
  min-height: 420px;
  border: 1px solid #d9e4ed;
  border-radius: 7px;
  background: #f7fafc;
}

.product-detail-info h2 {
  margin: 4px 0 16px;
  color: var(--navy-950);
  font-size: 23px;
  letter-spacing: 0;
}

.product-detail-info dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.product-detail-info dl > div {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid #e0e8ef;
  border-radius: 6px;
  background: #fff;
}

.product-detail-info dt {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
}

.product-detail-info dd {
  margin: 0;
  color: var(--navy-950);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.info-callout,
.product-image-rule {
  margin-top: 12px;
  padding: 10px 12px;
  border-left: 3px solid var(--blue-700);
  background: #eef6fb;
  line-height: 1.65;
}

.info-callout p,
.product-image-rule {
  color: #334e68;
  font-size: 12px;
}

.info-callout p {
  margin: 4px 0 0;
}

.product-history {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.product-history h3 {
  margin-bottom: 10px;
  font-size: 15px;
  letter-spacing: 0;
}

.product-history > div {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(124px, 1fr));
  gap: 10px;
}

.product-history figure {
  margin: 0;
  overflow: hidden;
  border: 1px solid #d9e4ed;
  border-radius: 6px;
  background: #fff;
}

.product-history img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
}

.product-history figcaption {
  padding: 6px 8px;
  border-top: 1px solid #e5ecf2;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.product-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 190px;
  flex-wrap: wrap;
}

.modal.product-editor-modal {
  width: min(1180px, 100%);
}

.product-editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px;
  align-items: start;
}

.product-master-fields {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.product-master-fields small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.product-active-check {
  display: flex;
  grid-template-columns: none;
  flex-direction: row;
  align-items: center;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid #d6e3ee;
  border-radius: 6px;
  background: #f7fafc;
}

.product-active-check input {
  width: 18px;
  min-height: 18px;
  margin: 0;
}

.product-editor-image {
  position: sticky;
  top: 76px;
  display: grid;
  gap: 12px;
}

.product-editor-image #product-editor-image-preview {
  display: grid;
  place-items: center;
  min-height: 260px;
  overflow: hidden;
  border: 1px solid #d9e4ed;
  border-radius: 7px;
  background: #f7fafc;
}

.product-editor-image .product-image-button.large,
.product-editor-image .product-image-placeholder.large,
.product-editor-image .product-detail-image {
  width: 100%;
  height: 260px;
  min-height: 260px;
  border: 0;
}

.product-editor-image .form-note {
  margin: 0;
  font-size: 12px;
}

.product-bom-editor {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  overflow-x: auto;
}

.product-bom-editor .panel-head {
  min-width: 860px;
  padding: 0 0 10px;
}

.product-bom-editor .panel-head h3 {
  margin: 0 0 3px;
  font-size: 16px;
  letter-spacing: 0;
}

.product-bom-header,
.product-bom-row {
  display: grid;
  grid-template-columns: 120px minmax(180px, 1.4fr) 130px 90px 130px 130px 42px;
  gap: 8px;
  align-items: center;
  min-width: 860px;
}

.product-bom-header {
  padding: 8px 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.product-bom-row {
  padding: 7px 0;
  border-top: 1px solid #e5ecf2;
}

.product-bom-row input,
.product-bom-row select {
  width: 100%;
  min-height: 38px;
  padding: 7px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
}

.product-bom-row input:focus,
.product-bom-row select:focus {
  border-color: var(--blue-700);
  box-shadow: 0 0 0 2px rgba(23, 104, 172, .12);
  outline: 0;
}

@media (max-width: 820px) {
  .product-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .product-summary article {
    min-height: 96px;
    padding: 11px 12px;
  }

  .product-summary strong {
    font-size: 23px;
  }

  .product-catalog-toolbar {
    grid-template-columns: minmax(0, 1fr) minmax(120px, .45fr) minmax(120px, .45fr);
  }

  .product-catalog-result {
    grid-column: 1 / -1;
  }

  .product-detail-layout {
    grid-template-columns: minmax(220px, .7fr) minmax(300px, 1fr);
    gap: 14px;
  }

  .product-image-button.large,
  .product-image-placeholder.large,
  .product-detail-image {
    height: 320px;
    min-height: 320px;
  }

  .product-editor-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .product-master-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .product-editor-image {
    position: static;
    grid-template-columns: minmax(220px, .8fr) minmax(260px, 1fr);
    align-items: start;
  }

  .product-editor-image #product-editor-image-preview {
    grid-row: 1 / 3;
  }
}

@media (max-width: 560px) {
  .product-summary {
    grid-template-columns: 1fr;
  }

  .product-summary article {
    min-height: 82px;
  }

  .product-catalog-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 12px;
  }

  .product-catalog-search,
  .product-catalog-result {
    grid-column: 1 / -1;
  }

  .product-detail-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .product-image-button.large,
  .product-image-placeholder.large,
  .product-detail-image {
    width: 100%;
    height: 280px;
    min-height: 280px;
  }

  .product-detail-info dl {
    grid-template-columns: minmax(0, 1fr);
  }

  .modal.product-editor-modal .modal-body {
    padding: 12px;
  }

  .product-master-fields,
  .product-editor-image {
    grid-template-columns: minmax(0, 1fr);
  }

  .product-editor-image #product-editor-image-preview {
    grid-row: auto;
    min-height: 240px;
  }

  .product-editor-image .product-image-button.large,
  .product-editor-image .product-image-placeholder.large,
  .product-editor-image .product-detail-image {
    height: 240px;
    min-height: 240px;
  }

  .product-bom-editor .panel-head {
    align-items: flex-start;
  }
}
