:root { --erp-canvas: #f7f7f5; --erp-surface: #ffffff; --erp-text: #252525; --erp-muted: #6f6f6f; --erp-border: #ecece8; --erp-primary: #c92b4b; --erp-primary-soft: #fff0f2; --erp-success: #29956a; --erp-shadow: 0 12px 32px rgba(38, 38, 38, 0.06); }

/* Tokens and reset */
* { box-sizing: border-box; }
.app-body { margin: 0; color: var(--erp-text); background: var(--erp-canvas); font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid color-mix(in srgb, var(--erp-primary) 45%, transparent); outline-offset: 2px; }

/* Shell */
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 14px; overflow-y: auto; background: var(--erp-surface); border-right: 1px solid var(--erp-border); }
.main-content { min-width: 0; }
.topbar, .content-wrap { width: min(1440px, 100%); margin: 0 auto; padding-inline: clamp(18px, 3vw, 42px); }
.content-wrap { padding-top: 12px; padding-bottom: 48px; }

/* Navigation and topbar */
.brand-mark { display: block; margin: 0 10px 24px; color: var(--erp-text); font-size: 1.2rem; font-weight: 800; letter-spacing: -0.04em; text-decoration: none; }
.sidebar-nav { display: flex; flex-direction: column; gap: 3px; }
.sidebar .nav-link, .mobile-nav-link { border-radius: 10px; color: var(--erp-muted); font-weight: 650; text-decoration: none; }
.sidebar .nav-link { padding: 9px 10px; }
.sidebar .nav-link:hover, .sidebar .nav-link.active, .mobile-nav-link:hover, .mobile-nav-link.active { color: var(--erp-primary); background: var(--erp-primary-soft); }
.sidebar .nav-link.disabled { color: #b9b9b4; cursor: not-allowed; pointer-events: none; }
.nav-section { margin: 16px 10px 4px; color: var(--erp-muted); font-size: 0.75rem; font-weight: 750; letter-spacing: 0.06em; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 76px; border-bottom: 1px solid var(--erp-border); }
.topbar-kicker { color: var(--erp-muted); font-size: 0.875rem; font-weight: 700; }
.topbar-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.btn-primary { --bs-btn-bg: var(--erp-primary); --bs-btn-border-color: var(--erp-primary); --bs-btn-hover-bg: #b42342; --bs-btn-hover-border-color: #b42342; --bs-btn-active-bg: #a61f3b; --bs-btn-active-border-color: #a61f3b; }
.btn-outline-primary { --bs-btn-color: var(--erp-primary); --bs-btn-border-color: var(--erp-primary); --bs-btn-hover-bg: var(--erp-primary); --bs-btn-hover-border-color: var(--erp-primary); --bs-btn-active-bg: #a61f3b; --bs-btn-active-border-color: #a61f3b; }
.mobile-nav { display: none; }

/* Page primitives */
.surface-card { border: 1px solid var(--erp-border); border-radius: 20px; background: var(--erp-surface); box-shadow: var(--erp-shadow); }
.page-header { display: flex; justify-content: space-between; gap: 20px; align-items: flex-end; margin-bottom: 24px; }
.eyebrow { margin: 0 0 0.35rem; color: var(--erp-primary); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.1em; }
.page-header h1 { margin: 0; font-size: clamp(1.75rem, 3vw, 2.25rem); font-weight: 800; letter-spacing: -0.04em; }
.page-description { max-width: 48rem; margin: 0.45rem 0 0; color: var(--erp-muted); }
.metric-grid { display: grid; gap: 16px; }
.metric-grid + .metric-grid { margin-top: 16px; }
.metric-grid-primary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric-grid-finance { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric-card { min-width: 0; min-height: 132px; padding: 20px; overflow: hidden; }
.replenishment-warning-card { margin-top: 16px; padding: clamp(16px, 3vw, 24px); }
.replenishment-warning-header h2 { margin: 0; font-size: 1.2rem; font-weight: 800; }
.replenishment-warning-list { display: grid; margin-top: 1rem; }
.replenishment-warning-row { display: grid; grid-template-columns: minmax(150px, 1.5fr) repeat(4, minmax(84px, 1fr)) auto; gap: 12px; align-items: center; padding: 14px 0; border-top: 1px solid var(--erp-border); }
.replenishment-product-name { font-weight: 750; }
.replenishment-label { display: block; margin-bottom: 2px; color: var(--erp-muted); font-size: 0.75rem; font-weight: 650; }
.replenishment-warning-empty { margin: 1rem 0 0; }
.metric-card--coral { border-color: #ffd7df; background: #fff5f7; }
.metric-card--mint { border-color: #d1eee1; background: #f2fbf7; }
.metric-card--lavender { border-color: #e4dbff; background: #f8f5ff; }
.metric-card--peach { border-color: #ffdfc9; background: #fff7f1; }
.metric-label { color: var(--erp-muted); font-size: 0.875rem; font-weight: 700; }
.metric-value { margin-top: 0.5rem; overflow-wrap: anywhere; font-size: 1.75rem; font-weight: 800; letter-spacing: -0.03em; }

/* Table, form, and status primitives */
.table-card { overflow: hidden; }
.table-responsive { overflow-x: auto; }
.table-responsive > .table { min-width: 680px; }
.table { --bs-table-bg: transparent; --bs-table-border-color: var(--erp-border); margin-bottom: 0; }
.table > :not(caption) > * > * { padding: 0.875rem 1rem; }
.form-layout { max-width: 760px; padding: clamp(20px, 3vw, 32px); }
.form-grid--two-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-errors { max-width: 760px; margin-bottom: 16px; border-radius: 14px; }
.form-control, .form-select { border-color: var(--erp-border); border-radius: 10px; }
.form-control:focus, .form-select:focus { border-color: var(--erp-primary); box-shadow: 0 0 0 0.25rem rgba(201, 43, 75, 0.18); }
.status-pill { display: inline-flex; align-items: center; min-height: 1.75rem; padding: 0.2rem 0.65rem; border-radius: 999px; font-size: 0.75rem; font-weight: 750; line-height: 1.2; }
.status-pill--draft { color: #8a5a00; background: #fff3cf; }
.status-pill--pending_receipt, .status-pill--pending_shipment { color: #874a08; background: #ffead2; }
.status-pill--completed, .status-pill--paid, .status-pill--success { color: #126847; background: #dff6eb; }
.status-pill--unpaid { color: #b42342; background: var(--erp-primary-soft); }
.status-pill--error { color: #a42525; background: #fde4e4; }
.status-pill--info { color: #315f8d; background: #e8f2ff; }
.order-form-card { overflow: hidden; }
.order-form-card__body { padding: clamp(20px, 3vw, 28px); }
.order-form-actions { padding: 4px 0 16px; }
.order-summary-card, .order-action-card, .order-settlement-card, .order-inventory-card { overflow: hidden; }
.order-summary-card__body, .order-action-card__body, .order-settlement-card__body, .order-inventory-card__body { padding: clamp(20px, 3vw, 28px); }
.order-summary-label { margin-bottom: 0.3rem; color: var(--erp-muted); font-size: 0.8rem; font-weight: 700; }
.order-summary-value { font-weight: 700; }
.order-section-title { margin: 0 0 1rem; font-size: 1rem; font-weight: 800; }

/* Assistant styles */
.assistant-page { max-width: 980px; margin: 0 auto; }
.assistant-chat { min-height: 360px; max-height: 560px; overflow-y: auto; padding: clamp(16px, 3vw, 28px); background: var(--erp-surface); }
.assistant-empty { padding: 1rem; text-align: center; }
.assistant-examples { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.chip { display: inline-flex; align-items: center; min-height: 2.25rem; padding: 0.45rem 0.8rem; border: 1px solid #ffd0d8; border-radius: 999px; color: var(--erp-primary); background: var(--erp-primary-soft); font-size: 0.875rem; font-weight: 650; }
.chip:hover { border-color: var(--erp-primary); background: #ffe1e6; }
.assistant-composer { padding: clamp(16px, 3vw, 24px); }
.assistant-input-row { display: flex; gap: 10px; }
.assistant-input-row .form-control { min-width: 0; }
.assistant-document-upload { margin-top: 14px; }
.assistant-document-upload .form-control { max-width: 520px; }
.assistant-document-disclosure { max-width: 720px; margin: 8px 0 0; color: var(--erp-muted); font-size: 0.82rem; }
.assistant-bubble { max-width: 85%; margin-bottom: 0.75rem; padding: 0.75rem 1rem; border-radius: 0.75rem; white-space: pre-wrap; }
.assistant-bubble-user { margin-left: auto; color: #ffffff; background: var(--erp-primary); }
.assistant-bubble-message, .assistant-bubble-clarification, .assistant-bubble-error { background: #f1f5f9; }
.assistant-bubble-error { color: #991b1b; background: #fef2f2; }
.assistant-preview { max-width: 90%; margin-bottom: 0.75rem; }
.assistant-preview-card { padding: clamp(16px, 2.5vw, 24px); border-color: #ffd0d8; background: #fff8f9; }
.assistant-preview-line { display: flex; justify-content: space-between; gap: 16px; margin-top: 0.65rem; }
.assistant-preview-total { margin-top: 1rem; font-weight: 800; }
.assistant-preview-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 1rem; }
.assistant-replenishment-basis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 16px; margin-top: 1rem; padding: 12px; border: 1px solid #ffd0d8; border-radius: 12px; background: #ffffff; }
.assistant-replenishment-basis > strong { grid-column: 1 / -1; }
.assistant-replenishment-basis-line { color: var(--erp-muted); font-size: 0.875rem; }

@media (max-width: 560px) { .assistant-input-row { align-items: stretch; flex-direction: column; } .assistant-input-row .btn { width: 100%; } .assistant-preview-line { align-items: flex-start; flex-direction: column; gap: 4px; } .assistant-replenishment-basis { grid-template-columns: minmax(0, 1fr); } }

/* Responsive overrides */
@media (max-width: 1100px) { .metric-grid-primary, .metric-grid-finance { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) { .app-shell { grid-template-columns: minmax(0, 1fr); } .sidebar { display: none; } .mobile-nav { display: block; margin: 14px clamp(18px, 3vw, 42px) 0; border: 1px solid var(--erp-border); border-radius: 12px; background: var(--erp-surface); } .mobile-nav summary { padding: 10px 14px; color: var(--erp-text); cursor: pointer; font-weight: 700; } .mobile-nav-panel { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 0 8px 8px; } .mobile-nav-link { padding: 8px 10px; } .topbar { min-height: auto; padding-top: 14px; padding-bottom: 14px; } .page-header { align-items: stretch; flex-direction: column; } }
@media (max-width: 700px) { .replenishment-warning-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } .replenishment-warning-row > :first-child { grid-column: 1 / -1; } }
@media (max-width: 560px) { .mobile-nav-panel, .metric-grid-primary, .metric-grid-finance, .form-grid--two-columns { grid-template-columns: minmax(0, 1fr); } .topbar { align-items: flex-start; flex-direction: column; } .topbar-actions { justify-content: flex-start; } .replenishment-warning-row { grid-template-columns: minmax(0, 1fr); } .replenishment-warning-row > :first-child { grid-column: auto; } }

.inventory-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inventory-stock-value { display: inline-block; min-width: 3rem; font-weight: 800; }
.inventory-empty { margin: 0; padding: 2.5rem 1rem; text-align: center; }
@media (max-width: 560px) {
  .inventory-toolbar { align-items: stretch; flex-direction: column; }
  .inventory-toolbar .btn { width: 100%; }
}
