/* Mercado ERP design system. Presentation adapters preserve existing handlers. */
:root {
  --color-canvas: #eef0f4;
  --color-surface: #ffffff;
  --color-surface-subtle: #f5f6f8;
  --color-surface-hover: #f0f4fa;
  --color-text: #202733;
  --color-text-secondary: #596474;
  --color-text-muted: #637083;
  --color-border: #e0e4eb;
  --color-border-control: #8792a3;
  --color-accent: #185fc7;
  --color-accent-hover: #104da6;
  --color-accent-subtle: #edf3fe;
  --color-success: #22724d;
  --color-success-subtle: #edf7f1;
  --color-warning: #86580b;
  --color-warning-subtle: #fff7e6;
  --color-danger: #b43438;
  --color-danger-subtle: #fdf0f0;
  --color-info: #185fc7;
  --color-info-subtle: #edf3fe;
  --color-neutral: #596273;
  --color-neutral-subtle: #f0f2f5;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-md: 14px;
  --text-lg: 20px;
  --text-xl: 24px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --radius-overlay: 18px;
  --shadow-sm: 0 1px 2px rgb(24 34 52 / 4%);
  --shadow-menu: 0 8px 32px rgb(24 34 52 / 14%);
  --shadow-overlay: 0 24px 80px rgb(17 24 39 / 20%);
  --control-height: 36px;
  --duration-fast: 120ms;
  --duration-normal: 160ms;
  --sidebar-width: 208px;
  /* Compatibility aliases. New UI uses semantic tokens above. */
  --ink: var(--color-text);
  --muted: var(--color-text-muted);
  --line: var(--color-border);
  --paper: var(--color-canvas);
  --surface: var(--color-surface);
  --navy: var(--color-accent);
  --blue: var(--color-accent);
  --green: var(--color-success);
  --coral: var(--color-danger);
  --shadow: none;
}

body.erp-app { background: var(--color-canvas); font: var(--text-sm)/1.5 var(--font-sans); -webkit-font-smoothing: antialiased; }
.erp-app [hidden] { display: none !important; }
.erp-app :where(button, input, select, textarea, a, summary) { -webkit-tap-highlight-color: transparent; }
.erp-app :where(button, a, summary, input, select, textarea, [tabindex]):focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.erp-app :where(button, select, summary) { touch-action: manipulation; }
.ui-icon { width: 18px; height: 18px; flex: none; display: inline-block; }
.erp-app code { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-text-secondary); }
.erp-app .panel, .ui-container { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: none; }

/* Shared control hierarchy; legacy commands keep their selectors and states. */
.erp-app .button, .erp-app .zy-btn, .ui-button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--control-height); padding: 6px 12px; border: 1px solid var(--color-border-control);
  border-radius: var(--radius-md); background: var(--color-surface); color: var(--color-text);
  font: 550 var(--text-xs)/1.5 var(--font-sans); text-decoration: none; cursor: pointer;
  box-shadow: var(--shadow-sm); transition: background var(--duration-fast), border-color var(--duration-fast), color var(--duration-fast);
}
.erp-app .button:hover, .erp-app .zy-btn:hover, .ui-button:hover { background: var(--color-surface-hover); border-color: var(--color-text-muted); transform: none; }
.erp-app .button:not(.secondary), .erp-app .zy-btn-primary, .ui-button-primary { background: var(--color-accent); border-color: var(--color-accent); color: white; }
.erp-app .button:not(.secondary):hover, .erp-app .zy-btn-primary:hover, .ui-button-primary:hover { background: var(--color-accent-hover); border-color: var(--color-accent-hover); }
.erp-app .ui-button-quiet, .ui-button-quiet { background: transparent; border-color: transparent; box-shadow: none; color: var(--color-text-secondary); }
.erp-app .ui-button-quiet:hover, .ui-button-quiet:hover { border-color: transparent; background: var(--color-surface-hover); }
.erp-app .uploaded-delete-btn, .ui-button-danger { color: var(--color-danger); border-color: var(--color-danger); background: var(--color-surface); }
.erp-app .uploaded-delete-btn:hover, .ui-button-danger:hover { background: var(--color-danger-subtle); }
.erp-app :where(.button, .zy-btn, .ui-button):active:not(:disabled) { box-shadow: none; }
.erp-app .button:disabled, .erp-app .zy-btn:disabled, .ui-button:disabled { background: var(--color-neutral-subtle); color: var(--color-text-muted); border-color: var(--color-border); box-shadow: none; opacity: .75; cursor: not-allowed; transform: none; }
.ui-input, .ui-select, .ui-textarea { width: 100%; min-width: 0; min-height: var(--control-height); padding: 6px 10px; border: 1px solid var(--color-border-control); border-radius: var(--radius-md); background: var(--color-surface); color: var(--color-text); font: var(--text-sm)/1.5 var(--font-sans); }
.ui-textarea { resize: vertical; }
.ui-field { display: flex; flex-direction: column; gap: var(--space-2); }
.ui-field label { font-size: var(--text-xs); font-weight: 550; }
.ui-field-hint { font-size: var(--text-xs); color: var(--color-text-muted); }
.ui-field-error { font-size: var(--text-xs); color: var(--color-danger); }
.ui-input:disabled, .ui-select:disabled, .ui-textarea:disabled { background: var(--color-neutral-subtle); color: var(--color-text-muted); }
.ui-input[readonly], .ui-textarea[readonly] { background: var(--color-surface-subtle); }
.erp-app input[type="checkbox"], .erp-app input[type="radio"] { accent-color: var(--color-accent); }

.ui-badge, .erp-app .zy-tag { display: inline-flex; align-items: center; gap: var(--space-1); padding: 2px 6px; border-radius: var(--radius-sm); background: var(--color-neutral-subtle); color: var(--color-neutral); font-size: var(--text-xs); line-height: 1.5; white-space: nowrap; }
.ui-badge-success, .erp-app .zy-tag-active, .erp-app .zy-tag-ready, .erp-app .zy-tag-upload-success { color: var(--color-success); background: var(--color-success-subtle); }
.ui-badge-warning, .erp-app .zy-tag-watching, .erp-app .zy-tag-todo, .erp-app .zy-tag-upload-partial { color: var(--color-warning); background: var(--color-warning-subtle); }
.ui-badge-danger, .erp-app .zy-tag-discontinued, .erp-app .zy-tag-upload-failed { color: var(--color-danger); background: var(--color-danger-subtle); }
.ui-badge-info, .erp-app .zy-tag-upload-uploading { color: var(--color-info); background: var(--color-info-subtle); }
.erp-app .notice { border-radius: var(--radius-md); background: var(--color-surface); font-size: var(--text-xs); padding: 10px 14px; margin-bottom: var(--space-4); }
.erp-app .notice.warning { color: var(--color-warning); background: var(--color-warning-subtle); border-color: #e4d3ac; }
.erp-app .notice.error { color: var(--color-danger); background: var(--color-danger-subtle); border-color: #e8b9bb; }
/* Existing feedback stays visible above an open editor, including failed saves. */
body:has(#erpProductModal:not(.hidden)) #message:not(.hidden) { position: fixed; z-index: 80; bottom: 32px; left: 50%; transform: translateX(-50%); width: max-content; max-width: min(720px, calc(100vw - 64px)); margin: 0; box-shadow: var(--shadow-menu); overflow-wrap: anywhere; }
body:has(#erpProductModal:not(.hidden)):has(#message:not(.hidden)) #erpProductModal .zy-modal-body { padding-bottom: 120px; scroll-padding-bottom: 120px; }
.ui-skeleton { min-height: 20px; background: var(--color-neutral-subtle); border-radius: var(--radius-sm); }
.ui-empty, .erp-app .empty { padding: var(--space-7) var(--space-5); color: var(--color-text-muted); text-align: center; }
.ui-drawer { width: min(480px, 100%); margin-left: auto; min-height: 100%; background: var(--color-surface); padding: var(--space-6); box-shadow: var(--shadow-overlay); }
.erp-app table, .ui-table { font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.erp-app th, .ui-table th { padding: 10px 12px; background: var(--color-surface-subtle); color: var(--color-text-secondary); font-size: var(--text-xs); font-weight: 600; text-align: left; }
.erp-app td, .ui-table td { padding: 10px 12px; border-top: 1px solid var(--color-border); }
.erp-app tbody tr:hover { background: var(--color-surface-subtle); }

/* Application shell: existing navigation buttons, new visual frame. */
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; padding: 10px 14px; background: var(--color-surface); color: var(--color-accent); border-radius: var(--radius-md); transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }
.app-sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; width: var(--sidebar-width); display: flex; flex-direction: column; border-right: 1px solid var(--color-border); background: var(--color-surface-subtle); padding: 24px 12px 20px; }
.app-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 24px; }
.app-brand-mark { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 7px; color: white; background: var(--color-text); font-size: 20px; font-weight: 700; }
.app-brand strong { display: block; font-size: 15px; line-height: 20px; letter-spacing: -.02em; }
.app-brand div > span { display: block; font-size: 11px; color: var(--color-text-muted); }
.app-workspace { display: flex; align-items: center; gap: 8px; margin: 0 2px 24px; padding: 10px 8px; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); }
.app-workspace-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: var(--radius-sm); background: var(--color-neutral-subtle); color: var(--color-text-secondary); font-size: 10px; font-weight: 650; }
.app-workspace strong, .app-workspace small { display: block; font-size: 12px; }
.app-workspace strong { font-weight: 600; }
.app-workspace small { color: var(--color-text-muted); font-size: 11px; }
.app-nav-label { padding: 0 12px 8px; font-size: var(--text-xs); color: var(--color-text-muted); }
.app-sidebar .view-tabs { display: flex; flex-direction: column; gap: 4px; padding: 0; margin: 0; background: transparent; border-radius: 0; }
.app-sidebar .view-tab { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 8px 12px; border-radius: var(--radius-md); color: var(--color-text-secondary); font-size: var(--text-sm); font-weight: 500; text-align: left; transition: background var(--duration-fast), color var(--duration-fast); }
.app-sidebar .view-tab:hover { background: var(--color-surface-hover); }
.app-sidebar .view-tab.active { background: var(--color-accent-subtle); color: var(--color-accent); font-weight: 600; box-shadow: none; }
.app-sidebar-foot { margin-top: auto; padding: 16px 8px 0; border-top: 1px solid var(--color-border); }
.app-sidebar-foot > * { display: block; font-size: 11px; color: var(--color-text-muted); }
.app-sidebar-foot strong { font-size: 10px; font-weight: 550; color: var(--color-text-secondary); margin: 6px 0; }
.app-topbar { min-height: 56px; margin-left: var(--sidebar-width); padding: 0 28px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--color-surface); border-bottom: 1px solid var(--color-border); }
.app-breadcrumb { display: flex; align-items: center; gap: 12px; font-size: var(--text-xs); color: var(--color-text-muted); }
.app-breadcrumb strong { font-weight: 550; color: var(--color-text); }
.app-topbar-note { color: var(--color-text-muted); font-size: var(--text-xs); }
.app-context { display: none; }
body:has(.view-tab[data-view="erp"].active) .app-context-erp,
body:has(.view-tab[data-view="inventory"].active) .app-context-inventory,
body:has(.view-tab[data-view="uploaded"].active) .app-context-uploaded,
body:has(.view-tab[data-view="time"].active) .app-context-time { display: inline; }
.erp-app main { max-width: 1600px; margin: 0 0 0 var(--sidebar-width); padding: 24px 28px 40px; min-height: calc(100dvh - 102px); }
.erp-app > footer { margin-left: var(--sidebar-width); padding: 14px 28px; text-align: left; color: var(--color-text-muted); font-size: var(--text-xs); }
.workspace-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 0 0 20px; }
.workspace-heading h1 { margin: 0 0 4px; font-size: var(--text-xl); line-height: 1.35; font-weight: 650; letter-spacing: -.025em; }
.workspace-heading p { margin: 0; color: var(--color-text-secondary); font-size: var(--text-sm); }
.workspace-heading-note { font-size: var(--text-xs); color: var(--color-text-muted); }
#erpListPanel { margin-top: 0; }
#erpListPanel .zy-toolbar { gap: 8px; padding: 14px 16px; }
#erpListPanel .zy-toolbar input, #erpListPanel .erp-cascader-field { min-height: var(--control-height); font-size: var(--text-xs); }
#erpListPanel .zy-card-code { color: var(--color-text); font-size: 13px; font-weight: 650; }
#erpListPanel .zy-card-title { font-size: var(--text-xs); }
#erpListPanel .zy-card-foot { font-size: 11px; color: var(--color-text-muted); }
#erpListPanel .zy-card:hover { box-shadow: var(--shadow-sm); }
#erpListPanel .zy-lib-switch { border-color: var(--color-border); border-radius: var(--radius-md); }
#erpListPanel .zy-lib-btn { min-height: var(--control-height); color: var(--color-text-secondary); }
#erpListPanel .zy-lib-btn.active { color: var(--color-accent); background: var(--color-accent-subtle); }
#erpListPanel .zy-lib-btn + .zy-lib-btn { border-left-color: var(--color-border); }

/* Product detail: opaque editor, anchored actions and one scrolling canvas. */
.erp-app .modal-backdrop { background: rgb(22 30 44 / 34%); }
.erp-app .modal-card { border-radius: var(--radius-overlay); box-shadow: var(--shadow-overlay); }
#erpProductModal { padding: 24px; align-items: center; overflow: hidden; }
#erpProductModal .erp-product-modal-card { display: flex; flex-direction: column; width: 100%; max-width: 1400px; height: calc(100dvh - 48px); max-height: 1120px; padding: 0; overflow: hidden; border: 1px solid var(--color-border); }
#erpProductModal .erp-detail-head { align-items: flex-start; margin: 0; padding: 20px 24px 16px; border-bottom: 1px solid var(--color-border); flex: none; }
.detail-identity { min-width: 0; }
.detail-breadcrumb { font-size: var(--text-xs); color: var(--color-text-muted); margin-bottom: 8px; }
.detail-breadcrumb > span { padding: 0 6px; color: var(--color-text-muted); }
#erpProductModal h2 { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 0; font-size: var(--text-lg); font-weight: 650; line-height: 1.4; letter-spacing: -.02em; }
#erpDetailTitle { overflow-wrap: anywhere; }
.detail-code { border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 2px 6px; color: var(--color-text-secondary); font: 500 var(--text-xs)/1.5 var(--font-mono); letter-spacing: 0; }
#erpProductModal .zy-detail-sku { margin-top: 6px; color: var(--color-text-muted); font-size: var(--text-xs); }
#erpProductModal .zy-detail-sku code { margin-left: 4px; font-weight: 400; color: var(--color-text-secondary); }
.detail-actionbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; padding: 12px 24px; flex: none; }
.detail-actionbar > .site-note { padding: 0; margin: 0; color: var(--color-text-secondary); font-size: var(--text-xs); }
.detail-actionbar > .site-note:empty { display: none; }
.detail-actionbar .zy-detail-actions { margin-left: auto; gap: 8px; }
.detail-status-label { color: var(--color-text-secondary); font-size: var(--text-xs); }
.detail-actionbar:has(#erpField_status.hidden) .detail-status-label { display: none; }
#erpField_status { min-height: var(--control-height); padding: 6px 8px; border-color: var(--color-border-control); border-radius: var(--radius-md); font-size: var(--text-xs); }
.detail-scope { background: var(--color-surface-subtle); border-block: 1px solid var(--color-border); padding: 8px 24px; font-size: var(--text-xs); color: var(--color-text-secondary); flex: none; }
#erpProductModal #erpPromotionNote { padding: 8px 24px; margin: 0; background: var(--color-warning-subtle); color: var(--color-warning); }
#erpProductModal #erpPromotionNote.zy-promotion-ready { background: var(--color-success-subtle); color: var(--color-success); }
#erpProductModal .erp-ai-result { max-height: 120px; overflow: auto; margin: 0; padding: 8px 24px; }
#erpProductModal .zy-modal-body { flex: 1 1 auto; min-height: 0; max-height: none; overflow: auto; overscroll-behavior: contain; scroll-padding: 16px; padding: 24px; }
.detail-overview { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 24px; align-items: start; }
.detail-side-column, .detail-main-column { min-width: 0; }
.detail-side-column { border: 1px solid var(--color-border); border-radius: var(--radius-lg); overflow: hidden; }
#erpProductModal .zy-section { padding: 20px 0; border-bottom: 1px solid var(--color-border); }
#erpProductModal .detail-side-column .zy-section { padding: 16px; }
#erpProductModal .detail-main-column .zy-section:first-child { padding-top: 0; }
#erpProductModal .zy-section-title { display: flex; flex-direction: column; gap: 4px; margin: 0 0 16px; }
#erpProductModal .zy-section-title h3 { margin: 0; font-size: var(--text-md); font-weight: 650; line-height: 1.5; }
#erpProductModal .zy-section-title small { margin: 0; font-size: var(--text-xs); color: var(--color-text-muted); font-weight: 400; line-height: 1.6; }
#erpProductModal .site-note { color: var(--color-text-muted); font-size: var(--text-xs); line-height: 1.6; }
#erpProductModal .zy-gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; max-width: none; }
#erpProductModal .zy-gallery-cell:first-child { grid-column: 1 / -1; aspect-ratio: 4 / 3; }
#erpProductModal .zy-gallery-cell img { object-fit: contain; background: var(--color-surface); }
#erpProductModal .zy-gallery-cell, #erpProductModal .zy-gallery-add { border-radius: var(--radius-md); }
#erpProductModal .zy-gallery-main { background: var(--color-text); font-size: var(--text-xs); }
#erpProductModal .zy-gallery-x { width: 26px; height: 26px; font-size: 16px; }
#erpProductModal .zy-gallery-setmain { padding: 6px 0; background: var(--color-accent); font-size: var(--text-xs); }
#erpProductModal .zy-gallery-cell:focus-within .zy-gallery-x, #erpProductModal .zy-gallery-cell:focus-within .zy-gallery-setmain { opacity: 1; }
#erpProductModal .zy-gallery-add { color: var(--color-accent); background: var(--color-surface-subtle); font-size: 24px; }
#erpProductModal .zy-fieldset { border: 0; border-radius: 0; margin: 0 0 16px; padding: 0; min-width: 0; }
#erpProductModal .zy-fieldset:last-child { margin-bottom: 0; }
#erpProductModal .zy-fieldset legend { color: var(--color-text-secondary); padding: 0; margin: 0 0 8px; font-size: var(--text-xs); font-weight: 600; }
#erpProductModal .zy-fields { grid-template-columns: minmax(0, 1fr); gap: 12px; }
#erpProductModal .zy-field { display: flex; flex-direction: column; align-items: stretch; gap: 6px; min-width: 0; }
#erpProductModal .zy-field > label { display: block; text-align: left; color: var(--color-text-secondary); font-size: var(--text-xs); font-weight: 550; line-height: 18px; }
#erpProductModal :where(input:not([type="checkbox"]), select, textarea) { min-height: var(--control-height); padding: 6px 10px; border: 1px solid var(--color-border-control); border-radius: var(--radius-md); background: var(--color-surface); color: var(--color-text); font: var(--text-sm)/1.5 var(--font-sans); min-width: 0; }
#erpProductModal input::placeholder, #erpProductModal textarea::placeholder { color: var(--color-text-muted); }
#erpProductModal :where(input, select, textarea):disabled { color: var(--color-text-muted); background: var(--color-neutral-subtle); }
#erpProductModal .zy-source-row { gap: 6px; }
#erpProductModal .zy-source-row .zy-btn { padding-inline: 8px; }
#erpProductModal .zy-cbt-row { padding: 12px; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface-subtle); align-items: center; }
#erpProductModal .zy-cbt-current { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
#erpProductModal .zy-cbt-current .site-note { padding: 0; margin: 0; overflow-wrap: anywhere; }
#erpProductModal #erpCbtZhPath { color: var(--color-text-secondary); margin-top: 8px; }
#erpProductModal #erpCbtStatus:empty { display: none; }
#erpProductModal #erpAttrMeta { margin: -4px 0 16px; }
#erpProductModal #erpAttrMeta.erp-status-error { padding: 10px 12px; color: var(--color-danger); background: var(--color-danger-subtle); border: 1px solid #e8b9bb; border-radius: var(--radius-md); }
#erpProductModal .zy-attr-group { margin-top: 16px; padding: 12px 16px 16px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); }
#erpProductModal .zy-attr-group:first-child { margin-top: 0; }
#erpProductModal .zy-attr-group legend { color: var(--color-text-secondary); font-size: var(--text-xs); font-weight: 600; }
#erpProductModal .zy-attr-group legend small { color: var(--color-text-muted); font-size: var(--text-xs); font-weight: 400; }
#erpProductModal .zy-attr-group-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
#erpProductModal .zy-attr-code { display: inline; margin-left: 6px; color: var(--color-text-muted); font-size: 11px; font-weight: 400; overflow-wrap: anywhere; }
#erpProductModal .zy-cond { color: var(--color-warning); background: var(--color-warning-subtle); border: 0; font-size: 11px; }
#erpProductModal .zy-req { color: var(--color-danger); float: none; }
#erpProductModal .zy-attr-quantity { display: flex; min-width: 0; }
#erpProductModal .zy-attr-quantity input { min-width: 0; flex: 1; }
#erpProductModal .zy-attr-quantity select { max-width: 130px; }
#erpProductModal .zy-package-line { display: grid; grid-template-columns: minmax(0, .6fr) minmax(0, .6fr) minmax(0, 1.4fr); gap: 16px; grid-column: 1 / -1; }
#erpProductModal .zy-package-field { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
#erpProductModal .zy-package-field label { text-align: left; font-size: var(--text-xs); color: var(--color-text-secondary); }
#erpProductModal .zy-package-control { gap: 6px; }
#erpProductModal .zy-package-measure { flex: 1 1 56px; width: auto; min-width: 44px; }
#erpProductModal .zy-package-measure input { height: var(--control-height); padding: 6px 8px; text-align: right; }
#erpProductModal #erpVolumetricWeight { background: var(--color-surface-subtle); }
#erpProductModal .zy-package-weight-control .zy-package-measure { flex: 0 1 120px; width: 120px; min-width: 70px; }
#erpProductModal .zy-package-unit, #erpProductModal .zy-package-times { color: var(--color-text-secondary); font-size: var(--text-xs); }
#erpProductModal .zy-attr-missing { outline: 2px solid var(--color-danger); outline-offset: 2px; border-radius: var(--radius-md); }
#erpProductModal .zy-axis-list { padding: 12px; margin: 0 0 16px; gap: 8px; background: var(--color-surface-subtle); border: 1px solid var(--color-border); border-radius: var(--radius-md); }
#erpProductModal .zy-axis-row { gap: 8px; }
#erpProductModal .zy-axis-name { min-width: 72px; font-size: var(--text-xs); }
#erpProductModal .zy-axis-name small { color: var(--color-text-muted); font-size: 11px; }
#erpProductModal .zy-axis-values { min-width: 180px; }
#erpProductModal .table-wrap { border: 1px solid var(--color-border); border-radius: var(--radius-md); overflow: auto; }
#erpProductModal th { white-space: nowrap; }
#erpProductModal td { color: var(--color-text); padding: 10px 12px; vertical-align: middle; }
#erpProductModal #erpVariantRows td:has(input[type="number"]), #erpProductModal #erpVariantHead th:nth-last-child(n+2):nth-last-child(-n+4) { text-align: right; }
#erpProductModal input[type="number"] { font-variant-numeric: tabular-nums; }
#erpProductModal .zy-var-num { text-align: right; width: 84px; max-width: 84px; }
#erpProductModal .zy-var-num-sm { width: 70px; max-width: 70px; }
#erpProductModal input[data-variant-name] { min-width: 170px; }
#erpProductModal button[data-variant-remove], #erpProductModal button[data-axis-remove] { color: var(--color-danger); }
#erpProductModal .zy-variant-gallery { min-width: 96px; max-width: 200px; }
#erpProductModal .zy-variant-gallery img { width: 40px; height: 40px; object-fit: contain; border-color: var(--color-border); }
#erpProductModal .zy-variant-spec { font-size: var(--text-xs); }
#erpProductModal .zy-variant-spec small { color: var(--color-text-muted); }
#erpProductModal #erpListingRows td:nth-child(5), #erpProductModal #erpListingRows td:nth-child(6), #erpProductModal #erpListingRows td:nth-child(7) { text-align: right; white-space: nowrap; }
#erpProductModal .zy-modal-body > .zy-section:last-child th:nth-child(n+5):nth-child(-n+7) { text-align: right; }
#erpProductModal #erpListingRows td:nth-child(2), #erpProductModal #erpListingRows td:nth-child(3) { min-width: 180px; }
#erpProductModal .zy-tabs, #erpProductModal .site-tabs { display: flex; gap: 16px; flex-wrap: nowrap; overflow-x: auto; border-bottom: 1px solid var(--color-border); padding: 0; margin: 0 0 16px; }
#erpProductModal .zy-tab, #erpProductModal .site-tab { border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 10px 2px; background: transparent; color: var(--color-text-secondary); font: 500 var(--text-xs)/1.5 var(--font-sans); white-space: nowrap; box-shadow: none; }
#erpProductModal .zy-tab.active, #erpProductModal .site-tab.active { color: var(--color-accent); border-bottom-color: var(--color-accent); font-weight: 600; }
#erpProductModal .zy-lang-edit { padding: 0; border: 0; gap: 16px; }
#erpProductModal .zy-lang-row { grid-template-columns: 64px minmax(0, 1fr) auto; gap: 12px; }
#erpProductModal .zy-lang-row > label { color: var(--color-text-secondary); font-size: var(--text-xs); }
#erpProductModal .zy-lang-row textarea { min-height: 128px; line-height: 1.7; }
.detail-help { font-size: var(--text-xs); color: var(--color-text-secondary); padding: 12px 0; border-bottom: 1px solid var(--color-border); }
.detail-help summary { cursor: pointer; min-height: 24px; }
.detail-help p { margin: 12px 0 0; max-width: 96ch; line-height: 1.8; }
#erpProductModal .radar-actions { margin-top: 12px; }
#erpProductModal a { color: var(--color-accent); }
.detail-listing-status[data-status="active"] { color: var(--color-success); background: var(--color-success-subtle); }
.detail-listing-status[data-status="under_review"], .detail-listing-status[data-status="payment_required"] { color: var(--color-warning); background: var(--color-warning-subtle); }
.detail-listing-status[data-status="forbidden"] { color: var(--color-danger); background: var(--color-danger-subtle); }
#erpCbtModal .erp-cbt-modal-card { border: 1px solid var(--color-border); }
#erpCbtModal .modal-head { margin-bottom: 16px; }
#erpCbtModal h3 { font-size: 18px; }
#erpCbtModal :where(input, select) { min-height: var(--control-height); padding: 6px 10px; border: 1px solid var(--color-border-control); border-radius: var(--radius-md); font: var(--text-sm)/1.5 var(--font-sans); color: var(--color-text); background: var(--color-surface); }
#erpCbtModal .zy-cbt-current .site-note { overflow-wrap: anywhere; }

@media (max-width: 1100px) {
  .detail-overview { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .detail-side-column { display: grid; grid-template-columns: 260px minmax(0, 1fr); }
  #erpProductModal .detail-side-column .zy-section:first-child { border-right: 1px solid var(--color-border); border-bottom: 0; }
  #erpProductModal .detail-main-column .zy-section:first-child { padding-top: 16px; }
  .workspace-heading-note { display: none; }
}
@media (max-width: 800px) {
  .app-sidebar { position: relative; inset: auto; width: 100%; padding: 12px 16px 0; border-right: 0; border-bottom: 1px solid var(--color-border); }
  .app-brand { padding: 0 0 12px; }
  .app-brand div { display: flex; align-items: baseline; gap: 8px; }
  .app-workspace, .app-nav-label, .app-sidebar-foot { display: none; }
  .app-sidebar .view-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding-bottom: 8px; }
  .app-sidebar .view-tab { min-height: 44px; justify-content: center; padding: 10px 6px; gap: 6px; font-size: var(--text-xs); }
  .app-topbar { min-height: 44px; margin-left: 0; padding: 0 16px; }
  .erp-app main { margin-left: 0; padding: 20px 16px 32px; }
  .erp-app > footer { margin-left: 0; padding: 16px; }
  .workspace-heading { margin-bottom: 16px; }
  #erpListPanel .zy-toolbar-right { flex-wrap: wrap; min-width: 0; flex-basis: 100%; margin-left: 0; }
  #erpListPanel .uploaded-pager { flex-wrap: wrap; gap: 8px; }
  #erpProductModal { padding: 8px; }
  #erpProductModal .erp-product-modal-card { height: calc(100dvh - 16px); max-height: none; }
  #erpProductModal .erp-detail-head { padding: 16px; flex-direction: row; gap: 8px; }
  #erpProductModal h2 { font-size: 18px; gap: 6px; }
  .detail-breadcrumb { margin-bottom: 4px; }
  .detail-actionbar { padding: 10px 16px; }
  .detail-actionbar .zy-detail-actions { margin: 0; justify-content: flex-start; gap: 8px; width: 100%; }
  .detail-status-label { display: none; }
  .detail-scope { padding: 8px 16px; }
  #erpProductModal .zy-modal-body { padding: 16px; }
  .detail-side-column { grid-template-columns: minmax(0, 1fr); }
  #erpProductModal .detail-side-column .zy-section:first-child { border-right: 0; border-bottom: 1px solid var(--color-border); }
  #erpProductModal .zy-gallery { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #erpProductModal .zy-gallery-cell:first-child { grid-column: auto; aspect-ratio: 1; }
  #erpProductModal .zy-attr-group-grid { grid-template-columns: minmax(0, 1fr); }
  #erpProductModal .zy-package-line { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  #erpProductModal .zy-attr-group { padding: 12px; }
  #erpProductModal .zy-attr-group legend small { display: block; margin: 2px 0 0; }
  #erpProductModal .zy-cbt-row { align-items: flex-start; flex-wrap: wrap; gap: 10px; }
  #erpProductModal .zy-axis-values { min-width: 120px; flex-basis: calc(100% - 90px); }
  #erpProductModal .zy-lang-row { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  #erpProductModal .zy-lang-row .zy-btn { justify-self: start; }
  #erpProductModal .zy-lang-row > label { padding-top: 0; }
  #erpProductModal :where(.zy-btn, select, input:not([type="checkbox"])) { min-height: 40px; }
  #erpProductModal #erpProductSaveButton, #erpProductModal #erpProductModalClose { min-height: 44px; }
  #erpProductModal .zy-package-measure input { height: 40px; }
  #erpProductModal #erpProductSyncButton { font-size: var(--text-xs); padding: 6px 8px; }
  #erpProductModal #erpProductSyncButton .ui-icon { display: none; }
  #erpProductModal #erpProductSaveButton { margin-left: auto; }
}
@media (max-width: 480px) {
  #erpProductModal #erpProductSaveButton { width: 100%; margin-left: 0; }
  #erpProductModal .zy-gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #erpProductModal .zy-gallery-add { grid-column: 1 / -1; min-height: 44px; aspect-ratio: auto; }
  body:has(#erpProductModal:not(.hidden)) #message:not(.hidden) { bottom: 20px; max-width: calc(100vw - 48px); }
}
@media (hover: none), (pointer: coarse) {
  #erpProductModal .zy-gallery-x, #erpProductModal .zy-gallery-setmain { opacity: 1; }
  #erpProductModal .zy-gallery-x { width: 32px; height: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  .erp-app *, .erp-app *::before, .erp-app *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; scroll-behavior: auto !important; }
}

/* Uploaded country workspace uses the existing operating-table tokens. */
.country-context { display:flex; align-items:center; flex-wrap:wrap; gap:12px; }
.country-draft { border:1px solid var(--color-border); border-radius:8px; padding:16px; min-width:0; }
.country-inherit { display:inline-flex; gap:6px; align-items:center; font-size:12px; font-weight:400; margin-left:8px; }
.country-full-text { white-space:pre-wrap; overflow-wrap:anywhere; max-width:640px; }
.country-draft .uploaded-edit-grid { grid-template-columns:minmax(0,1fr) minmax(0,1fr); }
.country-draft input[type=number] { width:120px; }
@media(max-width:800px) { .country-draft .uploaded-edit-grid { grid-template-columns:minmax(0,1fr); } .country-context .zy-btn { min-height:44px; } }

/* No workspace or data-bearing modal is visible before token validation. */
body.erp-app:not([data-auth-state="authenticated"]) > :not(#erpLogin):not(script) { display:none !important; }
.erp-login { min-height:100dvh; display:grid; place-items:center; padding:24px; }
body[data-auth-state="authenticated"] > .erp-login { display:none; }
.erp-login-panel { width:min(100%, 400px); padding:36px; background:var(--color-surface); border:1px solid var(--color-border); border-radius:24px; box-shadow:0 12px 40px rgb(28 44 70 / 7%); }
.erp-login-panel .app-brand { padding:0; margin-bottom:36px; }
.erp-login-panel h1 { margin:0 0 8px; font-size:24px; line-height:32px; font-weight:650; letter-spacing:-.03em; }
.erp-login-panel p { color:var(--color-text-secondary); font-size:13px; line-height:20px; }
.erp-login-panel form { display:grid; gap:12px; margin-top:24px; }
.erp-login-panel label { font-size:13px; font-weight:600; }
.erp-login-panel input, .erp-login-panel button { width:100%; min-height:44px; }
.erp-login-panel input { padding:8px 12px; border:1px solid var(--color-border-control); border-radius:var(--radius-md); font:inherit; }
.erp-login-panel input:focus-visible { outline:2px solid var(--color-accent); outline-offset:2px; }
.erp-touchid { display:grid; gap:12px; margin-top:20px; }
.erp-touchid .erp-touchid-hint { margin:0; text-align:center; }
#erpLoginStatus { min-height:40px; margin:0; }
.erp-session-actions { display:flex; align-items:center; gap:12px; }
@media(max-width:480px) { .erp-login { padding:16px; } .erp-login-panel { padding:24px; } .erp-session-actions .app-topbar-note { display:none; } }

.country-listing-actions { display:flex; flex-wrap:wrap; gap:10px; align-items:center; position:static; }
.country-listing-actions .zy-btn { scroll-margin-block:80px; }
.country-listings .uploaded-site-table { display:table; min-width:1100px; }
.country-draft .uploaded-site-table { display:table; min-width:520px; }
.uploaded-modal-body { scroll-padding-block:80px; }
