/* Shared presentation layer. Operational layouts and interaction hooks live in styles.css. */
:root {
  --ink: #252a31;
  --muted: #69717d;
  --line: #e3e6ea;
  --surface: #fff;
  --soft: #f6f7f9;
  --danger: #b42318;
  --warning: #956118;
  --success: #087a57;
  --control-height: 36px;
  font-size: 14px;
  line-height: 1.5;
  color-scheme: light;
}

body {
  background: var(--surface);
  font-size: 14px;
}

h1, h2, h3, h4, p, strong, span, label {
  overflow-wrap: break-word;
}

h1, h2, h3, h4 {
  color: var(--ink);
  font-weight: 650;
  letter-spacing: 0;
  line-height: 1.3;
}

h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
h4 { font-size: 14px; }

button, input, select, textarea {
  font-size: inherit;
  line-height: 1.4;
}

button, a, input, select, textarea, summary {
  -webkit-tap-highlight-color: transparent;
}

a:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
}

.sidebar {
  background: #f8f9fa;
  border-right: 1px solid var(--line);
  color: var(--ink);
  flex: 0 0 232px;
  height: 100dvh;
  scrollbar-width: thin;
  width: 232px;
}

.brand {
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  gap: 10px;
  min-height: 68px;
  padding: 12px 18px;
}

.system-logo-mark { background: white; border: 1px solid var(--line); border-radius: 5px; flex: 0 0 38px; height: 38px; overflow: hidden; position: relative; width: 38px; }
.system-logo-mark img { height: 120px; left: -38px; max-width: none; position: absolute; top: -36px; width: 180px; }
.brand-copy strong { color: var(--ink); font-size: 17px; font-weight: 750; }
.brand-copy span { color: var(--muted); font-size: 11px; }
.nav-menu { align-content: start; gap: 3px; padding: 12px 10px; }
.nav-group { color: var(--muted); font-size: 12px; letter-spacing: 0; margin: 18px 10px 5px; }
.nav-link { border-radius: 5px; color: #505965; font-size: 13px; gap: 10px; min-height: 36px; padding: 7px 10px; }
.nav-icon { flex: 0 0 20px; height: 20px; width: 20px; }
.nav-icon svg { height: 17px; width: 17px; }
.nav-link:hover { background: #eceff2; color: var(--ink); }
.nav-link.active { background: color-mix(in srgb, var(--brand) 10%, white); color: var(--brand); font-weight: 700; box-shadow: inset 3px 0 var(--brand); }
.sidebar-version { border-color: var(--line); gap: 2px; padding: 12px 18px; }
.sidebar-version span { color: var(--muted); font-size: 10px; letter-spacing: 0; }
.sidebar-version strong { color: #505965; font-size: 11px; font-weight: 500; }
.sidebar-hidden .sidebar { border: 0; flex-basis: 0; width: 0; visibility: hidden; }

.main { background: white; max-width: 100%; }
.topbar { background: rgba(255,255,255,.97); gap: 12px; justify-content: flex-start; min-height: 64px; padding: 10px 24px; }
.topbar-title { flex: 1; }
.topbar h1 { font-size: 20px; margin: 1px 0 0; }
.topbar-title .eyebrow { font-size: 12px; }
.topbar-actions { flex-shrink: 0; gap: 8px; }
.topbar-actions form { margin: 0; }
.company-pill { background: #fff; border-radius: 5px; font-size: 12px; max-width: 230px; padding: 7px 10px; }
.content { margin: 0 auto; max-width: 1920px; padding: 20px 24px 40px; }
.eyebrow { color: var(--muted); font-size: 12px; font-weight: 650; letter-spacing: 0; }
.section-header { flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
.section-header h2 { font-size: 17px; line-height: 1.35; margin-top: 2px; }
.section-header > div:first-child { flex: 1 1 180px; }
.section-header > .row-actions { flex: 0 1 auto; }
.section-spaced { margin-top: 22px; }
.section-spaced-tight { margin: 12px 0; }
.panel-grid { gap: 22px; margin-top: 22px; }
.panel-grid > * { min-width: 0; }
.panel { background: white; border: 0; border-top: 1px solid var(--line); border-radius: 0; box-shadow: none; padding: 18px 0 0; }
.content > .panel:first-child, .content > form.panel:first-child { border-top: 0; padding-top: 0; }
.panel .panel { border: 0; border-top: 1px solid var(--line); border-radius: 0; box-shadow: none; padding: 14px 0 0; }
.panel > h2 { font-size: 17px; margin: 0 0 14px; }
.panel > .eyebrow + h2 { margin-top: 2px; }
.form-card { border: 1px solid var(--line); border-radius: 6px; box-shadow: none; padding: 20px; }

.metrics-grid, .users-stats-grid, .purchase-summary, .reconciliation-metrics, .route-metrics {
  background: var(--soft);
  border-block: 1px solid var(--line);
  gap: 0;
  padding: 14px 0;
}

.metric-card { background: transparent; border: 0; border-radius: 0; box-shadow: none; gap: 4px; min-width: 0; padding: 8px 18px; }
.metric-card:not(:first-child) { border-left: 1px solid var(--line); }
.metric-card:nth-child(4n+1) { border-left: 0; }
.metric-card:nth-child(n+5) { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 14px; }
.metric-card strong, .users-stats-grid .metric-card strong { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.3; overflow-wrap: anywhere; }
.metric-card span { font-size: 12px; }
.metric-card small { font-size: 11px; }
.metric-card.warning strong { color: var(--warning); }
.metric-card.active strong { color: var(--success); }
.dashboard-metrics .metric-card:nth-child(4n+1) { border-left: 0; }
.dashboard-metrics .metric-card:nth-child(n+5) { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 14px; }
.pending-card, .alert-card, .order-tracking-card, .status-tile { border-radius: 6px; box-shadow: none; gap: 4px; min-height: 0; padding: 12px; }
.pending-card strong, .order-tracking-card strong, .status-tile strong { font-size: 24px; font-variant-numeric: tabular-nums; }
.pending-card span, .order-tracking-card span { font-size: 12px; }
.pending-card small, .order-tracking-card small, .order-tracking-card em { font-size: 11px; }
.status-board { gap: 8px; grid-template-columns: repeat(6, minmax(128px, 1fr)); }
.alert-card strong { font-size: 13px; }
.alert-card span { font-size: 12px; }
.alert-detail-card { flex-wrap: wrap; gap: 12px; padding: 14px 0; }

label { color: #515965; font-size: 12px; font-weight: 600; gap: 5px; min-width: 0; }
input, select, textarea { background: #fff; border-color: #d3d8df; border-radius: 5px; color: var(--ink); font-size: 14px; font-weight: 400; min-width: 0; padding: 8px 10px; }
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]), select { min-height: var(--control-height); }
input::placeholder, textarea::placeholder { color: #9299a3; opacity: 1; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 16%, transparent); outline-offset: 1px; }
input[readonly], textarea[readonly], input:disabled, select:disabled, textarea:disabled { background: #f7f8fa; color: #5d6570; opacity: 1; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--brand); flex: 0 0 16px; height: 16px; min-height: 0; padding: 0; width: 16px; }
input[type="number"] { font-variant-numeric: tabular-nums; }
input[type="color"] { height: 36px; padding: 4px; }
textarea { min-height: 90px; resize: vertical; }
.form-grid { align-items: start; gap: 14px 18px; }
.form-grid > * { min-width: 0; }
.stack-form { align-content: start; display: grid; gap: 14px; min-width: 0; }
.form-grid label:has(textarea), .form-grid .form-actions { align-self: end; }
.form-section-title { border-top: 1px solid var(--line); color: var(--ink); font-size: 12px; font-weight: 650; margin-top: 4px; padding-top: 14px; text-transform: none; }
.check-row { align-items: center; font-size: 13px; font-weight: 500; gap: 8px; }
.form-actions { align-items: center; gap: 8px; margin-top: 4px; }
.field-help, .field-link, .product-cost-field small { font-size: 11px; }
.field-link { color: var(--brand); }
.toolbar { align-items: end; flex-wrap: wrap; gap: 10px; }
.toolbar label { flex: 1 1 170px; }
.toolbar > input, .toolbar > select { flex: 1 1 180px; width: auto; }
.table-tools { gap: 8px; }
.table-tools > input { max-width: 340px; }

.primary-button, .secondary-button, .ghost-button, .danger-button, .icon-button {
  border: 1px solid transparent;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 600;
  gap: 6px;
  min-height: var(--control-height);
  padding: 7px 12px;
  text-align: center;
  text-decoration: none;
  transition: background .15s ease, border-color .15s ease;
  white-space: normal;
}

.primary-button { border-color: var(--brand); }
.primary-button:hover:not(:disabled) { background: color-mix(in srgb, var(--brand) 88%, black); border-color: color-mix(in srgb, var(--brand) 88%, black); }
.secondary-button { background: #fff; border-color: color-mix(in srgb, var(--brand) 30%, var(--line)); }
.secondary-button:hover:not(:disabled) { background: color-mix(in srgb, var(--brand) 6%, white); }
.ghost-button { background: #f7f8fa; border-color: var(--line); color: #515965; }
.ghost-button:hover:not(:disabled) { background: #eceff2; border-color: #cfd5dd; }
.danger-button { background: #fff6f5; border-color: #f4d6d3; color: var(--danger); }
.danger-button:hover:not(:disabled) { background: #feeceb; }
.icon-button { background: #fff; border-color: var(--line); flex: 0 0 36px; height: 36px; padding: 0; width: 36px; }
.primary-button:disabled, .secondary-button:disabled, .ghost-button:disabled, .danger-button:disabled, .icon-button:disabled { border-color: var(--line); }
.icon-danger { border-radius: 5px; font-size: 18px; height: 34px; min-width: 34px; width: 34px; }
.line-action-button { border-radius: 5px; font-size: 12px; min-height: 30px; padding: 6px 9px; }
.input-with-action .secondary-button, .sales-toolbar button, .sale-status-form .sale-control-field input, .sale-status-form .sale-control-field select { min-height: var(--control-height); }
.row-actions, .invoice-actions, .receivable-actions { gap: 6px; }

table { font-size: 13px; font-variant-numeric: tabular-nums; min-width: 560px; }
table caption { caption-side: top; color: var(--muted); font-size: 12px; line-height: 1.6; padding: 0 0 12px; text-align: left; }
th, td { line-height: 1.45; padding: 10px; vertical-align: top; }
th { background: #f7f8fa; color: #68707b; font-size: 11px; font-weight: 650; letter-spacing: 0; text-transform: none; vertical-align: middle; }
td strong { font-weight: 600; }
td small { color: var(--muted); font-size: 11px; }
tbody tr:hover { background: color-mix(in srgb, var(--brand) 3%, white); }
tbody tr:last-child > td { border-bottom-color: transparent; }
.table-wrap { scrollbar-width: thin; }
.table-cell-content { display: contents; }
.table-wrap td.row-actions > .table-cell-content { align-items: center; display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.table-wrap > .section-header { margin-bottom: 12px; }
.table-wrap :is(.primary-button, .secondary-button, .ghost-button, .danger-button) { font-size: 12px; min-height: 30px; padding: 5px 9px; }
.table-wrap :is(input, select) { font-size: 13px; padding: 6px 8px; }
.delivery-cell { min-width: 145px; }
.delivery-cell small { margin-top: 3px; }
.product-actions { box-shadow: -1px 0 0 var(--line); min-width: 160px; }
.product-actions :is(.secondary-button, .danger-button) { min-width: 68px; }
.numeric-cell { font-variant-numeric: tabular-nums; text-align: right; }
.status, .role-pill { border: 1px solid transparent; border-radius: 4px; font-size: 11px; font-weight: 600; line-height: 1.4; max-width: 100%; overflow-wrap: anywhere; padding: 3px 7px; white-space: normal; }
.status.active, .status.success { background: #edf8f3; color: #08734f; }
.status.warning { background: #fff7e7; color: #8a5c17; }
.status.danger { background: #fff0ee; color: #b42318; }
.status.draft, .status.inactive { background: #f0f2f5; color: #66717f; }
.role-pill { background: #f1f3f5; color: #66717f; }
.notice, .alert, .invoice-preview-warning { border-radius: 5px; font-size: 13px; font-weight: 500; line-height: 1.55; margin-bottom: 14px; overflow-wrap: anywhere; padding: 10px 12px; }
.notice.success { background: #f0faf5; border-color: #c9e8d8; }
.notice.warning { background: #fffbef; border-color: #efddb1; }
.notice.danger, .alert { background: #fff5f3; border-color: #f1d4ce; }
.flash-toast { box-shadow: 0 3px 14px #252a3114; top: 76px; }
.empty-state { color: #79818c; font-size: 13px; padding: 26px 16px; }
.danger-zone { background: #fff8f6; border-top: 1px solid #f1d4ce; gap: 16px; padding: 16px; }
.danger-zone h2 { font-size: 16px; }

.module-tabs { border-bottom: 1px solid var(--line); gap: 4px; margin: 0 0 18px; padding: 0; }
.module-tabs button, .module-tabs .module-tab-link { background: transparent; border: 0; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted); font-size: 13px; font-weight: 500; min-height: 40px; padding: 8px 12px; }
.module-tabs button.active, .module-tabs .module-tab-link.active { background: transparent; border-bottom-color: var(--brand); color: var(--brand); font-weight: 650; }
.module-tabs button:hover, .module-tabs .module-tab-link:hover { background: #f7f8fa; color: var(--ink); }
.segmented-tabs { background: #f1f3f5; border: 1px solid var(--line); border-radius: 5px; flex-wrap: wrap; gap: 2px; padding: 3px; }
.segmented-tabs a { border-radius: 3px; font-size: 12px; font-weight: 550; padding: 6px 10px; }
.segmented-tabs a.active { box-shadow: 0 1px 2px #252a3114; }
.report-preset { background: #fff; border-radius: 5px; font-size: 12px; font-weight: 550; min-height: 32px; padding: 5px 10px; }
.sales-board { gap: 12px; }
.sales-toolbar { gap: 10px; grid-template-columns: minmax(150px, 210px) minmax(0, 1fr) auto; }
.sales-status-strip { border-bottom: 1px solid var(--line); gap: 2px; padding-bottom: 0; }
.sales-status-strip a { background: transparent; border: 0; border-bottom: 2px solid transparent; border-radius: 0; font-size: 12px; font-weight: 500; padding: 8px 12px; }
.sales-status-strip a.active { background: transparent; border-bottom-color: var(--brand); color: var(--brand); font-weight: 650; }
.sales-summary-row { font-size: 12px; font-weight: 500; gap: 16px; }
.sale-hero { align-items: flex-start; background: #f7f8fa; border-block: 1px solid var(--line); gap: 20px; padding: 16px; }
.sale-hero-main { flex: 1 1 230px; min-width: 0; }
.sale-hero h2 { font-size: 22px; }
.sale-action-bar { flex: 0 1 60%; gap: 6px; }
.sale-action-bar :is(button, a) { font-size: 12px; min-height: 32px; padding: 6px 9px; }
.sale-hero-meta { font-size: 12px; gap: 7px 12px; }
.sale-folio-reference { display: grid; gap: 3px; min-width: 0; overflow-wrap: anywhere; }
.sale-secondary-reference { margin: 6px 0; overflow-wrap: anywhere; }
.sale-followup-history { grid-template-columns: minmax(0, 1fr); }
.sale-followup-history .timeline-item { grid-template-columns: minmax(0, 1fr); min-width: 0; }
.sale-followup-history .timeline-item p { overflow-wrap: anywhere; }
.sale-secondary-folio-form { align-items: end; grid-template-columns: minmax(0, 1fr) auto; max-width: 640px; }
.sale-hero-meta strong { font-size: 18px; }
.sale-form { gap: 20px; }
.sale-create-header { flex-wrap: wrap; }
.sale-create-header h2 { font-size: 20px; }
.sale-sticky-actions { border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 12px 0; z-index: 2; }
.sale-line-head, .sale-item { column-gap: 8px; grid-template-columns: minmax(180px, 1.7fr) repeat(5, minmax(64px, .55fr)) minmax(76px, .6fr) 50px; }
.sale-line-head { font-size: 11px; font-weight: 600; }
.sale-item { border-color: var(--line); border-radius: 5px; padding: 10px; }
.sale-item input, .sale-item select { padding-inline: 7px; }
.sale-line-field { font-size: 10px; font-weight: 600; letter-spacing: 0; }
.sale-line-field input, .sale-line-field select { font-size: 13px; font-weight: 400; }
.purchase-line-head, .purchase-items-grid .sale-item { grid-template-columns: minmax(170px, 1.5fr) minmax(64px, .55fr) minmax(76px, .55fr) minmax(64px, .45fr) minmax(85px, .7fr) minmax(100px, .75fr) minmax(76px, .55fr) 50px; }
.sales-detail-table { min-width: 980px; }
.sales-detail-table th, .sales-detail-table td { padding: 9px 7px; }
.sales-detail-table th:first-child, .sales-detail-table td:first-child { min-width: 190px; }
.sale-line-row input { padding: 6px 7px; }
.sale-location-meta { font-size: 12px; min-height: 0; }
.totals-box, .sale-total { flex-wrap: wrap; font-size: 12px; gap: 10px 16px; padding-top: 12px; }
.totals-box strong, .sale-total strong { font-size: 19px; }
.sale-total-card { border-radius: 0; gap: 12px; }
.sale-total-card strong { font-size: 22px; }
.purchase-live-summary { background: var(--soft); border: 0; border-block: 1px solid var(--line); border-radius: 0; padding: 12px; }
.purchase-live-summary span { font-size: 11px; font-weight: 550; text-transform: none; }
.purchase-live-summary strong { font-size: 17px; }
.invoice-import-card { background: #fafbfc; border: 1px dashed #d3d8df; border-radius: 5px; grid-template-columns: minmax(0, 1fr) minmax(160px, .8fr) auto; }
.invoice-import-card h2 { font-size: 16px; }
.product-cost-suggestion, .cost-breakdown-summary span { background: #f7f8fa; border: 0; border-radius: 4px; padding: 10px; }
.product-cost-suggestion strong { font-size: 16px; }
.product-cost-suggestion button { min-width: 50px; }

.detail-grid { font-size: 12px; gap: 14px 18px; }
.detail-grid > span { display: grid; gap: 3px; align-content: start; }
.detail-grid strong { color: var(--ink); font-size: 13px; font-weight: 550; overflow-wrap: anywhere; }
.invoice-top-grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); }
.invoice-toolbar { gap: 10px; grid-template-columns: minmax(180px, 1fr) repeat(2, minmax(130px, .5fr)) auto; }
.invoice-actions { min-width: 210px; }
.invoice-actions :is(.primary-button, .secondary-button, .ghost-button, .danger-button) { min-height: 30px; padding: 5px 9px; }
.invoice-preview-card { background: transparent; border: 0; border-left: 1px solid var(--line); border-radius: 0; padding: 0 14px; }
.invoice-preview-card:first-child { border-left: 0; padding-left: 0; }
.invoice-preview-card h3 { font-size: 13px; }
.invoice-preview-card dt { font-size: 10px; font-weight: 600; }
.invoice-preview-card dd { font-size: 12px; font-weight: 500; }
.invoice-footnotes { font-size: 12px; gap: 12px; }
.inline-form { grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); min-width: 0; }
.inline-form > * { min-width: 0; }
.receivable-payment-form { grid-template-columns: 95px 125px 160px minmax(120px, 1fr) minmax(190px, auto); min-width: 760px; }
.compact-field { font-size: 11px; }
.received-invoices-page .received-review-form { gap: 6px; grid-template-columns: minmax(110px, .8fr) minmax(115px, .8fr) minmax(175px, 1.2fr) minmax(130px, 1fr) auto auto; min-width: 730px; }
.received-invoices-page .received-invoice-table { min-width: 980px; }
.received-invoices-page .money-stack small { font-size: 10px; letter-spacing: 0; }
.received-invoices-page .money-stack.total strong { color: var(--ink); font-size: 14px; }
.tax-filter-form { grid-template-columns: minmax(180px, 250px) auto; }
.tax-attachment-form { background: transparent; border: 0; border-radius: 0; border-bottom: 1px solid var(--line); padding: 0 0 14px; }
.tax-attachment-card { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 12px 0; }
.tax-credit-inline-form { grid-template-columns: 135px 100px minmax(100px, 1fr) auto; }
.allocation-row { background: #fafbfc; border-radius: 4px; padding: 12px; }
.allocation-amounts { min-width: 140px; }
.money-move-cell { gap: 5px; min-width: 95px; }

.production-overview-header { align-items: center; gap: 12px; grid-template-columns: minmax(0, 1fr) auto; margin: 8px 0 22px; max-width: none; text-align: left; }
.production-overview-copy { grid-column: auto; }
.production-overview-copy h2 { font-size: 22px; margin: 3px 0 6px; }
.production-overview-copy p { margin: 4px 0; }
.production-overview-actions { grid-column: auto; justify-content: flex-end; gap: 8px; }
.production-overview-actions :is(.primary-button, .secondary-button) { min-height: var(--control-height); min-width: 140px; }
.touch-action-card, .operator-action-card, .inventory-product-card, .production-order-card, .recipe-card, .lot-card, .mini-card, .location-card, .quick-template-card { border-radius: 6px; box-shadow: none; gap: 8px; padding: 14px; }
.touch-action-card { min-height: 85px; }
.operator-action-card { min-height: 110px; }
.operator-action-card strong, .touch-action-card strong { font-size: 15px; }
.operator-action-card span, .touch-action-card span { font-size: 12px; }
.touch-search { font-size: 14px; min-height: var(--control-height); }
.inventory-card-stock strong { font-size: 28px; }
.inventory-layout { grid-template-columns: minmax(0, 1fr); }
.production-card-metrics { background: #f6f7f9; border-radius: 4px; gap: 10px; padding: 10px; }
.production-card-metrics strong { font-size: 18px; }
.production-card-metrics span { background: transparent; border: 0; border-radius: 0; padding: 0; }
.production-card-metrics span + span { border-left: 1px solid var(--line); padding-left: 10px; }
.recipe-cost-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.recipe-ingredient-cost { display: grid; gap: 2px; min-width: 0; }
.recipe-ingredient-cost small { color: var(--muted); overflow-wrap: anywhere; }
.recipe-ingredient-cost b { color: var(--ink); }
.packaging-step { background: transparent; border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 14px 0; }
.packaging-step-head strong { font-size: 14px; }
.packaging-step-head > span { border-radius: 4px; height: 24px; width: 24px; }
.packaging-line, .recipe-item-row { background: #fafbfc; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 12px; }
.recipe-item-row { grid-template-columns: minmax(0, 1fr) minmax(110px, 180px) auto; }
.packaging-line-head, .packaging-line-main, .packaging-material-grid { gap: 10px; }
.route-stop { background: #fafbfc; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; gap: 12px; padding: 14px; }
.route-meta { font-size: 12px; font-weight: 500; }
.route-card-head { gap: 16px; }
.touch-panel .form-grid { gap: 14px; }

.company-card { border-radius: 6px; box-shadow: none; padding: 20px; }
.company-card h3 { font-size: 17px; }
.company-card p { font-size: 13px; }
.company-card-logo { background: white; border-radius: 5px; height: 60px; min-height: 60px; width: 88px; }
.company-card-logo img { max-height: 100%; max-width: 100%; }
.brand-line { height: 3px; }
.user-card { border-radius: 6px; box-shadow: none; gap: 12px; padding: 14px; }
.user-card h3 { font-size: 14px; }
.user-avatar { border-radius: 5px; font-size: 15px; height: 36px; width: 36px; }
.user-meta { font-size: 11px; }
.user-edit-form, .role-editor-form, .role-custom-card { background: #fafbfc; border-color: var(--line); border-radius: 5px; padding: 14px; }
.role-guide-item, .role-template-card, .permission-summary-card { background: #f7f8fa; border: 0; border-radius: 4px; padding: 12px; }
.permission-summary-card strong { font-size: 21px; }
.permission-group { background: transparent; border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 16px 0; }
.permission-group-head h3 { font-size: 15px; }
.permission-card { border-radius: 5px; gap: 8px; padding: 10px; }
.permission-card strong { font-size: 13px; }
.permission-card small { font-size: 11px; }
.permission-column-title, .permission-chip-list span { font-size: 11px; letter-spacing: 0; }
.audit-toolbar { grid-template-columns: minmax(150px, 1fr) repeat(3, minmax(110px, .55fr)) repeat(2, minmax(115px, .5fr)) auto; }
.document-toolbar { grid-template-columns: minmax(180px, 1fr) minmax(150px, .4fr) auto; }
.timeline-item { border-bottom: 1px solid var(--line); border-radius: 0; padding: 12px 0; }
.timeline-item span { font-size: 12px; }
.timeline-item p { font-size: 13px; }
.file-picker-control, .logo-upload-control { border-radius: 5px; font-size: 13px; font-weight: 550; min-height: var(--control-height); padding: 8px 12px; }
.file-picker-name { font-size: 11px; }
.technical-grid > * { min-width: 0; }
.technical-box { background: #252a31; border: 0; border-radius: 5px; font-size: 12px; line-height: 1.65; max-width: 100%; min-width: 0; overflow-wrap: anywhere; padding: 14px; }
.db-explorer-shell { border: 1px solid var(--line); border-radius: 5px; padding: 0; }
.db-table-list { background: #f8f9fa; }
.db-table-button { border-radius: 4px; font-size: 12px; padding: 8px 10px; }
.db-explorer-toolbar { background: #fafbfc; padding: 14px; }
.db-content { padding: 14px; }
.db-info-row { flex-wrap: wrap; font-size: 12px; }
.db-sort { min-height: 32px; min-width: 32px; }
.db-query textarea { background: #fafbfc; font-size: 13px; line-height: 1.6; }

.pos-shell { gap: 18px; grid-template-columns: 180px minmax(0, 1fr) 310px; }
.pos-shell .panel { border: 0; min-height: 0; padding-top: 0; }
.pos-products { border-inline: 1px solid var(--line) !important; padding-inline: 18px; }
.pos-product-grid { gap: 10px; grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); }
.pos-product-button, .pos-order-tab { border-radius: 5px; font-size: 13px; padding: 12px; }
.pos-product-button { min-height: 88px; }
.pos-order-tab small, .pos-product-button span { font-size: 12px; }
.pos-product-config, .pos-group-card, .pos-option-group { border-radius: 5px; }
.pos-config-grid > *, .pos-config-grid .inline-form, .pos-group-card .inline-form, .pos-option-group { min-width: 0; }
.pos-option-group legend { max-width: 100%; overflow-wrap: anywhere; }
.tag-list form { max-width: 100%; min-width: 0; }
.tag-list .status { align-items: center; display: inline-flex; gap: 6px; }
.tag-list .status button { border-radius: 4px; display: inline-grid; flex: 0 0 32px; font-size: 18px; height: 32px; margin: 0; min-width: 32px; place-items: center; width: 32px; }
.tag-list .status button:hover { background: var(--soft); }
.pos-total { border-bottom: 1px solid var(--line); font-size: 18px; padding: 14px 0; }
.pos-change { font-size: 14px; }
.pos-products .section-header input { max-width: 240px; }
.pos-cart-line { grid-template-columns: minmax(0, 1fr) 60px auto; }

.modal-dialog { border: 1px solid var(--line); border-radius: 7px; max-height: calc(100dvh - 32px); overflow: auto; box-shadow: 0 16px 64px #252a3129; }
.modal-dialog::backdrop { background: #252a3170; backdrop-filter: blur(2px); }
.content .record-editor[data-modal-form] { display: none; }
.modal-form-dialog:has(.record-editor) { max-width: calc(100vw - 24px); width: min(680px, calc(100vw - 24px)); }
.record-editor { min-width: 0; }
.record-editor > h2 { font-size: 18px; margin: 0 0 8px; }
.record-editor > p { font-size: 13px; margin: 0 0 16px; overflow-wrap: anywhere; }
.record-editor .record-editor-form { align-items: end; display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; min-width: 0; }
.record-editor-form > * { min-width: 0; }
.record-editor-form > .record-editor-wide { grid-column: 1 / -1; }
.record-editor .receivable-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.record-editor .receivable-actions > button { min-width: 0; }
.record-editor .receivable-actions > button:last-child { grid-column: 1 / -1; }
.receivables-multi-toolbar { display: grid; grid-template-columns: minmax(130px, .7fr) minmax(210px, 1fr) minmax(170px, 1fr) auto; }
.metrics-grid.receivables-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.receivables-summary > .metric-card:first-child { border-bottom: 1px solid var(--line); border-left: 0; grid-column: 1 / -1; padding: 10px 12px; }
.receivables-summary > .metric-card:first-child strong { font-size: 15px; }
.receivables-summary > .metric-card:not(:first-child) { border-left: 1px solid var(--line); border-top: 0; margin: 0; padding: 12px; }
.receivables-summary > .metric-card:nth-child(2) { border-left: 0; }
.receivables-summary > .metric-card:not(:first-child) strong { font-size: 18px; }
.modal-panel, .modal-form-dialog .modal-panel { gap: 16px; padding: 22px; }
.modal-panel h2 { font-size: 18px; }
.modal-form-title { margin: 0 0 18px; }
.modal-panel p { margin-block: 0; }
.modal-panel .record-editor > p { margin: 0 0 16px; }
.modal-panel .panel { border: 0; padding: 0; }
.modal-panel .form-actions { border-top: 1px solid var(--line); padding-top: 14px; }
.modal-form-dialog { width: min(900px, calc(100vw - 32px)); }
.modal-dialog.product-cost-dialog { width: min(720px, calc(100vw - 32px)); }
.invoice-choice-button { border-radius: 5px; padding: 14px; }
.invoice-choice-button:hover { background: #f7f8fa; }
.invoice-choice-button strong { font-size: 14px; }
.invoice-choice-button span { font-size: 12px; }

.login-body, .company-select-body { background: #f6f7f9; }
.login-layout { display: block; min-height: 100dvh; }
.login-panel { background: transparent; border: 0; min-height: 100dvh; padding: 40px 24px; }
.login-card-shell { width: min(380px, 100%); }
.login-brand { margin-bottom: 24px; }
.login-brand-symbol { height: 80px; margin-bottom: 24px; overflow: hidden; position: relative; width: 210px; }
.login-brand-symbol img { height: 253px; left: -74px; max-width: none; position: absolute; top: -75px; width: 380px; }
.login-brand h1 { font-size: 26px; line-height: 1.3; margin: 5px 0 0; }
.login-copy { font-size: 13px; line-height: 1.6; margin-top: 10px; max-width: 360px; }
.login-form-card { background: white; backdrop-filter: none; border-color: var(--line); box-shadow: 0 2px 6px #252a3105; gap: 18px; padding: 24px; }
.login-form-card input { min-height: 40px; }
.login-form-card .primary-button { box-shadow: none; min-height: 40px; }
.login-footnote { font-size: 11px; text-align: center; }
.company-select-layout { max-width: 1080px; padding: 40px 0; }
.company-select-header { border-bottom: 1px solid var(--line); margin-bottom: 24px; padding-bottom: 20px; }
.company-select-header h1 { font-size: 24px; }
.company-select-grid { gap: 16px; }
.company-select-grid .company-card { background: white; }

@media (min-width: 901px) {
  .purchase-detail-table { min-width: 1160px; }
  .purchase-detail-table :is(th, td):first-child { min-width: 180px; }
  .purchase-detail-table input[type="number"] { min-width: 80px; }
  .purchase-detail-table input[name="unit_cost"] { min-width: 110px; }
  .purchase-detail-table .input-with-action { min-width: 190px; }
  td.row-actions { display: table-cell; text-align: right; vertical-align: middle; }
  td.row-actions > * { display: inline-flex; margin: 2px 0 2px 4px; vertical-align: middle; }
  td[data-label="Total"], td[data-label="Saldo"], td[data-label="Importe"], td[data-label="Precio"], td[data-label="Cantidad"], td[data-label="Cobrado"], td[data-label="Costo"], td[data-label="Utilidad"], td[data-label="IVA"], td[data-label="Subtotal"] { text-align: right; }
  td[data-label="Existencia"], td[data-label="Mínimo"], td[data-label="Costo acumulado"], td[data-label="Abonado"], td[data-label="Monto"], td[data-label="Monto a aplicar"], td[data-label="Partidas"], td[data-label="Gastos"] { text-align: right; }
  td:has(input[type="number"]) input[type="number"] { text-align: right; }
  .form-grid > .notice, .form-grid > .section-header { grid-column: 1 / -1; }
}

@media (max-width: 1280px) and (min-width: 901px) {
  .content { padding-inline: 20px; }
  .dashboard-layout, .users-layout, .invoice-top-grid, .tax-credit-grid { grid-template-columns: minmax(0, 1fr); }
  .audit-toolbar { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .invoice-toolbar { grid-template-columns: minmax(180px, 1fr) repeat(2, minmax(110px, .6fr)); }
  .invoice-toolbar button { justify-self: start; }
  .sale-line-head, .sale-item { grid-template-columns: repeat(4, minmax(0, 1fr)); row-gap: 10px; }
  .sale-line-head, .purchase-line-head { display: none; }
  .sale-item .product-search, .sale-item > .sale-line-field:first-child { grid-column: span 2; }
  .purchase-items-grid .sale-item { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .route-stop, .route-card-head, .production-overview-header { grid-template-columns: minmax(0, 1fr); }
  .production-overview-actions { justify-content: flex-start; }
  .tax-credit-inline-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .invoice-import-card { grid-template-columns: minmax(0, 1fr) minmax(160px, 1fr); }
  .invoice-import-card > :first-child { grid-column: 1 / -1; }
  .pos-shell { grid-template-columns: 160px minmax(0, 1fr); }
  .pos-cart { border-top: 1px solid var(--line) !important; grid-column: 1 / -1; padding-top: 16px !important; }
  .receivables-multi-toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1050px) and (min-width: 901px) {
  .metric-card:nth-child(2n+1) { border-left: 0; }
  .metric-card:nth-child(n+3) { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 14px; }
  .dashboard-metrics .metric-card:nth-child(n+5) { margin-top: 8px; }
  .sales-toolbar { grid-template-columns: minmax(130px, .6fr) minmax(0, 1fr) auto; }
  .sale-hero { flex-wrap: wrap; }
  .sale-action-bar { flex-basis: 100%; justify-content: flex-start; }
  .invoice-preview-card:nth-child(3) { border-left: 0; padding-left: 0; }
}

@media (max-width: 900px) {
  :root { --control-height: 44px; }
  .sidebar { height: 100dvh; max-width: calc(100vw - 56px); width: 232px; }
  .sidebar-open .sidebar { width: 232px; }
  .sidebar-hidden .sidebar { visibility: visible; }
  .nav-link { min-height: 42px; }
  .topbar { flex-wrap: nowrap; gap: 10px; min-height: 62px; padding: 10px 14px; }
  .topbar h1 { font-size: 18px; }
  .topbar-title { flex: 1; min-width: 0; }
  .topbar-actions { flex: 0 0 auto; flex-wrap: nowrap; width: auto; }
  .topbar-actions > * { flex: 0 1 auto; }
  .topbar-actions .company-pill { max-width: 150px; width: auto; }
  .topbar-actions .ghost-button { font-size: 12px; width: auto; }
  .content { padding: 18px 16px 32px; }
  .icon-button { flex-basis: 40px; height: 40px; min-height: 40px; width: 40px; }
  .section-header { gap: 10px; }
  .module-tabs { flex-wrap: wrap; overflow-x: visible; }
  .module-tabs > :is(button, .module-tab-link) { flex: 1 1 auto; min-width: 0; text-align: center; white-space: normal; }
  .section-header > div:first-child { flex-basis: auto; }
  .section-header > .row-actions { flex: 0 1 auto; }
  .section-header h2, .panel > h2 { font-size: 17px; }
  .section-spaced, .panel-grid { margin-top: 20px; }
  .panel { padding-top: 16px; }
  .panel-grid { gap: 18px; }
  .metrics-grid, .users-stats-grid, .purchase-summary, .reconciliation-metrics, .route-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 8px 0; }
  .metric-card { padding: 10px 12px; }
  .metric-card:nth-child(2n+1) { border-left: 0; }
  .metric-card:nth-child(n+3), .dashboard-metrics .metric-card:nth-child(n+5) { border-top: 1px solid var(--line); margin: 0; padding-top: 10px; }
  .metric-card strong, .users-stats-grid .metric-card strong { font-size: 21px; }
  .pending-center-grid, .order-tracking-grid, .alerts-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .pending-card, .order-tracking-card { padding: 11px; }
  .pending-card strong, .order-tracking-card strong { font-size: 22px; }
  input, select, textarea, .table-wrap :is(input, select), .sale-line-field input, .sale-line-field select, .db-query textarea { font-size: 16px; }
  .form-grid { gap: 14px; }
  .form-grid > .span-2 { grid-column: 1 / -1; }
  .toolbar { align-items: stretch; }
  .toolbar > :is(input:not([type="hidden"]), select, label, button) { flex: 0 1 auto; max-width: 100%; width: 100%; }
  .receivables-multi-toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sale-secondary-folio-form { grid-template-columns: minmax(0, 1fr); }
  label { font-size: 12px; }
  .primary-button, .secondary-button, .ghost-button, .danger-button { font-size: 13px; min-height: 44px; padding: 9px 12px; }
  .row-actions, .invoice-actions, .form-actions { gap: 8px; }
  .table-tools { align-items: stretch; }
  .table-tools > input { max-width: none; }
  .sales-toolbar, .invoice-toolbar, .tax-filter-form, .invoice-top-grid, .invoice-import-card, .production-overview-header, .receivable-payment-form, .tax-credit-inline-form { grid-template-columns: minmax(0, 1fr); }
  .audit-toolbar, .document-toolbar, .technical-grid { grid-template-columns: minmax(0, 1fr); }
  .invoice-import-card > *, .production-overview-copy, .production-overview-actions { grid-column: auto; }
  .sales-status-strip a { font-size: 12px; padding: 10px; }
  .sale-hero { align-items: stretch; flex-direction: column; gap: 14px; padding: 14px; }
  .sale-hero-main, .sale-action-bar { flex: 0 1 auto; }
  .sale-action-bar { justify-content: flex-start; }
  .sale-action-bar > * { width: auto; }
  .sale-action-bar :is(button, a) { min-height: 40px; }
  .sale-item, .purchase-items-grid .sale-item { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .sale-item > .sale-line-field:first-child { grid-column: 1 / -1; }
  .sale-item .product-search { grid-column: 1 / -1; }
  .sale-line-head, .purchase-line-head { display: none; }
  .sales-detail-table { min-width: 0; }
  .sale-sticky-actions { padding: 10px 0; position: static; }
  .totals-box { gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .totals-box strong { font-size: 18px; }
  .purchase-live-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table-wrap:not(.db-data-wrap) { overflow-x: auto; }
  .table-wrap:not(.db-data-wrap):has(.mobile-card-table) { overflow-x: visible; }
  .table-wrap:not(.db-data-wrap) table.mobile-card-table caption { display: block; width: 100%; }
  .table-wrap:not(.db-data-wrap) table.mobile-card-table tr { border-radius: 5px; box-shadow: none; }
  .table-wrap:not(.db-data-wrap) table.mobile-card-table tbody { gap: 12px; }
  .table-wrap:not(.db-data-wrap) table.mobile-card-table td { font-size: 13px; gap: 10px; grid-template-columns: minmax(88px, .38fr) minmax(0, 1fr); padding: 10px 12px; }
  .table-wrap:not(.db-data-wrap) table.mobile-card-table td::before { font-size: 11px; font-weight: 600; letter-spacing: 0; text-transform: none; }
  .table-wrap:not(.db-data-wrap) table.mobile-card-table td > .table-cell-content { display: block; min-width: 0; overflow-wrap: anywhere; }
  .table-cell-content > :is(.status, .role-pill) { max-width: 100%; }
  .table-cell-content > form { min-width: 0; width: 100%; }
  .table-wrap:not(.db-data-wrap) table.mobile-card-table td.row-actions > .table-cell-content { display: flex; justify-content: flex-start; }
  .table-wrap:not(.db-data-wrap) table.mobile-card-table :is(td[data-label=""], td.mobile-stack-cell) { grid-template-columns: minmax(0, 1fr); }
  .table-wrap :is(.primary-button, .secondary-button, .ghost-button, .danger-button), .line-action-button { min-height: 40px; }
  .table-wrap .table-tools :is(input, select) { min-height: 44px; }
  .db-sort { min-height: 44px; min-width: 44px; }
  .tag-list .status button { flex-basis: 44px; height: 44px; min-width: 44px; width: 44px; }
  .product-actions { box-shadow: none; min-width: 0; }
  .inline-form, .receivable-payment-form, .received-invoices-page .received-review-form { min-width: 0; }
  .received-invoices-page .received-invoice-table { min-width: 0; }
  .invoice-actions { min-width: 0; }
  .detail-grid, .pac-detail-grid, .compact-detail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .invoice-preview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .invoice-preview-card { padding: 0 12px; }
  .invoice-preview-card:nth-child(2n+1) { border-left: 0; padding-left: 0; }
  .invoice-preview-card:nth-child(n+3) { border-top: 1px solid var(--line); padding-top: 12px; }
  .production-overview-header { gap: 14px; margin: 6px 0 20px; }
  .production-overview-copy h2 { font-size: 20px; }
  .production-overview-actions { justify-content: flex-start; }
  .production-overview-actions :is(.primary-button, .secondary-button) { min-height: 44px; min-width: 0; }
  .recipe-item-row { grid-template-columns: minmax(0, 1fr); }
  .route-stop { grid-template-columns: minmax(0, 1fr); padding: 12px; }
  .touch-search { font-size: 16px; min-height: 44px; }
  .touch-action-card, .operator-action-card { min-height: 90px; }
  .inventory-card-stock strong { font-size: 26px; }
  .pos-shell { gap: 18px; grid-template-columns: minmax(0, 1fr); }
  .pos-products { border: 0 !important; padding: 0; }
  .pos-cart { border-top: 1px solid var(--line) !important; padding-top: 16px !important; }
  .pos-products .section-header input { max-width: none; }
  .pos-product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pos-cart-line { grid-template-columns: minmax(0, 1fr) 65px auto; }
  .pos-cart-lines input { min-width: 0; }
  .flash-toast { top: 74px; }
  .login-panel { padding: 28px 20px; }
  .login-brand h1 { font-size: 24px; }
  .login-brand-symbol { margin-bottom: 20px; }
  .login-form-card input, .login-form-card .primary-button { min-height: 44px; }
  .company-select-layout { padding-block: 28px; }
  .company-select-header { align-items: center; flex-direction: row; }
  .company-select-header h1 { font-size: 22px; }
  .modal-panel, .modal-form-dialog .modal-panel { padding: 18px; }
  .modal-dialog { max-height: calc(100dvh - 24px); }
}

@media (max-width: 540px) {
  .topbar { flex-wrap: wrap; }
  .topbar-title { flex: 1 1 calc(100% - 52px); }
  .topbar-actions { flex: 1 1 100%; justify-content: flex-end; width: 100%; }
  .topbar-actions .company-pill { max-width: calc(100% - 64px); padding: 6px 8px; }
  .topbar-actions .ghost-button { min-height: 36px; padding: 6px 8px; }
  .topbar h1 { font-size: 16px; }
  .topbar-title .eyebrow { max-width: 36ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .content { padding-inline: 12px; }
  .metric-card strong, .users-stats-grid .metric-card strong { font-size: 19px; }
  .metrics-grid .metric-card { padding-inline: 10px; }
  .alerts-grid, .invoice-preview-grid, .detail-grid, .pac-detail-grid { grid-template-columns: minmax(0, 1fr); }
  .invoice-preview-card { border: 0; border-top: 1px solid var(--line); padding: 12px 0 0; }
  .invoice-preview-card:first-child { border: 0; padding-top: 0; }
  .sale-action-bar > * { flex: 1 1 130px; }
  .sale-item, .purchase-items-grid .sale-item { grid-template-columns: minmax(0, 1fr); }
  .sale-item > .sale-line-field:first-child { grid-column: auto; }
  .login-form-card { padding: 20px; }
  .company-select-header { align-items: flex-start; gap: 12px; }
}

@media (max-width: 640px) {
  .record-editor .record-editor-form, .receivables-multi-toolbar { grid-template-columns: minmax(0, 1fr); }
  .metrics-grid.receivables-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .receivables-summary > .metric-card:nth-child(2n) { border-left: 0; }
  .receivables-summary > .metric-card:nth-child(n+4) { border-top: 1px solid var(--line); }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar, .primary-button, .secondary-button, .ghost-button, .danger-button, .nav-link, tbody tr { transition: none; }
  .flash-toast { animation: none; }
}
