:root {
    --mi-primary: #2563EB;
    --mi-primary-dark: #1e3a8a;
    --mi-success: #16A34A;
    --mi-danger: #DC2626;
    --mi-bg: #f4f6fb;
    --mi-sidebar: #0f172a;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--mi-bg);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: #1f2937;
}

.btn-primary { --bs-btn-bg: var(--mi-primary); --bs-btn-border-color: var(--mi-primary); --bs-btn-hover-bg: var(--mi-primary-dark); --bs-btn-hover-border-color: var(--mi-primary-dark); }
.text-bg-primary { background-color: var(--mi-primary) !important; }
.btn-success { --bs-btn-bg: var(--mi-success); --bs-btn-border-color: var(--mi-success); }
a { color: var(--mi-primary); }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    background: var(--mi-sidebar);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1045;
    transition: transform .25s ease;
}
.sidebar-brand {
    display: flex; align-items: center; gap: .6rem;
    padding: 1.15rem 1.25rem;
    font-size: 1.15rem; font-weight: 700; color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .bi { color: #60a5fa; font-size: 1.4rem; }
.sidebar-nav { list-style: none; margin: 0; padding: .75rem 0; flex: 1; overflow-y: auto; }
.sidebar-nav a {
    display: flex; align-items: center; gap: .75rem;
    padding: .7rem 1.25rem;
    color: #cbd5e1; text-decoration: none; font-size: .95rem;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav a.active { background: var(--mi-primary); color: #fff; }
.sidebar-section { padding: .9rem 1.25rem .35rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: #64748b; }
.sidebar-logout { padding: 1rem 1.25rem; border-top: 1px solid rgba(255,255,255,.08); }

.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1040; }
.sidebar-backdrop.show { display: block; }

.app-main { flex: 1; margin-left: 250px; display: flex; flex-direction: column; min-width: 0; }
.topbar {
    display: flex; align-items: center; gap: 1rem;
    background: #fff; padding: .85rem 1.5rem;
    border-bottom: 1px solid #e5e7eb; position: sticky; top: 0; z-index: 1030;
}
.topbar-title { font-size: 1.15rem; margin: 0; font-weight: 600; }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: .6rem; font-size: .9rem; }
.app-content { padding: 1.5rem; max-width: 1200px; width: 100%; }

.card { border: none; box-shadow: 0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04); border-radius: .75rem; }
.stat-card { padding: 1.1rem 1.25rem; }
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; }
.stat-card .stat-label { color: #6b7280; font-size: .85rem; }
.stat-card .bi { font-size: 1.5rem; opacity: .35; }

.table > :not(caption) > * > * { padding: .7rem .75rem; }
.product-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: .5rem; background: #e5e7eb; }

.quick-action {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: .5rem; padding: 1.25rem; text-align: center;
    background: #fff; border-radius: .75rem; text-decoration: none; color: #1f2937;
    box-shadow: 0 1px 3px rgba(15,23,42,.08); min-height: 110px;
}
.quick-action .bi { font-size: 1.75rem; color: var(--mi-primary); }

/* ---------- Order builder ---------- */
.cart-line { display: flex; gap: .5rem; align-items: center; padding: .6rem 0; border-bottom: 1px solid #eef2f7; flex-wrap: wrap; }
.cart-line .name { flex: 1 1 140px; min-width: 120px; font-weight: 600; }
.order-totals { position: sticky; bottom: 0; background: #fff; border-top: 2px solid var(--mi-primary); padding: 1rem; border-radius: .75rem .75rem 0 0; }

#reader { width: 100%; max-width: 400px; }

@media (min-width: 992px) {
    .sidebar { transform: none; }
}
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .app-content { padding: 1rem; }
}

/* Bigger touch targets on mobile */
@media (max-width: 767.98px) {
    .btn { padding: .55rem .9rem; }
    .form-control, .form-select { font-size: 1rem; min-height: 44px; }
}
