:root {
  --navy-950: #0b1729;
  --navy-900: #10213b;
  --navy-800: #19304e;
  --blue: #2368d8;
  --blue-dark: #1857ba;
  --blue-soft: #e9f1ff;
  --teal: #0f9f8f;
  --amber: #d8860b;
  --red: #d94b4b;
  --ink: #172033;
  --muted: #657086;
  --line: #e3e8ef;
  --surface: #ffffff;
  --background: #f4f6f9;
  --shadow: 0 10px 30px rgba(16, 33, 59, .08);
  --radius: 14px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--background); color: var(--ink); font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.app-shell { min-height: 100vh; display: flex; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 246px; z-index: 20; display: flex; flex-direction: column; padding: 24px 16px; background: var(--navy-950); color: #fff; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 9px 28px; }
.brand-mark { width: 39px; height: 39px; display: grid; place-items: center; border-radius: 11px; background: linear-gradient(145deg, #4d8dfa, #1d64d6); box-shadow: 0 7px 16px rgba(26, 99, 217, .32); }
.brand-mark svg { width: 24px; fill: none; stroke: #fff; stroke-width: 1.7; stroke-linejoin: round; }
.brand strong { display: block; font-size: 18px; letter-spacing: -.3px; }
.brand small, .sidebar-footer small { display: block; color: #92a2b9; font-size: 11px; }
.main-nav { display: grid; gap: 6px; }
.nav-link { color: #aebad0; text-decoration: none; display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: 9px; font-weight: 600; transition: .18s ease; }
.nav-link:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-link.active { color: #fff; background: #1e5fbd; box-shadow: 0 7px 16px rgba(0,0,0,.16); }
.nav-icon { width: 20px; text-align: center; font-size: 19px; line-height: 1; }
.sidebar-footer { margin-top: auto; padding: 15px 12px; border-top: 1px solid rgba(255,255,255,.09); display: flex; gap: 10px; align-items: center; }
.sidebar-footer strong { display: block; font-size: 12px; }
.status-dot { width: 9px; height: 9px; flex: 0 0 9px; border-radius: 50%; background: #38c6a7; box-shadow: 0 0 0 4px rgba(56,198,167,.12); }

.workspace { margin-left: 246px; width: calc(100% - 246px); min-height: 100vh; }
.topbar { min-height: 82px; padding: 15px clamp(20px, 3vw, 42px); display: flex; align-items: center; gap: 16px; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 12; backdrop-filter: blur(12px); }
.topbar h1 { margin: 0; font-size: 21px; letter-spacing: -.35px; }
.topbar p { margin: 1px 0 0; color: var(--muted); font-size: 12px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 18px; }
.docs-link { color: var(--muted); text-decoration: none; font-weight: 650; }
.docs-link:hover { color: var(--blue); }
.avatar { width: 37px; height: 37px; display: grid; place-items: center; background: var(--blue-soft); border: 1px solid #cbdbf7; border-radius: 50%; color: var(--blue-dark); font-size: 12px; font-weight: 800; }
.menu-button { display: none !important; }
.content { max-width: 1540px; margin: auto; padding: clamp(22px, 3vw, 42px); outline: none; }

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-heading h2 { margin: 0; font-size: 24px; letter-spacing: -.5px; }
.page-heading p { color: var(--muted); margin: 4px 0 0; }
.button { border: 0; min-height: 40px; padding: 9px 17px; border-radius: 9px; cursor: pointer; font-weight: 700; transition: .16s ease; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.button:disabled { opacity: .55; cursor: wait; }
.button.primary { color: #fff; background: var(--blue); box-shadow: 0 5px 12px rgba(35,104,216,.2); }
.button.primary:hover { background: var(--blue-dark); transform: translateY(-1px); }
.button.secondary { color: var(--ink); background: #fff; border: 1px solid var(--line); }
.button.secondary:hover { background: #f7f9fc; }
.button.danger { color: var(--red); background: #fff; border: 1px solid #f1cccc; }
.icon-button { width: 38px; height: 38px; border: 0; border-radius: 9px; display: inline-grid; place-items: center; color: var(--muted); background: transparent; cursor: pointer; font-size: 22px; }
.icon-button:hover { color: var(--ink); background: #edf1f6; }
.action-button { border: 0; color: var(--blue); background: transparent; cursor: pointer; font-weight: 700; padding: 5px 7px; border-radius: 6px; }
.action-button:hover { background: var(--blue-soft); }
.action-button.danger { color: var(--red); }

.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-bottom: 22px; }
.metric-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; gap: 15px; align-items: center; box-shadow: 0 2px 4px rgba(16,33,59,.025); }
.metric-icon { width: 47px; height: 47px; flex: 0 0 47px; border-radius: 12px; display: grid; place-items: center; color: var(--blue); background: var(--blue-soft); font-size: 22px; }
.metric-icon.teal { color: var(--teal); background: #e7f7f4; }
.metric-icon.amber { color: var(--amber); background: #fff5e3; }
.metric-label { display: block; color: var(--muted); font-weight: 600; font-size: 12px; }
.metric-value { display: block; margin-top: 1px; font-size: 26px; letter-spacing: -.7px; line-height: 1.15; }
.metric-meta { display: block; color: #8993a5; margin-top: 3px; font-size: 11px; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(290px, .75fr); gap: 20px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 2px 4px rgba(16,33,59,.025); overflow: hidden; }
.panel + .panel { margin-top: 20px; }
.panel-header { padding: 18px 20px 14px; display: flex; align-items: center; justify-content: space-between; gap: 15px; border-bottom: 1px solid #edf0f4; }
.panel-header h3 { margin: 0; font-size: 15px; }
.panel-header p { color: var(--muted); font-size: 12px; margin: 2px 0 0; }
.panel-link { color: var(--blue); text-decoration: none; font-weight: 700; font-size: 12px; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { background: #fafbfd; color: #778196; padding: 10px 18px; border-bottom: 1px solid var(--line); text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .65px; white-space: nowrap; }
td { padding: 13px 18px; border-bottom: 1px solid #edf0f4; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fcfdff; }
.cell-title { font-weight: 700; display: block; color: var(--ink); }
.cell-subtitle { display: block; color: var(--muted); font-size: 11px; margin-top: 1px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.number { font-variant-numeric: tabular-nums; font-weight: 750; }
.align-right { text-align: right; }
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 4px 8px; font-size: 10px; font-weight: 800; white-space: nowrap; }
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.active, .badge.entry { color: #09836f; background: #e7f7f2; }
.badge.inactive { color: #7b8494; background: #eef1f4; }
.badge.exit { color: #c33e48; background: #fff0f1; }
.badge.transfer { color: #2e64c6; background: #edf3ff; }
.badge.adjustment { color: #a56508; background: #fff4df; }
.badge.low { color: #bf7205; background: #fff2d9; }

.bar-list { padding: 8px 20px 18px; }
.bar-item { padding: 11px 0; }
.bar-label { display: flex; justify-content: space-between; gap: 15px; margin-bottom: 7px; font-size: 12px; }
.bar-label span:last-child { font-weight: 750; }
.bar-track { height: 7px; background: #edf1f6; border-radius: 9px; overflow: hidden; }
.bar-fill { height: 100%; min-width: 3px; background: linear-gradient(90deg, #2368d8, #5790ec); border-radius: inherit; }
.low-stock-list { padding: 7px 20px 15px; }
.low-stock-item { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid #edf0f4; }
.low-stock-item:last-child { border: 0; }
.low-stock-item strong { display: block; font-size: 12px; }
.low-stock-item small { color: var(--muted); }
.stock-gap { color: var(--amber); font-weight: 800; font-size: 12px; white-space: nowrap; }

.toolbar { padding: 14px 18px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.search-control { min-width: min(340px, 100%); position: relative; }
.search-control::before { content: "⌕"; position: absolute; left: 12px; top: 50%; transform: translateY(-51%); color: #8a94a6; font-size: 18px; }
.search-control input { padding-left: 38px; }
.toolbar .filter-select { width: auto; min-width: 145px; margin-left: auto; }
input, select, textarea { width: 100%; border: 1px solid #d6dce5; border-radius: 8px; background: #fff; color: var(--ink); padding: 9px 11px; outline: none; transition: border .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: #5990e6; box-shadow: 0 0 0 3px rgba(35,104,216,.1); }
textarea { resize: vertical; }

.empty-state { text-align: center; padding: 50px 24px; color: var(--muted); }
.empty-icon { width: 55px; height: 55px; margin: 0 auto 13px; border-radius: 16px; background: #eef2f7; display: grid; place-items: center; font-size: 25px; color: #79859a; }
.empty-state h3 { color: var(--ink); margin: 0 0 5px; font-size: 15px; }
.empty-state p { margin: 0 auto; max-width: 410px; }
.loading-state, .error-state { min-height: 340px; display: grid; place-content: center; justify-items: center; color: var(--muted); text-align: center; }
.spinner { width: 28px; height: 28px; border: 3px solid #dce5f3; border-top-color: var(--blue); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.modal { width: min(650px, calc(100% - 28px)); border: 0; border-radius: 15px; padding: 0; box-shadow: 0 30px 80px rgba(8,22,43,.27); color: var(--ink); }
.modal.modal-wide { width: min(720px, calc(100% - 28px)); }
.modal::backdrop { background: rgba(7,18,34,.57); backdrop-filter: blur(2px); }
.modal form { padding: 25px; }
.modal-header { display: flex; justify-content: space-between; gap: 15px; align-items: flex-start; margin-bottom: 22px; }
.modal-header h2 { font-size: 21px; margin: 2px 0 0; }
.eyebrow { color: var(--blue); font-size: 10px; letter-spacing: .9px; font-weight: 850; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; }
.form-grid label { color: #475267; font-size: 12px; font-weight: 700; }
.form-grid label > span { color: var(--red); }
.form-grid input, .form-grid select, .form-grid textarea { margin-top: 6px; font-weight: 450; }
.form-grid .full-width { grid-column: 1 / -1; }
.toggle-label { display: flex; flex-direction: column; }
.toggle-control { display: flex; align-items: center; gap: 8px; color: var(--ink) !important; margin-top: 12px; }
.toggle-control input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-control i { width: 38px; height: 21px; border-radius: 30px; background: #b8c0cd; position: relative; transition: .2s; }
.toggle-control i::after { content: ""; width: 15px; height: 15px; border-radius: 50%; background: #fff; position: absolute; top: 3px; left: 3px; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: .2s; }
.toggle-control input:checked + i { background: var(--blue); }
.toggle-control input:checked + i::after { transform: translateX(17px); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 22px; margin-top: 21px; border-top: 1px solid var(--line); }
.form-hint { margin: 15px 0 0; padding: 10px 12px; background: #f2f6fc; border-radius: 8px; color: var(--muted); font-size: 11px; }

.toast-region { position: fixed; z-index: 50; right: 22px; bottom: 22px; display: grid; gap: 9px; }
.toast { min-width: 290px; max-width: 400px; background: var(--navy-900); color: #fff; border-radius: 10px; padding: 13px 15px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 10px; animation: toast-in .22s ease both; }
.toast.success::before { content: "✓"; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--teal); font-weight: 900; }
.toast.error::before { content: "!"; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--red); font-weight: 900; }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } }

.sidebar-overlay { display: none; }
@media (max-width: 1050px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 800px) {
  .sidebar { transform: translateX(-100%); transition: transform .23s ease; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay { display: block; position: fixed; inset: 0; background: rgba(6,16,31,.45); z-index: 19; opacity: 0; pointer-events: none; transition: opacity .2s; }
  .sidebar-overlay.open { opacity: 1; pointer-events: auto; }
  .workspace { margin-left: 0; width: 100%; }
  .menu-button { display: inline-grid !important; }
  .metric-grid { grid-template-columns: 1fr; gap: 12px; }
  .topbar { min-height: 72px; }
  .content { padding: 22px 16px; }
}
@media (max-width: 580px) {
  .page-heading { align-items: stretch; flex-direction: column; }
  .page-heading .button { width: 100%; }
  .topbar-actions .docs-link { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full-width { grid-column: auto; }
  .toolbar { flex-wrap: wrap; }
  .search-control { width: 100%; }
  .toolbar .filter-select { margin-left: 0; flex: 1; }
  .modal form { padding: 20px; }
  .modal-actions .button { flex: 1; }
  th, td { padding-left: 13px; padding-right: 13px; }
  .toast-region { left: 14px; right: 14px; bottom: 14px; }
  .toast { min-width: 0; width: 100%; }
}
