/* Shared UI sizing. Business-specific layouts remain in app.css. */
:root {
  --control-height: 42px;
  --control-radius: 8px;
  --muted: #6f7d86;
}

/* Keep the indicator inside the control, away from both text and the edge. */
select:not([multiple]):not([size]) {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%23677680' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px 16px;
  padding-right: 40px;
  text-overflow: ellipsis;
}
input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=file]),
select:not([multiple]):not([size]) {
  height: var(--control-height);
  min-height: var(--control-height);
  border-radius: var(--control-radius);
  font-size: 13px;
  line-height: 20px;
  padding-top: 10px;
  padding-bottom: 10px;
}
input, select, textarea { border-color: #d5dee2; }
textarea { border-radius: var(--control-radius); font-size: 13px; line-height: 1.65; }
.shipping-section textarea[name="note"] {
  height: var(--control-height);
  min-height: var(--control-height);
  max-height: var(--control-height);
  line-height: 20px;
  padding-top: 10px;
  padding-bottom: 10px;
  resize: none;
}
input::placeholder, textarea::placeholder { color: #89969e; }
input[type=date], input[type=datetime-local] { font-variant-numeric: tabular-nums; }
input[type=date]::-webkit-calendar-picker-indicator,
input[type=datetime-local]::-webkit-calendar-picker-indicator { width: 16px; height: 16px; margin: 0; padding: 0 0 0 8px; opacity: .65; }
input[type=checkbox], input[type=radio] { width: 17px; height: 17px; margin: 0; flex-shrink: 0; accent-color: var(--green); }
input:disabled, select:disabled, textarea:disabled { background-color: #f4f6f7; color: #76838b; cursor: not-allowed; }
:where(button, a, summary, input, select, textarea):focus-visible { outline: 2px solid #397e61; outline-offset: 3px; }

.btn, .page-heading .actions .btn, .filter-buttons .btn, .batch-actions .btn {
  min-height: var(--control-height);
  padding: 10px 16px;
  border-radius: var(--control-radius);
  font-size: 13px;
  line-height: 20px;
  font-weight: 500;
}
.btn.small, .orders-table .order-handle { min-height: 34px; padding: 6px 12px; font-size: 12px; }
.btn svg { width: 16px; height: 16px; }
.actions { gap: 10px; }
.actions > form { display: flex; margin: 0; }
.page-heading { align-items: flex-start; flex-wrap: wrap; gap: 18px 24px; }
.page-heading > div:first-child { flex: 1 1 300px; min-width: 0; }
.page-heading > .actions, .page-heading > form, .page-heading > .btn { flex: 0 1 auto; align-self: center; }
.page-heading .actions { justify-content: flex-end; }
.page-heading h1 { overflow-wrap: anywhere; }
.page-heading p { font-size: 13px; color: var(--muted); line-height: 1.7; }
h2 { font-size: 15px; line-height: 1.5; }
.eyebrow { font-size: 10px; letter-spacing: 2px; }
.text-link, .text-button { font-size: 12px; line-height: 1.6; }
.subtle, .cell-sub, .meta-label, .field small, label small, .stat-foot, .setting-row small {
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}
.meta-label { margin-bottom: 8px; }

/* Labels and controls align independently of help text. */
label, .field label { font-size: 12px; line-height: 18px; color: #52626d; }
.field label { margin-bottom: 7px; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 20px; }
.form-grid > *, .django-form > *, .detail-layout > *, .settings-grid > * { min-width: 0; }
.form-grid > div > label { margin-bottom: 7px; }
.form-grid > div > input:not([type=checkbox]):not([type=radio]),
.form-grid > div > select, .form-grid > div > textarea { width: 100%; }
.form-grid .shipping-field-heading label { margin-bottom: 7px; }
.form-grid > label > small { margin-top: 0; }
.field.checkbox-field { display: grid; grid-template-columns: 17px minmax(0, 1fr); align-items: center; gap: 6px 10px; }
.field.checkbox-field > input[type=checkbox] { grid-column: 1; grid-row: 1; }
.field.checkbox-field > label { grid-column: 2; grid-row: 1; margin: 0; }
.field.checkbox-field > small, .field.checkbox-field > .errorlist { grid-column: 2; margin: 0; }
.form-footer { align-items: center; flex-wrap: wrap; gap: 12px; }
.form-footer > .subtle { flex: 1 1 240px; }
.form-panel .notice { margin: 0 0 22px; }

/* Filters use visible labels, a shared baseline and predictable widths. */
.filters { gap: 12px; padding: 20px 24px; }
.filters.labeled-filters { align-items: flex-end; }
.filter-field { flex: 1 1 170px; min-width: 150px; max-width: 280px; gap: 7px; }
.filter-field > select, .filter-field > input { width: 100%; max-width: none; }
.filter-field.filter-search { flex: 2 1 260px; min-width: 220px; max-width: 440px; }
.filter-field .search-field { width: 100%; min-width: 0; max-width: none; }
.filters > .text-link, .filters > .text-button { min-height: var(--control-height); display: inline-flex; align-items: center; padding: 0 4px; }
.filters .advanced { align-self: flex-end; margin-left: auto; }
.filters .advanced > summary { min-height: var(--control-height); padding-block: 10px; }
.filters .advanced > div { top: calc(100% + 8px); }
.panel:has(.advanced[open]) { overflow: visible; }
.document-filter-grid { gap: 16px; padding: 20px 24px; }
.document-filter-grid input, .document-filter-grid select { height: var(--control-height); }
.filter-buttons { min-height: var(--control-height); }

/* Compact, legible status tags and consistent navigation tabs. */
.pill { min-height: 26px; padding: 4px 9px; font-size: 12px; line-height: 18px; border-radius: 6px; font-weight: 500; vertical-align: middle; }
.pill i { width: 5px; height: 5px; flex-shrink: 0; }
.pill.green { color: #39744f; }
.pill.blue { color: #4e6e9d; }
.pill.amber { color: #896827; }
.pill.red { color: #a45246; }
.pill.gray { color: #687680; }
.platform-badge { display: inline-flex; align-items: center; min-height: 20px; padding: 1px 6px; font-size: 10px; line-height: 18px; border-radius: 4px; }
.count { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; min-height: 22px; padding: 1px 7px; font-size: 11px; line-height: 20px; }
.tabs { gap: 24px; }
.tabs a { display: inline-flex; align-items: center; min-height: 48px; padding: 12px 0; font-size: 13px; line-height: 22px; }
summary { display: list-item; padding-block: 5px; min-height: 32px; list-style: none; cursor: pointer; font-size: 13px; line-height: 1.6; }
summary::-webkit-details-marker { display: none; }
summary::before { content: ''; display: inline-block; vertical-align: middle; width: 7px; height: 7px; flex: 0 0 7px; border: solid #7b8b84; border-width: 0 1.5px 1.5px 0; transform: rotate(-45deg); margin: -3px 12px 0 1px; }
details[open] > summary::before { transform: rotate(45deg); }
.order-more > summary { display: inline-flex; }
.order-more > summary::before { display: none; }

/* Tables scroll within the panel, while the page itself stays in bounds. */
.table-wrap { max-width: 100%; min-width: 0; }
table { font-size: 13px; }
th, .orders-table th { font-size: 12px; line-height: 18px; color: #6f7e87; padding-top: 14px; padding-bottom: 14px; }
td { line-height: 1.6; }
.table-primary { font-size: 13px; }
.orders-table { min-width: 1060px; }
.orders-table .order-time, .orders-table .order-number, .orders-table .order-platform-name { font-size: 13px; }
.orders-table .order-product-meta, .orders-table .order-shop, .orders-table .order-offer,
.orders-table .order-erp-cell .cell-sub, .orders-table .order-progress-cell .order-platform-status { font-size: 11px; }
.orders-table .col-progress { width: 145px; }
.orders-table .col-actions { width: 112px; }
.document-table td:first-child, .cost-summary { font-variant-numeric: tabular-nums; }
.document-table { min-width: 960px; table-layout: fixed; }
.document-table th, .document-table td { padding-inline: 14px; overflow-wrap: anywhere; }
.document-table th:first-child { width: 105px; }
.document-table th:nth-child(2) { width: 21%; }
.document-table th:nth-child(3) { width: 14%; }
.document-table th:nth-child(5) { width: 112px; }
.document-table th:nth-child(6) { width: 110px; }
.document-table .document-actions { width: 96px; position: sticky; right: 0; background: white; box-shadow: -1px 0 var(--line); }
.document-table th.document-actions { background: #f8fafb; }
.document-order-numbers, .document-purchase-reference { margin-top: 10px; font-size: 12px; }
.document-reference-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 32px; margin: 20px 0 0; }
.document-reference-grid dt { color: #6f7e87; font-size: 12px; margin-bottom: 6px; }
.document-reference-grid dd { margin: 0; overflow-wrap: anywhere; }
.document-reference-wide { grid-column: 1 / -1; }
.document-order-list { display: flex; flex-wrap: wrap; gap: 8px 24px; }
@media (max-width: 550px) { .document-reference-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; } }
.pagination { font-size: 12px; min-height: 56px; }
.product-image, .product-placeholder { flex: 0 0 41px; }
.product-cell > div { min-width: 0; }
.panel-top { flex-wrap: wrap; }
.supplier-balances { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.balance-pair { gap: 20px; }
.balance-pair > div { min-width: 0; }
.balance-pair strong { font-size: 28px; line-height: 1.25; font-variant-numeric: tabular-nums; }
.balance-pair span { font-size: 13px; }
.sidebar { overflow-y: auto; overscroll-behavior: contain; }
.sidebar > * { flex-shrink: 0; }
.shipping-cost-tools label { flex-direction: row; }
.shipping-mode label { min-height: 52px; border-radius: 8px; font-size: 14px; gap: 10px; }
.shipping-mode #id_kind > div { min-width: 0; }
.shipping-mode input { width: 17px; height: 17px; }
.workspace-shipment-history > summary { flex-wrap: wrap; }
.workspace-shipment-history > summary > .subtle { margin-left: 8px; }
.auth-form input { min-height: 44px; }
.auth-form .field small, .auth-tip { font-size: 11px; color: var(--muted); }

@media (max-width: 1100px) {
  .page-heading .actions { justify-content: flex-start; }
  .filter-field { max-width: none; }
  .filter-field.filter-search { max-width: none; }
}
@media (max-width: 700px) {
  :root { --control-height: 44px; }
  .page-heading { gap: 16px; }
  .page-heading > div:first-child { flex-basis: auto; }
  .page-heading > .actions, .page-heading > form, .page-heading > .btn { align-self: flex-start; }
  .page-heading .actions { width: 100%; }
  .page-heading .actions .btn { padding: 10px 12px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .filters, .document-filter-grid { padding: 18px 16px; gap: 12px; }
  .filter-field { flex: 1 1 calc(50% - 12px); min-width: 0; }
  .filter-field.filter-search { flex-basis: 100%; min-width: 0; }
  .filter-field .search-field { flex-basis: auto; }
  .filters select { max-width: none; }
  .filters .advanced { margin-left: auto; }
  .filters .advanced > div { width: min(280px, calc(100vw - 62px)); }
  .document-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .document-search, .inventory-filters > label, .filter-buttons { grid-column: 1 / -1; }
  .form-grid label small, .field small { font-size: 12px; }
  .form-footer { justify-content: flex-end; }
  .form-footer > .subtle { flex-basis: 100%; }
  .tabs { gap: 22px; }
  .tabs a { min-height: 46px; }
  .order-summary, .order-summary:has(>div:nth-child(2):last-child) { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .order-summary > div { border-right: 0; border-bottom: 1px solid var(--line); padding: 0 0 14px; }
  .order-summary > div:last-child { padding-bottom: 0; grid-column: auto; }
  .setting-row { gap: 10px; flex-wrap: wrap; }
  .setting-row > div { min-width: 140px; }
  .shipping-mode label { padding: 12px; font-size: 13px; }
  .shipping-mode #id_kind { gap: 10px; }
  .workspace-shipment-history > summary > .subtle { flex-basis: 100%; margin-left: 20px; }
  .balance-pair strong { font-size: 24px; }
  .supplier-balance { padding: 18px; }
  .cost-summary { justify-content: flex-start; gap: 12px 18px; }
  .document-actions { width: 130px; }
  .topbar .breadcrumb { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .topbar-right { flex-shrink: 0; }
  .footer { flex-wrap: wrap; }
  .auth-layout { padding: 0; }
}

/* Anchor visually hidden table labels to the scroll container, not the page. */
.table-wrap { position: relative; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
.orders-table .order-number { display: inline-block; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }

/* Cancellation workbench: retain a clear distinction between stock and purchase handling. */
.cancellation-counts { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:20px; }
.cancellation-counts span { display:block; color:var(--muted); font-size:12px; margin-bottom:8px; }
.cancellation-counts strong { font-size:22px; }
.cancellation-form { display:grid; gap:16px; margin-top:20px; }
.cancellation-form input[type=number] { max-width:200px; }
.cancellation-correction { border-top:1px solid var(--line); }
.check-label { display:flex; align-items:flex-start; gap:10px; margin:18px 0; }
.check-label input { flex:none; margin-top:2px; }
.order-categories .count { margin-left:5px; }
@media (max-width:640px) { .cancellation-counts {grid-template-columns:repeat(2,minmax(0,1fr));} }
.category-hint {padding:14px 24px 0; margin:0; color:var(--muted); font-size:12px;}
a.stat {color:inherit; text-decoration:none;}
a.stat:hover {border-color:#77a993;}

.order-categories {overflow-x:auto;}
.order-categories > a {flex-shrink:0;white-space:nowrap;}
.order-shortcuts {display:flex;flex-wrap:wrap;gap:12px;margin:0 0 22px;}
.order-shortcut {display:flex;flex-direction:column;gap:3px;padding:12px 18px;border:1px solid var(--line);border-radius:9px;background:#fff;min-width:180px;}
.order-shortcut span {font-size:13px;}
.order-shortcut b {font-size:18px;padding:0 4px;font-variant-numeric:tabular-nums;}
.order-shortcut small {font-size:11px;color:var(--muted);}
.order-shortcut.attention {border-color:#eedcc2;background:#fffaf3;}
.order-shortcut.attention span {color:#896827;}
.order-shortcut.selected, .order-shortcut:hover {border-color:#77a993;background:#f0f7f2;}
@media(max-width:640px) {.order-shortcuts {gap:10px;}.order-shortcut {flex:1 1 160px;min-width:0;padding:10px 14px;}}
.cancellation-stages {display:flex;flex-wrap:wrap;gap:10px;padding:18px 24px 0;}
.cancellation-stages a {padding:9px 14px;border:1px solid var(--line);border-radius:8px;color:var(--muted);font-size:13px;}
.cancellation-stages a.selected {background:var(--green-light);border-color:#91b4a3;color:var(--green);font-weight:600;}
.cancel-orders-table {min-width:960px;table-layout:fixed;}
.cancel-orders-table th, .cancel-orders-table td {padding-inline:14px;}
.cancel-orders-table th:nth-child(1) {width:24%;}
.cancel-orders-table th:nth-child(2) {width:20%;}
.cancel-orders-table th:nth-child(3) {width:17%;}
.cancel-orders-table th:nth-child(4) {width:25%;}
.cancel-orders-table th:nth-child(5) {width:14%;}
.cancel-orders-table td {vertical-align:top;}
.cancel-guide > p {margin-top:12px;}
.aftersale-options > div {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;margin:18px 0;}
.aftersale-options label {display:flex;flex-direction:row;align-items:center;gap:10px;height:100%;padding:16px;border:1px solid var(--line);border-radius:8px;font-size:13px;cursor:pointer;}
.aftersale-options label:has(input:checked) {background:var(--green-light);border-color:#77a993;color:var(--green);}
.aftersale-options input {flex:none;}
@media(max-width:700px) {.aftersale-options > div {grid-template-columns:minmax(0,1fr);}}
.cancel-guide .cancellation-counts {grid-template-columns:repeat(4,minmax(0,1fr));}
.cancel-steps {list-style:none;display:flex;flex-wrap:wrap;gap:14px 26px;padding:16px 0;margin:0 0 12px;color:var(--muted);}
.cancel-steps li {display:flex;align-items:center;gap:8px;font-size:13px;}
.cancel-steps b {display:grid;place-items:center;width:26px;height:26px;border-radius:50%;background:#f1f4f2;}
.cancel-steps .done, .cancel-steps .current {color:var(--green);}
.cancel-steps .current b {background:var(--green);color:#fff;}
.cancel-products {display:flex;flex-wrap:wrap;gap:8px 24px;padding:0 24px 18px;border-bottom:1px solid var(--line);font-size:13px;}
.parcel-followup .panel-top > div {min-width:0;}
.parcel-followup .panel-top .subtle {display:block;overflow-wrap:anywhere;}
.cancel-followup {padding-bottom:20px;}
.cancel-outcomes {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;}
.cancel-outcomes a {display:block;border:1px solid #d4e3da;border-radius:8px;background:#f6faf7;padding:16px;color:var(--green);}
.cancel-outcomes a:hover {border-color:#77a993;background:#edf5ef;}
.cancel-outcomes strong {font-size:13px;}
.cancel-outcomes small {display:block;margin-top:7px;font-size:12px;color:var(--muted);}
.cancel-secondary {margin-top:16px;border-top:1px solid var(--line);padding-top:10px;}
@media(max-width:640px) {.cancellation-stages {padding:16px 16px 0;gap:8px;}.cancellation-stages a {padding:8px 10px;}.cancel-outcomes {grid-template-columns:minmax(0,1fr);}.cancel-products {padding-inline:16px;}.cancel-steps {gap:10px 16px;}}
@media(max-width:640px) {.cancel-guide .cancellation-counts {grid-template-columns:repeat(2,minmax(0,1fr));}}

.tracking-toolbar {display:flex;justify-content:space-between;align-items:center;gap:16px;padding:16px 24px;background:#f3f8f5;font-size:12px;}
.tracking-toolbar small {display:block;color:var(--muted);margin-top:4px;}
.cancel-tracking-table {min-width:960px;table-layout:fixed;}
.cancel-tracking-table th, .cancel-tracking-table td {padding-left:14px;padding-right:14px;}
.cancel-tracking-table th:nth-child(1) {width:18%;}
.cancel-tracking-table th:nth-child(2) {width:17%;}
.cancel-tracking-table th:nth-child(3) {width:18%;}
.cancel-tracking-table th:nth-child(4) {width:20%;}
.cancel-tracking-table th:nth-child(5) {width:150px;}
.cancel-tracking-table th:nth-child(6) {width:110px;}
.cancel-tracking-table td {vertical-align:top;overflow-wrap:anywhere;}
.cancel-tracking-table .tracking-actions .btn {padding-inline:10px;}
.cancel-tracking-table .tracking-actions {position:sticky;right:0;background:#fff;box-shadow:-5px 0 9px #20362b05;}
.tracking-product + .tracking-product {margin-top:12px;}
.tracking-note {font-size:12px;line-height:1.7;margin:8px 0 0;}
.parcel-followup + .parcel-followup {border-top:1px solid var(--line);}
.parcel-followup {scroll-margin-top:20px;}
.followup-heading {display:flex;justify-content:space-between;align-items:start;gap:16px;}
.followup-heading strong {overflow-wrap:anywhere;}
@media(max-width:640px) {.tracking-toolbar {padding:16px;}.followup-heading {flex-wrap:wrap;}}
