/* ==========================================================
   Stock Manager — design system on top of Bootstrap 5.3
   Fonts: Plus Jakarta Sans (UI) · JetBrains Mono (codes/numbers)
   ========================================================== */
:root {
    --brand: #4f46e5;
    --brand-600: #4338ca;
    --brand-50: #eef2ff;
    --brand-100: #e0e7ff;
    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #64748b;
    --line: #e7eaf0;
    --surface: #ffffff;
    --canvas: #f5f6fa;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .06);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, .06), 0 10px 24px -6px rgba(15, 23, 42, .10);
    --sidebar-w: 256px;

    --bs-body-font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-body-font-size: .925rem;
    --bs-body-color: var(--ink-2);
    --bs-body-bg: var(--canvas);
    --bs-border-color: var(--line);
    --bs-primary: var(--brand);
    --bs-primary-rgb: 79, 70, 229;
    --bs-link-color: var(--brand);
    --bs-link-color-rgb: 79, 70, 229;
    --bs-link-hover-color: var(--brand-600);
    --bs-border-radius: var(--radius-sm);
    --bs-border-radius-lg: var(--radius);
    --bs-success-rgb: 16, 163, 107;
    --bs-danger-rgb: 225, 29, 72;
    --bs-warning-rgb: 245, 158, 11;
}

body { background: var(--canvas); -webkit-font-smoothing: antialiased; letter-spacing: -.005em; }
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 { color: var(--ink); font-weight: 700; letter-spacing: -.02em; }
.mono, code { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82em; }
.text-muted { color: var(--muted) !important; }
a { text-decoration: none; }

/* ---------- Buttons ---------- */
.btn { --bs-btn-font-weight: 600; --bs-btn-padding-y: .5rem; --bs-btn-padding-x: 1rem; --bs-btn-border-radius: var(--radius-sm);
       --bs-btn-font-size: .875rem; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; transition: all .15s ease; }
.btn-sm { --bs-btn-padding-y: .3rem; --bs-btn-padding-x: .55rem; --bs-btn-font-size: .8rem; --bs-btn-border-radius: 8px; }
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand-600); --bs-btn-hover-border-color: var(--brand-600);
               --bs-btn-active-bg: var(--brand-600); --bs-btn-active-border-color: var(--brand-600); --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand);
               box-shadow: 0 1px 2px rgba(79, 70, 229, .25), inset 0 1px 0 rgba(255,255,255,.12); }
.btn-success { --bs-btn-bg: #10a36b; --bs-btn-border-color: #10a36b; --bs-btn-hover-bg: #0b8a5a; --bs-btn-hover-border-color: #0b8a5a; }
.btn-danger { --bs-btn-bg: #e11d48; --bs-btn-border-color: #e11d48; --bs-btn-hover-bg: #be123c; --bs-btn-hover-border-color: #be123c; }
.btn-light { --bs-btn-bg: #f1f5f9; --bs-btn-border-color: #f1f5f9; --bs-btn-hover-bg: #e2e8f0; --bs-btn-hover-border-color: #e2e8f0; }
.btn-outline-primary { --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand-100); --bs-btn-hover-bg: var(--brand-50);
                       --bs-btn-hover-color: var(--brand-600); --bs-btn-hover-border-color: var(--brand-100); --bs-btn-active-bg: var(--brand-100); --bs-btn-active-color: var(--brand-600); }
.btn-outline-secondary, .btn-outline-dark, .btn-outline-success, .btn-outline-danger {
    --bs-btn-border-color: var(--line); background: #fff; }
.btn-outline-secondary { --bs-btn-color: var(--ink-2); --bs-btn-hover-bg: #f8fafc; --bs-btn-hover-color: var(--ink); --bs-btn-hover-border-color: #cbd5e1; }
.btn-outline-dark { --bs-btn-color: var(--ink-2); --bs-btn-hover-bg: #f8fafc; --bs-btn-hover-color: var(--ink); --bs-btn-hover-border-color: #cbd5e1; }
.btn-outline-success { --bs-btn-color: #0b8a5a; --bs-btn-hover-bg: #ecfdf5; --bs-btn-hover-color: #0b8a5a; --bs-btn-hover-border-color: #a7f3d0; }
.btn-outline-danger { --bs-btn-color: #e11d48; --bs-btn-hover-bg: #fff1f2; --bs-btn-hover-color: #be123c; --bs-btn-hover-border-color: #fecdd3; }

/* Square icon buttons used in table rows */
.btn-icon { width: 32px; height: 32px; padding: 0 !important; }
.btn-icon .bi { font-size: 1rem; }

/* ---------- Forms ---------- */
.form-label { font-weight: 600; font-size: .8rem; color: var(--ink-2); margin-bottom: .35rem; }
.form-control, .form-select { border-color: var(--line); border-radius: var(--radius-sm); padding: .55rem .8rem; font-size: .9rem; color: var(--ink); background-color: #fff; }
.form-control::placeholder { color: #94a3b8; }
.form-control:focus, .form-select:focus { border-color: #a5b4fc; box-shadow: 0 0 0 4px rgba(99, 102, 241, .14); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-check-input:focus { box-shadow: 0 0 0 4px rgba(99, 102, 241, .14); border-color: #a5b4fc; }
.form-text { color: var(--muted); font-size: .78rem; }
.input-icon { position: relative; }
.input-icon > .bi { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: #94a3b8; pointer-events: none; }
.input-icon > .form-control { padding-left: 2.35rem; }
.pw-field { position: relative; }
.pw-field > .form-control { padding-right: 2.75rem; }
.pw-toggle { position: absolute; right: .35rem; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border: 0; border-radius: 8px;
             background: transparent; color: #94a3b8; display: grid; place-items: center; font-size: 1.05rem; transition: color .15s, background .15s; }
.pw-toggle:hover { color: var(--ink-2); background: #f1f5f9; }
.pw-toggle:focus-visible { outline: 0; box-shadow: 0 0 0 3px rgba(99, 102, 241, .25); color: var(--brand); }
.pw-toggle[aria-pressed="true"] { color: var(--brand); }

/* ---------- Layout: sidebar ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); }
@media (min-width: 992px) {
    .sidebar { width: var(--sidebar-w); flex-shrink: 0; position: sticky; top: 0; height: 100vh; }
}
.sidebar .offcanvas-header { padding: 1.25rem 1.25rem 1rem; }
.brand { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.brand-logo { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0;
              background: linear-gradient(135deg, #6366f1, #4338ca); color: #fff; font-size: 1.15rem; box-shadow: 0 6px 14px -4px rgba(79, 70, 229, .5); }
.brand-name { font-weight: 700; color: var(--ink); line-height: 1.2; font-size: .95rem; }
.brand-sub { font-size: .72rem; color: var(--muted); }

.nav-section { font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #94a3b8; padding: 1rem .9rem .4rem; }
.side-nav .nav-link { display: flex; align-items: center; gap: .75rem; color: var(--ink-2); font-weight: 500; font-size: .875rem;
                      padding: .55rem .9rem; border-radius: var(--radius-sm); margin-bottom: 2px; transition: background .15s, color .15s; }
.side-nav .nav-link .bi { font-size: 1.05rem; color: #94a3b8; transition: color .15s; }
.side-nav .nav-link:hover { background: #f5f7fb; color: var(--ink); }
.side-nav .nav-link:hover .bi { color: var(--ink-2); }
.side-nav .nav-link.active { background: var(--brand-50); color: var(--brand-600); font-weight: 600; }
.side-nav .nav-link.active .bi { color: var(--brand); }

.min-w-0 { min-width: 0; }
button.user-card { font: inherit; cursor: pointer; transition: background .15s, border-color .15s; }
button.user-card:hover { background: #f1f5f9; border-color: #dbe1ea; }
.dropdown-menu { border-radius: var(--radius-sm); padding: .35rem; font-size: .875rem; }
.dropdown-item { border-radius: 8px; padding: .5rem .75rem; }
.user-card { display: flex; align-items: center; gap: .7rem; padding: .7rem; border-radius: var(--radius); background: #f8fafc; border: 1px solid var(--line); }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .85rem; flex-shrink: 0;
          background: var(--brand-100); color: var(--brand-600); }
.user-card .name { font-weight: 600; color: var(--ink); font-size: .85rem; line-height: 1.2; }
.user-card .role { font-size: .72rem; color: var(--muted); text-transform: capitalize; }

/* ---------- Layout: main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 1020; background: rgba(245, 246, 250, .85); backdrop-filter: saturate(180%) blur(10px);
          border-bottom: 1px solid transparent; padding: .9rem 1rem; display: flex; align-items: center; gap: .75rem; }
@media (min-width: 768px) { .topbar { padding: 1.25rem 2rem; } }
.topbar h1 { font-size: 1.35rem; margin: 0; }
.topbar .crumb { font-size: .78rem; color: var(--muted); }
.page { padding: .25rem 1rem 2rem; }
@media (min-width: 768px) { .page { padding: .25rem 2rem 2.5rem; } }
.menu-btn { width: 40px; height: 40px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: #fff; color: var(--ink); font-size: 1.25rem; display: grid; place-items: center; }

/* ---------- Cards ---------- */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); background: var(--surface); }
.card-header { background: transparent !important; border-bottom: 1px solid var(--line); padding: 1rem 1.25rem; font-weight: 700; color: var(--ink); }
.card-header:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.card-body { padding: 1.25rem; }
.card-footer { background: transparent !important; border-top: 1px solid var(--line); padding: .8rem 1.25rem; }

/* Stat tiles */
.stat { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.2rem 1.25rem; height: 100%; transition: box-shadow .2s, transform .2s; }
a .stat:hover, a.card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-label { font-size: .8rem; color: var(--muted); font-weight: 500; margin-bottom: .35rem; }
.stat-value { font-size: clamp(1.2rem, .95rem + .7vw, 1.6rem); white-space: nowrap; font-weight: 700; color: var(--ink); letter-spacing: -.03em; line-height: 1.1; }
.stat-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 1.25rem; flex-shrink: 0; }
@media (max-width: 575.98px) {
    .stat { flex-direction: column-reverse; justify-content: flex-end; gap: .75rem; padding: 1rem; }
    .stat-icon { width: 36px; height: 36px; font-size: 1.05rem; border-radius: 10px; }
}
.tone-indigo { background: var(--brand-50); color: var(--brand); }
.tone-green { background: #ecfdf5; color: #0b8a5a; }
.tone-amber { background: #fffbeb; color: #d97706; }
.tone-rose { background: #fff1f2; color: #e11d48; }

/* Quick actions strip */
.quick { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.today-pill { display: inline-flex; gap: .9rem; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: .4rem .9rem; font-size: .8rem; color: var(--muted); }

/* ---------- Tables ---------- */
.table { --bs-table-bg: transparent; --bs-table-hover-bg: #f8fafc; margin-bottom: 0; font-size: .875rem; }
.table > :not(caption) > * > * { padding: .8rem 1rem; border-bottom-color: var(--line); }
.table-sm > :not(caption) > * > * { padding: .6rem 1rem; }
.table thead th, .table-light th { background: #f8fafc !important; color: var(--muted); font-size: .7rem; font-weight: 700; text-transform: uppercase;
                                   letter-spacing: .06em; white-space: nowrap; border-bottom: 1px solid var(--line); }
.table tfoot td { background: #f8fafc !important; color: var(--ink); }
.table td { vertical-align: middle; color: var(--ink-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .cell-title { font-weight: 600; color: var(--ink); }
.table .cell-sub { font-size: .76rem; color: var(--muted); }
.card > .table-responsive:first-child .table thead th:first-child { border-top-left-radius: var(--radius); }
.card > .table-responsive:first-child .table thead th:last-child { border-top-right-radius: var(--radius); }
.empty { text-align: center; color: var(--muted); padding: 3rem 1rem !important; }
.empty .bi { display: block; font-size: 2rem; color: #cbd5e1; margin-bottom: .5rem; }

/* ---------- Badges / pills ---------- */
.badge { font-weight: 600; font-size: .72rem; padding: .35em .65em; border-radius: 999px; letter-spacing: .01em; }
.pill { display: inline-flex; align-items: center; gap: .35rem; font-weight: 600; font-size: .75rem; padding: .25rem .65rem; border-radius: 999px; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-green { background: #ecfdf5; color: #047857; }
.pill-amber { background: #fffbeb; color: #b45309; }
.pill-rose { background: #fff1f2; color: #be123c; }
.pill-slate { background: #f1f5f9; color: #475569; }
.pill-indigo { background: var(--brand-50); color: var(--brand-600); }
.text-success { color: #0b8a5a !important; }
.text-danger { color: #e11d48 !important; }

/* ---------- Tabs, alerts, modals, filters ---------- */
.nav-tabs { border-bottom: 1px solid var(--line); gap: .25rem; }
.nav-tabs .nav-link { border: 0; color: var(--muted); font-weight: 600; font-size: .875rem; padding: .7rem 1rem; border-bottom: 2px solid transparent; border-radius: 0; }
.nav-tabs .nav-link:hover { color: var(--ink); }
.nav-tabs .nav-link.active { color: var(--brand); border-bottom-color: var(--brand); background: transparent; }

.alert { border: 1px solid transparent; border-radius: var(--radius-sm); font-size: .875rem; font-weight: 500; }
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-danger { background: #fff1f2; border-color: #fecdd3; color: #9f1239; }
.alert-info { background: var(--brand-50); border-color: var(--brand-100); color: #3730a3; }

.modal-content { border: 0; border-radius: 18px; box-shadow: 0 25px 50px -12px rgba(15, 23, 42, .25); }
.modal-header { border-bottom: 1px solid var(--line); padding: 1.1rem 1.5rem; }
.modal-title { font-weight: 700; font-size: 1.05rem; color: var(--ink); }
.modal-body { padding: 1.5rem; }
.modal-footer { border-top: 1px solid var(--line); padding: 1rem 1.5rem; background: #f8fafc; border-radius: 0 0 18px 18px; }
.modal-backdrop.show { opacity: .35; }

.toolbar .card-body { padding: 1rem; }
.section-title { font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #94a3b8; margin: .5rem 0 1rem; }

/* ---------- Auth pages ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
             background: radial-gradient(1200px 600px at 10% -10%, #e0e7ff 0%, transparent 60%),
                         radial-gradient(900px 500px at 110% 110%, #ede9fe 0%, transparent 55%), var(--canvas); }
.auth-card { width: 100%; max-width: 440px; border-radius: 20px; box-shadow: var(--shadow-md); border: 1px solid rgba(231, 234, 240, .8); }
.auth-card .card-body { padding: 2.25rem; }
.auth-card .brand-logo { width: 52px; height: 52px; border-radius: 15px; font-size: 1.5rem; margin: 0 auto 1rem; }

/* ---------- Print ---------- */
@media print {
    .sidebar, .topbar .menu-btn, .no-print, .btn { display: none !important; }
    body, .topbar { background: #fff !important; }
    .card { box-shadow: none; border-color: #ddd; }
    .page { padding: 0; }
}

/* ---------- Powered by ---------- */
.auth-page { align-content: center; gap: 1rem; }
.app-footer { margin-top: auto; padding: 1rem 1rem 1.5rem; text-align: center; }
.powered-by { margin: 0; font-size: .8rem; color: var(--muted); text-align: center; }
.powered-by strong { color: var(--ink-2); font-weight: 600; }

/* ---------- Import ---------- */
.flash-details { margin: .4rem 0 0; padding-left: 1.1rem; font-size: .85rem; }
.flash-details li + li { margin-top: .15rem; }
.import-steps { padding-left: 1.2rem; margin-bottom: 1.25rem; font-size: .9rem; }
.import-steps li + li { margin-top: .35rem; }
.import-cols { margin-top: 1rem; }
.import-cols summary { cursor: pointer; font-weight: 600; font-size: .9rem; }
