:root {
  --steel-dark: #1a2332;
  --steel-mid: #243044;
  --steel-light: #f4f6f9;
  --accent: #ffffff;
  --accent-deep: #6b7684;
  --in: #1e7e34;
  --in-bg: #e6f4ea;
  --out: #b02a37;
  --out-bg: #fbe9eb;
  --adj: #5c636a;
  --adj-bg: #eceff2;
  --border: #dee2e6;
  --text: #1a2332;
  --muted: #6c757d;
  --nav-h: 60px;
  --bottom-h: 62px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--text);
  background: var(--steel-light);
  margin: 0;
  min-height: 100vh;
}
body.has-nav { padding-bottom: calc(var(--bottom-h) + 16px); }
@media (min-width: 992px) { body.has-nav { padding-bottom: 32px; } }

a { color: var(--steel-dark); }
a:hover { color: #000; }

/* ── NAVBAR ── */
.main-nav { background: var(--steel-dark); min-height: var(--nav-h); box-shadow: 0 2px 10px rgba(0,0,0,0.25); }
.main-nav .nav-link { color: #c5ccd4; font-weight: 500; padding: 8px 12px; border-radius: 6px; }
.main-nav .nav-link:hover { color: #fff; background: rgba(255,255,255,0.06); }
.main-nav .nav-link.active { color: #fff; background: rgba(255,255,255,0.12); }
.main-nav .navbar-toggler:focus { box-shadow: none; }
.main-nav form .nav-link { border: 0; }
.brand-mark { width: 36px; height: 36px; color: #fff; flex-shrink: 0; }
.brand-mark-lg { width: 48px; height: 48px; color: var(--steel-dark); }
.brand-name { font-family: 'Bebas Neue', 'Inter', sans-serif; font-size: 1.35rem; letter-spacing: 0.06em; line-height: 1; color: #fff; }
.brand-tagline { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.12em; color: #9aa5b1; line-height: 1; margin-top: 3px; }
.login-card .brand-name { color: var(--steel-dark); }
.login-card .brand-tagline { color: var(--accent-deep); }

/* ── PAGE ── */
.page { padding-top: 20px; max-width: 1400px; margin: 0 auto; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { font-size: 1.45rem; font-weight: 700; margin: 0 0 2px; letter-spacing: -0.01em; }
@media (min-width: 768px) { .page-head h1 { font-size: 1.75rem; } }
.flash-stack .alert { margin-bottom: 10px; border: 0; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }

/* ── CARDS ── */
.card.panel, .filter-bar.card, .form-card { border: 1px solid var(--border); border-radius: 12px; background: #fff; box-shadow: 0 1px 3px rgba(20,30,50,0.05); }
.filter-bar { padding: 12px 14px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 10px; }
.panel-head h2 { font-size: 0.95rem; font-weight: 600; margin: 0; }
.panel-head a { text-decoration: none; color: var(--accent-deep); }
.panel-head a:hover { color: var(--steel-dark); }
.form-narrow { max-width: 480px; }

/* ── STAT CARDS ── */
.stat-card {
  display: flex; flex-direction: column; gap: 2px;
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; height: 100%; text-decoration: none; color: var(--text);
  box-shadow: 0 1px 3px rgba(20,30,50,0.05); transition: transform 0.15s, box-shadow 0.15s;
}
a.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(20,30,50,0.1); color: var(--text); }
.stat-card.stat-danger { border-color: #f1aeb5; background: #fff7f8; }
.stat-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 1.45rem; font-weight: 700; line-height: 1.2; }
.stat-value small { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.stat-sub { font-size: 0.75rem; color: var(--muted); }
@media (min-width: 768px) { .stat-value { font-size: 1.7rem; } }

/* ── TABLES ── */
.erp-table { font-size: 0.9rem; }
.erp-table thead th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); background: #fafbfc; white-space: nowrap; }
.erp-table tbody td { border-color: #eef0f3; }
.erp-table tfoot th { border-top: 2px solid var(--border); background: #fafbfc; }
.erp-table tbody tr:hover { background: #f7f9fb; }
.erp-table .table-responsive { border-radius: 0 0 12px 12px; }
.panel .table-responsive { border-radius: 0 0 12px 12px; }
.item-link { text-decoration: none; font-weight: 500; }
.item-link:hover { text-decoration: underline; }
.variant { color: var(--muted); font-weight: 400; }
.grade-pill { display: inline-block; background: var(--steel-dark); color: #fff; font-size: 0.7rem; font-weight: 700; padding: 2px 7px; border-radius: 4px; letter-spacing: 0.04em; vertical-align: middle; }
.grade-pill-lg { font-size: 0.9rem; padding: 3px 9px; vertical-align: 3px; }

/* status + movement badges */
.badge.status-ok { background: var(--in-bg); color: var(--in); font-weight: 600; }
.badge.status-low { background: #fff3cd; color: #8a6d00; font-weight: 600; }
.badge.status-out { background: var(--out-bg); color: var(--out); font-weight: 600; }
.badge.status-empty { background: var(--adj-bg); color: var(--adj); font-weight: 600; }
.mv { display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.mv-in { background: var(--in-bg); color: var(--in); }
.mv-out { background: var(--out-bg); color: var(--out); }
.mv-adj { background: var(--adj-bg); color: var(--adj); }
.text-in { color: var(--in) !important; }
.text-out { color: var(--out) !important; }

/* ── BUTTONS ── */
.btn-primary { background: var(--steel-dark); border-color: var(--steel-dark); }
.btn-primary:hover, .btn-primary:focus { background: var(--steel-mid); border-color: var(--steel-mid); }
.btn-in { background: var(--in); border-color: var(--in); color: #fff; }
.btn-in:hover, .btn-in:focus { background: #176429; border-color: #176429; color: #fff; }
.btn-out { background: var(--out); border-color: var(--out); color: #fff; }
.btn-out:hover, .btn-out:focus { background: #8f2130; border-color: #8f2130; color: #fff; }
.btn-dark { background: var(--steel-dark); border-color: var(--steel-dark); }
.btn, .form-control, .form-select { border-radius: 8px; }
.form-label { font-size: 0.82rem; font-weight: 600; color: #3c4653; margin-bottom: 4px; }
.form-control:focus, .form-select:focus { border-color: var(--steel-dark); box-shadow: 0 0 0 0.2rem rgba(26,35,50,0.12); }
.quick-picks { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.quick-picks:empty { display: none; }
.quick-picks .pick { border: 1px solid var(--border); background: #fff; color: var(--text); font-size: 0.75rem; padding: 2px 8px; border-radius: 999px; line-height: 1.4; }
.quick-picks .pick:hover, .quick-picks .pick.active { background: var(--steel-dark); border-color: var(--steel-dark); color: #fff; }

/* step-by-step item form */
.form-section { padding: 14px 0 18px; border-top: 1px solid #eef0f3; }
.form-section:first-child { border-top: 0; padding-top: 0; }
.form-section-title { font-weight: 600; font-size: 0.95rem; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.form-section-title .step { display: inline-flex; width: 24px; height: 24px; border-radius: 50%; background: var(--steel-dark); color: #fff; font-size: 0.75rem; align-items: center; justify-content: center; }
[hidden] { display: none !important; }

/* stock overview: category cards */
.search-bar .form-control { border-radius: 0; }
.cat-card { display: block; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 16px; height: 100%; text-decoration: none; color: var(--text); box-shadow: 0 1px 3px rgba(20,30,50,0.05); transition: transform 0.15s, box-shadow 0.15s; }
.cat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(20,30,50,0.1); color: var(--text); }
.cat-card.cat-empty { background: #fafbfc; border-style: dashed; }
.cat-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--steel-dark); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; margin-bottom: 10px; }
.cat-empty .cat-icon { background: #c5ccd4; }
.cat-name { font-weight: 700; font-size: 1.05rem; margin-bottom: 2px; }
.cat-meta { font-size: 0.8rem; color: var(--muted); }

/* category view */
.crumbs { font-size: 0.8rem; color: var(--muted); margin-bottom: 2px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--steel-dark); }
.crumbs i { font-size: 0.65rem; margin: 0 2px; }
.grade-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.grade-tab { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border); background: #fff; color: var(--text); font-weight: 600; font-size: 0.9rem; text-decoration: none; }
.grade-tab .count { background: var(--steel-light); color: var(--muted); font-size: 0.72rem; padding: 1px 7px; border-radius: 999px; font-weight: 600; }
.grade-tab.empty { color: var(--muted); border-style: dashed; font-weight: 500; }
.grade-tab:hover { border-color: var(--steel-dark); color: var(--steel-dark); }
.grade-tab.active { background: var(--steel-dark); border-color: var(--steel-dark); color: #fff; }
.grade-tab.active .count { background: rgba(255,255,255,0.18); color: #fff; }
.sched-tabs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: -6px 0 12px; }
.sched-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; margin-right: 4px; }
.sched-tab { display: inline-block; padding: 4px 12px; border-radius: 6px; border: 1px solid var(--border); background: #fff; color: var(--text); font-size: 0.82rem; font-weight: 600; text-decoration: none; }
.sched-tab:hover { border-color: var(--steel-dark); color: var(--steel-dark); }
.sched-tab.active { background: var(--steel-light); border-color: var(--steel-dark); color: var(--steel-dark); }
#sched-chips { margin: 0 0 8px; }
.size-table .group-row td { background: #f1f3f6; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: #3c4653; padding: 6px 12px; }
.size-table .row-empty .item-link { color: var(--muted); font-weight: 500; }
.size-table .item-link { font-size: 1rem; }
.size-table td { padding-top: 9px; padding-bottom: 9px; }

/* stock in/out form */
.move-form { max-width: 640px; }
.section-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; }
.item-card { background: var(--steel-light); border-radius: 10px; padding: 12px 14px; border-left: 4px solid var(--steel-dark); }
.item-card-in { border-left-color: var(--in); background: #f3faf5; }
.item-card-out { border-left-color: var(--out); background: #fdf5f6; }
.item-card-name { font-size: 1.15rem; font-weight: 600; }
.pick-step-label .step { display: inline-flex; width: 20px; height: 20px; border-radius: 50%; background: var(--steel-dark); color: #fff; font-size: 0.7rem; align-items: center; justify-content: center; margin-right: 4px; letter-spacing: 0; }
.move-actions { display: flex; gap: 8px; position: sticky; bottom: calc(var(--bottom-h) + 8px); background: var(--steel-light); padding: 8px 0; z-index: 5; }
@media (min-width: 992px) { .move-actions { position: static; padding: 0; } }
.item-card-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 0.85rem; color: var(--muted); margin-top: 6px; }
.item-card-meta strong { color: var(--text); }
.pick-step-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; margin-bottom: 8px; }
.pick-crumbs { font-size: 0.85rem; margin-bottom: 10px; color: var(--text); }
.pick-crumbs a { color: var(--accent-deep); text-decoration: none; }
.pick-crumbs a:hover { text-decoration: underline; }
.pick-crumbs i { font-size: 0.65rem; color: var(--muted); margin: 0 2px; }
.cat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (min-width: 576px) { .cat-grid { grid-template-columns: repeat(4, 1fr); } }
.cat-tile { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 6px; background: #fff; border: 1px solid var(--border); border-radius: 10px; color: var(--text); font-weight: 600; font-size: 0.85rem; }
.cat-tile i { font-size: 1.4rem; color: var(--steel-dark); }
.cat-tile small { font-weight: 500; color: var(--muted); font-size: 0.7rem; }
.cat-tile:hover:not(:disabled) { border-color: var(--steel-dark); background: var(--steel-light); }
.cat-tile:disabled { opacity: 0.45; border-style: dashed; }
.pick-results { display: flex; flex-direction: column; gap: 4px; max-height: 360px; overflow-y: auto; }
.pick-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; text-align: left; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: 0.95rem; color: var(--text); }
.pick-row:hover { border-color: var(--steel-dark); background: var(--steel-light); }
.pick-row.empty { color: var(--muted); }
.pick-row.empty strong { font-weight: 500; }
.pick-qty { font-size: 0.85rem; color: var(--in); font-weight: 600; white-space: nowrap; }
.pick-row.empty .pick-qty { color: var(--muted); font-weight: 400; }
.after-line { font-size: 0.95rem; }
#quantity, #pieces { font-weight: 600; font-size: 1.4rem; }
.move-form .form-control-plaintext { font-size: 1.1rem; }

/* stock list modes */
.mode-pill { display: inline-block; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; background: #fff3cd; color: #8a6d00; padding: 3px 9px; border-radius: 999px; vertical-align: middle; margin-left: 6px; }
.products-table.manage tbody tr { background: #fffdf5; }
.products-table.manage form { margin-left: 2px; }
select[size] { padding: 4px; }
select[size] option { padding: 8px 10px; border-radius: 6px; }

/* ── LOGIN ── */
.login-wrap { min-height: calc(100vh - 40px); display: flex; align-items: center; justify-content: center; padding: 20px 0; }
.login-card { background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 32px 28px; width: 100%; max-width: 400px; box-shadow: 0 10px 40px rgba(20,30,50,0.12); }
body:not(.has-nav) { background: linear-gradient(180deg, var(--steel-dark) 0%, var(--steel-dark) 45%, var(--steel-light) 45%); }

/* ── BOTTOM NAV (mobile) ── */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--bottom-h);
  background: #fff; border-top: 1px solid var(--border);
  display: flex; justify-content: space-around; align-items: stretch;
  box-shadow: 0 -4px 16px rgba(20,30,50,0.08); z-index: 1030;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 0.68rem; font-weight: 600; }
.bottom-nav a i { font-size: 1.3rem; line-height: 1; }
.bottom-nav a.active { color: var(--steel-dark); }
.bottom-nav a.in i { color: var(--in); }
.bottom-nav a.out i { color: var(--out); }

@media (max-width: 575.98px) {
  .page-head .btn { padding: 6px 10px; font-size: 0.85rem; }
  .erp-table { font-size: 0.84rem; }
  .erp-table td, .erp-table th { padding: 8px 8px; }
  .products-table .btn-sm { padding: 4px 7px; }
}
