:root {
  --bg: #EDF0EF;
  --surface: #FFFFFF;
  --ink: #1B2430;
  --muted: #5B6570;
  --line: #CBD2D4;
  --line-strong: #9AA5A8;

  --gudang1: #2C4A6E;
  --gudang1-soft: #E4EAF1;
  --gudang2: #3F6E5E;
  --gudang2-soft: #E4EFEB;
  --amber: #B97A1E;
  --amber-dark: #98630F;
  --rust: #A6432C;
  --rust-dark: #8A3521;

  --radius: 3px;
  --font: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
}

button, input, select {
  font-family: inherit;
}

.hidden { display: none !important; }

/* ---------- Layout ---------- */

.app {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.side {
  background: var(--ink);
  color: #EDF0EF;
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 4px;
}

.brand-mark {
  font-size: 20px;
  color: var(--amber);
}

.brand-text {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.25;
  letter-spacing: 0.2px;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  color: #C6CDCF;
  padding: 11px 10px;
  font-size: 14.5px;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
}

.nav-btn:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}

.nav-btn.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-weight: 600;
}

.nav-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  font-size: 11.5px;
  font-weight: 700;
  border-radius: 2px;
  flex-shrink: 0;
}

.tag-1 { background: var(--gudang1); color: #fff; }
.tag-2 { background: var(--gudang2); color: #fff; }
.tag-r { background: #454F5C; color: #fff; }
.tag-s { background: var(--amber); color: #fff; }
.tag-l { background: #454F5C; color: #fff; }

.content {
  padding: 36px 44px;
  max-width: 980px;
}

/* ---------- View header ---------- */

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 16px;
  flex-wrap: wrap;
}

.view-header h1 {
  font-size: 26px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.2px;
}

.filter-group {
  display: flex;
  gap: 8px;
}

.filter-group select {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 13.5px;
  color: var(--ink);
}

/* ---------- Stat strip ---------- */

.stat-strip {
  display: flex;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  margin-bottom: 26px;
  width: fit-content;
}

.stat {
  background: var(--surface);
  padding: 14px 26px;
  display: flex;
  flex-direction: column;
  min-width: 130px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* ---------- Search bar ---------- */

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  padding: 0 12px;
  max-width: 360px;
  margin-bottom: 18px;
}

.search-bar-lg {
  max-width: 480px;
  margin-bottom: 26px;
  padding: 2px 14px;
}

.search-icon {
  color: var(--muted);
  font-size: 15px;
}

.search-bar input {
  border: none;
  outline: none;
  padding: 10px 0;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  width: 100%;
  background: transparent;
}

/* ---------- Login page ---------- */

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
}

.login-wrap {
  width: 100%;
  max-width: 380px;
  padding: 20px;
}

.login-card {
  background: var(--surface);
  padding: 32px 28px;
  border-top: 3px solid var(--amber);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 17px;
  margin-bottom: 6px;
}

.login-sub {
  color: var(--muted);
  font-size: 13.5px;
  margin: 0 0 22px;
}

.login-card label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
}

.login-card input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-size: 14.5px;
  color: var(--ink);
  font-family: inherit;
}

.login-submit {
  width: 100%;
  padding: 11px;
  margin-top: 6px;
  font-size: 14.5px;
}

/* ---------- Sidebar user footer ---------- */

.side-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.side-user {
  font-size: 12.5px;
  color: #C6CDCF;
  margin-bottom: 8px;
  line-height: 1.5;
}

.side-user strong {
  color: #fff;
  display: block;
  font-size: 13.5px;
}

.role-badge {
  display: inline-block;
  margin-top: 3px;
  padding: 2px 7px;
  border-radius: 2px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  background: var(--amber);
  color: #fff;
}

.role-badge.staff { background: #454F5C; }

.side-link {
  display: block;
  width: 100%;
  background: transparent;
  border: none;
  color: #9AA9AE;
  padding: 4px 0 10px;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.side-link:hover { color: #fff; }

.btn-logout {
  width: 100%;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.18);
  color: #C6CDCF;
  padding: 8px 10px;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.btn-logout:hover { background: rgba(255,255,255,0.08); color: #fff; }

/* ---------- Item description & tags ---------- */

.item-nama-main { font-weight: 500; }

.item-desc {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}

.tag-chip {
  display: inline-block;
  padding: 2px 8px;
  background: #EEF1EF;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 10.5px;
  color: var(--muted);
}

/* ---------- Tag filter select ---------- */

.filter-tag select {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 13px;
  color: var(--ink);
}

.toolbar-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.toolbar-row .search-bar { margin-bottom: 0; }

/* ---------- Kelola Akun ---------- */

.role-pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 2px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.role-pill-admin { background: var(--gudang1-soft); color: var(--gudang1); }
.role-pill-staff { background: #EEF1EF; color: var(--muted); }

/* ---------- Ledger table ---------- */

.table-wrap {
  border: 1px solid var(--line);
  background: var(--surface);
}

.ledger {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.ledger thead th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.3px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-strong);
  background: #F5F7F6;
}

.ledger .col-num { text-align: right; width: 110px; }
.ledger .col-actions { text-align: right; width: 240px; }

.ledger tbody tr {
  border-bottom: 1px solid var(--line);
}

.ledger tbody tr:last-child { border-bottom: none; }

.ledger tbody tr:hover { background: #FAFBFA; }

.ledger td {
  padding: 13px 16px;
  vertical-align: middle;
}

.ledger td.col-num {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 15px;
}

.ledger td.col-actions {
  text-align: right;
  white-space: nowrap;
}

.item-name {
  font-weight: 500;
}

.empty-row td {
  text-align: center;
  color: var(--muted);
  padding: 30px 16px;
  font-size: 13.5px;
}

.qty-low {
  color: var(--rust-dark);
}

.qty-zero {
  color: var(--rust-dark);
  opacity: 0.65;
}

/* ---------- Buttons ---------- */

.btn {
  border: none;
  border-radius: var(--radius);
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.btn-primary {
  background: var(--ink);
  color: #fff;
}
.btn-primary:hover { background: #29323D; }

.btn-secondary {
  background: var(--amber);
  color: #fff;
}
.btn-secondary:hover { background: var(--amber-dark); }

.btn-danger {
  background: var(--rust);
  color: #fff;
}
.btn-danger:hover { background: var(--rust-dark); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line-strong);
}
.btn-ghost:hover { background: #F0F2F1; }

.row-actions {
  display: inline-flex;
  gap: 8px;
}

.btn-sm {
  padding: 7px 12px;
  font-size: 12.5px;
}

.btn-icon-del {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  padding: 6px 8px;
}
.btn-icon-del:hover { color: var(--rust-dark); }

/* ---------- Riwayat badges ---------- */

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 2px;
  font-size: 11.5px;
  font-weight: 600;
}

.badge-ambil { background: #F3E2DD; color: var(--rust-dark); }
.badge-tambah { background: #E4EFEB; color: var(--gudang2); }

.badge-gudang-1 { background: var(--gudang1-soft); color: var(--gudang1); }
.badge-gudang-2 { background: var(--gudang2-soft); color: var(--gudang2); }

.muted { color: var(--muted); }

/* ---------- Laporan ---------- */

.laporan-desc {
  color: var(--muted);
  font-size: 14px;
  max-width: 560px;
  margin: -8px 0 26px;
  line-height: 1.6;
}

.laporan-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  max-width: 720px;
}

.laporan-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--ink);
  padding: 20px;
}

.laporan-card h2 {
  font-size: 16px;
  margin: 0 0 8px;
  font-weight: 600;
}

.laporan-card p {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
  margin: 0 0 16px;
}

.laporan-card .btn {
  display: inline-block;
  text-decoration: none;
}

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 26, 32, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal {
  background: var(--surface);
  border-radius: 4px;
  padding: 28px;
  width: 100%;
  max-width: 380px;
  border-top: 3px solid var(--ink);
}

.modal h2 {
  margin: 0 0 4px;
  font-size: 19px;
  font-weight: 600;
}

.modal-sub {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13.5px;
}

.modal label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
}

.modal input, .modal textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-size: 14.5px;
  color: var(--ink);
  font-family: inherit;
}

.modal textarea {
  resize: vertical;
  min-height: 64px;
}

.modal-wide {
  max-width: 440px;
}

.field-hint {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  margin-top: 4px;
  font-weight: 400;
}

.modal input:focus, .filter-group select:focus, .nav-btn:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 1px;
}

.form-error {
  background: #F3E2DD;
  color: var(--rust-dark);
  font-size: 13px;
  padding: 8px 10px;
  border-radius: var(--radius);
  margin: -4px 0 14px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13.5px;
  z-index: 100;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
}

.toast.toast-error {
  background: var(--rust-dark);
}

/* ---------- Responsive ---------- */

@media (max-width: 760px) {
  .app {
    grid-template-columns: 1fr;
  }
  .side {
    flex-direction: row;
    align-items: center;
    padding: 14px 16px;
    gap: 16px;
    overflow-x: auto;
  }
  .brand { display: none; }
  .nav-list {
    flex-direction: row;
    gap: 6px;
  }
  .nav-btn { white-space: nowrap; }
  .content { padding: 24px 18px; }
  .ledger .col-actions { width: auto; }
  .row-actions { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
