/* EOCQ UI refresh — shared visual system, loaded after legacy critical CSS. */
:root {
    --bg-dark: #07111f;
    --bg-card: #101d2d;
    --bg-input: #16263a;
    --text-primary: #f5f8fc;
    --text-secondary: #9fb0c5;
    --accent-primary: #38bdf8;
    --accent-secondary: #6366f1;
    --accent-success: #34d399;
    --accent-warning: #fbbf24;
    --accent-danger: #fb7185;
    --accent-info: #22d3ee;
    --border-color: rgba(148, 163, 184, .18);
    --shadow: 0 14px 36px rgba(2, 8, 23, .22);
    --shadow-soft: 0 8px 24px rgba(2, 8, 23, .16);
    --surface-hover: rgba(56, 189, 248, .075);
    --focus-ring: 0 0 0 3px rgba(56, 189, 248, .22);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --font-size-xs: .75rem;
    --font-size-sm: .8125rem;
    --font-size-base: .875rem;
    --font-size-md: .9375rem;
    --font-size-lg: 1.05rem;
    --font-size-xl: 1.2rem;
    --font-size-2xl: 1.45rem;
    --font-size-3xl: clamp(1.45rem, 2vw, 1.9rem);
}

html { color-scheme: dark; scroll-behavior: smooth; }
body {
    min-height: 100dvh;
    background:
        radial-gradient(circle at 88% -10%, rgba(56,189,248,.12), transparent 32rem),
        radial-gradient(circle at 45% 110%, rgba(99,102,241,.09), transparent 34rem),
        var(--bg-dark);
    letter-spacing: .005em;
}
body.dialog-open { overflow: hidden !important; }
.toast-warning { background: #b45309; color: #fff; }
.toast-info { background: #0e7490; color: #fff; }
.user-info-dropdown:focus-within .dropdown-menu,
.user-info-dropdown.is-open .dropdown-menu { display: block; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}
::selection { background: rgba(56,189,248,.28); color: #fff; }

.sidebar {
    width: 232px;
    padding: 18px 12px;
    height: 100dvh;
    z-index: 1000;
    background: rgba(10, 23, 39, .9);
    border-right-color: rgba(148,163,184,.14);
    box-shadow: 12px 0 40px rgba(2,8,23,.16);
    backdrop-filter: blur(18px);
}
.logo { gap: 11px; padding: 4px 8px 16px; margin-bottom: 8px; border-bottom: 1px solid var(--border-color); }
.logo-img { width: 34px; height: 34px; border-radius: 10px; filter: drop-shadow(0 5px 10px rgba(56,189,248,.18)); }
.logo h2 { color: var(--text-primary); font-size: .95rem; font-weight: 700; letter-spacing: .02em; }
.nav-links { padding: 8px 0; scrollbar-color: rgba(148,163,184,.3) transparent; }
.nav-links li { margin-bottom: 3px; }
.nav-links a {
    min-height: 40px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: .82rem;
    transition: background-color .18s ease, color .18s ease, transform .18s ease;
}
.nav-links a:hover { background: var(--surface-hover); color: #dff6ff; transform: translateX(2px); }
.nav-links a.active { background: linear-gradient(100deg, rgba(56,189,248,.18), rgba(99,102,241,.1)); color: #7dd3fc; box-shadow: inset 3px 0 var(--accent-primary); }
.sidebar-user-section { border-top-color: var(--border-color); }
.sidebar-user-info { min-height: 42px; border: 1px solid var(--border-color); border-radius: 10px; background: rgba(255,255,255,.025); }
.sidebar-logout-btn { min-height: 40px; border-radius: 10px; }

.main-content { margin-left: 232px; padding: clamp(18px, 2vw, 32px); min-width: 0; }
.header { margin-bottom: 22px; }
.header h1, .table-header h2 { letter-spacing: -.02em; }
.dashboard-stats { grid-template-columns: repeat(auto-fit, minmax(205px, 1fr)); gap: 14px; }
.stat-card, .chart-card, .table-container {
    border-color: var(--border-color);
    border-radius: var(--radius-lg);
    background: linear-gradient(145deg, rgba(18,33,51,.96), rgba(13,26,42,.96));
    box-shadow: var(--shadow-soft);
}
.stat-card { min-height: 104px; padding: 18px; transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease; }
.stat-card:hover { transform: translateY(-3px); border-color: rgba(56,189,248,.3); box-shadow: var(--shadow); }
.stat-icon { font-size: 1.85rem; filter: saturate(.85); }
.stat-info h3 { color: #7dd3fc; font-size: var(--font-size-2xl); letter-spacing: -.03em; }
.chart-card, .table-container { padding: clamp(14px, 1.5vw, 22px); }
.table-header { margin-bottom: 16px; gap: 12px; }
table { border-collapse: separate; border-spacing: 0; }
th { background: rgba(148,163,184,.075); color: #b8c7d9; letter-spacing: .045em; border-bottom-color: rgba(148,163,184,.2); }
th:first-child { border-radius: 9px 0 0 9px; }
th:last-child { border-radius: 0 9px 9px 0; }
td { height: 42px; border-bottom-color: rgba(148,163,184,.1); }
tbody tr { transition: background-color .15s ease; }
tbody tr:hover { background: var(--surface-hover); }

.btn {
    min-height: 38px;
    padding: 8px 14px;
    border-radius: 9px;
    justify-content: center;
    border: 1px solid transparent;
    font-weight: 600;
    transition: transform .16s ease, filter .16s ease, background-color .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.08); }
.btn:active:not(:disabled) { transform: translateY(0) scale(.98); }
.btn-primary { background: linear-gradient(135deg, #0284c7, #4f46e5); box-shadow: 0 5px 14px rgba(14,165,233,.16); }
.btn-success { background: #059669; }
.btn-warning { background: #d97706; color: #fff; }
.btn-danger { background: #e11d48; }
.btn-outline { border-color: rgba(148,163,184,.3); background: rgba(255,255,255,.02); }
.btn-sm { min-height: 32px; padding: 6px 10px; }
.btn:disabled { cursor: not-allowed; opacity: .5; }

.form-group label { margin-bottom: 7px; color: #bdcad9; font-weight: 600; }
.form-control, select, textarea, input[type="text"], input[type="search"], input[type="number"], input[type="date"], input[type="password"], input[type="email"] {
    min-height: 42px;
    border: 1px solid rgba(148,163,184,.24);
    border-radius: 10px;
    background-color: var(--bg-input);
    color: var(--text-primary);
    transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease;
}
.form-control:hover, select:hover, textarea:hover, input:hover { border-color: rgba(148,163,184,.42); }
.form-control:focus, select:focus, textarea:focus, input:focus { outline: none; border-color: var(--accent-primary); box-shadow: var(--focus-ring); }
select, select.form-control, .pagination-select {
    cursor: pointer;
    appearance: none;
    padding-right: 36px !important;
    background-image: linear-gradient(45deg,transparent 50%,#94a3b8 50%),linear-gradient(135deg,#94a3b8 50%,transparent 50%);
    background-position: calc(100% - 16px) 50%,calc(100% - 11px) 50%;
    background-size: 5px 5px,5px 5px;
    background-repeat: no-repeat;
}
option { background: #132237; color: var(--text-primary); }
input[type="checkbox"], input[type="radio"] { min-height: auto; accent-color: var(--accent-primary); }
.filters { align-items: center; gap: 10px; }
.search-box input { max-width: 320px; }

.modal { padding: 20px; background: rgba(2,8,23,.72); backdrop-filter: blur(8px); }
.modal.active { animation: overlayIn .18s ease-out; }
.modal-content {
    width: min(94vw, 620px);
    max-height: min(88dvh, 820px);
    overflow-y: auto;
    border: 1px solid rgba(148,163,184,.2);
    border-radius: 18px;
    background: linear-gradient(155deg, #15263a, #0e1b2b);
    box-shadow: 0 28px 80px rgba(0,0,0,.45);
    animation: modalIn .2s cubic-bezier(.2,.8,.2,1);
}
.modal-header { position: sticky; top: 0; z-index: 2; padding: 18px 20px; background: rgba(18,33,51,.94); backdrop-filter: blur(12px); border-bottom-color: var(--border-color); }
.modal-header h2 { font-size: 1.08rem; }
.modal-close { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px; transition: background-color .16s ease, color .16s ease; }
.modal-close:hover { color: #fff; background: rgba(251,113,133,.15); }
.modal-footer, .modal-actions { gap: 10px; padding-top: 16px; }

.toast { left: auto; right: 20px; bottom: 20px; border: 1px solid rgba(255,255,255,.12); border-radius: 12px; box-shadow: 0 18px 40px rgba(0,0,0,.3); animation: toastIn .25s ease-out; }
.status-badge { border: 1px solid currentColor; border-radius: 999px; font-weight: 600; }
.pagination-container { border-top-color: var(--border-color); }
.pagination-btn, .pagination-page-btn, .pagination-select { min-height: 36px; border-radius: 8px; }

@keyframes overlayIn { from { opacity: 0; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.985); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } }

@media (min-width: 1600px) {
    .main-content { width: calc(100% - 232px); max-width: none; margin-right: 0; }
    .dashboard-stats { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
}

@media (max-width: 1024px) {
    .sidebar { width: 212px; }
    .main-content { margin-left: 212px; padding: 20px; }
    .charts-grid { grid-template-columns: 1fr; }
    .chart-card.full-width { grid-column: auto; }
}

@media (max-width: 768px) {
    body { display: block; padding-top: env(safe-area-inset-top); }
    .sidebar { width: min(86vw, 304px); padding: 72px 14px 18px; transform: translateX(-105%); transition: transform .24s cubic-bezier(.2,.8,.2,1); }
    .sidebar.active { transform: translateX(0); }
    .main-content { margin-left: 0 !important; width: 100%; padding: 72px 14px 24px !important; }
    .mobile-menu-toggle {
        display: grid; place-items: center; position: fixed; left: 14px; top: max(14px, env(safe-area-inset-top));
        width: 44px; height: 44px; border: 1px solid rgba(148,163,184,.22); border-radius: 12px;
        background: rgba(15,29,46,.9); box-shadow: var(--shadow-soft); backdrop-filter: blur(14px); z-index: 1101;
    }
    .mobile-menu-overlay { display: block; position: fixed; inset: 0; z-index: 999; background: rgba(2,8,23,.66); opacity: 0; visibility: hidden; transition: opacity .22s ease, visibility .22s; backdrop-filter: blur(3px); }
    .mobile-menu-overlay.active { opacity: 1; visibility: visible; }
    .dashboard-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat-card { min-height: 94px; padding: 14px; gap: 10px; }
    .table-container { padding: 12px; border-radius: 14px; overflow-x: auto !important; overscroll-behavior-inline: contain; }
    .table-header, .table-actions, .filters, .search-box { width: 100%; }
    .table-actions, .filters { flex-wrap: wrap; }
    .search-box input, .filters .form-control, .filters select { min-width: 0; max-width: none; flex: 1 1 150px; }
    .table-container { scrollbar-width: thin; }
    table { min-width: 680px; }
    th, td { white-space: nowrap; }
    .modal { align-items: flex-end !important; padding: 0 !important; }
    .modal-content { width: 100% !important; max-width: none; max-height: 92dvh !important; margin: 0 !important; border-radius: 20px 20px 0 0 !important; padding-bottom: env(safe-area-inset-bottom); }
    .toast { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); text-align: center; }
    .pagination-container { align-items: stretch; gap: 12px; }
    .pagination-controls { justify-content: center; flex-wrap: wrap; }
}

@media (max-width: 480px) {
    .main-content { padding-left: 10px; padding-right: 10px; }
    .dashboard-stats { gap: 10px; }
    .stat-card { align-items: flex-start; flex-direction: column; }
    .stat-icon { font-size: 1.5rem; }
    .btn { min-height: 42px; }
    .table-actions .btn { flex: 1 1 auto; }
}

@media (max-width: 600px) {
    .form-grid, .modal-content form > [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
}

.scan-next-dialog { position: fixed; z-index: 11000; inset: 0; display: none; place-items: center; padding: 20px; background: rgba(15,23,42,.58); backdrop-filter: blur(6px); }
.scan-next-dialog.active { display: grid; }
.scan-next-card { width: min(92vw, 390px); padding: 26px 22px 20px; border-radius: 20px; background: #fff; text-align: center; box-shadow: 0 28px 70px rgba(15,23,42,.3); }
.scan-next-success { display: grid; place-items: center; width: 50px; height: 50px; margin: 0 auto 13px; border-radius: 50%; background: #e8f7f2; color: #168b72; font-size: 25px; font-weight: 800; }
.scan-next-card h2 { margin: 0 0 7px; color: #1e293b; font-size: 19px; }
.scan-next-card p { margin: 0 0 20px; color: #64748b; font-size: 13px; }
.scan-next-primary { width: 100%; min-height: 58px; border: 0; border-radius: 13px; background: linear-gradient(135deg,#514bc9,#6d5ee8); color: #fff; font-size: 17px; font-weight: 750; box-shadow: 0 9px 22px rgba(81,75,201,.25); cursor: pointer; }
.scan-next-finish { min-width: 96px; min-height: 34px; margin-top: 13px; padding: 6px 16px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; color: #64748b; font-size: 12px; cursor: pointer; }
.scan-next-primary:active, .scan-next-finish:active { transform: scale(.98); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* v6 light business theme */
:root {
    --bg-dark: #f3f6fb;
    --bg-card: #ffffff;
    --bg-input: #f8fafc;
    --text-primary: #172033;
    --text-secondary: #64748b;
    --accent-primary: #4f46e5;
    --accent-secondary: #7c3aed;
    --accent-success: #15803d;
    --accent-warning: #b45309;
    --accent-danger: #dc2626;
    --accent-info: #0369a1;
    --border-color: #dce3ed;
    --shadow: 0 16px 36px rgba(51, 65, 85, .10);
    --shadow-soft: 0 5px 18px rgba(51, 65, 85, .07);
    --surface-hover: #f0f2ff;
    --focus-ring: 0 0 0 3px rgba(79, 70, 229, .16);
}

html { color-scheme: light; }
body {
    color: var(--text-primary);
    background:
        radial-gradient(circle at 92% -5%, rgba(99,102,241,.09), transparent 30rem),
        radial-gradient(circle at 20% 110%, rgba(14,165,233,.06), transparent 34rem),
        var(--bg-dark);
}
.sidebar {
    background: rgba(255,255,255,.94);
    border-right-color: var(--border-color);
    box-shadow: 8px 0 26px rgba(51,65,85,.07);
}
.logo h2 { color: #29304d; }
.logo-img { filter: drop-shadow(0 4px 8px rgba(79,70,229,.14)); }
.nav-links a { color: #59677d; }
.nav-links a:hover { background: #f4f5ff; color: #4338ca; }
.nav-links a.active { background: #eef0ff; color: #4338ca; box-shadow: inset 3px 0 #4f46e5; }
.sidebar-user-info { background: #f8fafc; }
.sidebar-user-name { color: #334155; }
.stat-card, .chart-card, .table-container {
    background: rgba(255,255,255,.96);
    border-color: var(--border-color);
}
.stat-card:hover { border-color: #c7d2fe; }
.stat-info h3 { color: #4338ca; }
th { background: #f5f7fb; color: #536176; border-bottom-color: #dce3ed; }
td { color: #334155; border-bottom-color: #e8edf4; }
tbody tr:hover { background: #f7f8ff; }
.btn-primary { background: linear-gradient(135deg, #4f46e5, #6d5ee8); box-shadow: 0 5px 14px rgba(79,70,229,.16); }
.btn-outline { background: #fff; color: #334155; border-color: #cbd5e1; }
.btn-outline:hover { background: #f8fafc; color: #4338ca; border-color: #a5b4fc; }
.form-group label { color: #475569; }
.form-control, select, textarea, input[type="text"], input[type="search"], input[type="number"], input[type="date"], input[type="password"], input[type="email"] {
    background-color: #fff;
    color: #172033;
    border-color: #cbd5e1;
}
.form-control::placeholder, input::placeholder, textarea::placeholder { color: #94a3b8; }
option { background: #fff; color: #172033; }
.modal { background: rgba(30,41,59,.42); }
.modal-content { background: #fff; color: #172033; border-color: #dce3ed; }
.modal-header { background: rgba(255,255,255,.96); }
.modal-close { color: #64748b; }
.pagination-btn, .pagination-page-btn, .pagination-select { background-color: #fff; color: #475569; border-color: #cbd5e1; }
.pagination-btn.active, .pagination-page-btn.active { background: #4f46e5; color: #fff; border-color: #4f46e5; }
.mobile-menu-toggle { background: rgba(255,255,255,.94); border-color: #dce3ed; }
.table-container { width: 100%; }
.desktop-table { width: 100%; overflow-x: auto; }
.table-action-cell { min-width: 178px; white-space: nowrap; }
.table-action-group {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: 6px;
}
.table-action-group .btn { flex: 0 0 auto; margin: 0 !important; }

/* Dashboard */
.dashboard-stats { grid-template-columns: repeat(5, minmax(150px, 1fr)); }
.dashboard-stats .stat-card { position: relative; overflow: hidden; }
.dashboard-stats .stat-card::after {
    content: "";
    position: absolute;
    right: -28px;
    bottom: -38px;
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: rgba(79,70,229,.055);
}
.charts-grid { align-items: stretch; }
.chart-card { min-width: 0; }
.chart-card-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.chart-card-heading h3 { margin-bottom: 4px; }
.chart-card-heading p { color: var(--text-secondary); font-size: .78rem; }
.chart-legend-summary { min-height: 30px; align-items: center; flex-wrap: wrap; }
.chart-viewport {
    position: relative;
    width: 100%;
    height: clamp(280px, 28vh, 340px);
    min-height: 0;
    overflow: hidden;
}
.chart-viewport-wide { height: clamp(300px, 34vh, 380px); }
.chart-viewport > canvas {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
    max-height: 100%;
}
.chart-expand-btn, .chart-period-switch button {
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #475569;
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: .76rem;
    font-weight: 600;
}
.cost-chart-tools { display: flex; align-items: center; gap: 8px; }
.cost-product-filter { position: relative; z-index: 30; }
.cost-filter-trigger {
    min-width: 128px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 10px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: #475569;
    cursor: pointer;
    font-size: .76rem;
    font-weight: 600;
}
.cost-filter-menu {
    display: none;
    position: absolute;
    top: calc(100% + 7px);
    right: 0;
    width: min(330px, 82vw);
    padding: 10px;
    border: 1px solid #dce3ed;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 18px 48px rgba(51,65,85,.18);
}
.cost-product-filter.open .cost-filter-menu { display: block; }
.cost-filter-menu input[type="search"] { width: 100%; min-height: 38px; padding: 7px 10px; }
.cost-filter-actions { display: flex; gap: 8px; padding: 9px 0; border-bottom: 1px solid #e8edf4; }
.cost-filter-actions button { border: 0; background: #eef0ff; color: #4338ca; border-radius: 7px; padding: 6px 10px; cursor: pointer; font-size: .75rem; font-weight: 600; }
.cost-filter-options { max-height: 300px; overflow-y: auto; padding-top: 6px; scrollbar-width: thin; }
.cost-filter-options label { display: flex; align-items: center; gap: 9px; min-height: 36px; padding: 6px 7px; border-radius: 7px; color: #334155; cursor: pointer; }
.cost-filter-options label:hover { background: #f4f5ff; }
.cost-filter-options label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-expand-btn:hover { color: #4338ca; border-color: #a5b4fc; background: #f5f6ff; }
.chart-period-switch { display: inline-flex; padding: 3px; border-radius: 10px; background: #f1f5f9; }
.chart-period-switch button { border: 0; background: transparent; min-width: 48px; }
.chart-period-switch button.active { color: #fff; background: #4f46e5; box-shadow: 0 3px 8px rgba(79,70,229,.2); }
.chart-interaction-hint { margin-top: 8px; color: #64748b; font-size: .75rem; text-align: center; }
.chart-card:has(#cost-pie-chart) .chart-viewport { height: clamp(390px, 44vh, 520px); }
.cost-chart-dialog {
    width: calc(100vw - 32px) !important;
    max-width: none !important;
    height: calc(100dvh - 32px);
    max-height: none !important;
    display: flex;
    flex-direction: column;
    overflow: hidden !important;
}
.cost-chart-modal-body {
    padding: clamp(12px, 1.5vw, 22px);
    flex: 1;
    min-height: 0;
    overflow: hidden;
}
.cost-modal-header-actions { display: flex; align-items: center; gap: 10px; }
.cost-analysis-layout { height: 100%; min-height: 0; display: grid; grid-template-columns: minmax(360px, 42%) 1fr; gap: clamp(14px, 2vw, 28px); }
.cost-top-panel, .cost-pie-panel { min-width: 0; min-height: 0; border: 1px solid #e2e8f0; border-radius: 14px; background: #fff; }
.cost-top-panel { display: flex; flex-direction: column; padding: 14px 16px; overflow: hidden; }
.cost-top-panel h3 { margin: 0 0 8px; color: #334155; font-size: .9rem; }
.cost-top-list { flex: 1; min-height: 0; display: grid; grid-template-rows: repeat(20, minmax(0, 1fr)); gap: 2px; }
.cost-top-row { min-height: 0; display: flex; align-items: center; gap: 8px; }
.cost-top-row { cursor: pointer; border-radius: 6px; padding: 0 4px; transition: background-color .15s ease, transform .15s ease; }
.cost-top-row:hover { background: #f4f5ff; transform: translateX(2px); }
.cost-top-row.active { background: #eef0ff; box-shadow: inset 3px 0 #6366f1; }
.cost-top-rank { width: 20px; color: #94a3b8; font-size: .68rem; font-weight: 700; text-align: center; }
.cost-top-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; }
.cost-top-main { min-width: 0; flex: 1; }
.cost-top-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; line-height: 1.1; }
.cost-top-meta strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #334155; font-size: .69rem; }
.cost-top-meta span { flex: 0 0 auto; color: #64748b; font-size: .64rem; }
.cost-top-track { height: 4px; margin-top: 3px; overflow: hidden; border-radius: 999px; background: #eef2f7; }
.cost-top-track i { display: block; height: 100%; border-radius: inherit; }
.cost-top-empty { display: grid; place-items: center; height: 100%; color: #94a3b8; }
.cost-pie-panel { display: flex; flex-direction: column; padding: 10px 14px 14px; }
.cost-chart-large { position: relative; width: 100%; flex: 1; min-height: 0; }
.cost-total-summary { flex: 0 0 auto; display: flex; align-items: baseline; justify-content: center; gap: 12px; padding-top: 7px; color: #64748b; }
.cost-total-summary strong { color: #4338ca; font-size: clamp(1.2rem, 2vw, 1.75rem); }
.sales-date-controls {
    display: flex;
    align-items: end;
    flex-wrap: wrap;
    gap: 10px;
    margin: 8px 0 14px;
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #f8fafc;
}
.sales-date-controls[hidden] { display: none !important; }
.sales-date-controls label { display: grid; gap: 4px; color: #64748b; font-size: .72rem; }
.sales-date-controls input { min-height: 34px; padding: 5px 9px; border-radius: 8px; }
.date-control-divider { align-self: center; color: #94a3b8; }
.sales-range-note { align-self: center; color: #64748b; font-size: .75rem; }
.sales-range-note.error { color: #dc2626; font-weight: 600; }

@media (max-width: 768px) {
    .sales-date-controls label { flex: 1 1 135px; }
    .sales-date-controls input { width: 100%; }
    .date-control-divider { display: none; }
}

@media (max-width: 1400px) {
    .dashboard-stats { grid-template-columns: repeat(3, minmax(180px, 1fr)); }
}

@media (max-width: 900px) {
    .dashboard-stats { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
    .chart-viewport, .chart-viewport-wide { height: 300px; }
}

@media (max-width: 480px) {
    .dashboard-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .chart-viewport, .chart-viewport-wide { height: 270px; }
    .chart-legend-summary { gap: 8px 14px !important; justify-content: flex-start !important; }
}

@media (max-width: 768px) {
    .cost-chart-dialog {
        width: 100% !important;
        height: 100dvh;
        max-height: 100dvh !important;
    }
    .cost-chart-modal-body { padding: 9px; }
    .cost-analysis-layout { grid-template-columns: 40% 60%; gap: 8px; }
    .cost-top-panel { padding: 9px; }
    .cost-top-meta { display: block; }
    .cost-top-meta span { display: block; margin-top: 2px; }
    .cost-pie-panel { padding: 7px; }
    .chart-card:has(#cost-pie-chart) .chart-viewport { height: 430px; }
}

/* Login page: no external font and no heavy continuous background animation. */
body:has(.login-container) {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: linear-gradient(145deg, #eef2ff 0%, #f8fafc 48%, #eff6ff 100%);
}
body:has(.login-container)::before { opacity: .45; animation: none; }
.login-card {
    width: min(92vw, 410px) !important;
    min-height: 0 !important;
    padding: 34px 38px 30px !important;
    background: rgba(255,255,255,.95) !important;
    border: 1px solid rgba(203,213,225,.8) !important;
    box-shadow: 0 24px 60px rgba(51,65,85,.13) !important;
}
.login-container { width: 100%; padding: 24px; }
.login-card .logo { margin-bottom: 24px !important; padding: 0 !important; }
.login-card .logo-icon-img { width: 58px !important; height: 58px !important; margin-bottom: 12px !important; }
.login-card .logo h1 { font-size: 1.55rem !important; margin-bottom: 5px !important; }
.login-card .logo p { font-size: .8rem !important; }
.login-card .form-group { margin-bottom: 17px !important; }
.login-card .input-wrapper input { height: 46px !important; padding-left: 44px !important; }
.login-card .btn-login { height: 46px !important; margin-top: 4px !important; border-radius: 10px !important; }
.login-card .mcp-link { margin-top: 20px !important; padding-top: 17px !important; }
.login-card .logo { border-bottom: 0; }
.login-card .logo h1 { color: #1e293b !important; }
.login-card .logo p, .mcp-link a { color: #64748b !important; }
.login-card label { color: #475569 !important; }
.login-card input { background: #fff !important; color: #172033 !important; border-color: #cbd5e1 !important; }
.login-card input:focus { border-color: #4f46e5 !important; box-shadow: var(--focus-ring) !important; }
.btn-login { background: linear-gradient(135deg, #4f46e5, #6d5ee8) !important; box-shadow: 0 8px 20px rgba(79,70,229,.2) !important; }

@media (max-width: 480px) {
    .login-container { padding: 16px; align-items: center; }
    .login-card { width: 100% !important; padding: 28px 22px 24px !important; border-radius: 18px !important; }
    .login-card .logo { margin-bottom: 20px !important; }
    .login-card .logo-icon-img { width: 52px !important; height: 52px !important; }
}

/* Unified business list pages — based on the inbound management layout. */
.business-list-page {
    font-size: 14px !important;
    line-height: 1.45 !important;
}
.business-list-page .main-content {
    width: calc(100% - 232px) !important;
    max-width: none !important;
    min-width: 0 !important;
    padding: clamp(16px, 1.5vw, 24px) !important;
}
.business-list-page .table-container {
    width: 100% !important;
    padding: 16px !important;
    border-radius: 16px !important;
    overflow-x: auto !important;
}
.business-list-page .table-header {
    width: 100% !important;
    display: flex !important;
    align-items: flex-start !important;
    justify-content: space-between !important;
    gap: 12px !important;
    margin-bottom: 16px !important;
}
.business-list-page .filters {
    flex: 1 1 560px !important;
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) !important;
    align-items: center !important;
    gap: 8px !important;
    margin: 0 !important;
}
.business-list-page .filters .form-control,
.business-list-page .filters input,
.business-list-page .filters select,
.business-list-page .search-box input {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 40px !important;
    min-height: 40px !important;
    padding-top: 7px !important;
    padding-bottom: 7px !important;
    font-size: 13px !important;
    border-radius: 9px !important;
}
.business-list-page .table-actions,
.business-list-page .export-import-group {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
}
.business-list-page .btn {
    min-height: 36px !important;
    padding: 7px 12px !important;
    border-radius: 9px !important;
    font-size: 12px !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
}
.business-list-page .btn-sm { min-height: 30px !important; padding: 5px 9px !important; font-size: 11px !important; }
.business-list-page .desktop-table { width: 100% !important; overflow-x: auto !important; }
.business-list-page table { width: 100% !important; font-size: 12px !important; table-layout: auto; }
.business-list-page th {
    height: 38px !important;
    padding: 8px 9px !important;
    font-size: 11px !important;
    line-height: 1.2 !important;
    text-transform: none !important;
    letter-spacing: .02em !important;
}
.business-list-page td {
    height: 44px !important;
    padding: 7px 9px !important;
    font-size: 12px !important;
    line-height: 1.35 !important;
    vertical-align: middle !important;
}
.business-list-page .status-badge,
.business-list-page .source-badge,
.business-list-page [class*="badge"] { font-size: 10px !important; line-height: 1.2 !important; }
.business-list-page .pagination-container { margin-top: 14px !important; padding-top: 14px !important; font-size: 12px !important; }
.business-list-page .pagination-btn,
.business-list-page .pagination-page-btn,
.business-list-page .pagination-select { min-height: 34px !important; font-size: 12px !important; }

@media (min-width: 1600px) {
    .business-list-page .filters { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)) !important; }
    .business-list-page table { font-size: 13px !important; }
    .business-list-page td { font-size: 13px !important; }
}

@media (max-width: 1100px) and (min-width: 769px) {
    .business-list-page .sidebar { width: 212px !important; }
    .business-list-page .main-content { margin-left: 212px !important; width: calc(100% - 212px) !important; padding: 16px !important; }
    .business-list-page .table-header { flex-direction: column !important; }
    .business-list-page .filters, .business-list-page .table-actions { width: 100% !important; }
}

@media (max-width: 768px) {
    .business-list-page .main-content { margin-left: 0 !important; width: 100% !important; padding: 68px 10px 20px !important; }
    .business-list-page .table-container { padding: 10px !important; border-radius: 14px !important; }
    .business-list-page .table-header { flex-direction: column !important; gap: 10px !important; }
    .business-list-page .filters { width: 100% !important; display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)) !important; flex-basis: auto !important; }
    .business-list-page .table-actions, .business-list-page .export-import-group { width: 100% !important; justify-content: stretch !important; }
    .business-list-page .table-actions .btn, .business-list-page .export-import-group .btn { flex: 1 1 auto !important; min-height: 40px !important; }
    .business-list-page .desktop-table { display: none !important; }
    .business-list-page .mobile-cards { display: block !important; padding: 0 !important; }
    .business-list-page .mobile-cards > [class*="-card"] {
        margin-bottom: 10px !important;
        border: 1px solid #dce3ed !important;
        border-radius: 12px !important;
        background: #fff !important;
        box-shadow: 0 4px 14px rgba(51,65,85,.06) !important;
    }
    .business-list-page [class*="-card-header"] { padding: 12px 14px !important; background: #f8fafc !important; }
    .business-list-page [class*="-card-body"] { padding: 12px 14px !important; }
    .business-list-page [class*="-card-row"] { padding: 6px 0 !important; }
    .business-list-page [class*="-card-label"] { font-size: 12px !important; color: #64748b !important; }
    .business-list-page [class*="-card-value"] { font-size: 13px !important; color: #334155 !important; }
    .business-list-page [class*="-card-actions"] { display: flex !important; gap: 7px !important; padding: 10px 14px !important; }
    .business-list-page [class*="-card-actions"] .btn { flex: 1 1 0 !important; min-height: 40px !important; font-size: 12px !important; }
}

@media (max-width: 480px) {
    .business-list-page .filters { grid-template-columns: 1fr !important; }
}

/* Semantic action buttons: consistent size and color across management pages. */
.action-button {
    min-width: 104px !important;
    min-height: 38px !important;
    justify-content: center !important;
    padding: 8px 14px !important;
    border-radius: 9px !important;
    border: 1px solid transparent !important;
    font-size: 12px !important;
    font-weight: 650 !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
    box-shadow: 0 3px 9px rgba(51, 65, 85, .08) !important;
}
.action-button.action-add { background: #5b55df !important; border-color: #5b55df !important; color: #fff !important; }
.action-button.action-import { background: #fff !important; border-color: #38a3a5 !important; color: #197b7d !important; }
.action-button.action-export { background: #168b72 !important; border-color: #168b72 !important; color: #fff !important; }
.action-button.action-download { background: #fff !important; border-color: #64748b !important; color: #475569 !important; }
.action-button.action-danger { background: #e11d48 !important; border-color: #e11d48 !important; color: #fff !important; }
.action-button:hover { transform: translateY(-1px) !important; filter: brightness(.97); box-shadow: 0 6px 14px rgba(51,65,85,.13) !important; }
.action-button:active { transform: translateY(0) !important; }

/* Business identifiers use the same emphasis on every list page. */
.business-list-page td.identifier-value,
.business-list-page td.identifier-value strong,
.business-list-page [class*="-card-order-no"],
.business-list-page [class*="-card-sku"],
.business-list-page .warehouse-card-id {
    color: #334155 !important;
    font-weight: 700 !important;
    font-variant-numeric: tabular-nums;
    letter-spacing: .01em;
}

/* Shared themed confirmation and notification components. */
.app-toast-host { position: fixed; z-index: 10050; top: 20px; right: 20px; display: grid; gap: 10px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.app-toast { display: grid; grid-template-columns: 30px 1fr; align-items: center; gap: 10px; min-height: 58px; padding: 12px 16px; border: 1px solid #e2e8f0; border-left: 4px solid #64748b; border-radius: 12px; background: rgba(255,255,255,.98); color: #334155; box-shadow: 0 16px 34px rgba(51,65,85,.16); opacity: 0; transform: translateY(-8px); transition: opacity .18s ease, transform .18s ease; pointer-events: auto; }
.app-toast.is-visible { opacity: 1; transform: translateY(0); }
.app-toast__icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #eef2ff; color: #4f46e5; font-weight: 800; }
.app-toast--success { border-left-color: #168b72; }.app-toast--success .app-toast__icon { background: #e7f7f2; color: #168b72; }
.app-toast--error { border-left-color: #e11d48; }.app-toast--error .app-toast__icon { background: #fff1f2; color: #e11d48; }
.app-toast--warning { border-left-color: #d97706; }.app-toast--warning .app-toast__icon { background: #fffbeb; color: #d97706; }
.app-toast__message { font-size: 13px; font-weight: 600; line-height: 1.45; }
.app-confirm-modal { z-index: 10040 !important; background: rgba(15,23,42,.48) !important; backdrop-filter: blur(5px); }
.app-confirm-dialog { width: min(92vw, 430px) !important; padding: 28px !important; border: 1px solid #e2e8f0 !important; border-radius: 18px !important; background: #fff !important; color: #334155 !important; text-align: center; box-shadow: 0 26px 70px rgba(15,23,42,.22) !important; }
.app-confirm__icon { display: grid; place-items: center; width: 48px; height: 48px; margin: 0 auto 14px; border-radius: 50%; background: #eef2ff; color: #4f46e5; font-size: 22px; font-weight: 800; }
.app-confirm__icon.is-danger { background: #fff1f2; color: #e11d48; }
.app-confirm-dialog h2 { margin: 0 0 9px !important; color: #1e293b !important; font-size: 18px !important; }
.app-confirm-dialog p { margin: 0; color: #64748b; font-size: 13px; line-height: 1.65; white-space: pre-line; }
.app-confirm-dialog .modal-actions { display: grid !important; grid-template-columns: 1fr 1fr; gap: 10px !important; margin-top: 22px !important; }
.app-confirm-dialog .modal-actions .btn { min-height: 42px !important; justify-content: center; border-radius: 9px !important; }
.app-reason-dialog { width: min(92vw, 480px) !important; text-align: left; }
.app-reason-dialog .app-confirm__icon { margin-inline: auto; }
.app-reason-dialog h2, .app-reason-dialog > p { text-align: center; }
.app-reason-label { display: flex; align-items: center; gap: 7px; margin: 19px 0 7px; color: #334155; font-size: 13px; font-weight: 700; }
.app-reason-label span { padding: 2px 6px; border-radius: 999px; background: #fff1f2; color: #e11d48; font-size: 11px; }
.app-reason-input { width: 100%; min-height: 104px; resize: vertical; line-height: 1.55; }
.app-reason-input[aria-invalid="true"] { border-color: #e11d48 !important; box-shadow: 0 0 0 3px rgba(225,29,72,.12) !important; }
.app-reason-error { min-height: 20px; padding-top: 5px; color: #e11d48; font-size: 12px; }

@media (max-width: 768px) {
    .action-button { flex: 1 1 calc(50% - 4px) !important; min-width: 0 !important; min-height: 42px !important; }
    .app-toast-host { top: auto; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); left: 16px; width: auto; }
}

@media (prefers-reduced-motion: reduce) {
    .app-toast, .action-button { transition: none !important; }
}

/* Mobile smart-scanner camera session. */
@media (max-width: 600px) {
    body.camera-session .sidebar, body.camera-session .scanner-head,
    body.camera-session .scan-note, body.camera-session .scan-input { display: none !important; }
    body.camera-session .main-content { margin: 0 !important; padding: 0 !important; width: 100% !important; }
    body.camera-session .scanner-shell, body.camera-session .scanner-grid { display: block !important; width: 100% !important; max-width: none !important; }
    body.camera-session .scanner-grid > section { position: sticky; z-index: 4; top: 0; padding: 8px !important; border: 0; border-radius: 0; box-shadow: 0 4px 18px rgba(15,23,42,.2); }
    body.camera-session .scanner-grid > section h2 { display: none; }
    body.camera-session .operation-controls { grid-template-columns: 1fr 1fr 1fr; margin: 0; }
    body.camera-session .scan-input-wrap { display: block; margin-top: 7px; }
    body.camera-session .btn-camera { position: absolute; z-index: 3; right: 16px; top: 72px; width: auto; min-height: 38px !important; background: #e11d48 !important; }
    body.camera-session .camera-view { height: 27dvh; min-height: 180px; margin-top: 7px; aspect-ratio: auto; border-radius: 12px; }
    body.camera-session #batch-panel { min-height: 65dvh; padding: 14px; border: 0; border-radius: 0; box-shadow: none; }
    body.camera-session .batch-list { max-height: none; overflow: visible; }
    body.camera-session .batch-footer { position: sticky; bottom: 0; padding: 10px 0 max(10px, env(safe-area-inset-bottom)); background: #fff; }
}
