:root {
  --paper: #f2f5f9;
  --surface: #ffffff;
  --surface-muted: #f7f9fc;
  --surface-selected: #eef5ff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #dce3ec;
  --line-strong: #cbd5e1;
  --blue: #0075de;
  --blue-hover: #0069c7;
  --blue-soft: #edf6ff;
  --slate: #111827;
  --slate-soft: #273449;
  --green: #16835c;
  --green-soft: #e8f7f0;
  --amber: #b45309;
  --amber-soft: #fff4d6;
  --red: #c4321c;
  --red-soft: #fff0ed;
  --radius-control: 8px;
  --radius-card: 12px;
  --rail-width: 64px;
  --queue-width: 320px;
  --topbar-height: 64px;
  --font-sans: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --motion-fast: 120ms;
  --motion-normal: 180ms;
  --motion-slow: 240ms;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--paper); }
body { min-width: 320px; font-size: 15px; line-height: 1.6; letter-spacing: -.012em; text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { outline-offset: 2px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--blue); }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .52; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
.ui-icon { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

[data-tooltip] { position: relative; }
[data-tooltip]::after {
  position: absolute;
  z-index: 120;
  left: 50%;
  bottom: calc(100% + 9px);
  width: max-content;
  max-width: 220px;
  padding: 6px 9px;
  border-radius: 6px;
  background: #111827;
  color: #ffffff;
  content: attr(data-tooltip);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px) scale(.97);
  transform-origin: center bottom;
  transition: opacity var(--motion-fast) ease, transform var(--motion-normal) var(--ease-out);
  white-space: nowrap;
}
[data-tooltip][data-tooltip-placement="right"]::after { top: 50%; right: auto; bottom: auto; left: calc(100% + 10px); transform: translate(-4px, -50%) scale(.97); transform-origin: left center; }
[data-tooltip]:hover::after, [data-tooltip]:focus-visible::after, [data-tooltip]:focus-within::after { opacity: 1; transform: translate(-50%, 0) scale(1); }
[data-tooltip][data-tooltip-placement="right"]:hover::after,
[data-tooltip][data-tooltip-placement="right"]:focus-visible::after,
[data-tooltip][data-tooltip-placement="right"]:focus-within::after { transform: translate(0, -50%) scale(1); }
[data-tooltip][data-tooltip-placement="bottom"]::after { top: calc(100% + 9px); bottom: auto; transform: translate(-50%, -4px) scale(.97); transform-origin: center top; }
[data-tooltip][data-tooltip-placement="bottom"]:hover::after,
[data-tooltip][data-tooltip-placement="bottom"]:focus-visible::after,
[data-tooltip][data-tooltip-placement="bottom"]:focus-within::after { transform: translate(-50%, 0) scale(1); }

.boot-screen, .login-screen { display: grid; min-height: 100vh; place-items: center; }
.boot-screen { align-content: center; gap: 10px; color: var(--muted); text-align: center; animation: soft-enter var(--motion-slow) var(--ease-out) both; }
.boot-screen strong { color: var(--ink); font-size: 22px; }
.boot-screen small { font-size: 15px; }
.login-screen { padding: 28px; }

.eyebrow { color: var(--blue); font-size: 13px; font-weight: 700; letter-spacing: .11em; }
.status-pill { display: inline-flex; align-items: center; gap: 7px; min-height: 30px; padding: 0 11px; border: 1px solid #b9dcfb; border-radius: 999px; background: var(--blue-soft); color: #075eaa; font-size: 14px; font-weight: 700; white-space: nowrap; }
.status-pill.connected { border-color: var(--line); background: var(--surface); color: #344054; }
.status-pill i, .queue-live i { width: 7px; height: 7px; border-radius: 50%; background: #22a06b; }
.queue-live i { animation: status-pulse 2.4s ease-in-out infinite; }

.login-card { display: grid; width: min(420px, 100%); gap: 24px; padding: 28px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); }
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-brand strong, .login-brand small { display: block; }
.login-brand small { margin-top: 2px; color: var(--muted); }
.login-card h1 { margin: 8px 0 6px; font-size: 30px; }
.login-card > p { margin: 0 0 22px; color: var(--muted); }
.login-card label { display: grid; gap: 7px; margin-top: 14px; font-weight: 700; }
.login-card input, .login-card button { min-height: 44px; border-radius: var(--radius-control); }
.login-card input { border: 1px solid var(--line-strong); padding: 0 12px; }
.login-card button { width: 100%; margin-top: 20px; border: 0; background: var(--blue); color: white; font-weight: 700; }
.login-error, .form-error { margin: 0; padding: 10px 12px; border-radius: var(--radius-control); background: var(--red-soft); color: var(--red); font-weight: 700; }

.app-shell { min-height: 100vh; }
.app-sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; display: flex; width: var(--rail-width); flex-direction: column; align-items: center; border-right: 1px solid #263348; background: var(--slate); color: white; }
.sidebar-brand { display: grid; width: 100%; height: var(--topbar-height); flex: 0 0 var(--topbar-height); place-items: center; border-bottom: 1px solid #2d3a52; }
.brand-mark { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 11px; background: linear-gradient(145deg, #2f7df4, var(--blue)); color: white; font-size: 16px; font-weight: 900; letter-spacing: -.03em; transition: transform var(--motion-normal) var(--ease-out), filter var(--motion-normal) ease; }
.sidebar-brand:hover .brand-mark { filter: brightness(1.08); transform: translateY(-1px) scale(1.025); }
.app-sidebar nav { display: grid; width: 100%; gap: 8px; padding: 14px 9px; }
.module-link { display: grid; width: 46px; height: 46px; place-items: center; border: 1px solid transparent; border-radius: 10px; background: transparent; color: #9aa8bd; font-weight: 900; transition: color var(--motion-fast) ease, background var(--motion-fast) ease, transform var(--motion-normal) var(--ease-out); }
.module-link:hover { background: var(--slate-soft); color: white; transform: translateY(-1px); }
.module-link.active { border-color: #4c9de6; background: var(--blue); color: white; }
.sidebar-user { display: grid; width: 100%; gap: 9px; margin-top: auto; padding: 14px 9px; place-items: center; border-top: 1px solid #2d3a52; }
#userAvatar { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; background: #e9f4ff; color: #075eaa; font-size: 15px; font-weight: 900; }
.icon-button { display: grid; width: 38px; height: 38px; place-items: center; border: 0; border-radius: var(--radius-control); background: transparent; color: #9aa8bd; font-size: 26px; transition: color var(--motion-fast) ease, background var(--motion-fast) ease, transform var(--motion-fast) ease; }
.icon-button:hover { background: var(--slate-soft); color: white; }
.icon-button:active, .module-link:active { transform: scale(.94); }

.app-main { min-height: 100vh; margin-left: var(--rail-width); }
.app-topbar { display: none; }
.app-topbar h1 { margin: 2px 0 0; font-size: 28px; line-height: 1.15; }
.app-topbar p { margin: 3px 0 0; color: var(--muted); font-size: 14px; }
.topbar-status { display: flex; gap: 8px; }
.top-notice { position: fixed; top: 14px; left: 50%; z-index: 80; max-width: min(600px, calc(100vw - 120px)); transform: translateX(-50%); padding: 11px 16px; border: 1px solid #b9dcfb; border-radius: var(--radius-control); background: var(--blue-soft); color: #075eaa; font-weight: 600; animation: notice-enter var(--motion-slow) var(--ease-out) both; }
.top-notice.error { border-color: #f0b9af; background: var(--red-soft); color: var(--red); }
.top-notice.success { border-color: #a8dfc7; background: var(--green-soft); color: var(--green); }

.orders-module { height: 100vh; min-height: 560px; overflow: hidden; }
.orders-workspace { display: grid; grid-template-columns: var(--queue-width) minmax(0, 1fr); height: 100%; }
.list-panel { display: grid; min-width: 0; grid-template-rows: auto auto auto auto minmax(0, 1fr) auto auto; gap: 10px; padding: 16px 14px 12px; border-right: 1px solid var(--line); background: var(--surface); overflow: hidden; }
.queue-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.queue-header h2 { margin: 2px 0 0; font-size: 22px; }
.queue-live { display: grid; width: 28px; height: 28px; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--surface-muted); }
.queue-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.queue-tabs button { display: inline-flex; min-width: 0; min-height: 42px; align-items: center; justify-content: space-between; gap: 7px; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface-muted); color: #475467; font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; transition: border-color var(--motion-fast) ease, background var(--motion-fast) ease, color var(--motion-fast) ease, transform var(--motion-fast) ease; white-space: nowrap; }
.queue-tabs button:hover:not(.active) { border-color: #aacbea; background: var(--blue-soft); color: #075eaa; transform: translateY(-1px); }
.queue-tabs button[aria-current="page"], .queue-tabs button.active { border-color: var(--blue); background: var(--blue); color: white; }
.queue-tabs button strong { display: inline-flex; min-width: 17px; min-height: 17px; align-items: center; justify-content: center; border-radius: 999px; background: rgba(100, 116, 139, .12); font-size: 13px; font-weight: 700; }
.queue-tabs button.active strong { background: rgba(255, 255, 255, .2); }
.queue-tabs button.secondary-queue { grid-column: span 2; background: var(--surface); }
.queue-tabs button.secondary-queue.active { background: var(--blue); }

.search-form { display: grid; grid-template-columns: minmax(0, 1fr) 38px; gap: 7px; }
.search-field { position: relative; min-width: 0; }
.search-form input { width: 100%; height: 42px; border: 1px solid var(--line-strong); border-radius: var(--radius-control); padding: 0 47px 0 12px; color: var(--ink); background: var(--surface); font-size: 15px; transition: border-color var(--motion-fast) ease, background var(--motion-fast) ease; }
.search-form input:hover { border-color: #9fb9d2; }
.search-form button { height: 42px; border-radius: var(--radius-control); font-size: 15px; font-weight: 700; }
.search-button { position: absolute; top: 3px; right: 3px; display: grid; width: 34px; height: 36px !important; place-items: center; border: 0; background: var(--blue); color: white; font-size: 26px; transition: background var(--motion-fast) ease, transform var(--motion-fast) ease; }
.search-button .ui-icon { width: 16px; height: 16px; }
.secondary-button { border: 1px solid var(--line-strong); background: var(--surface); color: #344054; }
.search-form button:hover:not(:disabled), .primary-button:hover:not(:disabled) { background: var(--blue-hover); }
.refresh-button:hover:not(:disabled), .secondary-button:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }
.refresh-button { display: grid; place-items: center; transition: color var(--motion-fast) ease, border-color var(--motion-fast) ease, background var(--motion-fast) ease, transform var(--motion-fast) ease; }
.search-form button:active:not(:disabled), .secondary-button:active:not(:disabled), .primary-button:active:not(:disabled), .action-buttons button:active:not(:disabled) { transform: scale(.97); }
.list-summary { margin: 0; color: var(--muted); font-size: 14px; }
.list-state { padding: 14px; border: 1px dashed var(--line-strong); border-radius: var(--radius-control); background: var(--surface-muted); color: var(--muted); font-size: 15px; }
.list-state.error { border-color: #f0b9af; background: var(--red-soft); color: var(--red); }
.list-skeleton { height: 106px; margin-bottom: 7px; border: 1px solid var(--line); border-radius: var(--radius-control); background: linear-gradient(90deg, #f6f7f9 20%, #eef1f4 36%, #f6f7f9 52%); background-size: 240% 100%; animation: list-pulse 1.2s ease-in-out infinite; }
@keyframes list-pulse { to { background-position: -160% 0; } }
.order-list { min-height: 0; overflow-y: auto; scrollbar-gutter: stable; }
.order-card { width: 100%; margin: 0 0 6px; padding: 10px 11px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); color: var(--ink); text-align: left; transition: border-color var(--motion-fast) ease, background var(--motion-fast) ease, transform var(--motion-normal) var(--ease-out); }
.order-card:hover { border-color: #9fc8ed; background: #f8fbff; transform: translateY(-1px); }
.order-card[aria-selected="true"], .order-card.active { border-color: #58a8ef; background: var(--surface-selected); }
.order-card.urgent:not([aria-selected="true"]):not(.active) { border-color: #f0b5ab; background: #fffaf9; }
.order-card-head, .order-card-meta, .order-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.order-card-head strong { font-size: 16px; }
.order-card-customer { display: block; margin: 6px 0 4px; overflow: hidden; color: #344054; font-size: 15px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.order-card-meta, .order-card-footer { color: var(--muted); font-size: 14px; }
.order-card-products { display: block; margin: 4px 0 7px; overflow: hidden; color: #475467; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.order-card-footer strong { color: #344054; font-size: 14px; }
.badge { display: inline-flex; min-height: 22px; align-items: center; padding: 2px 8px; border-radius: 999px; background: var(--amber-soft); color: var(--amber); font-size: 13px; font-weight: 700; white-space: nowrap; }
.badge.urgent { background: var(--red); color: white; }
.badge.green { background: var(--green-soft); color: var(--green); }
.pagination { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.pagination button { min-height: 34px; border-radius: var(--radius-control); }
.pagination button:last-child { justify-self: stretch; }
.pagination span { color: var(--muted); font-size: 14px; white-space: nowrap; }
.refresh-meta { display: grid; grid-template-columns: auto 1fr; gap: 2px 7px; padding-top: 9px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.refresh-meta strong { min-width: 0; overflow: hidden; color: #344054; text-overflow: ellipsis; white-space: nowrap; }
.refresh-meta small { grid-column: 1 / -1; }

.detail-panel { min-width: 0; height: 100%; background: var(--paper); overflow: hidden; isolation: isolate; }
.detail-empty { display: grid; height: 100%; place-content: center; justify-items: center; padding: 32px; color: var(--muted); text-align: center; }
.detail-empty > span { display: grid; width: 50px; height: 50px; place-items: center; margin-bottom: 14px; border-radius: 14px; background: var(--blue-soft); color: var(--blue); font-size: 26px; font-weight: 900; }
.detail-empty strong { color: var(--ink); font-size: 22px; }
.detail-empty p { max-width: 440px; margin: 7px 0 0; line-height: 1.6; }
.detail-content { display: grid; height: 100%; min-height: 0; grid-template-rows: auto minmax(0, 1fr) auto; background: var(--paper); overflow: hidden; }
.detail-header { display: flex; min-height: 64px; align-items: center; justify-content: space-between; gap: 20px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--surface); }
.detail-header h2 { margin: 3px 0 2px; font-size: 26px; }
.detail-identity { min-width: 0; }
.detail-customer-title { display: flex; min-width: 0; flex-wrap: wrap; align-items: baseline; gap: 6px; line-height: 1.2; }
.detail-order-number { color: var(--ink); font-variant-numeric: tabular-nums; }
.detail-title-separator { color: #b0bac7; font-weight: 500; }
.copy-email { display: inline-flex; max-width: 100%; align-items: center; gap: 6px; margin: 0; padding: 2px 0; border: 0; background: transparent; color: var(--muted); font-size: 14px; text-align: left; transition: color var(--motion-fast) ease; }
.copy-email span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy-email .ui-icon { width: 14px; height: 14px; flex: 0 0 auto; opacity: 0; transform: translateY(1px); transition: opacity var(--motion-fast) ease, transform var(--motion-fast) ease; }
.copy-email:hover:not(:disabled), .copy-email:focus-visible { color: var(--blue); }
.copy-email:hover .ui-icon, .copy-email:focus-visible .ui-icon { opacity: 1; transform: translateY(0); }
.detail-header-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.detail-header-actions a, .detail-header-actions .header-link { display: inline-flex; min-height: 34px; align-items: center; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: var(--radius-control); background: var(--surface); color: #344054; text-decoration: none; font-size: 14px; font-weight: 600; }
.detail-header-actions a, .detail-header-actions .header-link { transition: border-color var(--motion-fast) ease, color var(--motion-fast) ease, background var(--motion-fast) ease, transform var(--motion-fast) ease; }
.detail-header-actions a:hover { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); transform: translateY(-1px); }
.detail-header-actions .header-link.unavailable { border-color: #e1e6ec; background: #f6f7f9; color: #98a2b3; cursor: not-allowed; }
.detail-scroll { min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.review-form, .readonly-layout { min-height: 100%; }
.detail-layout { display: grid; grid-template-columns: minmax(0, 7fr) minmax(360px, 5fr); align-items: start; gap: 16px; padding: 16px 24px 28px; }
.detail-column { position: static; display: grid; align-content: start; gap: 16px; min-width: 0; overflow: visible; }
.detail-column > * { min-width: 0; }
.detail-card { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); overflow: hidden; }
.detail-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 13px 15px; border-bottom: 1px solid var(--line); }
.detail-card-header h3 { margin: 0; font-size: 18px; }
.detail-card-header p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.detail-card-body { padding: 14px 15px; }
.priority-card { border-color: #d6e2ed; }
.transaction-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; }
.summary-metric { min-width: 0; padding: 3px 16px; border-left: 1px solid var(--line); }
.summary-metric:first-child { padding-left: 0; border-left: 0; }
.summary-metric span, .summary-metric small { display: block; color: var(--muted); font-size: 13px; }
.summary-metric strong { display: block; margin-top: 7px; overflow-wrap: anywhere; font-size: 15px; }
.summary-metric.primary strong { font-size: 18px; letter-spacing: -.01em; }
.summary-metric small { margin-top: 3px; }
.shipping-risk-row { display: grid; grid-template-columns: minmax(190px, .75fr) minmax(0, 1.25fr); gap: 8px; margin-top: 13px; }
.shipping-snapshot { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface-muted); }
.shipping-snapshot span { display: block; color: var(--muted); font-size: 13px; }
.shipping-snapshot strong { display: block; margin-top: 4px; overflow-wrap: anywhere; font-size: 14px; }
.shipping-snapshot small { display: block; margin-top: 3px; color: var(--muted); font-size: 13px; }
.risk-banner { display: grid; align-content: center; gap: 3px; padding: 9px 11px; border: 1px solid #f4cf89; border-radius: var(--radius-control); background: var(--amber-soft); color: #8a4808; font-size: 14px; line-height: 1.45; }
.risk-banner strong, .risk-banner span { display: block; }
.risk-banner.safe { border-color: #a8dfc7; background: var(--green-soft); color: var(--green); }

.item-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.item-table th { padding: 8px 7px; color: var(--muted); font-size: 13px; font-weight: 600; text-align: left; }
.item-table td { padding: 10px 7px; border-top: 1px solid var(--line); vertical-align: top; font-size: 14px; }
.item-table th:nth-child(2), .item-table td:nth-child(2) { width: 25%; }
.item-table th:nth-child(3), .item-table td:nth-child(3) { width: 62px; text-align: center; }
.item-table th:nth-child(4), .item-table td:nth-child(4) { width: 96px; text-align: right; }
.product-name-zh { display: block; color: var(--ink); font-weight: 700; line-height: 1.45; overflow-wrap: anywhere; }
.product-name-en { display: block; margin-top: 3px; color: var(--muted); font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.product-attributes { margin-top: 5px; color: #8a5b10; font-size: 13px; line-height: 1.45; }
.quantity-badge { display: inline-flex; min-width: 28px; min-height: 24px; align-items: center; justify-content: center; border-radius: 999px; background: #eef2f6; color: #344054; font-weight: 700; }
.quantity-badge.multiple { border: 1px solid #f3c86e; outline: 3px solid rgba(244, 181, 55, .14); background: var(--amber-soft); color: #9a4d08; }

.note-panel { display: grid; gap: 10px; }
.note-original, .note-translation, .readonly-note { padding: 11px 12px; border-radius: var(--radius-control); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.note-original, .readonly-note { border: 1px solid var(--line); background: var(--surface-muted); color: #475467; }
.note-translation { border: 1px solid #b9dcfb; background: var(--blue-soft); color: #075eaa; }
.note-translation strong, .note-original strong { display: block; margin-bottom: 5px; font-size: 14px; }
.translate-button { justify-self: start; min-height: 34px; padding: 0 11px; border: 1px solid #b9dcfb; border-radius: var(--radius-control); background: var(--blue-soft); color: #075eaa; font-weight: 600; }

.decision-card { position: static; inset: auto; }
.decision-column { position: static; overflow: visible; }
.decision-notes textarea { min-height: 78px; }
.secondary-controls { margin-top: 14px; border: 1px dashed #b9cbe0; border-radius: var(--radius-control); background: #fbfdff; }
.secondary-controls-header { display: flex; min-height: 42px; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 12px; border-bottom: 1px dashed #b9cbe0; color: #36536f; }
.secondary-controls-header span { font-size: 14px; font-weight: 700; }
.secondary-controls-header small { color: var(--muted); font-size: 13px; font-weight: 500; }
.secondary-controls-content { padding: 12px; }
.secondary-divider { height: 1px; margin: 13px 0; background: var(--line); }
.secondary-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.secondary-heading strong { color: #344054; font-size: 14px; }
.secondary-heading span { color: var(--muted); font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.form-field { display: grid; gap: 5px; min-width: 0; color: #344054; font-size: 14px; font-weight: 600; }
.form-field.wide { grid-column: 1 / -1; }
.field-label { display: block; }
.field-label-row { display: flex; min-width: 0; align-items: baseline; justify-content: space-between; gap: 12px; }
.field-label-row > small { min-width: 0; color: #667085; font-size: 13px; font-weight: 500; text-align: right; }
.field-label-row > small strong { color: #344054; font-weight: 700; overflow-wrap: anywhere; }
.required-mark { color: var(--red); }
.form-field input, .form-field select, .form-field textarea { width: 100%; min-height: 38px; border: 1px solid var(--line-strong); border-radius: var(--radius-control); padding: 8px 10px; background: var(--surface); color: var(--ink); }
.form-field input, .form-field select, .form-field textarea { transition: border-color var(--motion-fast) ease, background var(--motion-fast) ease; }
.form-field input:hover, .form-field select:hover, .form-field textarea:hover { border-color: #9fb9d2; }
.form-field textarea { min-height: 76px; resize: vertical; }
.shipping-combobox { position: relative; display: block; min-width: 0; }
.shipping-combobox input { padding-right: 38px; }
.shipping-combobox [data-shipping-toggle] { position: absolute; top: 1px; right: 1px; width: 36px; height: 36px; border: 0; border-radius: 7px; background: transparent; color: #475467; font-size: 22px; }
.shipping-combobox [data-shipping-toggle]:hover:not(:disabled) { background: var(--blue-soft); color: var(--blue); }
.shipping-options { position: absolute; z-index: 30; top: calc(100% + 5px); right: 0; left: 0; display: grid; max-height: 220px; padding: 5px; overflow-y: auto; border: 1px solid var(--line-strong); border-radius: var(--radius-control); background: var(--surface); box-shadow: 0 10px 24px rgba(15, 23, 42, .12); }
.shipping-options button { min-height: 34px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: #344054; text-align: left; }
.shipping-options button:hover, .shipping-options button:focus-visible, .shipping-options button.selected { background: var(--blue-soft); color: #075eaa; }
.field-invalid select, .field-invalid .shipping-combobox > input { border-color: #d92d20; outline: 3px solid rgba(217, 45, 32, .1); }
.urgent-card { display: grid; grid-column: 1 / -1; gap: 9px; padding: 11px 12px; border: 1px solid #f2ca73; border-radius: var(--radius-control); background: #fffbeb; color: #92400e; transition: border-color var(--motion-fast) ease, background var(--motion-fast) ease, transform var(--motion-fast) ease; }
.urgent-card:hover { border-color: #e8ae32; background: #fff8dd; }
.urgent-toggle { display: grid; grid-template-columns: auto 1fr; gap: 9px; align-items: start; }
.urgent-toggle input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--red); }
.urgent-card strong { display: block; font-size: 15px; }
.urgent-card small { display: block; margin-top: 3px; line-height: 1.45; }
.urgent-card > input { width: 100%; min-height: 38px; border: 1px solid #eccb87; border-radius: var(--radius-control); padding: 8px 10px; background: rgba(255, 255, 255, .78); color: var(--ink); }
.urgent-card > input::placeholder { color: #a87539; }
.urgent-card.active { border-color: #e9a51d; outline: 3px solid rgba(233, 165, 29, .1); }

.product-picker { display: grid; gap: 9px; }
.product-categories { display: flex; max-height: 64px; flex-wrap: wrap; gap: 5px; overflow-y: auto; }
.product-category { display: inline-flex; min-height: 26px; align-items: center; gap: 5px; padding: 0 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: #475467; font-size: 13px; font-weight: 650; }
.product-category em { color: #8a9caf; font-size: 13px; font-style: normal; }
.product-category:hover, .product-category[aria-pressed="true"] { border-color: #8fc3f1; background: var(--blue-soft); color: #075eaa; }
.product-search { display: block; min-width: 0; }
.product-search input { width: 100%; min-width: 0; height: 38px; border: 1px solid var(--line-strong); border-radius: var(--radius-control); padding: 0 11px; }
.product-search button, .primary-button { min-height: 38px; padding: 0 13px; border: 0; border-radius: var(--radius-control); background: var(--blue); color: white; font-weight: 700; }
.product-matches { display: grid; max-height: 188px; gap: 0; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface); }
.extra-rows { display: grid; gap: 7px; }
.product-match, .product-matches > button { display: grid; width: 100%; grid-template-columns: minmax(0, 1fr); gap: 3px; padding: 8px 10px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: var(--surface); color: var(--ink); text-align: left; }
.product-matches > button:last-child { border-bottom: 0; }
.product-matches > .product-option { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.product-option em { align-self: start; padding: 3px 7px; border-radius: 999px; background: #eef2f6; color: var(--muted); font-size: 13px; font-style: normal; font-weight: 500; white-space: nowrap; }
.product-matches > .manual-product-action { border-style: dashed; border-color: #9fc8ed; background: var(--blue-soft); color: #075eaa; }
.product-matches > button:hover { border-color: var(--blue); background: var(--blue-soft); }
.product-matches > button strong, .product-matches > button small { display: block; overflow-wrap: anywhere; }
.product-matches > button strong { font-size: 14px; font-weight: 650; line-height: 1.35; }
.product-matches > button small { margin-top: 2px; color: var(--muted); font-size: 13px; font-weight: 400; line-height: 1.4; }
.selected-products-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 3px; padding-top: 10px; border-top: 1px solid var(--line); color: #344054; font-size: 14px; }
.selected-products-heading span { color: var(--muted); }
.product-match button, .extra-row button { min-height: 30px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface); color: #344054; font-weight: 600; }
.extra-row { display: grid; grid-template-columns: minmax(0, 1fr) 70px minmax(120px, .8fr) 32px; gap: 7px; align-items: end; padding: 9px 10px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface-muted); }
.extra-row.manual { grid-template-columns: minmax(0, 1.35fr) 70px minmax(110px, .65fr) 32px; border-style: dashed; }
.manual-product-fields { display: grid; min-width: 0; grid-template-columns: minmax(0, 1fr) minmax(90px, .55fr); gap: 7px; }
.extra-row-summary { min-width: 0; align-self: center; }
.extra-row-summary strong, .extra-row-summary small { display: block; overflow-wrap: anywhere; }
.extra-row-summary strong { font-size: 14px; font-weight: 650; line-height: 1.35; }
.extra-row-summary small { margin-top: 3px; color: var(--muted); font-size: 13px; }
.extra-row label { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
.extra-row input { width: 100%; min-height: 34px; border: 1px solid var(--line-strong); border-radius: 7px; padding: 0 8px; }
.empty-inline { color: var(--muted); font-size: 14px; }
.review-meta { margin-top: 9px; color: var(--muted); font-size: 13px; }
.readonly-message { padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); color: var(--muted); line-height: 1.6; }

.detail-actions { position: relative; z-index: 6; display: flex; min-height: 64px; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 18px; border-top: 1px solid var(--line); background: rgba(255, 255, 255, .98); }
.save-status { display: flex; min-width: 0; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.save-status i { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: #98a2b3; }
.save-status.dirty i { background: var(--amber); }
.save-status.saved i { background: var(--green); }
.save-status.error i { background: var(--red); }
.save-status[data-state="saving"] i { background: var(--amber); }
.save-status[data-state="saved"] { color: var(--green); }
.save-status[data-state="saved"] i { background: var(--green); }
.save-status[data-state="error"] { color: var(--red); }
.save-status[data-state="error"] i { background: var(--red); }
.action-buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.action-buttons button { min-height: 38px; padding: 0 14px; border-radius: var(--radius-control); font-weight: 700; }
.action-buttons .danger-button { border: 1px solid #f0b9af; background: var(--red-soft); color: var(--red); }
.action-buttons .warning-button { border: 1px solid #f3c86e; background: var(--amber-soft); color: #8a4808; }

.danger-button { border: 1px solid #f0b9af; background: var(--red-soft); color: var(--red); }
.warning-button { border: 1px solid #f3c86e; background: var(--amber-soft); color: #8a4808; }
.confirm-dialog { width: min(430px, calc(100vw - 32px)); max-height: min(680px, calc(100vh - 32px)); padding: 0; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); color: var(--ink); box-shadow: 0 18px 48px rgba(15, 23, 42, .18); }
.confirm-dialog::backdrop { background: rgba(15, 23, 42, .48); backdrop-filter: blur(2px); }
.confirm-dialog form { display: grid; justify-items: center; gap: 13px; padding: 28px; text-align: center; }
.confirm-dialog[open] form { animation: dialog-enter var(--motion-slow) var(--ease-out) both; }
.confirm-dialog .dialog-icon { display: grid; width: 42px; height: 42px; place-items: center; border: 1px solid #b9dcfb; border-radius: 50%; background: var(--blue-soft); color: var(--blue); font-weight: 900; }
.confirm-dialog h2 { margin: 0; font-size: 26px; }
.confirm-dialog p { max-width: 350px; margin: 0; color: var(--muted); line-height: 1.6; }
.confirm-dialog .dialog-actions { display: grid; width: 100%; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 8px; }
.confirm-dialog button { min-height: 40px; padding: 0 15px; border-radius: var(--radius-control); font-weight: 700; }

.order-list.is-entering .order-card { animation: queue-card-enter var(--motion-slow) var(--ease-out) both; }
.order-list.is-entering .order-card:nth-child(2) { animation-delay: 24ms; }
.order-list.is-entering .order-card:nth-child(3) { animation-delay: 48ms; }
.order-list.is-entering .order-card:nth-child(n+4) { animation-delay: 64ms; }
.detail-content.is-entering .detail-header { animation: detail-enter var(--motion-slow) var(--ease-out) both; }
.detail-content.is-entering .detail-card,
.detail-content.is-entering .readonly-message { animation: detail-enter var(--motion-slow) var(--ease-out) both; }
.detail-content.is-entering .detail-card:nth-child(2) { animation-delay: 28ms; }
.detail-content.is-entering .detail-card:nth-child(3) { animation-delay: 48ms; }

@keyframes soft-enter { from { opacity: 0; transform: translateY(4px); } }
@keyframes notice-enter { from { opacity: 0; transform: translate(-50%, -8px); } }
@keyframes queue-card-enter { from { opacity: 0; transform: translateY(5px); } }
@keyframes detail-enter { from { opacity: 0; transform: translateY(6px); } }
@keyframes dialog-enter { from { opacity: 0; transform: translateY(8px) scale(.985); } }
@keyframes status-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media (max-width: 1180px) {
  :root { --queue-width: 292px; }
  .detail-layout { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 920px) {
  .transaction-summary { grid-template-columns: 1fr 1fr; row-gap: 12px; }
  .summary-metric:nth-child(3) { grid-column: 1 / -1; padding: 12px 0 0; border-top: 1px solid var(--line); border-left: 0; }
  .shipping-risk-row { grid-template-columns: minmax(0, 1fr); }
  .extra-row, .extra-row.manual { grid-template-columns: minmax(0, 1fr) 66px 32px; }
  .extra-notes-field { grid-column: 1 / 3; }
}

@media (max-width: 860px) {
  :root { --queue-width: 270px; }
  .app-topbar { padding-inline: 16px; }
  .app-topbar p { display: none; }
  .detail-header { padding-inline: 14px; }
  .detail-layout { padding-inline: 12px; }
}

@media (max-width: 720px) {
  :root { --rail-width: 52px; --topbar-height: 60px; }
  .brand-mark { width: 34px; height: 34px; }
  .module-link { width: 40px; height: 40px; }
  .orders-module { height: auto; min-height: 100vh; overflow: visible; }
  .orders-workspace { grid-template-columns: 1fr; height: auto; }
  .list-panel { height: auto; min-height: 520px; border-right: 0; border-bottom: 1px solid var(--line); overflow: visible; }
  .order-list { max-height: 52vh; }
  .detail-panel, .detail-content { height: auto; min-height: 70vh; overflow: visible; }
  .detail-scroll { overflow: visible; }
  .detail-actions { position: sticky; bottom: 0; z-index: 10; align-items: flex-start; }
  .topbar-status .connected { display: none; }
}

@media (max-width: 520px) {
  .app-topbar h1 { font-size: 26px; }
  .app-topbar .eyebrow { display: none; }
  .topbar-status { display: none; }
  .queue-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-header { align-items: flex-start; }
  .detail-header-actions { justify-content: flex-start; }
  .detail-layout { padding: 10px 8px 18px; }
  .fact-grid, .form-grid { grid-template-columns: 1fr; }
  .fact.wide, .form-field.wide { grid-column: auto; }
  .item-table th:nth-child(2), .item-table td:nth-child(2) { display: none; }
  .item-table th:nth-child(4), .item-table td:nth-child(4) { width: 74px; }
  .detail-actions { display: grid; }
  .action-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .action-buttons button:last-child { grid-column: 1 / -1; }
  .secondary-controls-header, .secondary-heading { align-items: flex-start; flex-direction: column; }
  .extra-row, .extra-row.manual { grid-template-columns: minmax(0, 1fr) 32px; }
  .manual-product-fields { grid-template-columns: 1fr; }
  .extra-quantity-field, .extra-notes-field { grid-column: 1 / -1; }
}
