:root {
  color-scheme: light;
  --ink: #17201a;
  --muted: #667169;
  --line: #dfe5e0;
  --soft: #f3f6f3;
  --paper: #ffffff;
  --green: #147a4b;
  --green-dark: #0c5835;
  --green-soft: #e8f5ed;
  --orange: #ef6737;
  --red: #c94343;
  --sidebar: #17231c;
  --shadow: 0 14px 40px rgba(16, 30, 21, 0.14);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--soft); }
body { margin: 0; color: var(--ink); background: var(--soft); font-family: "Microsoft YaHei", "PingFang HK", Arial, sans-serif; letter-spacing: 0; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
[hidden] { display: none !important; }

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(110deg, #eef3ef 0 58%, #dfe9e2 58% 100%); }
.login-panel { width: min(430px, 100%); background: var(--paper); border: 1px solid #d7dfd9; box-shadow: var(--shadow); padding: 40px; }
.admin-brand { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; min-width: 0; }
.admin-brand-mark { width: 42px; height: 42px; flex: 0 0 42px; display: grid; place-items: center; color: white; background: var(--orange); font-weight: 900; font-size: 17px; }
.admin-brand strong, .admin-brand small { display: block; letter-spacing: 0; }
.admin-brand strong { font-size: 18px; }
.admin-brand small { margin-top: 2px; color: #849088; font-size: 10px; }
.login-copy { margin: 54px 0 28px; }
.login-copy > span { color: var(--green); font-size: 12px; font-weight: 800; }
.login-copy h1 { margin: 8px 0 0; font-size: 28px; line-height: 1.25; }
.login-panel form > label { display: block; margin: 14px 0 8px; font-size: 13px; font-weight: 700; }
.login-panel form > label:first-child { margin-top: 0; }
.password-field { height: 48px; display: flex; align-items: center; border: 1px solid #cfd8d1; background: white; }
.login-username-field button { display: none; }
.password-field:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px rgba(20, 122, 75, 0.1); }
.password-field > svg { width: 18px; margin-left: 14px; color: #728078; }
.password-field input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; padding: 0 12px; }
.password-field button { width: 44px; height: 100%; border: 0; background: transparent; cursor: pointer; color: #657168; }
.password-field button svg { width: 18px; }
.form-error { margin: 8px 0 0; color: var(--red); font-size: 12px; }
.login-submit { width: 100%; height: 48px; margin-top: 18px; border: 0; background: var(--green); color: white; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; font-weight: 800; cursor: pointer; }
.login-submit:hover { background: var(--green-dark); }
.login-submit svg { width: 18px; }
.back-store { display: inline-flex; align-items: center; gap: 7px; margin-top: 24px; color: var(--muted); text-decoration: none; font-size: 13px; }
.back-store svg { width: 16px; }

.admin-app { min-height: 100vh; }
.admin-sidebar { position: fixed; z-index: 30; inset: 0 auto 0 0; width: 232px; background: var(--sidebar); color: #dce5df; padding: 24px 16px; display: flex; flex-direction: column; }
.admin-sidebar .admin-brand { color: white; padding: 0 8px; }
.admin-sidebar .admin-brand small { color: #91a097; }
.admin-nav { margin-top: 42px; display: grid; gap: 6px; }
.admin-nav button { position: relative; width: 100%; height: 44px; display: flex; align-items: center; gap: 12px; border: 0; background: transparent; color: #aebbb3; padding: 0 13px; cursor: pointer; font-size: 14px; text-align: left; }
.admin-nav button:hover { color: white; background: rgba(255,255,255,.06); }
.admin-nav button.active { color: white; background: var(--green); }
.admin-nav svg { width: 19px; }
.admin-nav b { margin-left: auto; min-width: 20px; height: 20px; display: grid; place-items: center; border-radius: 10px; background: var(--orange); color: white; font-size: 11px; }
.sidebar-footer { margin-top: auto; padding: 18px 8px 2px; border-top: 1px solid rgba(255,255,255,.1); display: grid; gap: 14px; font-size: 12px; color: #91a097; }
.sidebar-footer a, .sidebar-footer div { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 8px; }
.sidebar-footer a:hover { color: white; }
.sidebar-footer svg { width: 15px; }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: #4bd183; box-shadow: 0 0 0 3px rgba(75,209,131,.12); }
.sidebar-overlay { display: none; }

.admin-workspace { min-height: 100vh; margin-left: 232px; }
.admin-header { position: sticky; z-index: 20; top: 0; height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 30px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); }
.header-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.header-title h1 { margin: 0; font-size: 20px; line-height: 1.2; }
.header-title p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.account-badge { max-width: 220px; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-app.sales-account .overview-layout { grid-template-columns: 1fr; }
.icon-command { width: 38px; height: 38px; border: 1px solid var(--line); background: white; display: inline-grid; place-items: center; cursor: pointer; }
.icon-command:hover { border-color: #9aa69e; background: var(--soft); }
.icon-command:disabled { opacity: .45; cursor: default; }
.icon-command svg { width: 17px; }
.mobile-menu { display: none; }
.sync-button { height: 38px; display: inline-flex; align-items: center; gap: 8px; border: 0; background: var(--green); color: white; padding: 0 15px; font-size: 13px; font-weight: 800; cursor: pointer; }
.sync-button:hover { background: var(--green-dark); }
.sync-button:disabled { opacity: .7; cursor: wait; }
.sync-button svg { width: 16px; }
.sync-button.syncing svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.admin-content { padding: 28px 30px 46px; max-width: 1600px; margin: 0 auto; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); background: white; border: 1px solid var(--line); }
.metric { min-height: 122px; padding: 23px 24px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric > span { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.metric > span svg { width: 16px; color: var(--green); }
.metric strong { display: block; margin: 10px 0 5px; font-size: 28px; line-height: 1; }
.metric small { color: #7b877f; font-size: 11px; }
.metric.loading span, .metric.loading strong, .metric.loading small { display: block; height: 11px; width: 55%; background: #edf1ee; color: transparent; }
.metric.loading strong { height: 27px; width: 35%; margin-top: 14px; }
.metric.loading small { width: 68%; }
.overview-layout { margin-top: 22px; display: grid; grid-template-columns: minmax(0,1.15fr) minmax(360px,.85fr); gap: 22px; }
.work-section { min-width: 0; background: white; border: 1px solid var(--line); padding: 24px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.section-title span { color: var(--green); font-size: 10px; font-weight: 900; }
.section-title h2 { margin: 4px 0 0; font-size: 17px; }
.text-command { border: 0; background: transparent; color: var(--green); display: inline-flex; align-items: center; gap: 6px; padding: 4px; cursor: pointer; font-size: 12px; font-weight: 700; }
.text-command svg { width: 14px; }
.inventory-bars { display: grid; gap: 17px; }
.inventory-line { display: grid; grid-template-columns: 84px minmax(100px,1fr) 58px; align-items: center; gap: 12px; font-size: 12px; }
.inventory-line > span { color: var(--muted); }
.inventory-line > strong { text-align: right; font-size: 12px; }
.bar-track { height: 7px; background: #edf1ee; overflow: hidden; }
.bar-track i { display: block; height: 100%; background: var(--green); }
.inventory-line.orange .bar-track i { background: var(--orange); }
.inventory-line.gray .bar-track i { background: #87938b; }
.source-status { margin-top: 25px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); display: flex; justify-content: space-between; gap: 16px; font-size: 11px; }
.source-status strong { color: var(--ink); }
.compact-orders { min-height: 190px; }
.compact-order { width: 100%; min-height: 62px; padding: 11px 0; border: 0; border-bottom: 1px solid #edf0ee; background: transparent; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px; text-align: left; cursor: pointer; }
.compact-order:last-child { border-bottom: 0; }
.compact-order strong, .compact-order span, .compact-order small { display: block; }
.compact-order strong { font-size: 13px; }
.compact-order span { margin-top: 4px; color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compact-order b { align-self: center; font-size: 13px; }
.empty-copy { min-height: 180px; display: grid; place-items: center; color: var(--muted); font-size: 13px; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.admin-search { width: min(520px, 100%); height: 42px; background: white; border: 1px solid var(--line); display: flex; align-items: center; }
.admin-search:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px rgba(20,122,75,.08); }
.admin-search svg { width: 17px; margin-left: 13px; color: #7c8880; }
.admin-search input { min-width: 0; flex: 1; height: 100%; padding: 0 12px; border: 0; outline: 0; background: transparent; }
.filter-select { height: 42px; display: flex; align-items: center; background: white; border: 1px solid var(--line); padding-left: 12px; }
.filter-select > span { color: var(--muted); font-size: 11px; white-space: nowrap; }
.filter-select select { height: 100%; border: 0; outline: 0; background: transparent; padding: 0 30px 0 9px; cursor: pointer; font-size: 12px; }
.bulk-bar { min-height: 46px; margin-bottom: 12px; padding: 7px 12px; background: var(--green-soft); border: 1px solid #bfe0cc; display: flex; align-items: center; gap: 10px; font-size: 12px; }
.bulk-bar select { height: 30px; border: 1px solid #b4cdbd; background: white; padding: 0 26px 0 8px; }
.bulk-bar button { height: 30px; border: 0; padding: 0 12px; background: var(--green); color: white; cursor: pointer; }
.bulk-bar .clear-selection { background: transparent; color: var(--muted); }
.table-tool { background: white; border: 1px solid var(--line); overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.data-table th { height: 43px; background: #f7f9f7; color: #667169; border-bottom: 1px solid var(--line); padding: 0 13px; font-size: 11px; text-align: left; white-space: nowrap; }
.data-table td { height: 66px; border-bottom: 1px solid #edf0ee; padding: 8px 13px; font-size: 12px; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fafcfb; }
.check-column { width: 42px; text-align: center !important; }
.check-column input, .row-check { width: 15px; height: 15px; accent-color: var(--green); }
.action-column { width: 70px; text-align: right !important; }
.product-table th:nth-child(2) { width: 32%; }
.product-table th:nth-child(3) { width: 18%; }
.product-table th:nth-child(4) { width: 175px; }
.product-table th:nth-child(5) { width: 130px; }
.product-table th:nth-child(6) { width: 130px; }
.table-product { display: flex; align-items: center; gap: 11px; min-width: 0; }
.table-thumb { width: 45px; height: 45px; flex: 0 0 45px; object-fit: contain; background: #f2f5f2; border: 1px solid #e7ece8; }
.table-thumb-placeholder { width: 45px; height: 45px; flex: 0 0 45px; display: grid; place-items: center; background: #f2f5f2; color: #a3ada6; }
.table-thumb-placeholder svg { width: 18px; }
.table-product div { min-width: 0; }
.table-product strong, .table-product span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-product strong { font-size: 12px; }
.table-product span { margin-top: 5px; color: var(--muted); font-size: 10px; }
.price-cell strong, .price-cell small { display: block; }
.price-cell small { margin-top: 3px; color: var(--orange); font-size: 9px; }
.stock-cell strong, .stock-cell small { display: block; }
.stock-cell small { margin-top: 4px; color: var(--muted); font-size: 9px; line-height: 1.35; }
.stock-cell.shortage strong { color: var(--red); }
.stock-cell.shortage.scheduled small { color: #a45d18; }
.stock-cell.shortage.delayed small { color: var(--red); }
.status-stack { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.status-pill { display: inline-flex; align-items: center; min-height: 22px; padding: 0 7px; color: var(--green-dark); background: var(--green-soft); font-size: 9px; font-weight: 800; white-space: nowrap; }
.status-pill.hidden { color: #6b716d; background: #ecefed; }
.status-pill.featured { color: #a74623; background: #fff0e9; }
.row-edit { margin-left: auto; }
.table-empty { min-height: 260px; display: grid; place-items: center; align-content: center; gap: 9px; color: var(--muted); }
.table-empty svg { width: 28px; }
.table-empty strong { font-size: 13px; }
.pagination { min-height: 56px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; }
.pagination > div { display: flex; align-items: center; gap: 9px; }
.order-table th:nth-child(1) { width: 160px; }
.order-table th:nth-child(2) { width: 24%; }
.order-table th:nth-child(3) { width: 90px; }
.order-table th:nth-child(4) { width: 120px; }
.order-table th:nth-child(5) { width: 150px; }
.order-table th:nth-child(6) { width: 100px; }
.customer-cell strong, .customer-cell span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.customer-cell span { margin-top: 4px; color: var(--muted); font-size: 10px; }
.order-status { display: inline-flex; align-items: center; height: 23px; padding: 0 8px; background: #edf1ee; color: #5e6861; font-size: 9px; font-weight: 800; }
.order-status.new { color: #a74623; background: #fff0e9; }
.order-status.confirmed, .order-status.picking { color: var(--green-dark); background: var(--green-soft); }
.order-status.delivering { color: #1b5f78; background: #e7f3f7; }
.order-status.cancelled { color: #984141; background: #faeaea; }

.admin-dialog { width: min(850px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 0; box-shadow: var(--shadow); color: var(--ink); }
.admin-dialog::backdrop { background: rgba(10,18,13,.56); }
.dialog-shell { margin: 0; }
.dialog-heading { min-height: 84px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.dialog-heading span { color: var(--green); font-size: 9px; font-weight: 900; }
.dialog-heading h2 { margin: 3px 0 0; font-size: 19px; }
.dialog-heading p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.editor-layout { display: grid; grid-template-columns: 280px minmax(0,1fr); gap: 28px; padding: 24px; }
.image-editor { min-width: 0; }
.edit-image-preview { width: 100%; aspect-ratio: 1; display: grid; place-items: center; background: #f4f6f4; border: 1px solid var(--line); overflow: hidden; color: #98a299; }
.edit-image-preview img { width: 100%; height: 100%; object-fit: contain; }
.edit-image-preview svg { width: 42px; }
.edit-image-gallery { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; }
.edit-image-gallery:empty { display: none; }
.edit-image-gallery button { width: 45px; height: 45px; flex: 0 0 45px; overflow: hidden; padding: 2px; border: 1px solid var(--line); background: white; cursor: pointer; }
.edit-image-gallery button.active { border: 2px solid var(--green); padding: 1px; }
.edit-image-gallery img { width: 100%; height: 100%; object-fit: contain; }
.image-actions { margin-top: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.image-actions label, .image-actions button { height: 34px; border: 1px solid var(--line); background: white; display: flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; font-size: 11px; }
.image-actions svg { width: 14px; }
.image-editor > small { display: block; margin-top: 8px; color: var(--muted); font-size: 10px; }
.edit-fields { display: grid; align-content: start; gap: 9px; }
.edit-fields > label, .order-edit-row label { display: grid; gap: 6px; }
.edit-fields label > span, .order-edit-row label > span { font-size: 11px; font-weight: 800; }
.edit-fields input, .edit-fields textarea, .order-edit-row select, .order-edit-row textarea { width: 100%; border: 1px solid #cfd8d1; background: white; outline: 0; padding: 9px 10px; font-size: 12px; resize: vertical; }
.edit-fields input { height: 39px; }
.edit-fields input:focus, .edit-fields textarea:focus, .order-edit-row select:focus, .order-edit-row textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(20,122,75,.08); }
.field-help { min-height: 16px; color: var(--muted); font-size: 9px; }
.toggle-row { margin-top: 7px; display: flex; flex-wrap: wrap; gap: 24px; }
.switch-control { display: flex !important; grid-template-columns: none !important; align-items: center; gap: 8px !important; cursor: pointer; }
.switch-control input { position: absolute; opacity: 0; pointer-events: none; }
.switch-control > span { position: relative; width: 36px; height: 20px; border-radius: 10px; background: #cbd3cd; transition: .2s; }
.switch-control > span::after { content: ""; position: absolute; width: 16px; height: 16px; top: 2px; left: 2px; border-radius: 50%; background: white; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch-control input:checked + span { background: var(--green); }
.switch-control input:checked + span::after { transform: translateX(16px); }
.switch-control b { font-size: 11px; }
.dialog-footer { min-height: 66px; padding: 13px 22px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: flex-end; gap: 9px; }
.primary-command, .secondary-command { min-height: 38px; border: 0; padding: 0 15px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; cursor: pointer; font-size: 12px; font-weight: 800; }
.primary-command { color: white; background: var(--green); }
.primary-command:hover { background: var(--green-dark); }
.primary-command:disabled { opacity: .55; cursor: wait; }
.secondary-command { color: var(--ink); background: #edf1ee; }
.primary-command svg { width: 15px; }
.order-detail { width: min(900px, calc(100vw - 32px)); }
.customer-summary { margin: 20px 22px 0; padding: 14px 16px; background: var(--soft); display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px; }
.customer-summary div { min-width: 0; }
.customer-summary span, .customer-summary strong { display: block; }
.customer-summary span { color: var(--muted); font-size: 9px; }
.customer-summary strong { margin-top: 4px; font-size: 12px; overflow-wrap: anywhere; }
.customer-summary .remarks { grid-column: 1 / -1; }
.order-lines-wrap { margin: 18px 22px; max-height: 280px; overflow: auto; border: 1px solid var(--line); }
.order-lines-wrap table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.order-lines-wrap th, .order-lines-wrap td { padding: 9px 10px; border-bottom: 1px solid #edf0ee; font-size: 11px; text-align: left; }
.order-lines-wrap th { background: #f7f9f7; color: var(--muted); font-size: 10px; }
.order-lines-wrap th:nth-child(2) { width: 38%; }
.order-edit-row { display: grid; grid-template-columns: 180px 1fr; gap: 16px; padding: 0 22px 20px; }
.order-edit-row select { height: 39px; }
.order-detail .dialog-footer { justify-content: space-between; }
.order-detail .dialog-footer > strong { color: var(--orange); font-size: 20px; }
.admin-toast { position: fixed; z-index: 100; right: 24px; bottom: 24px; max-width: min(380px, calc(100vw - 32px)); transform: translateY(18px); opacity: 0; pointer-events: none; background: var(--ink); color: white; padding: 12px 16px; box-shadow: var(--shadow); font-size: 12px; transition: .2s; }
.admin-toast.show { transform: translateY(0); opacity: 1; }

.insight-metrics { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); margin-bottom: 16px; background: white; border: 1px solid var(--line); }
.insight-metric { min-width: 0; min-height: 92px; padding: 17px 18px; border-right: 1px solid var(--line); }
.insight-metric:last-child { border-right: 0; }
.insight-metric span, .insight-metric strong, .insight-metric small { display: block; }
.insight-metric span { color: var(--muted); font-size: 10px; font-weight: 700; }
.insight-metric strong { margin: 8px 0 4px; overflow: hidden; text-overflow: ellipsis; font-size: 21px; white-space: nowrap; }
.insight-metric small { color: #879089; font-size: 9px; }
.analysis-tabs { margin-bottom: 14px; display: flex; overflow-x: auto; background: white; border: 1px solid var(--line); scrollbar-width: thin; }
.analysis-tabs button { min-width: max-content; height: 39px; padding: 0 16px; border: 0; border-right: 1px solid var(--line); background: white; color: var(--muted); cursor: pointer; font-size: 11px; font-weight: 700; }
.analysis-tabs button:hover { color: var(--ink); background: var(--soft); }
.analysis-tabs button.active { color: white; background: var(--green); }
.analytics-toolbar, .customer-toolbar { margin-bottom: 14px; }
.toolbar-selects { display: flex; align-items: center; gap: 10px; }
.analysis-chart-panel { margin-bottom: 14px; padding: 18px 20px; background: white; border: 1px solid var(--line); }
.analysis-chart-panel .section-title { margin-bottom: 14px; }
.analysis-chart-panel .section-title small { color: var(--muted); font-size: 9px; }
.rank-chart { display: grid; gap: 8px; }
.rank-chart-row { min-width: 0; display: grid; grid-template-columns: 22px minmax(150px,240px) minmax(120px,1fr) 90px; align-items: center; gap: 10px; font-size: 10px; }
.rank-chart-row > b { color: #8a948d; font-size: 10px; text-align: center; }
.rank-chart-row > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-chart-row > strong { text-align: right; font-size: 10px; }
.rank-track { height: 9px; background: #edf1ee; overflow: hidden; }
.rank-track i { display: block; height: 100%; background: var(--green); }
.rank-chart-row:nth-child(-n+3) .rank-track i { background: var(--orange); }
.analytics-table { min-width: 1120px; }
.analytics-table .rank-column { width: 54px; text-align: center; }
.analytics-table th:nth-child(2) { width: 28%; }
.analytics-table th:nth-child(3) { width: 100px; }
.analytics-table th:nth-child(4) { width: 115px; }
.analytics-table th:nth-child(5) { width: 130px; }
.analytics-table th:nth-child(6) { width: 110px; }
.analytics-table th:nth-child(7), .analytics-table th:nth-child(8) { width: 100px; }
.analytics-rank { text-align: center; color: var(--muted); font-weight: 800; }
.heat-cell { display: flex; align-items: center; gap: 7px; }
.heat-score { min-width: 28px; color: var(--green-dark); font-weight: 900; }
.heat-track { width: 45px; height: 5px; background: #e6ebe7; }
.heat-track i { display: block; height: 100%; background: var(--green); }
.heat-label { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; color: #6c746f; background: #edf0ee; font-size: 8px; font-weight: 800; }
.heat-label.hot { color: #a74623; background: #fff0e9; }
.heat-label.strong { color: var(--green-dark); background: var(--green-soft); }
.trend-value { display: inline-flex; align-items: center; gap: 3px; font-weight: 800; }
.trend-value.up { color: var(--green); }
.trend-value.down { color: var(--red); }
.trend-value svg { width: 12px; }
.analytics-secondary { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }

.customer-table { min-width: 1240px; }
.customer-table th:nth-child(1) { width: 24%; }
.customer-table th:nth-child(2) { width: 130px; }
.customer-table th:nth-child(3) { width: 130px; }
.customer-table th:nth-child(4) { width: 125px; }
.customer-table th:nth-child(5) { width: 18%; }
.customer-table th:nth-child(6) { width: 115px; }
.customer-table th:nth-child(7), .customer-table th:nth-child(8) { width: 95px; }
.customer-cell-main { min-width: 0; display: flex; align-items: center; gap: 10px; }
.customer-mini-avatar { width: 38px; height: 38px; flex: 0 0 38px; display: grid; place-items: center; color: white; background: #647168; font-size: 11px; font-weight: 900; }
.customer-cell-main > div { min-width: 0; }
.customer-cell-main strong, .customer-cell-main span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.customer-cell-main span { margin-top: 4px; color: var(--muted); font-size: 9px; }
.profile-badges { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.tier-badge, .lifecycle-badge { display: inline-flex; align-items: center; justify-content: center; min-height: 21px; padding: 0 7px; background: #edf0ee; color: #5f6862; font-size: 8px; font-weight: 900; }
.tier-badge.A { background: #fff0e9; color: #ad4926; }
.tier-badge.B { background: var(--green-soft); color: var(--green-dark); }
.lifecycle-badge.active, .lifecycle-badge.new { background: var(--green-soft); color: var(--green-dark); }
.lifecycle-badge.cooling, .lifecycle-badge.at-risk, .lifecycle-badge.lost { background: #fff1dd; color: #9b5b19; }
.lifecycle-badge.dormant, .lifecycle-badge.prospect { background: #ecefed; color: #6c746f; }
.customer-score { color: var(--muted); font-size: 9px; }
.preference-cell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.overdue-value { color: var(--red); font-weight: 800; }

.customer-profile-dialog { width: min(980px,calc(100vw - 32px)); }
.customer-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.customer-avatar { width: 46px; height: 46px; flex: 0 0 46px; display: grid; place-items: center; color: white; background: var(--green); font-size: 15px !important; font-weight: 900 !important; }
.profile-body { max-height: calc(100vh - 170px); overflow-y: auto; padding: 20px 22px 24px; }
.profile-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 16px; }
.profile-tags span { display: inline-flex; align-items: center; min-height: 24px; padding: 0 9px; color: var(--green-dark); background: var(--green-soft); font-size: 9px; font-weight: 800; }
.profile-tags span.warning { color: #9b5b19; background: #fff1dd; }
.profile-tags span.danger { color: #994040; background: #faeaea; }
.profile-kpis { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); border: 1px solid var(--line); }
.profile-kpi { min-width: 0; padding: 13px 14px; border-right: 1px solid var(--line); }
.profile-kpi:last-child { border-right: 0; }
.profile-kpi span, .profile-kpi strong { display: block; }
.profile-kpi span { color: var(--muted); font-size: 8px; }
.profile-kpi strong { margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.profile-grid { margin-top: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.profile-section { min-width: 0; border: 1px solid var(--line); padding: 15px; }
.profile-section-title { display: flex; align-items: center; gap: 7px; margin-bottom: 13px; }
.profile-section-title svg { width: 15px; color: var(--green); }
.profile-section-title strong { font-size: 12px; }
.profile-section dl { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 11px 16px; }
.profile-section dl div { min-width: 0; }
.profile-section dt, .profile-section dd { margin: 0; }
.profile-section dt { color: var(--muted); font-size: 8px; }
.profile-section dd { margin-top: 4px; overflow-wrap: anywhere; font-size: 10px; font-weight: 700; }
.preference-list { display: grid; gap: 7px; }
.preference-item { min-width: 0; display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 10px; padding-bottom: 7px; border-bottom: 1px solid #edf0ee; }
.preference-item:last-child { padding-bottom: 0; border-bottom: 0; }
.preference-item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.preference-item strong { font-size: 10px; }
.customer-profile-dialog .dialog-footer > span { margin-right: auto; color: var(--muted); font-size: 9px; }

.crm-pipeline { margin-bottom: 14px; padding: 18px 20px 20px; background: white; border: 1px solid var(--line); }
.crm-pipeline .section-title { margin-bottom: 14px; }
.crm-pipeline .section-title small { color: var(--muted); font-size: 9px; }
.crm-stage-board { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); border: 1px solid var(--line); }
.crm-stage { min-width: 0; height: 72px; padding: 10px 12px; border: 0; border-right: 1px solid var(--line); background: white; color: var(--muted); text-align: left; cursor: pointer; }
.crm-stage:last-child { border-right: 0; }
.crm-stage:hover { background: var(--soft); }
.crm-stage.active { color: white; background: var(--green); }
.crm-stage span, .crm-stage strong { display: block; }
.crm-stage span { overflow: hidden; text-overflow: ellipsis; font-size: 9px; font-weight: 800; white-space: nowrap; }
.crm-stage strong { margin-top: 7px; font-size: 20px; }
.crm-overview-grid { margin-bottom: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.crm-work-section { min-width: 0; min-height: 330px; padding: 18px 20px; background: white; border: 1px solid var(--line); }
.crm-work-section .section-title { margin-bottom: 12px; }
.crm-task-list, .crm-activity-list { display: grid; }
.crm-task-row, .crm-activity-row { min-width: 0; min-height: 54px; padding: 9px 0; border-bottom: 1px solid #edf0ee; display: grid; align-items: center; gap: 10px; }
.crm-task-row:last-child, .crm-activity-row:last-child { border-bottom: 0; }
.crm-task-row { grid-template-columns: 28px minmax(0,1fr) auto; }
.crm-task-check { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid var(--line); background: white; color: var(--green); cursor: pointer; }
.crm-task-check:hover { color: white; background: var(--green); }
.crm-task-check svg { width: 14px; }
.crm-task-main, .crm-activity-main { min-width: 0; }
.crm-task-main strong, .crm-task-main span, .crm-activity-main strong, .crm-activity-main span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-task-main strong, .crm-activity-main strong { font-size: 11px; }
.crm-task-main span, .crm-activity-main span { margin-top: 4px; color: var(--muted); font-size: 9px; }
.crm-task-due { color: var(--muted); font-size: 9px; font-weight: 800; text-align: right; }
.crm-task-due.overdue { color: var(--red); }
.crm-priority { width: 6px; height: 32px; background: #aab3ad; }
.crm-priority.high { background: var(--red); }
.crm-priority.low { background: #4f879d; }
.crm-activity-row { grid-template-columns: 28px minmax(0,1fr) auto; }
.crm-activity-icon { width: 28px; height: 28px; display: grid; place-items: center; color: var(--green-dark); background: var(--green-soft); }
.crm-activity-icon svg { width: 13px; }
.crm-activity-time { color: var(--muted); font-size: 9px; white-space: nowrap; }
.crm-toolbar { margin-top: 18px; }
.crm-toolbar-selects { flex: 1; justify-content: flex-end; }
.crm-table { min-width: 1250px; }
.crm-table th:nth-child(1) { width: 24%; }
.crm-table th:nth-child(2) { width: 105px; }
.crm-table th:nth-child(3) { width: 150px; }
.crm-table th:nth-child(4) { width: 17%; }
.crm-table th:nth-child(5), .crm-table th:nth-child(6) { width: 150px; }
.crm-table th:nth-child(7) { width: 125px; }
.crm-table .action-column { width: 100px; }
.crm-stage-badge { display: inline-flex; min-height: 23px; align-items: center; padding: 0 8px; color: #56615a; background: #edf0ee; font-size: 9px; font-weight: 800; }
.crm-stage-badge.lead { color: #445d82; background: #eaf0f8; }
.crm-stage-badge.contacted { color: #7b6026; background: #f8f1df; }
.crm-stage-badge.opportunity { color: #a14b27; background: #fff0e9; }
.crm-stage-badge.customer { color: var(--green-dark); background: var(--green-soft); }
.crm-stage-badge.retention { color: #76558b; background: #f0eaf4; }
.crm-stage-badge.lost { color: #7a7f7c; background: #ecefed; }
.crm-owner-cell strong, .crm-owner-cell small, .crm-date-cell strong, .crm-date-cell small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-owner-cell small, .crm-date-cell small { margin-top: 4px; color: var(--muted); font-size: 9px; }
.crm-tag-list { display: flex; flex-wrap: wrap; gap: 4px; max-height: 48px; overflow: hidden; }
.crm-tag-list span { min-height: 20px; padding: 0 6px; display: inline-flex; align-items: center; color: #57625b; background: #edf0ee; font-size: 8px; font-weight: 800; }
.crm-actions { display: flex; justify-content: flex-end; gap: 5px; }
.crm-actions .icon-command { width: 32px; height: 32px; }
.crm-date-cell.overdue strong { color: var(--red); }

.crm-followup-dialog { width: min(980px,calc(100vw - 32px)); }
.crm-dialog-body { max-height: calc(100vh - 210px); overflow-y: auto; padding: 20px 22px 24px; }
.crm-form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px 14px; }
.crm-form-grid label, .crm-next-grid label { min-width: 0; display: grid; gap: 6px; }
.crm-form-grid label > span, .crm-next-grid label > span { font-size: 10px; font-weight: 800; }
.crm-form-grid input, .crm-form-grid select, .crm-form-grid textarea, .crm-next-grid input, .crm-next-grid select { width: 100%; border: 1px solid #cfd8d1; background: white; outline: 0; padding: 9px 10px; font-size: 12px; }
.crm-form-grid input, .crm-form-grid select, .crm-next-grid input, .crm-next-grid select { height: 39px; }
.crm-form-grid textarea { resize: vertical; }
.crm-form-grid input:focus, .crm-form-grid select:focus, .crm-form-grid textarea:focus, .crm-next-grid input:focus, .crm-next-grid select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(20,122,75,.08); }
.crm-wide-field { grid-column: 1 / -1; }
.crm-next-action, .crm-history-section { margin-top: 16px; padding: 15px; border: 1px solid var(--line); }
.crm-next-grid { display: grid; grid-template-columns: minmax(0,1.4fr) minmax(190px,1fr) 120px; gap: 12px; }
.crm-history { display: grid; }
.crm-history-row { min-width: 0; padding: 10px 0; border-bottom: 1px solid #edf0ee; display: grid; grid-template-columns: 92px minmax(0,1fr) auto; gap: 12px; }
.crm-history-row:last-child { border-bottom: 0; }
.crm-history-row > span { color: var(--muted); font-size: 9px; }
.crm-history-row div { min-width: 0; }
.crm-history-row strong, .crm-history-row p { display: block; margin: 0; }
.crm-history-row strong { font-size: 10px; }
.crm-history-row p { margin-top: 4px; color: #59635c; font-size: 10px; line-height: 1.5; overflow-wrap: anywhere; }
.crm-history-row small { color: var(--muted); font-size: 9px; white-space: nowrap; }

.whatsapp-status { min-height: 86px; margin-bottom: 14px; padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; gap: 18px; background: white; border: 1px solid var(--line); }
.whatsapp-status-main, .whatsapp-status-actions, .whatsapp-chat-person, .whatsapp-chat-controls { display: flex; align-items: center; gap: 11px; min-width: 0; }
.whatsapp-logo { width: 44px; height: 44px; flex: 0 0 44px; display: grid; place-items: center; color: white; background: #1f8f5f; }
.whatsapp-logo svg { width: 21px; }
.whatsapp-status-main > div { min-width: 0; }
.whatsapp-status-main > div > span { color: var(--green); font-size: 8px; font-weight: 900; }
.whatsapp-status-main h2 { margin: 3px 0 0; font-size: 16px; }
.whatsapp-status-main p { margin: 4px 0 0; color: var(--muted); font-size: 9px; }
.connection-pill { min-height: 25px; padding: 0 8px; display: inline-flex; align-items: center; color: #745a22; background: #f8f1df; font-size: 9px; font-weight: 800; }
.connection-pill.connected { color: var(--green-dark); background: var(--green-soft); }
.connection-pill.disabled { color: #68716b; background: #ecefed; }
.whatsapp-inbox { height: calc(100vh - 344px); min-height: 580px; max-height: 760px; display: grid; grid-template-columns: 330px minmax(0,1fr); background: white; border: 1px solid var(--line); }
.whatsapp-contacts-panel { min-width: 0; height: 100%; border-right: 1px solid var(--line); }
.whatsapp-panel-heading, .whatsapp-chat-heading { min-height: 68px; padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.whatsapp-panel-heading span { color: var(--green); font-size: 8px; font-weight: 900; }
.whatsapp-panel-heading h2 { margin: 3px 0 0; font-size: 15px; }
.whatsapp-search { height: 40px; margin: 10px; display: flex; align-items: center; border: 1px solid var(--line); }
.whatsapp-search svg { width: 15px; margin-left: 10px; color: var(--muted); }
.whatsapp-search input { min-width: 0; flex: 1; height: 100%; border: 0; outline: 0; padding: 0 9px; font-size: 11px; }
.whatsapp-contact-list { height: calc(100% - 129px); overflow-y: auto; }
.whatsapp-contact { width: 100%; min-width: 0; min-height: 72px; padding: 10px 12px; display: grid; grid-template-columns: 38px minmax(0,1fr) auto; align-items: center; gap: 9px; border: 0; border-top: 1px solid #edf0ee; background: white; text-align: left; cursor: pointer; }
.whatsapp-contact:hover { background: #f8faf8; }
.whatsapp-contact.active { background: var(--green-soft); }
.whatsapp-contact > div { min-width: 0; }
.whatsapp-contact strong, .whatsapp-contact span, .whatsapp-contact small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.whatsapp-contact strong { font-size: 11px; }
.whatsapp-contact span { margin-top: 4px; color: var(--muted); font-size: 9px; }
.whatsapp-contact small { margin-top: 4px; color: #88918b; font-size: 8px; }
.whatsapp-contact-meta { align-self: stretch; display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; }
.whatsapp-unread { min-width: 18px; height: 18px; padding: 0 5px; display: grid; place-items: center; border-radius: 9px; color: white; background: var(--green); font-size: 8px; font-weight: 900; }
.whatsapp-sales-flag { color: var(--orange); font-size: 8px; font-weight: 900; }
.whatsapp-chat-panel { min-width: 0; height: 100%; min-height: 0; }
.whatsapp-chat-empty { height: 100%; min-height: 0; display: grid; place-items: center; align-content: center; gap: 8px; color: var(--muted); }
.whatsapp-chat-empty svg { width: 34px; }
.whatsapp-chat-empty strong { color: var(--ink); font-size: 13px; }
.whatsapp-chat-empty span { font-size: 10px; }
.whatsapp-chat { height: 100%; min-height: 0; display: grid; grid-template-rows: auto auto minmax(180px,1fr) auto; }
.whatsapp-chat-heading { min-height: 68px; }
.whatsapp-chat-person > div { min-width: 0; }
.whatsapp-chat-person strong, .whatsapp-chat-person span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.whatsapp-chat-person strong { font-size: 12px; }
.whatsapp-chat-person span { margin-top: 4px; color: var(--muted); font-size: 9px; }
.whatsapp-chat-controls select { height: 34px; border: 1px solid var(--line); background: white; padding: 0 24px 0 8px; font-size: 10px; }
.whatsapp-chat-controls .icon-command { width: 34px; height: 34px; }
.whatsapp-customer-link { min-height: 58px; padding: 8px 14px; display: grid; grid-template-columns: 150px 160px minmax(0,1fr); align-items: center; gap: 10px; border-bottom: 1px solid var(--line); background: #f8faf8; }
.whatsapp-customer-link label { min-width: 0; display: grid; gap: 3px; }
.whatsapp-customer-link label > span { color: var(--muted); font-size: 8px; }
.whatsapp-customer-link input { width: 100%; height: 28px; border: 1px solid #d5ddd7; background: white; padding: 0 7px; font-size: 10px; }
.whatsapp-customer-link > span { color: var(--muted); font-size: 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.whatsapp-messages { min-height: 180px; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 9px; background: #f2f5f2; }
.whatsapp-message { width: fit-content; max-width: min(72%,560px); padding: 9px 11px; color: #334038; background: white; border: 1px solid #dfe5e0; box-shadow: 0 1px 2px rgba(16,30,21,.04); }
.whatsapp-message.out { align-self: flex-end; color: #153824; background: #dff2e6; border-color: #c8e5d3; }
.whatsapp-message p { margin: 0; font-size: 11px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.whatsapp-message span { margin-top: 5px; display: flex; justify-content: flex-end; gap: 5px; color: #7b857e; font-size: 8px; }
.whatsapp-composer { padding: 11px 14px 13px; border-top: 1px solid var(--line); background: white; }
.whatsapp-compose-mode { margin-bottom: 8px; display: inline-flex; border: 1px solid var(--line); }
.whatsapp-compose-mode button { height: 27px; padding: 0 10px; border: 0; border-right: 1px solid var(--line); background: white; color: var(--muted); cursor: pointer; font-size: 9px; font-weight: 800; }
.whatsapp-compose-mode button:last-child { border-right: 0; }
.whatsapp-compose-mode button.active { color: white; background: var(--green); }
.whatsapp-composer textarea, .whatsapp-template-compose input { width: 100%; border: 1px solid #cfd8d1; outline: 0; padding: 8px 10px; resize: vertical; font-size: 11px; }
.whatsapp-template-compose { display: grid; grid-template-columns: minmax(180px,1fr) 90px minmax(180px,1fr); gap: 8px; }
.whatsapp-template-compose input { height: 38px; }
.whatsapp-compose-footer { margin-top: 8px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.whatsapp-compose-footer > span { color: var(--muted); font-size: 8px; }
.whatsapp-settings-dialog { width: min(920px,calc(100vw - 32px)); }
.whatsapp-settings-body { max-height: calc(100vh - 190px); overflow-y: auto; padding: 20px 22px 24px; }
.whatsapp-setup-notice { min-height: 58px; margin-bottom: 16px; padding: 10px 12px; display: flex; align-items: center; gap: 10px; color: #73521f; background: #fff5e5; border: 1px solid #f0d7ad; }
.whatsapp-setup-notice svg { width: 18px; flex: 0 0 18px; }
.whatsapp-setup-notice strong, .whatsapp-setup-notice span { display: block; }
.whatsapp-setup-notice strong { font-size: 10px; }
.whatsapp-setup-notice span { margin-top: 4px; font-size: 9px; overflow-wrap: anywhere; }
.whatsapp-settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.whatsapp-settings-grid label, .whatsapp-new-body label { min-width: 0; display: grid; gap: 6px; }
.whatsapp-settings-grid label > span, .whatsapp-new-body label > span { font-size: 10px; font-weight: 800; }
.whatsapp-settings-grid input, .whatsapp-settings-grid textarea, .whatsapp-new-body input { width: 100%; border: 1px solid #cfd8d1; outline: 0; background: white; padding: 9px 10px; font-size: 11px; }
.whatsapp-settings-grid input, .whatsapp-new-body input { height: 39px; }
.whatsapp-settings-grid textarea { resize: vertical; }
.whatsapp-secret-field small { color: var(--muted); font-size: 8px; }
.whatsapp-wide-setting { grid-column: 1 / -1; }
.whatsapp-toggle-row { margin-top: 16px; padding: 12px 14px; display: flex; gap: 28px; background: var(--soft); border: 1px solid var(--line); }
.whatsapp-new-dialog { width: min(500px,calc(100vw - 32px)); }
.whatsapp-new-body { padding: 22px; }

.purchase-system-panel { min-width: 0; }
.purchase-commandbar { display: flex; flex-wrap: wrap; gap: 7px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.purchase-commandbar button, .purchase-metrics button, .purchase-quick-add button, .purchase-tool-controls button, .purchase-list-form button { min-height: 36px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 11px; border: 1px solid #cfd7d1; border-radius: 4px; background: white; font-size: 11px; font-weight: 700; cursor: pointer; }
.purchase-commandbar button:hover, .purchase-metrics button:hover, .purchase-quick-add button:hover { border-color: var(--green); color: var(--green); }
.purchase-commandbar button svg, .purchase-metrics button svg, .purchase-quick-add button svg, .purchase-tool-controls button svg, .purchase-list-form button svg { width: 15px; }
.purchase-commandbar .primary-command { color: white; background: var(--green); border-color: var(--green); }
.purchase-filters { display: grid; grid-template-columns: repeat(3,minmax(180px,1fr)) minmax(360px,1.4fr); gap: 12px; padding: 15px 0 10px; }
.purchase-filters label, .purchase-parameters label { min-width: 0; display: flex; align-items: center; gap: 8px; }
.purchase-filters label > span, .purchase-parameters label > span { flex: 0 0 auto; font-size: 11px; font-weight: 800; }
.purchase-filters select, .purchase-filters input, .purchase-parameters input, .purchase-quick-add input, .purchase-list-form input { min-width: 0; height: 37px; border: 1px solid #cfd7d1; border-radius: 3px; background: white; padding: 0 9px; }
.purchase-filters select { flex: 1; }
.purchase-date input { width: 132px; }
.purchase-date b { color: var(--muted); font-size: 11px; }
.purchase-parameters { display: flex; flex-wrap: wrap; gap: 20px; padding: 9px 0 13px; }
.purchase-parameters input { width: 74px; color: #194eae; font-size: 14px; font-weight: 800; }
.purchase-parameters .critical span, .purchase-parameters .critical input { color: #d52f2f; }
.purchase-parameters .critical input { background: #fff5f5; }
.purchase-metrics { min-height: 50px; display: flex; align-items: center; gap: 26px; padding: 9px 14px; border-block: 1px solid var(--line); background: #f7f9f7; }
.purchase-metrics > div { display: flex; align-items: baseline; gap: 8px; }
.purchase-metrics span { font-size: 11px; font-weight: 800; }
.purchase-metrics strong { font-size: 18px; }
.purchase-metrics button:first-of-type { margin-left: auto; }
.purchase-quick-add { display: flex; align-items: center; gap: 9px; padding: 12px 0; }
.purchase-quick-add label { font-size: 11px; font-weight: 800; }
.purchase-quick-add input { width: min(340px,30vw); }
.purchase-status { min-height: 34px; display: flex; align-items: center; margin-bottom: 8px; padding: 0 10px; border-left: 3px solid var(--green); color: #4f5d53; background: #f2f6f3; font-size: 11px; }
.purchase-table-wrap { width: 100%; min-height: 360px; overflow: auto; border: 1px solid #d8ded9; background: white; }
.purchase-table { min-width: 2280px; width: 100%; border-collapse: separate; border-spacing: 0; font-size: 10px; }
.purchase-table th { position: sticky; top: 0; z-index: 2; height: 43px; padding: 6px 8px; border-right: 1px solid #dfe4e0; border-bottom: 1px solid #cdd5cf; background: #f1f4f2; white-space: pre-line; text-align: center; }
.purchase-table td { height: 36px; padding: 5px 8px; border-right: 1px solid #edf0ed; border-bottom: 1px solid #e8ece9; white-space: nowrap; text-align: center; }
.purchase-table th:nth-child(2), .purchase-table td:nth-child(2) { min-width: 260px; text-align: left; }
.purchase-table th:first-child, .purchase-table td:first-child { position: sticky; left: 0; z-index: 1; min-width: 92px; background: inherit; text-align: left; }
.purchase-table th:first-child { z-index: 3; background: #f1f4f2; }
.purchase-table tbody tr:hover { background: #f5faf6; }
.purchase-table tbody tr.high-volume { background: #ffe1e6; }
.purchase-table tbody tr.preorder { background: #fff5a8; }
.purchase-table tbody tr.selected { outline: 2px solid #2c6a46; outline-offset: -2px; }
.purchase-table tbody tr[draggable="true"] { cursor: grab; }
.purchase-table td[contenteditable="true"] { min-width: 86px; color: #b62525; background: #fff7f7; font-weight: 800; cursor: text; }
.purchase-tool-dialog { width: min(1500px,96vw); }
.purchase-tool-dialog .dialog-shell, .purchase-list-dialog .dialog-shell, .purchase-draft-dialog .dialog-shell { width: 100%; max-height: 90vh; }
.purchase-tool-controls { display: flex; align-items: center; gap: 9px; padding: 12px 20px; }
.purchase-tool-controls form { width: 280px; height: 37px; display: flex; align-items: center; border: 1px solid #cfd7d1; }
.purchase-tool-controls form svg { width: 16px; margin-left: 10px; }
.purchase-tool-controls form input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; padding: 0 9px; }
.purchase-region-tabs { flex: 1; display: flex; gap: 5px; overflow-x: auto; }
.purchase-region-tabs button.active { color: white; border-color: var(--green); background: var(--green); }
.purchase-tool-mode-controls { min-height: 48px; display: flex; align-items: center; flex-wrap: wrap; gap: 9px; padding: 8px 20px; border-top: 1px solid var(--line); background: #f7f9f7; }
.purchase-tool-mode-controls[hidden] { display: none; }
.purchase-tool-mode-controls form, .purchase-tool-mode-controls label { display: inline-flex; align-items: center; gap: 7px; font-size: 10px; font-weight: 800; }
.purchase-tool-mode-controls input, .purchase-tool-mode-controls select { height: 34px; border: 1px solid #cfd7d1; background: white; padding: 0 8px; }
.purchase-tool-mode-controls button { min-height: 34px; display: inline-flex; align-items: center; gap: 5px; border: 1px solid #cfd7d1; background: white; padding: 0 10px; cursor: pointer; }
.tool-table { min-height: 520px; max-height: 68vh; border-inline: 0; }
.purchase-list-form { display: grid; grid-template-columns: 160px 1fr 1fr auto; gap: 9px; padding: 14px 20px; }
.purchase-list-filter { display: flex; justify-content: flex-end; padding: 0 20px 10px; }
.purchase-list-filter label { display: inline-flex; align-items: center; gap: 8px; font-size: 10px; font-weight: 800; }
.purchase-list-filter select { min-width: 240px; height: 35px; border: 1px solid #cfd7d1; background: white; padding: 0 8px; }
.purchase-list-dialog { width: min(940px,94vw); }
.purchase-list-dialog .purchase-table { min-width: 850px; }
.purchase-draft-dialog { width: min(720px,94vw); }
.purchase-draft-list { display: grid; gap: 8px; max-height: 65vh; overflow-y: auto; padding: 18px 20px; }
.purchase-draft-list button { min-height: 58px; display: flex; align-items: center; justify-content: space-between; padding: 8px 13px; border: 1px solid #d5ddd7; background: white; text-align: left; cursor: pointer; }
.purchase-draft-list button:hover { border-color: var(--green); }
.purchase-draft-list button span, .purchase-draft-list button strong { display: block; }
.purchase-draft-list button span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.purchase-add-dialog { width: min(1180px,96vw); }
.purchase-add-dialog .dialog-shell { width: 100%; max-height: 90vh; }
.purchase-add-modes { display: flex; gap: 6px; padding: 14px 20px 8px; }
.purchase-add-modes label { min-height: 36px; display: inline-flex; align-items: center; gap: 7px; padding: 0 12px; border: 1px solid #cfd7d1; background: white; font-size: 11px; font-weight: 800; cursor: pointer; }
.purchase-add-modes label:has(input:checked) { color: white; border-color: var(--green); background: var(--green); }
.purchase-add-search { display: flex; gap: 8px; padding: 8px 20px 12px; }
.purchase-add-search input { flex: 1; height: 38px; border: 1px solid #cfd7d1; padding: 0 10px; }
.purchase-add-search button { min-width: 90px; border: 1px solid var(--green); color: white; background: var(--green); }
.purchase-add-table { min-height: 390px; max-height: 56vh; border-inline: 0; }
.purchase-add-table .purchase-table { min-width: 1100px; }
.purchase-add-table .purchase-table th:first-child, .purchase-add-table .purchase-table td:first-child { min-width: 42px; width: 42px; text-align: center; }
.purchase-context-menu { position: fixed; z-index: 80; min-width: 210px; padding: 5px; border: 1px solid #ccd5ce; background: white; box-shadow: 0 12px 30px rgba(21,35,26,.2); }
.purchase-context-menu[hidden] { display: none; }
.purchase-context-menu button { width: 100%; min-height: 34px; display: flex; align-items: center; gap: 8px; border: 0; background: transparent; padding: 0 9px; font-size: 10px; text-align: left; cursor: pointer; }
.purchase-context-menu button:hover { background: var(--soft); }
.purchase-context-menu svg { width: 14px; }

@media (max-width: 1050px) {
  .purchase-filters { grid-template-columns: 1fr 1fr; }
  .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .overview-layout { grid-template-columns: 1fr; }
  .product-table { min-width: 900px; }
  .order-table { min-width: 880px; }
  .insight-metrics { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .insight-metric { border-bottom: 1px solid var(--line); }
  .insight-metric:nth-child(3) { border-right: 0; }
  .profile-kpis { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .profile-kpi { border-bottom: 1px solid var(--line); }
  .crm-stage-board { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .crm-stage:nth-child(3) { border-right: 0; }
  .crm-stage:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
  .crm-overview-grid { grid-template-columns: 1fr; }
  .whatsapp-inbox { grid-template-columns: 280px minmax(0,1fr); }
  .whatsapp-customer-link { grid-template-columns: 1fr 1fr; }
  .whatsapp-customer-link > span { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .purchase-filters { grid-template-columns: 1fr; }
  .purchase-date { flex-wrap: wrap; }
  .purchase-metrics { align-items: stretch; flex-direction: column; gap: 8px; }
  .purchase-metrics button:first-of-type { margin-left: 0; }
  .purchase-quick-add { align-items: stretch; flex-direction: column; }
  .purchase-quick-add input { width: 100%; }
  .purchase-list-form { grid-template-columns: 1fr; }
  .purchase-add-modes, .purchase-tool-controls { align-items: stretch; flex-direction: column; }
  .purchase-add-modes label, .purchase-tool-controls form { width: 100%; }
  .purchase-add-search { flex-direction: column; }
  .login-screen { background: var(--soft); padding: 14px; }
  .login-panel { padding: 30px 24px; }
  .login-copy { margin-top: 44px; }
  .admin-sidebar { transform: translateX(-100%); visibility: hidden; transition: transform .22s ease, visibility 0s .22s; }
  .admin-sidebar.open { transform: translateX(0); visibility: visible; transition-delay: 0s; }
  .sidebar-overlay { position: fixed; z-index: 25; inset: 0; width: 100%; height: 100%; border: 0; background: rgba(8,14,10,.48); }
  .sidebar-overlay.open { display: block; }
  .admin-workspace { margin-left: 0; }
  .admin-header { height: 64px; padding: 0 14px; }
  .mobile-menu { display: inline-grid; border: 0; }
  .header-title h1 { font-size: 17px; }
  .header-title p { display: none; }
  .sync-button { width: 38px; padding: 0; justify-content: center; }
  .sync-button span { display: none; }
  .admin-content { padding: 16px 14px 36px; }
  .metric { min-height: 108px; padding: 18px; }
  .metric strong { font-size: 24px; }
  .overview-layout { margin-top: 14px; gap: 14px; }
  .work-section { padding: 18px; }
  .source-status { display: grid; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-selects { display: grid; grid-template-columns: 1fr 1fr; }
  .filter-select { width: 100%; }
  .filter-select select { flex: 1; }
  .bulk-bar { flex-wrap: wrap; }
  .pagination { min-height: 68px; }
  .editor-layout { grid-template-columns: 1fr; max-height: calc(100vh - 170px); overflow-y: auto; padding: 18px; }
  .image-editor { width: min(280px,100%); margin: 0 auto; }
  .dialog-heading { padding: 15px 18px; }
  .dialog-footer { padding: 12px 18px; }
  .customer-summary { grid-template-columns: 1fr 1fr; margin: 14px 16px 0; }
  .customer-summary .remarks { grid-column: 1 / -1; }
  .order-lines-wrap { margin: 14px 16px; }
  .order-lines-wrap table { min-width: 650px; }
  .order-edit-row { grid-template-columns: 1fr; padding: 0 16px 18px; }
  .insight-metrics { grid-template-columns: 1fr 1fr; }
  .insight-metric:nth-child(2n) { border-right: 0; }
  .insight-metric:nth-child(3) { border-right: 1px solid var(--line); }
  .insight-metric strong { overflow: visible; font-size: 15px; white-space: normal; overflow-wrap: anywhere; }
  .rank-chart-row { grid-template-columns: 20px minmax(100px,1fr) 70px; }
  .rank-chart-row .rank-track { display: none; }
  .profile-body { padding: 16px; }
  .profile-kpis { grid-template-columns: 1fr 1fr; }
  .profile-kpi:nth-child(2n) { border-right: 0; }
  .profile-grid { grid-template-columns: 1fr; }
  .crm-pipeline, .crm-work-section { padding: 16px; }
  .crm-toolbar-selects { grid-template-columns: 1fr; }
  .crm-dialog-body { padding: 16px; }
  .crm-form-grid { grid-template-columns: 1fr; }
  .crm-wide-field { grid-column: auto; }
  .crm-next-grid { grid-template-columns: 1fr; }
  .crm-history-row { grid-template-columns: 72px minmax(0,1fr); }
  .crm-history-row small { grid-column: 2; }
  .whatsapp-status { align-items: stretch; flex-direction: column; }
  .whatsapp-status-actions { justify-content: space-between; }
  .whatsapp-inbox { height: auto; min-height: 620px; max-height: none; grid-template-columns: 1fr; }
  .whatsapp-contacts-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .whatsapp-contact-list { height: 300px; }
  .whatsapp-chat-panel, .whatsapp-chat-empty, .whatsapp-chat { min-height: 620px; }
  .whatsapp-chat-heading { align-items: stretch; flex-direction: column; }
  .whatsapp-chat-controls { justify-content: space-between; }
  .whatsapp-customer-link { grid-template-columns: 1fr; }
  .whatsapp-customer-link > span { grid-column: auto; }
  .whatsapp-message { max-width: 88%; }
  .whatsapp-template-compose { grid-template-columns: 1fr; }
  .whatsapp-settings-body { padding: 16px; }
  .whatsapp-settings-grid { grid-template-columns: 1fr; }
  .whatsapp-wide-setting { grid-column: auto; }
  .whatsapp-toggle-row { align-items: flex-start; flex-direction: column; gap: 14px; }
}

@media (max-width: 430px) {
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric { padding: 15px 13px; }
  .metric > span { font-size: 10px; }
  .metric strong { font-size: 22px; }
  .header-actions { gap: 5px; }
  .header-actions .icon-command { width: 34px; }
  .sync-button { width: 34px; }
  .inventory-line { grid-template-columns: 70px minmax(70px,1fr) 48px; gap: 8px; }
  .dialog-footer .primary-command { flex: 1; }
  .toolbar-selects { grid-template-columns: 1fr; }
  .customer-dialog-heading .customer-avatar { display: none; }
}
