:root {
  --ink: #17211f;
  --muted: #67736f;
  --line: #dde3de;
  --surface: #ffffff;
  --canvas: #f4f6f2;
  --green-950: #0c2723;
  --green-900: #14352f;
  --green-800: #1d4c43;
  --green-700: #28665a;
  --green-100: #dfebe7;
  --green-50: #edf5f2;
  --amber: #f4b942;
  --amber-soft: #fff4d9;
  --orange: #ec8b38;
  --red: #c33d3d;
  --red-soft: #fce8e8;
  --blue-soft: #e5eefc;
  --shadow-sm: 0 2px 8px rgb(13 42 36 / 6%);
  --shadow-md: 0 14px 36px rgb(13 42 36 / 12%);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --sidebar: 260px;
  font-family: "DM Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
svg { display: block; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.boot-screen {
  min-height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  color: var(--muted);
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: var(--green-950);
  background: var(--amber);
  font-weight: 800;
  letter-spacing: -1px;
}

/* Login */
.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(340px, 0.9fr) minmax(520px, 1.1fr);
  background: var(--surface);
}

.auth-form-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px clamp(28px, 6vw, 92px);
}

.auth-form { width: min(100%, 430px); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 56px; }
.auth-brand strong { color: var(--green-900); font-size: 22px; letter-spacing: -0.7px; }
.auth-form h1 { margin: 0 0 10px; font-size: clamp(30px, 4vw, 42px); line-height: 1.05; letter-spacing: -1.6px; }
.auth-form > p { color: var(--muted); margin: 0 0 34px; line-height: 1.6; }
.auth-form .field + .field { margin-top: 18px; }
.auth-actions { display: grid; gap: 12px; margin-top: 26px; }
.auth-switch { text-align: center; color: var(--muted); font-size: 14px; }
.auth-switch button { border: 0; background: transparent; color: var(--green-700); font-weight: 700; padding: 4px; }
.demo-hint { margin-top: 24px; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--green-50); color: var(--green-800); font-size: 13px; line-height: 1.5; }
.demo-hint strong { color: var(--green-950); }

.auth-visual {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  display: flex;
  align-items: flex-end;
  padding: clamp(42px, 7vw, 104px);
  background:
    linear-gradient(140deg, rgb(12 39 35 / 88%), rgb(20 53 47 / 96%)),
    repeating-linear-gradient(90deg, transparent 0 79px, rgb(255 255 255 / 4%) 80px),
    var(--green-900);
  color: white;
}

.auth-visual::before,
.auth-visual::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgb(255 255 255 / 10%);
}
.auth-visual::before { width: 560px; height: 560px; top: -180px; right: -130px; }
.auth-visual::after { width: 360px; height: 360px; top: -80px; right: -30px; }
.visual-content { position: relative; z-index: 1; max-width: 600px; }
.visual-eyebrow { color: var(--amber); font-weight: 700; text-transform: uppercase; letter-spacing: 1.8px; font-size: 12px; }
.visual-content h2 { margin: 18px 0; font-size: clamp(40px, 5.5vw, 72px); line-height: 0.98; letter-spacing: -3px; }
.visual-content p { color: rgb(255 255 255 / 68%); line-height: 1.7; max-width: 520px; }
.visual-stats { display: flex; gap: 34px; margin-top: 38px; }
.visual-stats strong { display: block; font-size: 25px; color: var(--amber); }
.visual-stats span { font-size: 13px; color: rgb(255 255 255 / 60%); }

/* App shell */
.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  background: var(--green-950);
  color: white;
}

.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 0 10px 24px; }
.sidebar-brand .brand-mark { width: 39px; height: 39px; border-radius: 11px; font-size: 14px; }
.brand-copy strong { display: block; letter-spacing: -0.4px; }
.brand-copy span { color: rgb(255 255 255 / 48%); font-size: 11px; }
.sidebar-nav { display: grid; gap: 6px; margin-top: 18px; }
.nav-label { padding: 0 13px 8px; color: rgb(255 255 255 / 37%); font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px; font-weight: 700; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 13px;
  border: 0;
  border-radius: 11px;
  color: rgb(255 255 255 / 62%);
  background: transparent;
  text-align: left;
  font-weight: 600;
  font-size: 14px;
  transition: 160ms ease;
}
.nav-item:hover { color: white; background: rgb(255 255 255 / 6%); }
.nav-item.active { color: var(--green-950); background: var(--amber); box-shadow: 0 8px 20px rgb(0 0 0 / 12%); }
.nav-item svg { width: 19px; height: 19px; }
.sidebar-bottom { margin-top: auto; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 13px 10px; border-top: 1px solid rgb(255 255 255 / 8%); margin-top: 10px; }
.avatar { width: 35px; height: 35px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--green-700); font-weight: 700; font-size: 13px; }
.user-meta { min-width: 0; }
.user-meta strong, .user-meta span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta strong { font-size: 13px; }
.user-meta span { font-size: 11px; color: rgb(255 255 255 / 45%); }

.main { margin-left: var(--sidebar); min-height: 100vh; }
.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 clamp(20px, 4vw, 50px);
  border-bottom: 1px solid var(--line);
  background: rgb(244 246 242 / 86%);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { margin: 0; font-size: 21px; letter-spacing: -0.7px; }
.topbar-date { color: var(--muted); font-size: 13px; }
.mobile-menu { display: none; }
.content { padding: 34px clamp(20px, 4vw, 50px) 64px; max-width: 1500px; margin: 0 auto; }

/* Reusable */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.page-head h2 { margin: 0 0 7px; font-size: 28px; letter-spacing: -1px; }
.page-head p { margin: 0; color: var(--muted); }
.page-actions { display: flex; gap: 10px; }
.btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 14px;
  transition: 160ms ease;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }
.btn-primary { color: white; background: var(--green-800); }
.btn-primary:hover { background: var(--green-900); transform: translateY(-1px); }
.btn-accent { color: var(--green-950); background: var(--amber); }
.btn-accent:hover { background: #e9aa2c; transform: translateY(-1px); }
.btn-ghost { color: var(--ink); background: var(--surface); border-color: var(--line); }
.btn-ghost:hover { border-color: #bdc8c1; background: #fafbf9; }
.btn-danger { color: var(--red); background: var(--red-soft); }
.btn-icon { width: 38px; min-height: 38px; padding: 8px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); }
.btn-icon:hover { background: var(--green-50); color: var(--green-800); }
.btn-icon.danger:hover { color: var(--red); background: var(--red-soft); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; font-size: 16px; letter-spacing: -0.35px; }
.panel-body { padding: 22px; }
.section-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, 0.75fr); gap: 20px; margin-top: 20px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat-card { position: relative; overflow: hidden; min-height: 142px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.stat-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; color: var(--green-800); background: var(--green-50); }
.stat-icon.amber { background: var(--amber-soft); color: #9a6910; }
.stat-icon.red { background: var(--red-soft); color: var(--red); }
.stat-icon.blue { background: var(--blue-soft); color: #3164a8; }
.stat-icon svg { width: 21px; height: 21px; }
.stat-value { margin-top: 18px; font-size: 25px; line-height: 1; letter-spacing: -1px; font-weight: 700; }
.stat-label { margin-top: 7px; color: var(--muted); font-size: 12px; }
.trend { position: absolute; right: 16px; top: 18px; padding: 4px 7px; border-radius: 20px; color: var(--green-700); background: var(--green-50); font-size: 10px; font-weight: 700; }

.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick-action { min-height: 105px; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: #fafbf9; color: var(--ink); text-align: left; font-weight: 700; }
.quick-action:hover { border-color: #aec0b7; background: var(--green-50); }
.quick-action svg { width: 22px; height: 22px; color: var(--green-700); }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.search-box { position: relative; width: min(100%, 380px); }
.search-box svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: #87918e; pointer-events: none; }
.search-box input { width: 100%; min-height: 42px; padding: 9px 13px 9px 40px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); outline: none; }
.search-box input:focus { border-color: var(--green-700); box-shadow: 0 0 0 3px rgb(40 102 90 / 12%); }
.filter-row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.filter-row .field { min-width: 150px; flex: 1; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--muted); background: #fafbf9; text-align: left; text-transform: uppercase; letter-spacing: 0.6px; font-size: 10px; }
td { padding: 15px 16px; border-bottom: 1px solid #edf0ed; font-size: 13px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfcfa; }
.cell-main { display: block; font-weight: 700; color: var(--ink); }
.cell-sub { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.table-actions { display: flex; justify-content: flex-end; gap: 2px; }
.number { font-variant-numeric: tabular-nums; }
.align-right { text-align: right; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 5px 9px; border-radius: 99px; font-size: 11px; font-weight: 700; }
.badge.success, .badge.entry { color: #23664f; background: #e2f3eb; }
.badge.warning { color: #91620a; background: var(--amber-soft); }
.badge.danger, .badge.exit { color: #a33131; background: var(--red-soft); }
.badge.neutral { color: #59645f; background: #edf0ed; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.empty-state { min-height: 260px; display: grid; place-content: center; justify-items: center; padding: 40px; text-align: center; color: var(--muted); }
.empty-icon { width: 54px; height: 54px; display: grid; place-items: center; margin-bottom: 12px; border-radius: 16px; color: var(--green-700); background: var(--green-50); }
.empty-icon svg { width: 26px; height: 26px; }
.empty-state h3 { margin: 4px 0 6px; color: var(--ink); font-size: 16px; }
.empty-state p { max-width: 380px; margin: 0; font-size: 13px; line-height: 1.55; }

.stock-name { display: flex; align-items: center; gap: 10px; }
.stock-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green-700); box-shadow: 0 0 0 4px var(--green-50); }
.stock-dot.low { background: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }
.stock-meter { width: 86px; height: 5px; overflow: hidden; border-radius: 99px; background: #e8ece8; }
.stock-meter span { display: block; height: 100%; border-radius: inherit; background: var(--green-700); }
.stock-meter span.low { background: var(--red); }

/* Forms and modal */
.field { display: grid; gap: 7px; }
.field label { color: #3d4945; font-size: 12px; font-weight: 700; }
.required::after { content: " *"; color: var(--red); }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 43px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: 150ms ease;
}
.field textarea { min-height: 86px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--green-700); box-shadow: 0 0 0 3px rgb(40 102 90 / 12%); }
.field small { color: var(--muted); font-size: 11px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.form-grid .span-2 { grid-column: span 2; }
.radio-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.radio-card { position: relative; }
.radio-card input { position: absolute; opacity: 0; pointer-events: none; }
.radio-card label { min-height: 74px; display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.radio-card label svg { width: 22px; height: 22px; color: var(--muted); }
.radio-card input:checked + label { border-color: var(--green-700); background: var(--green-50); box-shadow: 0 0 0 2px rgb(40 102 90 / 10%); }
.radio-card input:checked + label svg { color: var(--green-700); }
.radio-card strong { display: block; font-size: 13px; }
.radio-card span { color: var(--muted); font-size: 11px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; background: rgb(8 25 22 / 55%); backdrop-filter: blur(4px); animation: fade-in 150ms ease; }
.modal { width: min(100%, 610px); max-height: calc(100vh - 40px); overflow-y: auto; border-radius: var(--radius-lg); background: var(--surface); box-shadow: 0 28px 80px rgb(0 0 0 / 25%); animation: rise 180ms ease; }
.modal.small { max-width: 440px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 23px 24px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0 0 5px; font-size: 21px; letter-spacing: -0.6px; }
.modal-head p { margin: 0; color: var(--muted); font-size: 12px; }
.modal-body { padding: 22px 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 17px 24px 22px; border-top: 1px solid var(--line); }
.summary-box { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; padding: 15px; border-radius: 11px; background: var(--green-50); color: var(--green-900); }
.summary-box span { font-size: 12px; }
.summary-box strong { font-size: 18px; }

/* Reports */
.report-header { padding: 22px; }
.report-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.report-title-row h3 { margin: 0 0 5px; font-size: 20px; }
.report-title-row p { margin: 0; color: var(--muted); font-size: 13px; }
.report-totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 20px; }
.report-total { padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: #fafbf9; }
.report-total span { display: block; color: var(--muted); font-size: 11px; }
.report-total strong { display: block; margin-top: 5px; font-size: 19px; }
.report-total.balance strong { color: var(--green-700); }

.toast-region { position: fixed; top: 18px; right: 18px; z-index: 120; display: grid; gap: 10px; width: min(360px, calc(100vw - 36px)); }
.toast { display: flex; align-items: flex-start; gap: 11px; padding: 14px 16px; border: 1px solid var(--line); border-left: 4px solid var(--green-700); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-md); animation: slide-in 200ms ease; }
.toast.error { border-left-color: var(--red); }
.toast strong { display: block; margin-bottom: 2px; font-size: 13px; }
.toast span { color: var(--muted); font-size: 12px; line-height: 1.4; }
.toast svg { width: 19px; height: 19px; flex: 0 0 auto; color: var(--green-700); }
.toast.error svg { color: var(--red); }

.loading { display: grid; place-content: center; min-height: 320px; color: var(--muted); }
.spinner { width: 28px; height: 28px; margin: 0 auto 12px; border: 3px solid var(--green-100); border-top-color: var(--green-700); border-radius: 50%; animation: spin 0.75s linear infinite; }
.sidebar-overlay { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(12px) scale(0.985); opacity: 0; } }
@keyframes slide-in { from { transform: translateX(15px); opacity: 0; } }

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .auth-form-wrap { padding: 34px 24px; }
  .auth-brand { margin-bottom: 44px; }
  .sidebar { transform: translateX(-105%); transition: transform 180ms ease; box-shadow: var(--shadow-md); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay { position: fixed; inset: 0; z-index: 25; display: block; visibility: hidden; opacity: 0; background: rgb(8 25 22 / 45%); transition: 180ms ease; }
  .sidebar-overlay.show { visibility: visible; opacity: 1; }
  .main { margin-left: 0; }
  .mobile-menu { display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
  .topbar { height: 68px; padding-inline: 16px; justify-content: flex-start; }
  .topbar-date { margin-left: auto; }
  .content { padding: 24px 16px 50px; }
}

@media (max-width: 620px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { min-height: 128px; padding: 16px; }
  .stat-value { font-size: 21px; }
  .trend { display: none; }
  .page-head { align-items: stretch; flex-direction: column; margin-bottom: 22px; }
  .page-head h2 { font-size: 24px; }
  .page-actions .btn { flex: 1; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .search-box { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  .modal-backdrop { padding: 0; align-items: end; }
  .modal { width: 100%; max-height: 92vh; border-radius: 22px 22px 0 0; }
  .modal-head, .modal-body { padding-inline: 18px; }
  .modal-foot { padding: 15px 18px 22px; }
  .modal-foot .btn { flex: 1; }
  .report-totals { grid-template-columns: 1fr; }
  .report-title-row { flex-direction: column; }
  .filter-row { display: grid; grid-template-columns: 1fr 1fr; }
  .filter-row .field:first-child { grid-column: span 2; }
}

@media print {
  body { background: white; }
  .sidebar, .topbar, .page-head, .filter-panel, .no-print, .toast-region { display: none !important; }
  .main { margin: 0; }
  .content { max-width: none; padding: 0; }
  .panel { border: 0; box-shadow: none; }
  .table-wrap { overflow: visible; }
  table { white-space: normal; }
  th, td { padding: 8px; }
}
