:root {
    --ui-border: #cbd5e1;
    --ui-radius: 12px;
    --ui-shadow: 0 3px 12px rgb(20 45 78 / 7%);
    --ui-motion: 160ms ease;
}

html { font-size: 16.5px; }

/* Shared surfaces keep each workspace's existing typography and accent. */
body.admin-workspace { background-color: #f1f4f8; }
body :is(.workspace-main, .main-content) { background-color: #f1f4f8; }
body :is(.panel, .table-scroll) { min-width: 0; }
body :is(.forecast-chart, .report-chart, .chart-container) canvas { max-width: 100%; }
body :is(.panel, .card, .account-create-card, .table-container, .table-wrapper,
    .checkout-card, .checkout-summary, .cart-summary, .library-panel, .template-card,
    .modal-content, .modal-box, .form-section, .report-section) {
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    box-shadow: var(--ui-shadow);
}
body :is(.panel, .account-create-card, .table-container, .table-wrapper,
    .checkout-card, .library-panel, .template-card, .form-section) { background-color: #fff; }
body :is(.workspace-toolbar, .report-filters, .filter-container, .filters) {
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background-color: #f8fafc;
    padding: 14px;
}
body :is(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select, textarea) {
    border-color: #aab8c8;
    max-width: 100%;
}
body :is(button, a, summary, input, select, textarea) {
    transition: color var(--ui-motion), background-color var(--ui-motion), border-color var(--ui-motion), box-shadow var(--ui-motion), transform var(--ui-motion);
}
body :is(button:not(:disabled), a[href], summary) { cursor: pointer; }
body :is(button, .button):not(:disabled):hover { box-shadow: 0 2px 7px rgb(20 45 78 / 16%); }
.field-error { display: block; color: #a62424; font-size: 12px; line-height: 1.5; margin-top: 5px; }
body :is(button, .button, .ui-back):not(:disabled):active { transform: translateY(1px); }
body :is(button, a, summary, input, select, textarea):focus-visible {
    outline: 3px solid #3979c6;
    outline-offset: 3px;
}
/* Links use color, shape and focus outlines rather than text underlines. */
body a, body a:is(:hover, :focus, :active, :visited) { text-decoration: none !important; }
.ui-back, .workspace-main .customer-action {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 40px; padding: 9px 14px; border: 1px solid #aab8c8;
    border-radius: 8px; background: #fff; color: #142d4e;
    font-size: 13px; font-weight: 600; text-decoration: none;
}
.ui-back { margin-bottom: 14px; }
.ui-back:hover, .workspace-main .customer-action:hover { background: #eaf0f7; border-color: #29496b; box-shadow: var(--ui-shadow); }
.customer-action[aria-busy="true"] { cursor: progress; background: #eaf0f7; }
.customer-action[aria-busy="true"]::after { content: '…'; }
body .ui-metrics {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
    grid-auto-rows: 1fr; align-items: stretch; gap: 16px; margin: 20px 0 24px;
}
body .ui-metric {
    --metric-ink: #245b96; --metric-tint: #eaf2fc;
    display: flex; flex-direction: column; gap: 12px; min-width: 0; min-height: 146px; container-type: inline-size;
    padding: 20px; border: 1px solid var(--ui-border); border-top: 3px solid var(--metric-ink);
    border-radius: var(--ui-radius); background: #fff; color: #142d4e; box-shadow: var(--ui-shadow);
}
body .ui-metric--success { --metric-ink: #237443; --metric-tint: #e8f5ed; }
body .ui-metric--warning { --metric-ink: #916000; --metric-tint: #fff3d6; }
body .ui-metric--danger { --metric-ink: #af3030; --metric-tint: #ffeded; }
body .ui-metric--neutral { --metric-ink: #586575; --metric-tint: #edf0f4; }
.ui-metric-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; }
.ui-metric-label { font-size: 13px; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
.ui-metric-icon { flex: 0 0 36px; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px; font-size: 17px; color: var(--metric-ink); background: var(--metric-tint); }
.ui-metric-value { font-size: clamp(22px, 10cqi, 28px); line-height: 1.25; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.ui-metric-hint { margin: auto 0 0; color: #5b6675; font-size: 12px; line-height: 1.5; }
@keyframes ui-appear { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
body :is(.modal-content, .modal-box, .notification-dropdown, details[open] > :not(summary)) { animation: ui-appear 160ms ease; }
@media (max-width: 600px) {
    body .ui-metrics { gap: 12px; }
    body .ui-metric { padding: 16px; }
    body :is(.workspace-heading, .page-header, .checkout-header) { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
@media print { .ui-back { display: none; } body .ui-metric { box-shadow: none; break-inside: avoid; } }

/* Light & Minimal workspace theme shared by dashboards and module pages.
   Sign-in uses the same palette in login-animation.css; receipt paper stays printable. */
.dashboard-theme .access-page-main {
    max-width: 640px;
    margin: 12vh auto;
    padding: 24px;
}

@media screen {
    body.receipt-preview {
        background: #f3f7fc;
        color: #10213d;
    }

    .receipt-preview .print-toolbar button,
    .dashboard-theme.receipt-library :is(button, .button) {
        background: #1683f5;
        color: #fff;
    }
}
.dashboard-theme .customer-dashboard-main {
    max-width: 720px;
    margin: 10vh auto;
    padding: 24px;
}

.dashboard-theme :is(.main, .main-content) {
    min-height: 100vh;
}

.dashboard-theme :is(.card, .large, .notification-dropdown) {
    background: #fff;
    color: #10213d;
    border-color: #dce5f0;
    box-shadow: var(--ui-shadow);
}

.dashboard-theme :is(.page-title h2, .section-title, .topbar .left h2, .card h2, .large h3, .large h4) {
    color: #10213d;
}

.dashboard-theme :is(.page-title p, .note, .subtitle, .ui-metric-hint) {
    color: #64748b;
}

.dashboard-theme :is(.datetime, .user, .user-pill) {
    background: #fff;
    color: #10213d;
    box-shadow: inset 0 0 0 1px #dce5f0, var(--ui-shadow);
}

.dashboard-theme :is(.btn.primary, .btn.info, .actions .btn.success, .actions .btn.warning) {
    background: #1683f5;
    color: #fff;
}

.dashboard-theme :is(.btn.primary, .btn.info, .actions .btn.success, .actions .btn.warning):hover {
    background: #096ed4;
}

.dashboard-theme .btn.danger {
    background: #dc2626;
    color: #fff;
}

.dashboard-theme .btn.danger:hover {
    background: #b91c1c;
}

.dashboard-theme :is(.table th, .main th) {
    background: #f3f7fc;
    color: #64748b;
    border-color: #dce5f0;
}

.dashboard-theme :is(.table td, .main td, .list li) {
    border-color: #dce5f0;
    color: #10213d;
}

body.dashboard-theme {
    --accent: #1683f5;
    --ink: #10213d;
    --muted: #64748b;
    --line: #dce5f0;
    --ui-border: #dce5f0;
    --ui-shadow: 0 3px 12px rgb(20 45 78 / 7%);
    background: #f3f7fc;
    color: var(--ink);
}

/* Shared surfaces and actions; semantic stock/payment/status colors stay local. */
.dashboard-theme :is(.add-btn, .save-btn, .filter-btn, .print-btn, .new-po-btn,
    .blue-btn, .add-item-btn) {
    background: #1683f5;
    border-color: #1683f5;
    color: #fff;
}

.dashboard-theme :is(.add-btn, .save-btn, .filter-btn, .print-btn, .new-po-btn,
    .blue-btn, .add-item-btn):hover {
    background: #096ed4;
    border-color: #096ed4;
    color: #fff;
}

.dashboard-theme :is(.account-create-card, .table-container, .table-wrapper,
    .library-panel, .template-card, .form-section, .report-section) {
    background-color: #fff;
    border-color: var(--line);
    color: var(--ink);
}

.dashboard-theme .workspace-main :is(button, .button):not(.danger):not(.secondary):not(.remove-item) {
    background: #1683f5;
    color: #fff;
}

.dashboard-theme .workspace-main :is(button, .button):not(.danger):not(.secondary):not(.remove-item):hover {
    background: #096ed4;
}

.dashboard-theme .workspace-main .workspace-heading .new-sale-action {
    background: #f4cf55;
    color: #10213d;
}

.dashboard-theme .workspace-main .workspace-heading .new-sale-action:hover {
    background: #edc442;
}

.customer-theme {
    --customer-ink: #10213d;
    --customer-muted: #64748b;
    --customer-line: #dce5f0;
    --customer-accent: #1683f5;
}

.customer-theme .app {
    background: #f3f7fc;
}

.customer-theme .sidebar {
    background: #fff;
    color: #10213d;
    border-right: 1px solid #dce5f0;
}

.customer-theme :is(.brand, .customer-account) {
    border-color: #dce5f0;
}

.customer-theme :is(.brand h2, .customer-details strong, .nav-item) {
    color: #10213d;
}

.customer-theme :is(.brand p, .customer-details small, .sidebar-footer) {
    color: #64748b;
}

.customer-theme .nav-item:hover {
    background: #eaf5ff;
}

.customer-theme .nav-item.active,
.customer-theme .customer-icon {
    background: #dcebff;
    color: #1683f5;
}

.customer-theme .nav-item.active .customer-nav-icon {
    color: #1683f5;
}

.customer-theme .customer-logout {
    background: #ff4d4d;
    border-color: #ff4d4d;
    color: #fff;
}

.customer-theme .customer-logout:hover {
    background: #e53935;
    border-color: #e53935;
}

.customer-theme :is(.add-product, .cart-button, .checkout-button,
    .cart-checkout-button, .place-order-button, .empty-cart button, .slide-cta) {
    background: #1683f5;
    border-color: #1683f5;
    color: #fff;
}

.customer-theme :is(.add-product, .cart-button, .checkout-button,
    .cart-checkout-button, .place-order-button, .empty-cart button, .slide-cta):hover {
    background: #096ed4;
    border-color: #096ed4;
    color: #fff;
}

.customer-theme .order-category.selected {
    background: #dcebff;
    border-color: #dce5f0;
    color: #1683f5;
}

.customer-theme .category-icon {
    background: #dcebff;
    color: #1683f5;
}

.dashboard-theme :is(.workspace-main, .main, .main-content, .customer-dashboard-main) {
    position: relative;
    isolation: isolate;
    background: #f3f7fc;
}

/* Clipped SVG backgrounds cannot intercept clicks or extend the page width. */
.dashboard-theme :is(.workspace-main, .main, .main-content, .customer-dashboard-main)::before,
.dashboard-theme :is(.workspace-main, .main, .main-content, .customer-dashboard-main)::after {
    content: '';
    position: absolute;
    right: 0;
    z-index: -1;
    pointer-events: none;
    width: min(75%, 850px);
    background-repeat: no-repeat;
    background-size: 100% 100%;
}

.dashboard-theme :is(.workspace-main, .main, .main-content, .customer-dashboard-main)::before {
    top: 0;
    height: 230px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 850 230' preserveAspectRatio='none'%3E%3Cpath fill='%23EAF5FF' d='M0 0H850V220C700 155 610 30 450 45S170 170 100 110S80 35 120 0Z'/%3E%3Cpath fill='%23D9EDFF' d='M160 0H850V105C690 90 620 0 470 22S240 135 180 95S130 35 160 0Z'/%3E%3C/svg%3E");
}

.dashboard-theme :is(.workspace-main, .main, .main-content, .customer-dashboard-main)::after {
    bottom: 0;
    height: 440px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 850 440' preserveAspectRatio='none'%3E%3Cpath fill='%23EAF5FF' d='M0 440C130 270 340 330 500 190S700 40 850 35V440Z'/%3E%3Cpath fill='%23D9EDFF' d='M180 440C300 310 480 370 610 235S750 135 850 120V440Z'/%3E%3C/svg%3E");
}

.dashboard-theme .admin-sidebar {
    background: #fff;
    color: var(--ink);
    border-right: 1px solid var(--line);
}

.dashboard-theme .admin-sidebar a,
.dashboard-theme .admin-sidebar .admin-sidebar-name {
    color: var(--ink);
}

.dashboard-theme .admin-sidebar a:hover {
    background: #eaf5ff;
}

.dashboard-theme .admin-sidebar-menu .active a {
    background: #dcebff;
    color: #1683f5;
}

.dashboard-theme .admin-sidebar-brand,
.dashboard-theme .admin-sidebar-logout {
    border-color: var(--line);
}

.dashboard-theme .admin-sidebar-account span {
    color: var(--muted);
}

.dashboard-theme .admin-sidebar-menu {
    scrollbar-color: #b8cde5 #fff;
}

.dashboard-theme .admin-sidebar a:focus-visible,
.dashboard-theme .admin-sidebar-logout button:focus-visible,
.dashboard-theme :is(.workspace-main, .main, .main-content, .customer-dashboard-main) :focus-visible {
    outline-color: #1683f5;
}

.dashboard-theme .workspace-clock {
    background: #fff;
    color: var(--ink);
    box-shadow: inset 0 0 0 1px var(--line), var(--ui-shadow);
}

body.dashboard-theme .ui-metric {
    --metric-ink: #1683f5;
    --metric-tint: #dcebff;
    color: var(--ink);
}

body.dashboard-theme .ui-metric--success {
    --metric-ink: #15803d;
    --metric-tint: #dcf3e3;
}

body.dashboard-theme .ui-metric--warning {
    --metric-ink: #a66b00;
    --metric-tint: #fff1cc;
}

body.dashboard-theme .ui-metric--danger {
    --metric-ink: #b42318;
    --metric-tint: #fdecec;
}

body.dashboard-theme .ui-metric--neutral {
    --metric-ink: #64748b;
    --metric-tint: #f3f7fc;
}

.dashboard-theme :is(.workspace-main, .main, .main-content, .customer-dashboard-main) a:not([class]) {
    color: #1683f5;
}

.dashboard-theme :is(.workspace-main, .main, .main-content, .customer-dashboard-main) .inventory-alert-product {
    color: var(--ink);
    text-decoration-color: var(--line);
}

.dashboard-theme :is(.workspace-main, .main, .main-content, .customer-dashboard-main) a:hover {
    text-decoration-color: currentColor;
}

.dashboard-theme .workspace-heading .new-sale-action {
    background: #f4cf55;
    color: #10213d;
}

.dashboard-theme .workspace-heading .new-sale-action:hover {
    background: #edc442;
}

.dashboard-theme :is(.workspace-main, .main, .main-content, .customer-dashboard-main) .workspace-table th {
    background: #f3f7fc;
    color: var(--muted);
}

.dashboard-theme .workspace-table tbody tr:hover {
    background: #eaf5ff;
}

.dashboard-theme .inventory-alerts-count,
.dashboard-theme .badge:not([class*=" "]) {
    background: #f3f7fc;
    color: var(--ink);
    border-color: var(--line);
}

.dashboard-theme .inventory-alert-quantity {
    color: var(--muted);
}

.dashboard-theme .inventory-alerts-list .inventory-alert-item,
.dashboard-theme .inventory-alerts-footer {
    border-color: var(--line);
}

.dashboard-theme .panel,
.dashboard-theme .simple-list li > span {
    min-width: 0;
    overflow-wrap: anywhere;
}

@media print {
    .dashboard-theme :is(.workspace-main, .main, .main-content, .customer-dashboard-main)::before,
    .dashboard-theme :is(.workspace-main, .main, .main-content, .customer-dashboard-main)::after {
        display: none;
    }
}
