/* ===============================================
   v3 — Clean Workspace
   Professional dark-first design for daily use.
   No animations on load, no backdrop-filter spam,
   click-based sidebar, WCAG AA contrast.
   =============================================== */

:root {
    --sidebar-width: 252px;
    --sidebar-collapsed-width: 68px;
    --sidebar-bg: #111118;
    --sidebar-hover: rgba(20,184,166,0.08);
    --sidebar-active: rgba(20,184,166,0.12);
    --header-height: 56px;
    --accent: #14b8a6;
    --accent-light: #2dd4bf;
    --accent-dim: #0d9488;
    --accent-glow: rgba(20,184,166,0.25);
    --font-ui: 'Commissioner', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: 0.2s ease;

    /* Dark theme (default) */
    --bg-body: #0c0c12;
    --bg-card: #16161e;
    --bg-card-raised: #1c1c26;
    --bg-header: #111118;
    --bg-table-head: #1a1a24;
    --bg-hover: rgba(20,184,166,0.04);
    --border-color: rgba(255,255,255,0.07);
    --border-light: rgba(255,255,255,0.04);
    --text-primary: #e4e4e7;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --text-heading: #fafafa;
    --input-bg: #1a1a24;
    --code-bg: rgba(20,184,166,0.08);
    --modal-header-bg: #1a1a24;
    --kanban-col-bg: #111118;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.3);
    --card-shadow-hover: 0 4px 16px rgba(0,0,0,0.4);
}

/* Light theme */
[data-theme="light"] {
    --bg-body: #f4f4f5;
    --bg-card: #ffffff;
    --bg-card-raised: #ffffff;
    --bg-header: #ffffff;
    --bg-table-head: #fafafa;
    --bg-hover: rgba(20,184,166,0.04);
    --border-color: #e4e4e7;
    --border-light: #f4f4f5;
    --text-primary: #18181b;
    --text-secondary: #52525b;
    --text-muted: #71717a;
    --text-heading: #09090b;
    --input-bg: #ffffff;
    --code-bg: rgba(20,184,166,0.06);
    --modal-header-bg: #fafafa;
    --kanban-col-bg: #fafafa;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.06);
    --card-shadow-hover: 0 4px 16px rgba(0,0,0,0.1);
    --sidebar-bg: #ffffff;
    --sidebar-hover: rgba(20,184,166,0.06);
    --sidebar-active: rgba(20,184,166,0.1);
}

/* Theme transition — only on toggle, not on load */
html.theme-transition,
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
    transition: background-color 0.4s ease, color 0.3s ease, border-color 0.4s ease, box-shadow 0.3s ease !important;
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== Base ===== */
html { background: var(--bg-body); }

body {
    font-family: var(--font-ui);
    background: var(--bg-body);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    overflow-x: hidden;
}

code, pre { font-family: var(--font-mono); }

/* Scrollbar — subtle */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

::selection { background: rgba(20,184,166,0.2); color: inherit; }

/* ===================================================
   SIDEBAR — Click-based collapse, no hover expand
   =================================================== */
.sidebar, .sidebar.sidebar-auto {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--text-secondary);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    transition: width 0.25s ease;
    overflow: hidden;
}

[data-theme="light"] .sidebar,
[data-theme="light"] .sidebar.sidebar-auto {
    box-shadow: 1px 0 0 var(--border-color);
}

/* Sidebar header */
.sidebar .sidebar-header,
.sidebar.sidebar-auto .sidebar-header {
    padding: 0 20px;
    height: 56px;
    font-size: 15px;
    font-weight: 700;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-heading);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar .sidebar-header i,
.sidebar.sidebar-auto .sidebar-header i {
    font-size: 22px;
    color: var(--accent);
    flex-shrink: 0;
}

.sidebar .sidebar-brand-text,
.sidebar.sidebar-auto .sidebar-brand-text {
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.2s ease, width 0.25s ease;
}

/* Sidebar nav */
.sidebar .sidebar-nav,
.sidebar.sidebar-auto .sidebar-nav {
    list-style: none;
    padding: 8px 0;
    margin: 0;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar .sidebar-nav li a,
.sidebar.sidebar-auto .sidebar-nav li a {
    display: flex;
    align-items: center;
    padding: 9px 20px;
    color: inherit;
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 450;
    transition: background var(--transition), color var(--transition);
    border-radius: var(--radius-sm);
    margin: 1px 8px;
    white-space: nowrap;
    overflow: hidden;
    position: relative;
}

.sidebar .sidebar-nav li a .icon,
.sidebar.sidebar-auto .sidebar-nav li a .icon {
    width: 20px;
    text-align: center;
    font-size: 16px;
    flex-shrink: 0;
    margin-right: 12px;
    opacity: 0.6;
    transition: opacity var(--transition);
}

.sidebar .sidebar-nav li a:hover,
.sidebar.sidebar-auto .sidebar-nav li a:hover {
    background: var(--sidebar-hover);
    color: var(--text-primary);
}

.sidebar .sidebar-nav li a:hover .icon,
.sidebar.sidebar-auto .sidebar-nav li a:hover .icon {
    opacity: 1;
}

.sidebar .sidebar-nav li a.active,
.sidebar.sidebar-auto .sidebar-nav li a.active {
    background: var(--sidebar-active);
    color: var(--accent-light);
    font-weight: 600;
}

.sidebar .sidebar-nav li a.active .icon,
.sidebar.sidebar-auto .sidebar-nav li a.active .icon {
    opacity: 1;
    color: var(--accent);
}

/* Nav section headers */
.nav-section {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    padding: 16px 20px 6px;
    margin: 0;
    border-top: 1px solid var(--border-light);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-nav li:first-child .nav-section,
.sidebar.sidebar-auto .sidebar-nav li:nth-child(2) .nav-section {
    border-top: none;
}

/* Collapse button */
.sidebar-collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 14px 0;
    background: transparent;
    border: none;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    flex-shrink: 0;
    transition: color var(--transition), background var(--transition);
}

.sidebar-collapse-btn:hover {
    color: var(--accent);
    background: var(--sidebar-hover);
}

/* ===== Collapsed state ===== */
.sidebar.collapsed,
.sidebar.sidebar-auto.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .sidebar-header,
.sidebar.sidebar-auto.collapsed .sidebar-header {
    justify-content: center;
    padding: 0;
}

.sidebar.collapsed .sidebar-brand-text,
.sidebar.sidebar-auto.collapsed .sidebar-brand-text {
    opacity: 0;
    width: 0;
}

.sidebar.collapsed .sidebar-nav li a,
.sidebar.sidebar-auto.collapsed .sidebar-nav li a {
    justify-content: center;
    padding: 10px 0;
    margin: 1px 8px;
}

.sidebar.collapsed .sidebar-nav li a .icon,
.sidebar.sidebar-auto.collapsed .sidebar-nav li a .icon {
    margin-right: 0;
    font-size: 18px;
}

.sidebar.collapsed .sidebar-nav li a span:not(.icon),
.sidebar.sidebar-auto.collapsed .sidebar-nav li a span:not(.icon) {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar.collapsed .nav-section,
.sidebar.sidebar-auto.collapsed .nav-section {
    font-size: 0;
    padding: 0;
    height: 1px;
    background: var(--border-light);
    margin: 6px 12px;
    border-top: none;
    overflow: hidden;
}

.sidebar.collapsed .sidebar-collapse-btn i,
.sidebar.sidebar-auto.collapsed .sidebar-collapse-btn i {
    transform: rotate(180deg);
}

/* Tooltips when collapsed */
.sidebar.collapsed .sidebar-nav li a[data-title]::before,
.sidebar.sidebar-auto.collapsed .sidebar-nav li a[data-title]::before {
    content: attr(data-title);
    position: absolute;
    left: calc(var(--sidebar-collapsed-width) + 4px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-card-raised);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    z-index: 1001;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    border: 1px solid var(--border-color);
}

.sidebar.collapsed .sidebar-nav li a[data-title]:hover::before,
.sidebar.sidebar-auto.collapsed .sidebar-nav li a[data-title]:hover::before {
    opacity: 1;
}

/* Pre-collapse sidebar before JS loads (prevents flash) */
html.sidebar-will-collapse .sidebar,
html.sidebar-will-collapse .sidebar.sidebar-auto {
    width: var(--sidebar-collapsed-width);
}
html.sidebar-will-collapse .sidebar .sidebar-brand-text,
html.sidebar-will-collapse .sidebar.sidebar-auto .sidebar-brand-text {
    opacity: 0; width: 0;
}
html.sidebar-will-collapse .sidebar .sidebar-nav li a span:not(.icon),
html.sidebar-will-collapse .sidebar.sidebar-auto .sidebar-nav li a span:not(.icon) {
    opacity: 0; width: 0; overflow: hidden;
}
html.sidebar-will-collapse .sidebar .sidebar-nav li a,
html.sidebar-will-collapse .sidebar.sidebar-auto .sidebar-nav li a {
    justify-content: center; padding: 10px 0;
}
html.sidebar-will-collapse .sidebar .sidebar-nav li a .icon,
html.sidebar-will-collapse .sidebar.sidebar-auto .sidebar-nav li a .icon {
    margin-right: 0;
}
html.sidebar-will-collapse .sidebar .nav-section,
html.sidebar-will-collapse .sidebar.sidebar-auto .nav-section {
    font-size: 0; padding: 0; height: 1px; overflow: hidden; border-top: none;
    background: var(--border-light); margin: 6px 12px;
}
html.sidebar-will-collapse .sidebar .sidebar-header,
html.sidebar-will-collapse .sidebar.sidebar-auto .sidebar-header {
    justify-content: center; padding: 0;
}

/* ===== Main content ===== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.25s ease;
}

body.sidebar-collapsed .main-content,
html.sidebar-will-collapse .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

.top-header {
    background: var(--bg-header);
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-header strong {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-heading);
}

.top-header .user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
}

.page-content {
    padding: 20px 24px 32px;
}

/* ===== Cards ===== */
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 22px;
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
    transition: box-shadow var(--transition), transform var(--transition);
}

.stat-card:hover {
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-1px);
}

.stat-card .stat-value {
    font-size: 30px;
    font-weight: 700;
    color: var(--text-heading);
    letter-spacing: -0.5px;
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ===== Tables ===== */
.table-container {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    box-shadow: var(--card-shadow);
}

.table-toolbar {
    padding: 16px 20px;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border-color);
}

.table-toolbar input[type="search"] {
    min-width: 240px;
    border-radius: var(--radius-md);
}

.data-table {
    width: 100%;
    font-size: 13.5px;
}

.data-table th {
    background: var(--bg-table-head);
    padding: 10px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.data-table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background var(--transition);
}

.data-table tbody tr:hover td {
    background: var(--bg-hover);
}

.data-table .text-danger { color: #f87171; font-weight: 600; }
[data-theme="light"] .data-table .text-danger { color: #ef4444; }

.data-table code {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--code-bg);
    letter-spacing: 0.3px;
    border: 1px solid var(--border-light);
}

/* ===== Status badges ===== */
.badge-draft { background: rgba(251,191,36,0.12); color: #fbbf24; }
.badge-confirmed { background: rgba(34,197,94,0.12); color: #4ade80; }
.badge-cancelled { background: rgba(239,68,68,0.12); color: #f87171; }

[data-theme="light"] .badge-draft { background: #fef3c7; color: #92400e; }
[data-theme="light"] .badge-confirmed { background: #d1fae5; color: #065f46; }
[data-theme="light"] .badge-cancelled { background: #fee2e2; color: #991b1b; }

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

/* ===== Buttons ===== */
.btn {
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 500;
    transition: all var(--transition);
}

.btn-primary {
    --bs-btn-bg: var(--accent);
    --bs-btn-border-color: var(--accent);
    --bs-btn-hover-bg: var(--accent-dim);
    --bs-btn-hover-border-color: var(--accent-dim);
    --bs-btn-active-bg: var(--accent-dim);
    --bs-btn-active-border-color: var(--accent-dim);
    --bs-btn-disabled-bg: var(--accent);
    --bs-btn-disabled-border-color: var(--accent);
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-dim);
    border-color: var(--accent-dim);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-success {
    --bs-btn-bg: #16a34a;
    --bs-btn-border-color: #16a34a;
    --bs-btn-hover-bg: #15803d;
    --bs-btn-hover-border-color: #15803d;
    --bs-btn-active-bg: #15803d;
    --bs-btn-active-border-color: #15803d;
    background: #16a34a;
    border-color: #16a34a;
    color: #fff;
}

.btn-success:hover {
    background: #15803d;
    border-color: #15803d;
    color: #fff;
    transform: translateY(-1px);
}

.btn-danger {
    --bs-btn-bg: #ef4444;
    --bs-btn-border-color: #ef4444;
    --bs-btn-hover-bg: #dc2626;
    --bs-btn-hover-border-color: #dc2626;
    --bs-btn-active-bg: #dc2626;
    --bs-btn-active-border-color: #dc2626;
    --bs-btn-color: #fff;
    --bs-btn-hover-color: #fff;
    --bs-btn-active-color: #fff;
    background: #ef4444;
    border-color: #ef4444;
    color: #fff !important;
}

.btn-danger:hover {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
    transform: translateY(-1px);
}

.btn-info {
    --bs-btn-bg: #0891b2;
    --bs-btn-border-color: #0891b2;
    --bs-btn-hover-bg: #0e7490;
    --bs-btn-hover-border-color: #0e7490;
    --bs-btn-active-bg: #0e7490;
    --bs-btn-active-border-color: #0e7490;
    background: #0891b2;
    border-color: #0891b2;
    color: #fff;
}

.btn-sm { border-radius: var(--radius-sm); font-size: 12.5px; }

.btn-outline-secondary {
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.btn-outline-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--accent);
}

.btn-outline-primary {
    --bs-btn-color: var(--accent-light);
    --bs-btn-border-color: var(--accent);
    --bs-btn-hover-bg: var(--accent);
    --bs-btn-hover-border-color: var(--accent);
    --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: var(--accent);
    --bs-btn-active-border-color: var(--accent);
    --bs-btn-active-color: #fff;
    color: var(--accent-light);
    border-color: var(--accent);
}

.btn-outline-primary:hover,
.btn-outline-primary.active,
.btn-outline-primary:active {
    background: var(--accent) !important;
    border-color: var(--accent) !important;
    color: #fff !important;
}

[data-theme="light"] .btn-outline-primary {
    --bs-btn-color: var(--accent-dim);
    --bs-btn-border-color: var(--accent-dim);
    color: var(--accent-dim);
    border-color: var(--accent-dim);
}

[data-theme="light"] .btn-outline-primary:hover,
[data-theme="light"] .btn-outline-primary.active,
[data-theme="light"] .btn-outline-primary:active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn-outline-danger { color: #f87171; border-color: #f87171; }
.btn-outline-danger:hover { background: #ef4444; border-color: #ef4444; color: #fff; }

/* ===== Forms ===== */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border-color);
    font-size: 14px;
    background: var(--input-bg);
    color: var(--text-primary);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: var(--input-bg);
    color: var(--text-primary);
}

.form-control::placeholder { color: var(--text-muted); }
.form-text { color: var(--text-muted) !important; }
.form-check-input { background-color: var(--input-bg); border-color: var(--border-color); }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }

/* ===== Low stock ===== */
.low-stock-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}
.low-stock-item:last-child { border-bottom: none; }

/* ===== Login page ===== */
.login-bg {
    min-height: 100vh;
    background: var(--bg-body);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container {
    max-width: 420px;
    width: 100%;
    margin: 0 20px;
    padding: 48px 40px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: 0 16px 48px rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
}

[data-theme="light"] .login-container {
    box-shadow: 0 16px 48px rgba(0,0,0,0.08);
}

.login-container h1 {
    text-align: center;
    color: var(--text-heading);
    margin-bottom: 28px;
    font-size: 22px;
    font-weight: 700;
}

.login-container h1 i {
    font-size: 48px;
    display: block;
    margin-bottom: 16px;
    color: var(--accent);
}

.login-container .btn-outline-primary {
    border-radius: var(--radius-md);
    padding: 12px;
    font-size: 15px;
    font-weight: 600;
    border-width: 1px;
}

.login-container .btn-primary.btn-lg {
    border-radius: var(--radius-md);
    padding: 12px;
    font-size: 15px;
    font-weight: 600;
}

/* ===== Modal ===== */
.modal-content {
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}
.modal-header {
    background: var(--modal-header-bg);
    border-bottom-color: var(--border-color);
}
.modal-footer { border-top-color: var(--border-color); }
.btn-close { filter: invert(1) grayscale(100%) brightness(200%); }
[data-theme="light"] .btn-close { filter: none; }

/* ===== Tree view ===== */
.tree-item { padding: 6px 12px; cursor: pointer; border-radius: 6px; }
.tree-item:hover { background: var(--bg-hover); }
.tree-children { margin-left: 24px; }

/* ===== Nav tabs ===== */
.nav-tabs {
    border-bottom: 1px solid var(--border-color);
}
.nav-tabs .nav-link {
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    padding: 10px 16px;
    font-weight: 500;
    font-size: 14px;
    color: var(--text-muted);
    transition: all var(--transition);
    border-radius: 0;
}
.nav-tabs .nav-link:hover {
    color: var(--text-primary);
    border-bottom-color: var(--border-color);
    background: none;
}
.nav-tabs .nav-link.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: none;
    font-weight: 600;
}

/* ===== Mobile ===== */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    padding: 6px;
    color: var(--text-primary);
}

@media (max-width: 768px) {
    .sidebar, .sidebar.sidebar-auto {
        transform: translateX(-100%);
        width: var(--sidebar-width);
        box-shadow: none;
    }
    .sidebar.open, .sidebar.sidebar-auto.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.3);
    }
    /* In mobile, always show full sidebar (not collapsed) */
    .sidebar.collapsed.open, .sidebar.sidebar-auto.collapsed.open {
        width: var(--sidebar-width);
    }
    .sidebar.collapsed.open .sidebar-brand-text,
    .sidebar.sidebar-auto.collapsed.open .sidebar-brand-text {
        opacity: 1; width: auto;
    }
    .sidebar.collapsed.open .sidebar-nav li a,
    .sidebar.sidebar-auto.collapsed.open .sidebar-nav li a {
        justify-content: flex-start; padding: 9px 20px;
    }
    .sidebar.collapsed.open .sidebar-nav li a .icon,
    .sidebar.sidebar-auto.collapsed.open .sidebar-nav li a .icon {
        margin-right: 12px; font-size: 16px;
    }
    .sidebar.collapsed.open .sidebar-nav li a span:not(.icon),
    .sidebar.sidebar-auto.collapsed.open .sidebar-nav li a span:not(.icon) {
        opacity: 1; width: auto;
    }
    .sidebar.collapsed.open .nav-section,
    .sidebar.sidebar-auto.collapsed.open .nav-section {
        font-size: 10px; height: auto; padding: 16px 20px 6px;
        background: transparent; margin: 0;
    }

    .sidebar-toggle { display: block; }
    .sidebar-collapse-btn { display: none; }
    .main-content { margin-left: 0 !important; }
    .table-toolbar { flex-direction: column; }
    .table-toolbar input[type="search"] { min-width: auto; width: 100%; }
    .page-content { padding: 16px; }
    .login-container { margin: 20px; padding: 32px 24px; }
}

/* ===== Kanban board ===== */
.kanban-board {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 12px;
    min-height: 400px;
}

.kanban-column {
    min-width: 260px;
    max-width: 300px;
    flex: 1 0 260px;
    background: var(--kanban-col-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.kanban-column-header {
    padding: 12px 14px;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-card);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.kanban-column-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kanban-column-body {
    padding: 8px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.kanban-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 12px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: box-shadow var(--transition), transform var(--transition);
}

.kanban-card:hover {
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-1px);
}

.kanban-card-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.kanban-empty { text-align: center; color: var(--text-muted); padding: 24px 12px; font-size: 13px; }

/* Priority colors */
.priority-urgent { border-left: 3px solid #ef4444; }
.priority-high { border-left: 3px solid #f59e0b; }
.priority-normal { border-left: 3px solid var(--accent); }
.priority-low { border-left: 3px solid #6b7280; }

/* Stage progress */
.stage-progress { overflow-x: auto; }
.stage-step {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    background: var(--bg-card);
}
.stage-step.active {
    border-color: var(--accent);
    color: var(--accent-light);
    background: rgba(20,184,166,0.08);
    font-weight: 700;
}
.stage-step.done {
    border-color: #22c55e;
    color: #fff;
    background: #16a34a;
}
.stage-arrow { color: var(--text-muted); font-size: 12px; }

/* Timeline */
.timeline { position: relative; padding-left: 24px; }
.timeline::before {
    content: '';
    position: absolute; left: 8px; top: 4px; bottom: 4px; width: 2px;
    background: var(--border-color);
}
.timeline-item { position: relative; padding-bottom: 16px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-marker {
    position: absolute; left: -20px; top: 4px; width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg-body);
}
.timeline-content { padding: 4px 0; }

@media (max-width: 768px) {
    .kanban-board { flex-direction: column; }
    .kanban-column { min-width: auto; max-width: none; }
}

/* Operation labels */
.op-receipt { color: #4ade80; }
.op-expense { color: #f87171; }
.op-production_input { color: #fbbf24; }
.op-production_output { color: var(--accent-light); }
.op-inventory_adjust { color: #a78bfa; }
.op-movement { color: #22d3ee; }

[data-theme="light"] .op-receipt { color: #16a34a; }
[data-theme="light"] .op-expense { color: #dc2626; }
[data-theme="light"] .op-production_input { color: #ea580c; }
[data-theme="light"] .op-production_output { color: var(--accent-dim); }
[data-theme="light"] .op-inventory_adjust { color: #7c3aed; }
[data-theme="light"] .op-movement { color: #0891b2; }

/* ===== Bootstrap overrides ===== */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-primary);
    --bs-table-border-color: var(--border-color);
    --bs-table-striped-bg: var(--bg-hover);
    --bs-table-hover-bg: var(--bg-hover);
}
.table-light {
    --bs-table-bg: var(--bg-table-head);
    --bs-table-color: var(--text-primary);
    --bs-table-border-color: var(--border-color);
}

.dropdown-menu {
    background: var(--bg-card-raised);
    border-color: var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}
.dropdown-item { color: var(--text-primary); }
.dropdown-item:hover { background: var(--bg-hover); color: var(--text-primary); }
[data-theme="light"] .dropdown-menu { box-shadow: 0 8px 24px rgba(0,0,0,0.08); }

.text-muted { color: var(--text-muted) !important; }
.text-dark { color: var(--text-primary) !important; }
.bg-light { background-color: var(--bg-table-head) !important; }
.card {
    background-color: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-md);
}
.list-group-item {
    background-color: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.alert-warning { background: rgba(251,191,36,0.08); border-color: rgba(251,191,36,0.15); color: #fbbf24; }
.alert-danger { background: rgba(239,68,68,0.08); border-color: rgba(239,68,68,0.15); color: #f87171; }
.alert-info { background: rgba(6,182,212,0.08); border-color: rgba(6,182,212,0.15); color: #22d3ee; }

[data-theme="light"] .alert-warning { background: #fffbeb; border-color: #fef3c7; color: #92400e; }
[data-theme="light"] .alert-danger { background: #fef2f2; border-color: #fee2e2; color: #991b1b; }
[data-theme="light"] .alert-info { background: #ecfeff; border-color: #cffafe; color: #155e75; }

/* ===== Theme toggle ===== */
.theme-toggle {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 15px;
    transition: all var(--transition);
}
.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* ===== Product form sections ===== */
.product-form-section {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 16px;
    background: var(--bg-card);
}
.product-form-section-title {
    font-weight: 600; font-size: 15px; color: var(--text-heading);
    margin-bottom: 16px; display: flex; align-items: center; gap: 8px;
}
.product-form-section-title i { color: var(--accent); }

/* ===== Dashboard KPIs (unified) ===== */
.dashboard-kpi, .dash-kpi-card, .dash-kpi {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: box-shadow var(--transition), transform var(--transition);
    box-shadow: var(--card-shadow);
    position: relative;
    overflow: hidden;
}

.dashboard-kpi:hover, .dash-kpi-card:hover, .dash-kpi:hover {
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-1px);
}

.kpi-icon, .dash-kpi-icon {
    width: 46px; height: 46px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; flex-shrink: 0;
}

.dashboard-kpi .kpi-value, .dash-kpi-value {
    font-size: 26px; font-weight: 700; color: var(--text-heading); line-height: 1.2;
}
.dashboard-kpi .kpi-label, .dash-kpi-label {
    font-size: 12px; color: var(--text-muted); margin-top: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.dash-kpi-info, .dash-kpi-body { flex: 1; min-width: 0; }

/* KPI color line at bottom */
.dash-kpi-card::before, .dash-kpi::before {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 2px;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* KPI themes — solid colors, no gradients */
.kpi-icon.kpi-primary, .dash-kpi-blue .dash-kpi-icon { background: rgba(59,130,246,0.1); color: #60a5fa; }
.kpi-icon.kpi-success, .dash-kpi-green .dash-kpi-icon { background: rgba(34,197,94,0.1); color: #4ade80; }
.kpi-icon.kpi-danger, .dash-kpi-red .dash-kpi-icon { background: rgba(239,68,68,0.1); color: #f87171; }
.kpi-icon.kpi-info, .dash-kpi-teal .dash-kpi-icon, .dash-kpi-cyan .dash-kpi-icon { background: rgba(6,182,212,0.1); color: #22d3ee; }
.kpi-icon.kpi-warning, .dash-kpi-orange .dash-kpi-icon { background: rgba(245,158,11,0.1); color: #fbbf24; }
.kpi-icon.kpi-secondary { background: rgba(113,113,122,0.1); color: #a1a1aa; }
.dash-kpi-purple .dash-kpi-icon { background: rgba(139,92,246,0.1); color: #a78bfa; }
.dash-kpi-yellow .dash-kpi-icon { background: rgba(234,179,8,0.1); color: #fde047; }

.dash-kpi-blue::before { background: #3b82f6; }
.dash-kpi-green::before { background: #22c55e; }
.dash-kpi-purple::before { background: #8b5cf6; }
.dash-kpi-red::before { background: #ef4444; }
.dash-kpi-orange::before { background: #f59e0b; }
.dash-kpi-teal::before, .dash-kpi-cyan::before { background: #06b6d4; }
.dash-kpi-yellow::before { background: #eab308; }

[data-theme="light"] .kpi-icon.kpi-primary, [data-theme="light"] .dash-kpi-blue .dash-kpi-icon { background: rgba(59,130,246,0.08); color: #3b82f6; }
[data-theme="light"] .kpi-icon.kpi-success, [data-theme="light"] .dash-kpi-green .dash-kpi-icon { background: rgba(34,197,94,0.08); color: #22c55e; }
[data-theme="light"] .kpi-icon.kpi-danger, [data-theme="light"] .dash-kpi-red .dash-kpi-icon { background: rgba(239,68,68,0.08); color: #ef4444; }
[data-theme="light"] .kpi-icon.kpi-info, [data-theme="light"] .dash-kpi-teal .dash-kpi-icon, [data-theme="light"] .dash-kpi-cyan .dash-kpi-icon { background: rgba(6,182,212,0.08); color: #0891b2; }
[data-theme="light"] .kpi-icon.kpi-warning, [data-theme="light"] .dash-kpi-orange .dash-kpi-icon { background: rgba(245,158,11,0.08); color: #d97706; }
[data-theme="light"] .dash-kpi-purple .dash-kpi-icon { background: rgba(139,92,246,0.08); color: #7c3aed; }
[data-theme="light"] .dash-kpi-yellow .dash-kpi-icon { background: rgba(234,179,8,0.08); color: #ca8a04; }

/* OK icon */
.dash-ok-icon {
    width: 64px; height: 64px; border-radius: 50%;
    background: rgba(34,197,94,0.1); color: #4ade80;
    font-size: 32px; display: inline-flex; align-items: center; justify-content: center;
}

/* Attention list */
.attention-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-light); }
.attention-item:last-child { border-bottom: none; }
.attention-marker { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.attention-marker.marker-danger { background: #ef4444; }
.attention-marker.marker-warning { background: #f59e0b; }
.attention-marker.marker-info { background: var(--accent); }
.attention-item .attention-body { flex: 1; min-width: 0; }
.attention-item .attention-meta { font-size: 12px; }

/* Attention list v2 */
.dash-attention-list { display: flex; flex-direction: column; gap: 4px; max-height: 340px; overflow-y: auto; }
.dash-attention-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 12px;
    border-radius: var(--radius-sm); text-decoration: none; color: inherit;
    transition: background var(--transition); border: 1px solid transparent;
}
.dash-attention-item:hover { background: var(--bg-hover); color: inherit; text-decoration: none; }
.dash-attention-icon {
    width: 34px; height: 34px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0;
}
.dash-attention-danger .dash-attention-icon { background: rgba(239,68,68,0.1); color: #f87171; }
.dash-attention-warning .dash-attention-icon { background: rgba(245,158,11,0.1); color: #fbbf24; }
.dash-attention-info .dash-attention-icon { background: rgba(20,184,166,0.1); color: var(--accent-light); }
.dash-attention-body { flex: 1; min-width: 0; }
.dash-attention-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-attention-meta { font-size: 12px; color: var(--text-muted); }
.dash-attention-arrow { color: var(--text-muted); font-size: 12px; flex-shrink: 0; }

/* Operation badges */
.dash-op-badge { display: inline-block; padding: 2px 10px; border-radius: 6px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.dash-op-receipt { background: rgba(34,197,94,0.1); color: #4ade80; }
.dash-op-expense { background: rgba(239,68,68,0.1); color: #f87171; }
.dash-op-production_input { background: rgba(245,158,11,0.1); color: #fbbf24; }
.dash-op-production_output { background: rgba(20,184,166,0.1); color: var(--accent-light); }
.dash-op-inventory_adjust { background: rgba(167,139,250,0.1); color: #c4b5fd; }
.dash-op-movement { background: rgba(6,182,212,0.1); color: #22d3ee; }
.dash-op-defect { background: rgba(236,72,153,0.1); color: #f472b6; }

@media (max-width: 768px) {
    .dash-kpi-card { padding: 14px; gap: 12px; }
    .dash-kpi-value { font-size: 20px; }
    .dash-kpi-icon { width: 40px; height: 40px; font-size: 16px; }
}

/* ===== Product detail ===== */
.product-hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 16px;
    gap: 16px;
}

.product-hero-main {
    display: flex;
    align-items: center;
    gap: 20px;
    min-width: 0;
}

.product-hero-icon {
    width: 56px; height: 56px; border-radius: 14px;
    background: linear-gradient(135deg, rgba(20,184,166,0.1), rgba(20,184,166,0.05));
    color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; flex-shrink: 0;
}
.product-hero-icon-finished { background: linear-gradient(135deg, rgba(16,185,129,0.1), rgba(16,185,129,0.05)); color: #10b981; }
.product-hero-icon-semifinished { background: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(99,102,241,0.05)); color: #6366f1; }
.product-hero-icon-service { background: linear-gradient(135deg, rgba(245,158,11,0.1), rgba(245,158,11,0.05)); color: #f59e0b; }
.product-hero-icon-danger { background: linear-gradient(135deg, rgba(239,68,68,0.1), rgba(239,68,68,0.05)); color: #ef4444; }

[data-theme="light"] .product-hero-icon-finished { color: #059669; }
[data-theme="light"] .product-hero-icon-semifinished { color: #4f46e5; }
[data-theme="light"] .product-hero-icon-service { color: #d97706; }
[data-theme="light"] .product-hero-icon-danger { color: #dc2626; }

.product-hero-info { min-width: 0; }
.product-hero-name { font-size: 22px; font-weight: 700; margin: 0 0 2px 0; color: var(--text-heading); line-height: 1.3; }
.product-hero-sku { font-size: 14px; color: var(--text-muted); }
.product-hero-sku code {
    font-size: 14px; padding: 2px 8px; border-radius: 4px;
    background: var(--code-bg);
}
.product-hero-badges { display: flex; gap: 6px; margin-bottom: 4px; }
.product-badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.product-badge-component { background: rgba(113,113,122,0.1); color: #a1a1aa; }
.product-badge-finished { background: rgba(34,197,94,0.1); color: #4ade80; }
.product-badge-semifinished { background: rgba(99,102,241,0.1); color: #818cf8; }
.product-badge-service { background: rgba(245,158,11,0.1); color: #fbbf24; }
.product-badge-variations { background: rgba(167,139,250,0.1); color: #c4b5fd; }
[data-theme="light"] .product-badge-component { background: rgba(113,113,122,0.08); color: #71717a; }
[data-theme="light"] .product-badge-finished { background: rgba(16,185,129,0.08); color: #059669; }
[data-theme="light"] .product-badge-semifinished { background: rgba(99,102,241,0.08); color: #4f46e5; }
[data-theme="light"] .product-badge-service { background: rgba(245,158,11,0.08); color: #d97706; }
.product-hero-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* Product KPIs */
.product-kpis { display: flex; gap: 12px; flex-wrap: wrap; margin: 16px 0; }
.product-kpi {
    flex: 1; min-width: 120px; padding: 14px 18px; border-radius: 10px;
    background: var(--bg-card); text-align: center;
    border: 1px solid var(--border-color); transition: box-shadow 0.2s;
}
.product-kpi:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.product-kpi-value { font-size: 22px; font-weight: 700; color: var(--text-heading); line-height: 1.2; }
.product-kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-top: 4px; }
.product-kpi-danger { border-color: rgba(239,68,68,0.3); background: rgba(239,68,68,0.03); }
.product-kpi-danger .product-kpi-value { color: #ef4444; }

/* Product info grid */
.product-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.product-info-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 20px;
}

.product-info-section-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
}

.product-info-section-title i {
    margin-right: 6px;
    font-size: 13px;
}

.product-info-row {
    display: flex;
    justify-content: space-between;
    padding: 7px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
}

.product-info-row:last-child {
    border-bottom: none;
}

.product-info-label {
    color: var(--text-muted);
    font-weight: 500;
}

.product-info-value {
    color: var(--text-primary);
    font-weight: 500;
    text-align: right;
}

@media (max-width: 768px) {
    .product-hero { flex-direction: column; align-items: flex-start; }
    .product-hero-actions { width: 100%; flex-wrap: wrap; }
    .product-kpis { gap: 8px; }
    .product-kpi { min-width: 80px; padding: 10px 12px; }
    .product-kpi-value { font-size: 18px; }
    .product-info-grid { grid-template-columns: 1fr; }
}

/* ===== TomSelect ===== */
.ts-control, .ts-wrapper.single .ts-control {
    background-color: var(--input-bg) !important;
    color: var(--text-primary);
    border-color: var(--border-color);
    border-radius: var(--radius-sm);
}
.ts-dropdown {
    background-color: var(--bg-card-raised) !important;
    border-color: var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}
.ts-dropdown .option { color: var(--text-primary); }
.ts-dropdown .active { background-color: var(--bg-hover) !important; }

[data-theme="light"] .ts-dropdown {
    background-color: #fff !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

/* ===== Toast ===== */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 10000; }
.toast-container .toast {
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-card-raised);
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

/* App toast */
#toast-container {
    position: fixed; bottom: 20px; right: 20px; z-index: 10000;
    display: flex; flex-direction: column-reverse; gap: 8px;
}
.app-toast {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; min-width: 280px; max-width: 440px;
    background: var(--bg-card-raised); border: 1px solid var(--border-color);
    border-radius: var(--radius-md); box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    position: relative; overflow: hidden;
    transform: translateX(120%); transition: transform 0.3s ease;
}
.app-toast.app-toast-in { transform: translateX(0); }
.app-toast.app-toast-out { transform: translateX(120%); }
.app-toast-icon { font-size: 18px; flex-shrink: 0; }
.app-toast-message { flex: 1; font-size: 13px; color: var(--text-primary); }
.app-toast-close {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    font-size: 16px; padding: 0; flex-shrink: 0;
}
.app-toast-close:hover { color: var(--text-primary); }
.app-toast-progress {
    position: absolute; bottom: 0; left: 0; right: 0; height: 2px;
    animation: toastProgress linear forwards;
}
@keyframes toastProgress { from { width: 100%; } to { width: 0; } }

[data-theme="light"] .app-toast { box-shadow: 0 8px 24px rgba(0,0,0,0.08); }

/* Print */
@media print {
    .sidebar, .topbar, .main-header, .sidebar-collapse-btn, .sidebar-toggle { display: none !important; }
    .main-content { margin-left: 0 !important; }
}
