:root {
  /* SBX palette — change brand colors here only */
  --brand: #1b2350;          /* deep navy from the logo */
  --brand-hover: #141a3d;
  --brand-tint: #2a3366;     /* navy surfaces inside the sidebar */
  --accent: #4c6fff;         /* electric blue: focus, links, progress */
  --accent-soft: #eef1ff;
  --ink: #1b2134;
  --muted: #6b7288;
  --line: #e6e8f0;
  --surface: #ffffff;
  --canvas: #f5f6fa;
  --ok-bg: #e7f6ee; --ok-fg: #1d7a46;
  --low-bg: #fff4e0; --low-fg: #9a5b0b;
  --out-bg: #fdecec; --out-fg: #b42318;
  --sidebar-w: 236px;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .05);
}
body { font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--canvas); color: var(--ink); font-size: .925rem; }
a { color: var(--accent); }
code { color: var(--brand); }
.text-accent { color: var(--accent); }
.min-w-0 { min-width: 0; }
.tabular { font-variant-numeric: tabular-nums; }

/* Buttons */
.btn { border-radius: 10px; font-weight: 500; padding: .5rem 1rem; }
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand:hover, .btn-brand:focus, .btn-brand:active { background: var(--brand-hover) !important; border-color: var(--brand-hover) !important; color: #fff !important; }
.btn-brand:disabled { background: #8a90ad; border-color: #8a90ad; }
.btn:focus-visible { box-shadow: 0 0 0 .2rem rgba(76, 111, 255, .3); }
.btn-light-outline { background: #fff; border: 1px solid var(--line); color: var(--ink); }
.btn-light-outline:hover { border-color: var(--accent); color: var(--accent); background: #fff; }
.btn-icon { border: 1px solid var(--line); background: #fff; width: 40px; height: 40px; padding: 0; font-size: 1.25rem; }
.form-control, .form-select, .input-group-text { border-radius: 10px; border-color: var(--line); }
.input-group-text { background: #fafbfc; color: var(--muted); }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: var(--accent); box-shadow: 0 0 0 .2rem rgba(76, 111, 255, .18); }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-label { font-weight: 500; font-size: .85rem; margin-bottom: .3rem; }

/* Layout */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--brand); color: #fff; position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; padding: 1.25rem .85rem; z-index: 1040; transition: transform .2s ease; }
.brand { display: flex; align-items: center; gap: .7rem; text-decoration: none; color: #fff; padding: 0 .5rem 1.5rem; }
.brand:hover { color: #fff; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 1.1rem; letter-spacing: .08em; }
.brand-text small { font-size: .72rem; color: rgba(255, 255, 255, .65); letter-spacing: .02em; }
.brand-mark { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--brand-tint); color: #fff; font-size: 1.2rem; border: 1px solid rgba(255, 255, 255, .15); }
.brand-mark-lg { width: 72px; height: 72px; font-size: 2.1rem; border-radius: 18px; background: var(--brand); }
.brand-logo { width: 38px; height: 38px; border-radius: 10px; object-fit: contain; background: var(--brand); }
.brand-logo-lg { width: 96px; height: 96px; border-radius: 20px; box-shadow: var(--shadow); }
.nav-menu { display: flex; flex-direction: column; gap: .2rem; }
.nav-item { display: flex; align-items: center; gap: .7rem; padding: .6rem .75rem; border-radius: 10px; color: rgba(255, 255, 255, .72); text-decoration: none; font-weight: 500; text-align: left; }
.nav-item i { font-size: 1.05rem; }
.nav-item:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav-item.active { background: var(--brand-tint); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sidebar-footer { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, .12); padding-top: .85rem; }
.user-chip { display: flex; align-items: center; gap: .6rem; padding: .25rem .75rem .6rem; font-weight: 500; min-width: 0; }
.avatar { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; font-size: .8rem; }
.main { flex: 1; margin-left: var(--sidebar-w); padding: 1.75rem 2rem 3rem; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.page-title { font-size: 1.45rem; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.page-subtitle { color: var(--muted); margin: .15rem 0 0; font-size: .875rem; }
.sidebar-backdrop { display: none; }

/* Surfaces */
.card-surface { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.stat { display: flex; gap: .9rem; align-items: flex-start; padding: 1.15rem 1.2rem; height: 100%; color: inherit; text-decoration: none; }
.stat-link { transition: border-color .15s, transform .15s; }
.stat-link:hover { border-color: var(--accent); transform: translateY(-1px); color: inherit; }
.stat-icon { flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--accent-soft); color: var(--brand); font-size: 1.15rem; }
.stat-icon.icon-low { background: var(--low-bg); color: var(--low-fg); }
.stat-icon.icon-out { background: var(--out-bg); color: var(--out-fg); }
.stat-label { color: var(--muted); font-size: .8rem; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-hint { color: var(--muted); font-size: .78rem; margin-top: .15rem; }
.empty-state { text-align: center; padding: 3.5rem 1.5rem; }
.empty-icon { display: inline-grid; place-items: center; width: 72px; height: 72px; border-radius: 50%; background: var(--accent-soft); color: var(--brand); font-size: 2rem; box-shadow: 0 0 0 10px #f7f8ff; }
.section-title { font-size: .95rem; font-weight: 600; display: flex; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.section-title i { color: var(--accent); }
.meta { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; font-size: .85rem; }
.meta dt { color: var(--muted); font-weight: 500; }
.meta dd { margin: 0; text-align: right; }
.help code { color: var(--brand); background: var(--accent-soft); padding: 0 .25rem; border-radius: 4px; }
.help li { margin-bottom: .45rem; }

/* Status */
.status-pill { display: inline-flex; align-items: center; gap: .4rem; font-size: .8rem; font-weight: 600; padding: .25rem .65rem; border-radius: 999px; }
.status-pill i { font-size: .5rem; }
.status-ok { background: var(--ok-bg); color: var(--ok-fg); }
.status-error { background: var(--out-bg); color: var(--out-fg); }
.status-warn { background: var(--low-bg); color: var(--low-fg); }
.status-info { background: var(--accent-soft); color: var(--accent); }
.status-muted { background: #eceef3; color: var(--muted); }
.badge-status { display: inline-block; font-size: .75rem; font-weight: 600; padding: .2rem .6rem; border-radius: 999px; white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge-low { background: var(--low-bg); color: var(--low-fg); }
.badge-out { background: var(--out-bg); color: var(--out-fg); }
.badge-muted { background: #eceef3; color: var(--muted); }

/* Table */
.filters { display: flex; flex-wrap: wrap; gap: .6rem; padding: 1rem; border-bottom: 1px solid var(--line); }
.filters .search { flex: 1 1 260px; }
.filters .form-select { flex: 0 1 200px; }
.data-table th { background: #fafbfc; color: var(--muted); font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--line); padding: .75rem 1rem; white-space: nowrap; }
.data-table th a { color: inherit; text-decoration: none; }
.data-table th a:hover { color: var(--accent); }
.data-table td { padding: .8rem 1rem; border-color: var(--line); }
.data-table tbody tr:hover td { background: #f8f9fe; }
.table-footer { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .85rem 1rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pagination .page-link { color: var(--brand); border-color: var(--line); }
.messages .alert { border-radius: 12px; }

/* Auth */
body.auth { background: radial-gradient(circle at 15% 0%, #e3e8ff 0, transparent 45%), linear-gradient(180deg, var(--canvas), #eceef6); }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.auth-card { width: 100%; max-width: 410px; padding: 2.5rem 2.25rem; border-top: 4px solid var(--brand); }
.error-code { font-size: 3.5rem; font-weight: 700; color: var(--brand); line-height: 1; }

/* Mobile */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .25); }
  .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(27, 35, 80, .35); z-index: 1030; }
  .main { margin-left: 0; padding: 1rem 1rem 2rem; }
  .stat-value { font-size: 1.4rem; }
  .data-table th, .data-table td { padding: .7rem .6rem; }
  .filters .form-select { flex: 1 1 140px; }
}

/* Sidebar extras */
.nav-section { color: rgba(255, 255, 255, .45); font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; padding: .25rem .75rem .4rem; }
.lang-switch { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: rgba(255, 255, 255, .08); }
.lang-switch button { border: 0; background: transparent; color: rgba(255, 255, 255, .7); font-size: .75rem; font-weight: 600; padding: .25rem .6rem; border-radius: 7px; }
.lang-switch button:hover { color: #fff; }
.lang-switch button.active { background: #fff; color: var(--brand); }
.lang-switch-light { background: var(--canvas); border: 1px solid var(--line); }
.lang-switch-light button { color: var(--muted); }
.lang-switch-light button:hover { color: var(--brand); }
.lang-switch-light button.active { background: var(--brand); color: #fff; }

/* Stock table (1C report layout) */
.stock-table th { background: #fafbfc; color: var(--muted); font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; padding: .75rem 1rem; white-space: nowrap; border-bottom: 1px solid var(--line); }
.stock-table td { padding: .55rem 1rem; border-color: var(--line); vertical-align: middle; }
.stock-table .row-store td { background: var(--brand); color: #fff; font-weight: 700; border: 0; }
.stock-table .row-group td { background: var(--accent-soft); color: var(--brand); font-weight: 600; cursor: pointer; user-select: none; }
.stock-table .row-group:hover td { background: #e2e7ff; }
.stock-table .row-group:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.stock-table .row-group .count { font-size: .72rem; font-weight: 600; color: var(--muted); background: #fff; border-radius: 999px; padding: .05rem .5rem; margin-left: .35rem; }
.stock-table .toggle-icon { display: inline-block; transition: transform .15s; }
.stock-table .row-group[aria-expanded="false"] .toggle-icon { transform: rotate(-90deg); }
.stock-table .row-item td:first-child { padding-left: 2.6rem; }
.stock-table .row-item:hover td { background: #f8f9fe; }
.stock-table .item-name { min-width: 260px; }
.stock-table .barcode { word-break: break-all; min-width: 110px; }
.stock-table .unit { color: var(--muted); font-size: .78rem; }
.qty-out, .stock-table td.qty-out { color: var(--out-fg); font-weight: 700; }
.qty-low, .stock-table td.qty-low { color: var(--low-fg); font-weight: 700; }
.legend { font-size: .9rem; }
.sort-select { flex: 0 1 190px !important; }

/* Administration */
.form-narrow { max-width: 760px; }
.stat-value-sm { font-size: 1.05rem; margin-top: .25rem; }
.badge-info { background: var(--accent-soft); color: var(--accent); }
.credentials { display: grid; grid-template-columns: auto 1fr; gap: .6rem 1.25rem; align-items: center; margin-bottom: 1.5rem; }
.credentials dt { color: var(--muted); font-weight: 500; }
.credentials dd { margin: 0; }
.credentials code { font-size: 1.15rem; color: var(--brand); background: var(--accent-soft); padding: .25rem .6rem; border-radius: 8px; user-select: all; }
.run-message { max-width: 520px; }

/* Mobile: keep the Quantity column visible while the table scrolls horizontally */
@media (max-width: 767.98px) {
  .stock-table th:last-child, .stock-table td:last-child { position: sticky; right: 0; z-index: 1; background: #fff; box-shadow: -8px 0 8px -8px rgba(16, 24, 40, .18); }
  .stock-table th:last-child { background: #fafbfc; }
  .stock-table .row-store td:last-child { background: var(--brand); }
  .stock-table .row-group td:last-child { background: var(--accent-soft); }
  .stock-table .item-name { min-width: 200px; }
  .stock-table .row-item td:first-child { padding-left: 1.6rem; }
  .stock-table .row-store td:first-child, .stock-table .row-group td:first-child { position: sticky; left: 0; }
}

/* Turnover */
.period-bar { display: flex; flex-wrap: wrap; gap: .75rem; padding: 1rem; align-items: flex-end; }
.period-field { flex: 0 1 190px; }
.period-field .form-label { font-size: .75rem; color: var(--muted); margin-bottom: .2rem; }
.quick-ranges { display: flex; flex-wrap: wrap; gap: .35rem; margin-left: auto; }
.nav-item-sm { font-size: .85rem; padding: .45rem .75rem; }
