:root {
    --kb-charcoal: #1c1f26;
    --kb-charcoal-light: #262b35;
    --kb-amber: #e8952e;
    --kb-amber-dark: #c97a1a;
    --kb-bg: #f5f6f8;
    --kb-border: #e3e5ea;
    --kb-text-muted: #6b7280;
    --kb-text: #1f2430;
    --kb-card-bg: #ffffff;
    --kb-topbar-bg: #ffffff;
}

[data-theme="dark"] {
    --kb-bg: #14161b;
    --kb-border: #2a2e38;
    --kb-text-muted: #9aa1ad;
    --kb-text: #e7e9ee;
    --kb-card-bg: #1c1f26;
    --kb-topbar-bg: #1c1f26;
}

[data-theme="dark"] .table,
[data-theme="dark"] .table td,
[data-theme="dark"] .table th {
    color: var(--kb-text);
    border-color: var(--kb-border);
}

[data-theme="dark"] .table-card thead th {
    background: #20242d;
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background-color: #20242d;
    border-color: var(--kb-border);
    color: var(--kb-text);
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background-color: #20242d;
    color: var(--kb-text);
}

[data-theme="dark"] .text-muted {
    color: var(--kb-text-muted) !important;
}

[data-theme="dark"] .btn-outline-secondary {
    color: var(--kb-text);
    border-color: var(--kb-border);
}

[data-theme="dark"] .dropdown-menu {
    background-color: var(--kb-card-bg);
    border-color: var(--kb-border);
}

[data-theme="dark"] .dropdown-item {
    color: var(--kb-text);
}

[data-theme="dark"] .dropdown-item:hover {
    background-color: var(--kb-charcoal-light);
    color: #fff;
}

body {
    background: var(--kb-bg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    color: var(--kb-text);
}

/* ---------- Sidebar ---------- */
.sidebar,
.sidebar-offcanvas {
    width: 240px;
    min-height: 100vh;
    background: var(--kb-charcoal);
    color: #cfd3db;
}

.sidebar-offcanvas {
    background: var(--kb-charcoal);
    color: #cfd3db;
}

.sidebar-brand {
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-section-label {
    font-size: .7rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #6b7280;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .55rem .75rem;
    border-radius: .5rem;
    color: #cfd3db;
    font-size: .92rem;
    margin-bottom: 2px;
    transition: background .15s ease, color .15s ease;
}

.sidebar-link i {
    font-size: 1.05rem;
    width: 1.2rem;
    text-align: center;
}

.sidebar-link:hover:not(.disabled) {
    background: var(--kb-charcoal-light);
    color: #fff;
}

.sidebar-link.active {
    background: var(--kb-amber);
    color: #1c1f26;
    font-weight: 600;
}

.sidebar-link.disabled {
    color: #565b66;
    cursor: default;
}

.sidebar-link .badge {
    font-size: .6rem;
    font-weight: 500;
}

/* ---------- Layout ---------- */
.main-content {
    min-height: 100vh;
    width: 0; /* allow flex child to shrink properly */
}

.topbar {
    height: 60px;
    background: var(--kb-topbar-bg);
    border-bottom: 1px solid var(--kb-border);
}

/* ---------- Cards / stats ---------- */
.stat-card {
    background: var(--kb-card-bg);
    border: 1px solid var(--kb-border);
    border-radius: .75rem;
    padding: 1.25rem 1.5rem;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.1;
}

.stat-card .stat-label {
    color: var(--kb-text-muted);
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: .6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    background: rgba(232, 149, 46, .12);
    color: var(--kb-amber-dark);
}

/* ---------- Buttons ---------- */
.btn-amber {
    background: var(--kb-amber);
    border-color: var(--kb-amber);
    color: #1c1f26;
    font-weight: 600;
}

.btn-amber:hover {
    background: var(--kb-amber-dark);
    border-color: var(--kb-amber-dark);
    color: #fff;
}

/* ---------- Tables ---------- */
.table-card {
    background: var(--kb-card-bg);
    border: 1px solid var(--kb-border);
    border-radius: .75rem;
    overflow: hidden;
}

.table-card table {
    margin-bottom: 0;
}

.table-card thead th {
    background: #fafbfc;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--kb-text-muted);
    border-bottom: 1px solid var(--kb-border);
    white-space: nowrap;
}

.table-card td {
    vertical-align: middle;
}

.stock-number {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-weight: 600;
    color: var(--kb-amber-dark);
}
