:root {
  --bg: #0d1018;
  --bg-deep: #090c12;
  --sidebar: #151a25;
  --card: #151b28;
  --card-soft: #1a2233;
  --border: #273149;
  --border-soft: #202a3f;
  --text: #dce7ff;
  --muted: #7d8ba8;
  --muted-2: #5f6d88;
  --blue: #4b8dff;
  --blue-2: #2563eb;
  --green: #21d07a;
  --yellow: #ffad1f;
  --red: #ff565e;
  --purple: #7c4dff;
  --shadow: 0 20px 50px rgba(0, 0, 0, .24);
  --radius: 14px;
  --sidebar-width: 272px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-deep);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

body.light-theme {
  --bg: #edf2fb;
  --bg-deep: #e6edf8;
  --sidebar: #ffffff;
  --card: #ffffff;
  --card-soft: #eef4ff;
  --border: #d9e3f3;
  --border-soft: #e6edf8;
  --text: #172033;
  --muted: #64708a;
  --muted-2: #7f8aa1;
  color-scheme: light;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  background: var(--sidebar);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.brand {
  padding: 26px 22px 22px;
  display: flex;
  align-items: center;
  gap: 13px;
  border-bottom: 1px solid var(--border-soft);
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(255, 172, 31, .14);
}

.brand-mark.logo {
  overflow: hidden;
  background: linear-gradient(135deg, rgba(75, 141, 255, .25), rgba(33, 208, 122, .14));
  border: 1px solid rgba(75, 141, 255, .28);
}

.brand-mark.logo img {
  width: 100%;
  height: 100%;
  display: block;
}

.brand-title {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -.03em;
}

.brand-title span {
  color: var(--blue);
}

.role-badge {
  display: inline-flex;
  margin-top: 12px;
  padding: 5px 10px;
  color: #8fb8ff;
  border-radius: 6px;
  background: rgba(75, 141, 255, .15);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
}

.nav {
  padding: 20px 0;
  overflow-y: auto;
  flex: 1;
}

.nav p {
  margin: 20px 22px 8px;
  color: var(--muted-2);
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .11em;
}

.nav p:first-child {
  margin-top: 0;
}

.nav-item {
  width: 100%;
  border: 0;
  color: var(--muted);
  background: transparent;
  padding: 13px 22px;
  text-align: left;
  font-weight: 700;
  display: block;
  border-left: 3px solid transparent;
}

.nav-item:hover,
.nav-item.active {
  color: #77aaff;
  background: rgba(75, 141, 255, .13);
  border-left-color: var(--blue);
}

.profile {
  min-height: 72px;
  padding: 14px 18px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: white;
  background: var(--blue);
}

.profile-meta {
  min-width: 0;
  flex: 1;
}

.profile strong,
.profile span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile strong {
  font-size: 12px;
}

.profile span {
  color: var(--muted);
  margin-top: 3px;
  font-size: 11px;
}

.logout {
  color: var(--muted-2);
  background: transparent;
  border: 0;
  padding: 6px;
  border-radius: 8px;
  line-height: 1;
}

.logout:hover {
  color: var(--text);
  background: rgba(255, 255, 255, .06);
}

.main {
  min-height: 100vh;
  margin-left: var(--sidebar-width);
  background: var(--bg-deep);
}

.topbar {
  height: 42px;
  padding: 0 18px 0 34px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(10, 13, 20, .62);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.light-theme .topbar {
  background: rgba(255, 255, 255, .8);
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -.02em;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stock-alert {
  border: 1px solid rgba(255, 86, 94, .2);
  background: rgba(255, 86, 94, .13);
  color: var(--red);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 800;
  font-size: 12px;
}

.circle-btn,
.theme-btn {
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--card);
  border-radius: 999px;
  height: 32px;
}

.circle-btn {
  width: 32px;
}

.theme-btn {
  padding: 0 13px;
  font-weight: 700;
}

.view {
  display: none;
  padding: 34px;
}

.view.active {
  display: block;
}

.period-row {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  margin-bottom: 22px;
}

.period-btn {
  border: 0;
  color: var(--muted);
  background: var(--card-soft);
  border-radius: 999px;
  padding: 9px 20px;
  font-size: 12px;
  font-weight: 800;
}

.period-btn.active {
  color: #ffffff;
  background: var(--blue);
  box-shadow: 0 12px 25px rgba(75, 141, 255, .28);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.kpi-card {
  min-height: 108px;
  padding: 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
}

.kpi-card .label {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .1em;
}

.kpi-card .value {
  margin-top: 8px;
  font-size: 34px;
  font-weight: 900;
  line-height: 1;
}

.kpi-card .icon {
  font-size: 34px;
  opacity: .32;
}

.kpi-card.blue .value { color: var(--blue); }
.kpi-card.yellow .value { color: var(--yellow); }
.kpi-card.green .value { color: var(--green); }
.kpi-card.red .value { color: var(--red); }
.kpi-card.purple .value { color: var(--purple); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  min-width: 0;
}

.card-title {
  color: #9cacce;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
  margin-bottom: 16px;
}

.card-title.warning {
  color: #c9a665;
}

.card-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.card-toolbar .card-title {
  margin-bottom: 0;
}

.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.trend-card,
.status-card {
  min-height: 286px;
}

#trendCanvas {
  width: 100%;
  display: block;
}

.status-wrap {
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
}

.legend {
  display: grid;
  gap: 10px;
  min-width: 130px;
}

.legend-item {
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 700;
}

.legend-swatch {
  width: 42px;
  height: 10px;
  border-radius: 4px;
}

.mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.bottom-grid {
  display: grid;
  grid-template-columns: minmax(300px, .9fr) minmax(280px, .9fr) minmax(280px, .9fr);
  gap: 18px;
  align-items: start;
}

.low-stock-card {
  max-height: none;
}

.low-stock-list,
.activity-list,
.dept-stock-list,
.list {
  display: grid;
  gap: 8px;
}

.low-row,
.activity-row,
.dept-row,
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(39, 49, 73, .45);
  padding: 7px 0;
  color: var(--text);
}

.low-row .name,
.activity-row .name,
.list-row .name,
.dept-row .name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
  font-size: 13px;
}

.low-row .qty {
  color: var(--red);
  font-weight: 900;
  white-space: nowrap;
  font-size: 12px;
}

.muted-list,
.empty {
  color: var(--muted);
}

.activity-row {
  align-items: flex-start;
  padding: 9px 0;
}

.activity-row p {
  margin: 0;
  color: var(--text);
  font-weight: 800;
}

.activity-row span {
  color: var(--muted);
  display: block;
  margin-top: 3px;
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}

.badge.Pending { color: #ffe0a3; background: rgba(255, 173, 31, .16); }
.badge.Approved { color: #91bdff; background: rgba(75, 141, 255, .16); }
.badge.Delivered { color: #7affb7; background: rgba(33, 208, 122, .16); }
.badge.Rejected { color: #ff9fa4; background: rgba(255, 86, 94, .16); }
.badge.low { color: #ff9fa4; background: rgba(255, 86, 94, .16); }
.badge.ok { color: #7affb7; background: rgba(33, 208, 122, .16); }
.badge.locked { color: #f4d28b; background: rgba(244, 210, 139, .14); }

.content-grid {
  display: grid;
  gap: 18px;
}

.two-col {
  grid-template-columns: 360px minmax(0, 1fr);
}

.two-col.equal {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-card {
  align-self: start;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  background: rgba(9, 12, 18, .55);
  padding: 11px 12px;
  outline: none;
}

.light-theme input,
.light-theme select,
.light-theme textarea {
  background: #f7f9fd;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(75, 141, 255, .12);
}

.primary-btn,
.ghost-btn,
.danger-btn,
.success-btn,
.warn-btn,
.file-btn {
  min-height: 42px;
  border: 0;
  border-radius: 10px;
  padding: 0 14px;
  font-weight: 900;
}

.primary-btn {
  color: #ffffff;
  background: var(--blue);
}

.ghost-btn {
  color: var(--text);
  border: 1px solid var(--border);
  background: transparent;
}

.success-btn { color: #082315; background: var(--green); }
.warn-btn { color: #241701; background: var(--yellow); }
.danger-btn { color: white; background: var(--red); }

.small-select,
.search {
  max-width: 220px;
}

.table-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.small-action {
  min-height: 36px;
  padding: 0 12px;
  font-size: 12px;
  white-space: nowrap;
}

.file-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  border: 1px solid var(--border);
  background: rgba(75, 141, 255, .08);
  text-transform: none;
  letter-spacing: 0;
}

.file-btn:hover,
.ghost-btn:hover {
  border-color: rgba(75, 141, 255, .55);
  background: rgba(75, 141, 255, .13);
}

.code-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  color: #9ec2ff;
  background: rgba(75, 141, 255, .12);
  border: 1px solid rgba(75, 141, 255, .18);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .02em;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 16px;
}

.inline-form.two-inputs {
  grid-template-columns: 1fr 130px auto;
}

.table-wrap {
  overflow: auto;
  max-width: 100%;
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.compact-table table {
  min-width: 0;
}

th,
td {
  border-bottom: 1px solid rgba(39, 49, 73, .55);
  padding: 12px 10px;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .06em;
}

td {
  color: var(--text);
  font-size: 13px;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.table-actions button {
  min-height: 31px;
  border-radius: 8px;
  padding: 0 10px;
  font-size: 11px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 100;
  background: #101827;
  color: white;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 13px 16px;
  border-radius: 12px;
  font-weight: 800;
  opacity: 0;
  transform: translateY(18px);
  pointer-events: none;
  transition: .2s ease;
  max-width: 360px;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  border-color: rgba(255, 86, 94, .45);
  color: #ffd6d8;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: #2b3650;
  border-radius: 999px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

@media (max-width: 1180px) {
  :root { --sidebar-width: 232px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
  .charts-grid,
  .mini-grid,
  .bottom-grid,
  .two-col,
  .two-col.equal { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .sidebar {
    position: static;
    width: 100%;
    min-height: auto;
  }

  .nav {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    max-height: 340px;
  }

  .nav p {
    grid-column: 1 / -1;
  }

  .main {
    margin-left: 0;
  }

  .topbar {
    position: static;
    height: auto;
    padding: 18px;
    align-items: flex-start;
    gap: 14px;
    flex-direction: column;
  }

  .view {
    padding: 18px;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .period-row,
  .top-actions,
  .card-toolbar,
  .status-wrap {
    flex-wrap: wrap;
  }

  .form-grid,
  .inline-form,
  .inline-form.two-inputs {
    grid-template-columns: 1fr;
  }

  .small-select,
  .search,
  .table-tools {
    max-width: none;
    width: 100%;
  }

  .table-tools {
    justify-content: stretch;
  }

  .table-tools .search,
  .table-tools .small-action {
    flex: 1 1 auto;
  }
}

/* Responsive and access-control refinements */
.main,
.view,
.card,
.table-card,
.form-card {
  min-width: 0;
}

.main {
  overflow-x: hidden;
}

.view {
  padding: clamp(16px, 3vw, 34px);
}

.kpi-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr));
}

.charts-grid {
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
}

.mini-grid,
.bottom-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
}

.two-col {
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
}

.two-col.equal {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
}

.card {
  overflow: hidden;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-wrap table {
  min-width: 760px;
}

.compact-table table {
  min-width: 520px;
}

.helper-text {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.disabled-card {
  opacity: .62;
}

.disabled-card::after {
  content: "Akses dibatasi sesuai role user.";
  display: block;
  margin-top: 12px;
  color: var(--yellow);
  font-size: 12px;
  font-weight: 800;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: .6;
}

body.cannot-users .requires-users {
  display: none !important;
}

.badge.inactive {
  color: #cbd5e1;
  background: rgba(125, 139, 168, .18);
}

.inactive-row {
  opacity: .62;
}

.category-form {
  grid-template-columns: minmax(180px, 1fr) auto auto;
}

.department-form,
.inline-form.two-inputs.department-form {
  grid-template-columns: minmax(160px, 1fr) 130px auto auto;
}

#userTableCard {
  margin-top: 18px;
}

#trendCanvas,
#statusCanvas {
  max-width: 100%;
}

.status-wrap {
  min-width: 0;
}

button,
.file-btn {
  touch-action: manipulation;
}

.primary-btn:hover,
.success-btn:hover,
.warn-btn:hover,
.danger-btn:hover,
.theme-btn:hover,
.circle-btn:hover {
  filter: brightness(1.06);
}

@media (max-width: 900px) {
  .charts-grid,
  .two-col,
  .department-form,
  .inline-form.two-inputs.department-form,
  .category-form {
    grid-template-columns: 1fr;
  }

  .content-grid {
    gap: 14px;
  }

  .card {
    padding: 16px;
  }
}

@media (max-width: 760px) {
  .brand {
    padding: 18px;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav-item {
    padding: 12px 16px;
  }

  .profile {
    min-height: 64px;
  }

  .top-actions {
    width: 100%;
  }

  .stock-alert,
  .theme-btn {
    flex: 1 1 auto;
    text-align: center;
  }

  .period-row {
    gap: 8px;
  }

  .period-btn {
    flex: 1 1 120px;
    padding: 9px 12px;
  }

  .table-tools .search,
  .table-tools .small-action {
    flex: 1 1 100%;
  }
}

@media (max-width: 480px) {
  body {
    font-size: 13px;
  }

  .nav {
    grid-template-columns: 1fr;
    max-height: none;
  }

  .kpi-card {
    min-height: 92px;
    padding: 18px;
  }

  .kpi-card .value {
    font-size: 28px;
  }

  .status-wrap {
    flex-direction: column;
    align-items: stretch;
  }

  .legend {
    min-width: 0;
  }

  .toast {
    left: 14px;
    right: 14px;
    bottom: 14px;
    max-width: none;
  }
}

/* Department stock movement tools */
.dept-stock-grid.two-col {
  grid-template-columns: repeat(2, minmax(300px, 1fr));
}

.span-two {
  grid-column: 1 / -1;
}

.no-margin {
  margin: 4px 0 0;
}

.is-hidden {
  display: none !important;
}

.positive {
  color: var(--green);
  font-weight: 900;
}

.negative {
  color: var(--red);
  font-weight: 900;
}

@media (max-width: 900px) {
  .dept-stock-grid.two-col {
    grid-template-columns: 1fr;
  }

  .span-two {
    grid-column: auto;
  }
}

.focus-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 9px;
  border-radius: 999px;
  color: white;
  background: var(--blue);
  box-shadow: 0 0 0 3px rgba(75, 141, 255, .22);
  font-weight: 900;
}


/* Arbe Chemindo visual refresh, filters, grouped department stock, notification modal */
:root {
  --bg: #0b1220;
  --bg-deep: #07101d;
  --sidebar: #101827;
  --card: #121c2e;
  --card-soft: #17243a;
  --border: #243654;
  --border-soft: #1b2a43;
  --text: #e8f1ff;
  --muted: #9eb0cf;
  --muted-2: #7486a7;
  --blue: #62a1ff;
  --blue-2: #2f76ff;
  --blue-3: #0ea5e9;
  --green: #2ddf8f;
  --yellow: #ffc857;
  --red: #ff6370;
  --purple: #9b7cff;
  --shadow: 0 22px 60px rgba(0, 0, 0, .28);
}

body.light-theme {
  --bg: #eef4fb;
  --bg-deep: #e8f0fa;
  --sidebar: #f7fbff;
  --card: #fbfdff;
  --card-soft: #edf5ff;
  --border: #cdddf1;
  --border-soft: #dbe7f7;
  --text: #15233a;
  --muted: #55657f;
  --muted-2: #72829b;
  --blue: #2563eb;
  --blue-2: #1d4ed8;
  --blue-3: #0284c7;
  --green: #0f9f67;
  --yellow: #b7791f;
  --red: #dc3545;
  --purple: #6d5bd0;
  --shadow: 0 18px 45px rgba(38, 72, 120, .12);
}

body {
  background:
    radial-gradient(circle at 18% 0%, rgba(47, 118, 255, .18), transparent 34%),
    radial-gradient(circle at 85% 8%, rgba(45, 223, 143, .10), transparent 28%),
    var(--bg-deep);
}

body.light-theme {
  background:
    radial-gradient(circle at 15% 0%, rgba(37, 99, 235, .10), transparent 32%),
    radial-gradient(circle at 86% 6%, rgba(14, 165, 233, .08), transparent 28%),
    var(--bg-deep);
}

.sidebar,
.card,
.kpi-card,
.topbar,
.profile {
  border-color: color-mix(in srgb, var(--border) 88%, transparent);
}

.card,
.kpi-card {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--card) 96%, var(--blue) 4%), var(--card));
}

.light-theme .card,
.light-theme .kpi-card {
  background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
}

.brand-title {
  font-size: 17px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
}

.nav-icon {
  width: 27px;
  height: 27px;
  display: inline-grid;
  place-items: center;
  border-radius: 9px;
  color: #9cc4ff;
  background: rgba(98, 161, 255, .10);
  border: 1px solid rgba(98, 161, 255, .18);
  font-weight: 900;
}

.nav-item:hover .nav-icon,
.nav-item.active .nav-icon {
  color: #ffffff;
  background: linear-gradient(135deg, var(--blue-2), var(--blue-3));
  box-shadow: 0 10px 24px rgba(47, 118, 255, .22);
}

.feature-guide {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px 18px;
  margin-bottom: 18px;
  border: 1px solid rgba(98, 161, 255, .24);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(98, 161, 255, .16), rgba(14, 165, 233, .06)),
    color-mix(in srgb, var(--card) 84%, transparent);
  box-shadow: var(--shadow);
}

.light-theme .feature-guide {
  background: linear-gradient(135deg, rgba(37, 99, 235, .08), rgba(14, 165, 233, .05)), #ffffff;
}

.guide-icon {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--blue-2), var(--blue-3));
  box-shadow: 0 14px 30px rgba(47, 118, 255, .24);
  font-weight: 900;
}

.feature-guide strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  font-size: 14px;
}

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

.filter-tools {
  align-items: stretch;
}

.filter-tools .search,
.filter-tools .small-select {
  min-width: 180px;
  max-width: none;
}

.stacked-toolbar {
  align-items: flex-start;
}

.stacked-toolbar .table-tools {
  flex: 1 1 560px;
}

.badge.empty-stock {
  color: #ffd0d4;
  background: rgba(255, 99, 112, .18);
}

.department-groups {
  display: grid;
  gap: 14px;
}

.dept-group-card {
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 14px;
  background: color-mix(in srgb, var(--card-soft) 72%, transparent);
}

.light-theme .dept-group-card {
  background: #f3f7fe;
}

.dept-group-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.dept-badge {
  min-width: 54px;
  height: 42px;
  padding: 0 10px;
  display: inline-grid;
  place-items: center;
  border-radius: 13px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--blue-2), var(--blue-3));
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .04em;
}

.dept-group-head h3 {
  margin: 0;
  color: var(--text);
  font-size: 16px;
}

.dept-group-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.dept-inner-table table {
  min-width: 880px;
}

.muted-line {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.empty-card {
  border: 1px dashed var(--border);
  color: var(--muted);
  border-radius: 16px;
  padding: 18px;
  text-align: center;
  background: color-mix(in srgb, var(--card-soft) 48%, transparent);
  font-weight: 800;
}

.circle-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
}

.notification-count {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #ffffff;
  background: var(--red);
  border: 2px solid var(--bg-deep);
  font-size: 10px;
  font-weight: 900;
}

.notification-modal[hidden] {
  display: none !important;
}

.notification-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  padding: 58px 22px 22px;
  background: rgba(2, 8, 23, .52);
  backdrop-filter: blur(8px);
}

.modal-panel {
  width: min(460px, calc(100vw - 32px));
  max-height: min(720px, calc(100vh - 86px));
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--card);
  box-shadow: 0 28px 80px rgba(0, 0, 0, .42);
}

.light-theme .modal-panel {
  background: #ffffff;
}

.modal-head {
  padding: 18px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border-soft);
}

.notification-list {
  padding: 12px;
  overflow: auto;
  display: grid;
  gap: 10px;
}

.notification-item {
  width: 100%;
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  gap: 12px;
  text-align: left;
  color: var(--text);
  background: color-mix(in srgb, var(--card-soft) 74%, transparent);
}

.light-theme .notification-item {
  background: #f7fbff;
}

.notification-item:hover {
  border-color: rgba(98, 161, 255, .48);
  transform: translateY(-1px);
}

.notification-icon {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--blue-2), var(--blue-3));
  font-weight: 900;
}

.notification-item.yellow .notification-icon { background: linear-gradient(135deg, #f59e0b, #f97316); }
.notification-item.red .notification-icon { background: linear-gradient(135deg, #ef4444, #fb7185); }
.notification-item.muted .notification-icon { background: linear-gradient(135deg, #64748b, #94a3b8); }

.notification-text {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.notification-text strong,
.notification-text span,
.notification-text small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notification-text strong {
  color: var(--text);
  font-size: 13px;
}

.notification-text span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.notification-text small {
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 800;
}

.toast {
  border-color: rgba(98, 161, 255, .36);
  background: linear-gradient(135deg, #0f1c31, #12264a);
}

.light-theme .toast {
  color: #0f172a;
  background: #ffffff;
}

.primary-btn {
  background: linear-gradient(135deg, var(--blue-2), var(--blue-3));
  box-shadow: 0 12px 28px rgba(47, 118, 255, .22);
}

.card-title {
  color: #a9c7ff;
}

.light-theme .card-title {
  color: #255aa8;
}

@media (max-width: 760px) {
  .feature-guide {
    padding: 14px;
  }

  .filter-tools .search,
  .filter-tools .small-select,
  .filter-tools .small-action {
    flex: 1 1 100%;
    min-width: 0;
  }

  .notification-modal {
    justify-content: center;
    padding: 18px;
  }

  .modal-panel {
    width: 100%;
    max-height: calc(100vh - 36px);
  }

  .dept-group-head {
    align-items: flex-start;
  }
}

/* Dashboard CTA refresh and department PIC tools */
.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, .85fr);
  gap: 18px;
  align-items: stretch;
  padding: clamp(18px, 3vw, 28px);
  margin-bottom: 18px;
  border: 1px solid rgba(98, 161, 255, .28);
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(47, 118, 255, .20), rgba(14, 165, 233, .10)),
    linear-gradient(180deg, color-mix(in srgb, var(--card) 92%, transparent), var(--card));
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}

.dashboard-hero::after {
  content: "";
  position: absolute;
  right: -70px;
  top: -80px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(98, 161, 255, .28), transparent 68%);
  pointer-events: none;
}

.light-theme .dashboard-hero {
  background:
    linear-gradient(135deg, rgba(37, 99, 235, .10), rgba(14, 165, 233, .06)),
    #ffffff;
}

.dashboard-hero .eyebrow {
  margin: 0 0 8px;
  color: #9dc4ff;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 11px;
  font-weight: 900;
}

.light-theme .dashboard-hero .eyebrow { color: var(--blue-2); }

.dashboard-hero h2 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.1;
  letter-spacing: -.04em;
}

.dashboard-hero p:not(.eyebrow) {
  max-width: 680px;
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.quick-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  z-index: 1;
}

.quick-action {
  width: 100%;
  border: 1px solid rgba(98, 161, 255, .22);
  border-radius: 16px;
  padding: 13px;
  color: var(--text);
  background: color-mix(in srgb, var(--card-soft) 78%, transparent);
  display: grid;
  grid-template-columns: 42px 1fr;
  column-gap: 12px;
  text-align: left;
  align-items: center;
}

.light-theme .quick-action { background: #f5f9ff; }

.quick-action span {
  grid-row: span 2;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--blue-2), var(--blue-3));
  font-weight: 900;
  box-shadow: 0 14px 28px rgba(47, 118, 255, .20);
}

.quick-action strong { font-size: 13px; }
.quick-action small { color: var(--muted); font-weight: 700; }

.kpi-card {
  width: 100%;
  border: 1px solid var(--border);
  color: var(--text);
  text-align: left;
}

.kpi-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.dashboard-cta:hover,
.notification-item:hover {
  border-color: rgba(98, 161, 255, .58);
  transform: translateY(-2px);
  box-shadow: 0 20px 42px rgba(47, 118, 255, .16);
}

.cta-row {
  width: 100%;
  border: 0;
  border-bottom: 1px solid rgba(39, 49, 73, .45);
  background: transparent;
  text-align: left;
  padding-left: 0;
  padding-right: 0;
}

.light-theme .cta-row { border-bottom-color: rgba(205, 221, 241, .8); }

.cta-row:hover .name,
.cta-row:hover p {
  color: #9dc4ff;
}

.light-theme .cta-row:hover .name,
.light-theme .cta-row:hover p {
  color: var(--blue-2);
}

body.cannot-manage-pics .requires-pics {
  display: none !important;
}

#picTableCard {
  margin-top: 18px;
}

@media (max-width: 980px) {
  .dashboard-hero { grid-template-columns: 1fr; }
  .quick-actions { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
}

@media (max-width: 560px) {
  .quick-actions { grid-template-columns: 1fr; }
  .dashboard-hero { border-radius: 18px; }
}

/* Final compact dashboard + mobile alignment refresh */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

.main,
.view,
.content-grid,
.card,
.table-card,
.form-card,
.dashboard-hero,
.feature-guide {
  max-width: 100%;
}

.card-headline {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.dashboard-metrics-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, .95fr);
  gap: 18px;
  margin-bottom: 18px;
  align-items: stretch;
}

.compact-dashboard-card {
  min-height: 0;
}

.trend-summary {
  display: grid;
  gap: 9px;
}

.trend-row {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 10px 12px;
  color: var(--text);
  background: color-mix(in srgb, var(--card-soft) 78%, transparent);
  display: grid;
  grid-template-columns: minmax(68px, .42fr) minmax(88px, 1fr) minmax(36px, auto) 28px;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.light-theme .trend-row {
  background: #f5f9ff;
}

.trend-row:hover,
.status-total:hover,
.status-tile:hover,
.status-link:hover {
  border-color: rgba(98, 161, 255, .6);
  transform: translateY(-1px);
  box-shadow: 0 14px 34px rgba(47, 118, 255, .16);
}

.trend-date {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.trend-bar {
  height: 9px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(125, 139, 168, .16);
}

.trend-bar i {
  display: block;
  height: 100%;
  min-width: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue-2), var(--blue-3));
  box-shadow: 0 0 18px rgba(98, 161, 255, .28);
}

.trend-row strong {
  text-align: right;
  color: var(--text);
  font-size: 15px;
}

.trend-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-weight: 900;
  background: rgba(125, 139, 168, .14);
}

.trend-icon.up { color: var(--green); background: rgba(45, 223, 143, .12); }
.trend-icon.down { color: var(--red); background: rgba(255, 99, 112, .12); }
.trend-icon.flat { color: var(--muted); }

.status-summary {
  display: grid;
  gap: 12px;
}

.status-total {
  width: 100%;
  min-height: 76px;
  border: 1px solid rgba(98, 161, 255, .28);
  border-radius: 18px;
  padding: 14px 16px;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(98, 161, 255, .18), rgba(14, 165, 233, .07)),
    color-mix(in srgb, var(--card-soft) 80%, transparent);
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "label value" "hint value";
  align-items: center;
  text-align: left;
}

.light-theme .status-total {
  background: linear-gradient(135deg, rgba(37, 99, 235, .09), rgba(14, 165, 233, .06)), #f6faff;
}

.status-total span { grid-area: label; color: var(--muted); font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
.status-total strong { grid-area: value; font-size: 34px; color: var(--blue); line-height: 1; }
.status-total small { grid-area: hint; color: var(--muted); font-weight: 800; }

.status-tile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.status-tile {
  min-height: 76px;
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 12px;
  color: var(--text);
  background: color-mix(in srgb, var(--card-soft) 76%, transparent);
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.light-theme .status-tile {
  background: #f7fbff;
}

.status-tile-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: white;
  background: linear-gradient(135deg, var(--blue-2), var(--blue-3));
  font-weight: 900;
}
.status-tile.Pending .status-tile-icon { background: linear-gradient(135deg, #f59e0b, #f97316); }
.status-tile.Delivered .status-tile-icon { background: linear-gradient(135deg, #0f9f67, #2ddf8f); }
.status-tile.Rejected .status-tile-icon { background: linear-gradient(135deg, #dc3545, #ff6370); }

.status-tile-text,
.status-tile-count {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.status-tile-text strong,
.status-tile-count {
  font-size: 13px;
  font-weight: 900;
}

.status-tile-text small,
.status-tile-count small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.status-tile-count {
  text-align: right;
  color: var(--blue);
}

.status-link {
  border: 1px solid transparent;
  min-height: auto;
  cursor: pointer;
}

.status-link.badge {
  padding: 5px 10px;
}

.compact-empty {
  padding: 14px;
}

.low-stock-list,
.activity-list,
.dept-stock-list,
.list.compact {
  max-height: 310px;
  overflow-y: auto;
  padding-right: 2px;
}

.dashboard-hero {
  min-height: 0;
}

.quick-action,
.kpi-card,
.cta-row,
.notification-item,
.status-tile,
.status-total,
.trend-row {
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease, background .16s ease;
}

.table-card {
  overflow: hidden;
}

.table-wrap {
  border-radius: 14px;
}

.table-wrap table {
  table-layout: auto;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(98, 161, 255, .32);
  outline-offset: 2px;
}

/* Mobile: menu tidak lagi memanjang ke bawah, tetapi menjadi bar horizontal. */
@media (max-width: 760px) {
  :root { --sidebar-width: 0px; }

  body {
    font-size: 13px;
  }

  .sidebar {
    position: sticky;
    top: 0;
    width: 100%;
    z-index: 50;
    border-right: 0;
    border-bottom: 1px solid var(--border-soft);
    box-shadow: 0 18px 42px rgba(0, 0, 0, .22);
  }

  .brand {
    padding: 12px 14px 10px;
    gap: 10px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 13px;
  }

  .brand-title {
    font-size: 14px;
    line-height: 1.05;
  }

  .role-badge {
    margin-top: 6px;
    padding: 3px 7px;
    font-size: 9px;
  }

  .nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    max-height: none;
    padding: 8px 12px 10px;
    scroll-snap-type: x proximity;
  }

  .nav p {
    display: none;
  }

  .nav-item {
    flex: 0 0 auto;
    width: auto;
    min-width: max-content;
    border-left: 0;
    border-bottom: 3px solid transparent;
    border-radius: 13px;
    padding: 9px 11px;
    scroll-snap-align: start;
  }

  .nav-item.active,
  .nav-item:hover {
    border-left-color: transparent;
    border-bottom-color: var(--blue);
  }

  .nav-icon {
    width: 24px;
    height: 24px;
  }

  .profile {
    min-height: 52px;
    padding: 10px 14px;
  }

  .avatar {
    width: 32px;
    height: 32px;
  }

  .main {
    margin-left: 0;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    padding: 12px 14px;
    gap: 10px;
  }

  .topbar h1 {
    font-size: 18px;
  }

  .view {
    padding: 14px;
  }

  .feature-guide {
    gap: 10px;
    border-radius: 16px;
    margin-bottom: 14px;
  }

  .guide-icon {
    width: 34px;
    height: 34px;
    border-radius: 12px;
  }

  .dashboard-hero {
    padding: 16px;
    border-radius: 18px;
    gap: 14px;
  }

  .dashboard-hero h2 {
    font-size: 22px;
  }

  .period-row {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }

  .period-row span,
  .period-btn {
    flex: 0 0 auto;
  }

  .dashboard-metrics-grid,
  .charts-grid,
  .mini-grid,
  .bottom-grid,
  .content-grid,
  .two-col,
  .two-col.equal,
  .dept-stock-grid.two-col {
    grid-template-columns: 1fr !important;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .kpi-card {
    min-height: 88px;
    padding: 14px;
    border-radius: 16px;
  }

  .kpi-card .value {
    font-size: 25px;
  }

  .kpi-card .icon {
    font-size: 24px;
  }

  .status-tile-grid {
    grid-template-columns: 1fr;
  }

  .trend-row {
    grid-template-columns: minmax(58px, .44fr) minmax(72px, 1fr) auto 26px;
    gap: 8px;
    padding: 9px 10px;
  }

  .trend-date,
  .status-tile-text small,
  .status-tile-count small {
    font-size: 10px;
  }

  .status-total strong {
    font-size: 28px;
  }

  .card {
    padding: 14px;
    border-radius: 17px;
  }

  .card-title {
    font-size: 11px;
    margin-bottom: 12px;
  }

  .table-wrap {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .table-wrap table {
    min-width: 720px;
  }

  th,
  td {
    padding: 10px 9px;
  }

  .filter-tools,
  .table-tools,
  .card-toolbar {
    width: 100%;
    align-items: stretch;
  }

  .filter-tools .search,
  .filter-tools .small-select,
  .filter-tools .small-action,
  .table-tools .search,
  .table-tools .small-select,
  .table-tools .small-action,
  .table-tools button,
  .file-btn {
    width: 100%;
    max-width: none;
    flex: 1 1 100%;
  }

  .form-grid,
  .inline-form,
  .inline-form.two-inputs,
  .category-form,
  .department-form,
  .inline-form.two-inputs.department-form {
    grid-template-columns: 1fr !important;
  }

  .low-stock-list,
  .activity-list,
  .dept-stock-list,
  .list.compact {
    max-height: 260px;
  }
}

@media (max-width: 420px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .quick-actions {
    grid-template-columns: 1fr;
  }

  .trend-row {
    grid-template-columns: 1fr auto;
  }

  .trend-bar {
    grid-column: 1 / -1;
    order: 3;
  }

  .trend-icon {
    display: none;
  }
}


/* =========================================================
   Layout refinement: form di atas, data full-width, aksi terlihat
   ========================================================= */
#master-stock-view .content-grid.master-stack,
#approval-view .content-grid.approval-stack {
  grid-template-columns: 1fr !important;
  gap: 14px;
  align-items: stretch;
}

#master-stock-view .feature-guide,
#approval-view .feature-guide {
  margin-bottom: 12px;
}

.compact-form {
  padding: 15px 18px;
}

.compact-form .card-title {
  margin-bottom: 10px;
}

.compact-helper {
  margin-top: 8px;
  font-size: 11px;
}

.master-stock-form {
  grid-template-columns: minmax(140px, .75fr) minmax(240px, 1.45fr) minmax(155px, .9fr) minmax(86px, .48fr) minmax(82px, .42fr) minmax(82px, .42fr) minmax(118px, .55fr) minmax(92px, .45fr);
  gap: 9px;
  align-items: end;
}

.master-stock-form .full {
  grid-column: auto;
}

.master-stock-form label,
.approval-form-card label {
  gap: 5px;
  font-size: 11px;
}

.master-stock-form input,
.master-stock-form select,
.approval-form-card input,
.approval-form-card select,
.approval-form-card textarea {
  min-height: 36px;
  padding: 8px 10px;
  border-radius: 9px;
}

.master-stock-form button,
.approval-form-card button {
  min-height: 36px;
  border-radius: 9px;
  padding: 0 12px;
}

.approval-form-card .form-grid {
  grid-template-columns: minmax(220px, 1.3fr) minmax(180px, 1fr) minmax(180px, 1fr) 90px minmax(220px, 1fr) 150px;
  gap: 10px;
  align-items: end;
}

.approval-form-card .form-grid .full {
  grid-column: auto;
}

.approval-form-card textarea {
  min-height: 36px;
  max-height: 72px;
}

.master-stock-data,
.approval-data-card {
  padding: 18px;
}

.master-toolbar,
.approval-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, .8fr) minmax(0, 1.8fr);
  gap: 14px;
  align-items: start;
}

.master-toolbar .table-tools,
.approval-toolbar .table-tools {
  justify-content: end;
}

.master-toolbar .filter-tools {
  display: grid;
  grid-template-columns: minmax(180px, 1.3fr) minmax(150px, .9fr) minmax(145px, .8fr) minmax(145px, .8fr) minmax(150px, .85fr) repeat(4, max-content);
  gap: 8px;
  width: 100%;
}

.master-toolbar .filter-tools .search,
.master-toolbar .filter-tools .small-select {
  min-width: 0;
  max-width: none;
}

.master-toolbar .small-action,
.approval-toolbar .small-select {
  min-height: 36px;
}

.table-wrap {
  border: 1px solid rgba(68, 86, 128, .34);
  background: rgba(7, 12, 22, .18);
}

.responsive-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.responsive-table th,
.responsive-table td {
  padding: 9px 8px;
  vertical-align: middle;
  white-space: normal;
  line-height: 1.35;
}

.responsive-table .text-cell {
  word-break: break-word;
  overflow-wrap: anywhere;
}

.responsive-table .action-cell {
  background: linear-gradient(90deg, rgba(19, 29, 48, .72), var(--card) 22%);
}

.light-theme .responsive-table .action-cell {
  background: linear-gradient(90deg, rgba(242, 246, 255, .72), var(--card) 22%);
}

.responsive-table .table-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 5px;
}

.responsive-table .table-actions button {
  min-height: 29px;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 10px;
}

#itemTable,
#requestTable {
  min-width: 0 !important;
  table-layout: fixed;
}

#itemTable th:nth-child(1), #itemTable td:nth-child(1) { width: 110px; }
#itemTable th:nth-child(2), #itemTable td:nth-child(2) { width: auto; }
#itemTable th:nth-child(3), #itemTable td:nth-child(3) { width: 130px; }
#itemTable th:nth-child(4), #itemTable td:nth-child(4) { width: 70px; text-align: right; }
#itemTable th:nth-child(5), #itemTable td:nth-child(5) { width: 72px; text-align: right; }
#itemTable th:nth-child(6), #itemTable td:nth-child(6) { width: 72px; }
#itemTable th:nth-child(7), #itemTable td:nth-child(7) { width: 86px; }
#itemTable th:nth-child(8), #itemTable td:nth-child(8) { width: 82px; }
#itemTable th:nth-child(9), #itemTable td:nth-child(9) { width: 188px; }

#requestTable {
  font-size: 12px;
}

#requestTable th:nth-child(1), #requestTable td:nth-child(1) { width: 54px; }
#requestTable th:nth-child(2), #requestTable td:nth-child(2) { width: 92px; }
#requestTable th:nth-child(3), #requestTable td:nth-child(3) { width: 14%; }
#requestTable th:nth-child(4), #requestTable td:nth-child(4) { width: 11%; }
#requestTable th:nth-child(5), #requestTable td:nth-child(5) { width: 10%; }
#requestTable th:nth-child(6), #requestTable td:nth-child(6) { width: 76px; }
#requestTable th:nth-child(7), #requestTable td:nth-child(7) { width: 92px; }
#requestTable th:nth-child(8), #requestTable td:nth-child(8) { width: 10%; }
#requestTable th:nth-child(9), #requestTable td:nth-child(9) { width: 12%; }
#requestTable th:nth-child(10), #requestTable td:nth-child(10) { width: 96px; }
#requestTable th:nth-child(11), #requestTable td:nth-child(11) { width: 185px; }

#requestTable .action-cell,
#itemTable .action-cell,
#userTable .action-cell,
#employeeTable .action-cell,
#departmentMovementTable .action-cell,
#auditTable .action-cell {
  position: sticky;
  right: 0;
  z-index: 2;
  box-shadow: -14px 0 22px rgba(0, 0, 0, .14);
}

#requestTable th:last-child,
#itemTable th:last-child,
#userTable th:last-child,
#employeeTable th:last-child {
  position: sticky;
  right: 0;
  z-index: 3;
  background: var(--card);
  box-shadow: -14px 0 22px rgba(0, 0, 0, .14);
}

.light-theme #requestTable th:last-child,
.light-theme #itemTable th:last-child,
.light-theme #userTable th:last-child,
.light-theme #employeeTable th:last-child {
  background: var(--card);
}

@media (max-width: 1380px) {
  .master-stock-form {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
  .master-stock-form label:nth-of-type(2) {
    grid-column: span 2;
  }
  .master-stock-form button {
    grid-column: span 1;
  }
  .master-toolbar {
    grid-template-columns: 1fr;
  }
  .master-toolbar .filter-tools {
    grid-template-columns: repeat(4, minmax(130px, 1fr));
  }
  .master-toolbar .filter-tools .search {
    grid-column: span 2;
  }
}

@media (max-width: 1180px) {
  .approval-form-card .form-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .approval-form-card .form-grid .full {
    grid-column: span 2;
  }
  #requestTable .table-actions,
  #itemTable .table-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 980px) {
  .master-stock-form,
  .approval-form-card .form-grid,
  .master-toolbar .filter-tools {
    grid-template-columns: 1fr 1fr;
  }

  .master-stock-form .full,
  .approval-form-card .form-grid .full,
  .master-toolbar .filter-tools .search {
    grid-column: 1 / -1;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .responsive-table,
  .responsive-table thead,
  .responsive-table tbody,
  .responsive-table tr,
  .responsive-table td {
    display: block;
    width: 100% !important;
    min-width: 0 !important;
  }

  .responsive-table thead {
    display: none;
  }

  .responsive-table tbody {
    display: grid;
    gap: 10px;
  }

  .responsive-table tr {
    border: 1px solid rgba(74, 99, 148, .28);
    border-radius: 16px;
    background: rgba(17, 27, 45, .82);
    box-shadow: 0 16px 34px rgba(0, 0, 0, .16);
    padding: 8px;
  }

  .light-theme .responsive-table tr {
    background: rgba(255, 255, 255, .88);
  }

  .responsive-table td {
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    padding: 8px 6px;
    border-bottom: 1px solid rgba(72, 90, 130, .2);
    text-align: left !important;
    white-space: normal;
  }

  .responsive-table td:last-child {
    border-bottom: 0;
  }

  .responsive-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .06em;
    text-transform: uppercase;
  }

  .responsive-table .action-cell,
  .responsive-table th:last-child {
    position: static !important;
    right: auto;
    z-index: auto;
    box-shadow: none;
    background: transparent;
  }

  .responsive-table .action-cell {
    grid-template-columns: 104px minmax(0, 1fr);
  }

  .responsive-table .table-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .compact-form,
  .master-stock-data,
  .approval-data-card {
    padding: 13px;
  }

  .master-stock-form,
  .approval-form-card .form-grid,
  .master-toolbar .filter-tools {
    grid-template-columns: 1fr;
  }

  .master-stock-form label:nth-of-type(2),
  .master-stock-form .full,
  .approval-form-card .form-grid .full,
  .master-toolbar .filter-tools .search {
    grid-column: auto;
  }

  .responsive-table td {
    grid-template-columns: 92px minmax(0, 1fr);
  }

  .responsive-table .action-cell {
    grid-template-columns: 92px minmax(0, 1fr);
  }

  .table-actions button {
    flex: 1 1 auto;
  }
}

/* =========================================================
   Approval + all menu usability polish v3
   Fokus: form di atas, tabel di bawah, mobile tidak melebar,
   CTA/aksi selalu mudah terlihat.
   ========================================================= */
.main {
  width: calc(100% - var(--sidebar-width));
  max-width: none;
}

.view {
  width: 100%;
  max-width: 1680px;
  margin: 0 auto;
}

.card {
  border: 1px solid rgba(98, 161, 255, .16);
}

.card-title {
  letter-spacing: .01em;
}

/* Paksa Approval dan Master Stock menjadi atas-bawah di semua ukuran */
#approval-view .approval-stack,
#master-stock-view .master-stack {
  display: flex !important;
  flex-direction: column !important;
  grid-template-columns: none !important;
  width: 100%;
  gap: 14px;
}

#approval-view .approval-form-card,
#master-stock-view .master-form-card {
  width: 100%;
  max-width: none;
}

#approval-view .approval-data-card,
#master-stock-view .master-stock-data {
  width: 100%;
  max-width: none;
}

/* Form approval dibuat horizontal compact agar area data lebih luas */
#approval-view .approval-form-card {
  padding: 14px 16px;
}

#approval-view .approval-form-card .form-grid {
  display: grid !important;
  grid-template-columns: minmax(180px, 1.1fr) minmax(150px, .9fr) minmax(150px, .9fr) 84px minmax(180px, 1fr) 148px;
  gap: 10px;
  align-items: end;
}

#approval-view .approval-form-card .form-grid .full {
  grid-column: auto;
}

#approval-view .approval-form-card textarea {
  min-height: 36px;
  height: 36px;
  resize: vertical;
}

#approval-view .approval-form-card .primary-btn {
  width: 100%;
}

/* Toolbar lebih jelas dan tidak memaksa tabel mengecil */
#approval-view .approval-toolbar,
#master-stock-view .master-toolbar {
  display: grid;
  grid-template-columns: minmax(250px, .9fr) minmax(0, 1.6fr);
  gap: 14px;
  align-items: center;
}

#approval-view .approval-toolbar .small-select {
  justify-self: end;
  min-width: 190px;
  max-width: 260px;
}

/* Tabel approval lebih ringkas: aksi di kiri dan sticky */
#requestTable {
  min-width: 0 !important;
  table-layout: fixed;
  font-size: 12px;
}

#requestTable th,
#requestTable td {
  padding: 10px 9px;
}

#requestTable th:nth-child(1), #requestTable td:nth-child(1) { width: 210px; }
#requestTable th:nth-child(2), #requestTable td:nth-child(2) { width: 76px; }
#requestTable th:nth-child(3), #requestTable td:nth-child(3) { width: 20%; }
#requestTable th:nth-child(4), #requestTable td:nth-child(4) { width: 18%; }
#requestTable th:nth-child(5), #requestTable td:nth-child(5) { width: 80px; }
#requestTable th:nth-child(6), #requestTable td:nth-child(6) { width: 106px; }
#requestTable th:nth-child(7), #requestTable td:nth-child(7) { width: 140px; }
#requestTable th:nth-child(8), #requestTable td:nth-child(8) { width: 18%; }

#requestTable .action-cell,
#requestTable th:first-child {
  position: sticky;
  left: 0;
  right: auto;
  z-index: 4;
  background: var(--card);
  box-shadow: 14px 0 22px rgba(0, 0, 0, .14);
}

.light-theme #requestTable .action-cell,
.light-theme #requestTable th:first-child {
  background: var(--card);
}

#requestTable th:last-child,
#requestTable td:last-child {
  position: static !important;
  right: auto !important;
  box-shadow: none !important;
}

.approval-actions {
  justify-content: flex-start !important;
  gap: 5px;
}

.approval-actions button {
  min-height: 28px;
  padding: 0 8px;
  font-size: 10px;
  border-radius: 8px;
}

.stacked-cell {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.stacked-cell strong,
.stacked-cell span,
.stacked-cell small {
  overflow-wrap: anywhere;
  white-space: normal;
}

.stacked-cell small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

/* Semua halaman data dibuat lebih konsisten */
#department-stock-view .dept-stock-grid,
#employees-view .content-grid,
#master-data-view .content-grid,
#users-view .content-grid {
  gap: 14px;
}

#employees-view .content-grid.two-col,
#users-view .content-grid.two-col {
  grid-template-columns: minmax(280px, 390px) minmax(0, 1fr);
}

#department-stock-view .dept-stock-grid.two-col {
  grid-template-columns: repeat(2, minmax(260px, 1fr));
}

#userTable,
#employeeTable,
#categoryTable,
#departmentTable,
#departmentMovementTable,
#auditTable {
  table-layout: fixed;
}

/* Tombol dan input lebih nyaman di HP */
.primary-btn,
.ghost-btn,
.danger-btn,
.success-btn,
.warn-btn,
.file-btn,
.circle-btn,
.theme-btn,
.nav-item,
.quick-action,
.kpi-card,
.cta-row {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
.file-btn:focus-visible {
  outline: 3px solid rgba(98, 161, 255, .35);
  outline-offset: 2px;
}

/* Responsive tablet */
@media (max-width: 1240px) {
  #approval-view .approval-form-card .form-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #approval-view .approval-form-card .form-grid .full {
    grid-column: span 2;
  }

  #approval-view .approval-toolbar,
  #master-stock-view .master-toolbar {
    grid-template-columns: 1fr;
  }

  #approval-view .approval-toolbar .small-select {
    justify-self: start;
  }

  #employees-view .content-grid.two-col,
  #users-view .content-grid.two-col,
  #department-stock-view .dept-stock-grid.two-col {
    grid-template-columns: 1fr;
  }
}

/* Responsive HP besar: tabel berubah menjadi kartu rapi */
@media (max-width: 980px) {
  #approval-view .approval-form-card .form-grid,
  #master-stock-view .master-stock-form,
  #employees-view .form-grid,
  #users-view .form-grid,
  #department-stock-view .form-grid {
    grid-template-columns: 1fr 1fr !important;
  }

  #approval-view .approval-form-card .form-grid .full,
  #master-stock-view .master-stock-form .full,
  #employees-view .form-grid .full,
  #users-view .form-grid .full,
  #department-stock-view .form-grid .full {
    grid-column: 1 / -1 !important;
  }

  #approval-view .approval-form-card button[type="submit"] {
    grid-column: 1 / -1;
  }

  #requestTable .action-cell,
  #requestTable th:first-child,
  #itemTable .action-cell,
  #itemTable th:last-child,
  #userTable .action-cell,
  #employeeTable .action-cell {
    position: static !important;
    left: auto !important;
    right: auto !important;
    box-shadow: none !important;
    background: transparent !important;
  }

  #requestTable td:first-child {
    border-radius: 12px;
    background: rgba(98, 161, 255, .08) !important;
    margin-bottom: 4px;
  }

  .responsive-table td::before {
    align-self: start;
  }

  .approval-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .approval-actions button,
  .approval-actions .empty {
    width: 100%;
    text-align: center;
  }
}

/* Responsive HP kecil */
@media (max-width: 640px) {
  :root { --sidebar-width: 0px; }

  body {
    font-size: 13px;
  }

  .view {
    padding: 12px;
  }

  .feature-guide {
    margin-bottom: 10px;
    border-radius: 16px;
  }

  .feature-guide p {
    font-size: 12px;
  }

  .card,
  .compact-form,
  .master-stock-data,
  .approval-data-card {
    padding: 12px !important;
    border-radius: 16px;
  }

  #approval-view .approval-form-card .form-grid,
  #master-stock-view .master-stock-form,
  #employees-view .form-grid,
  #users-view .form-grid,
  #department-stock-view .form-grid,
  #master-data-view .inline-form,
  #master-data-view .inline-form.two-inputs {
    grid-template-columns: 1fr !important;
  }

  #approval-view .approval-form-card .form-grid .full,
  #master-stock-view .master-stock-form .full,
  #employees-view .form-grid .full,
  #users-view .form-grid .full,
  #department-stock-view .form-grid .full {
    grid-column: auto !important;
  }

  #approval-view .approval-form-card textarea {
    height: 72px;
  }

  .card-toolbar,
  .stacked-toolbar,
  .master-toolbar,
  .approval-toolbar {
    gap: 10px;
  }

  .table-tools,
  .filter-tools {
    display: grid !important;
    grid-template-columns: 1fr !important;
    width: 100%;
  }

  .small-select,
  .search,
  .small-action,
  .file-btn,
  #approval-view .approval-toolbar .small-select {
    width: 100%;
    max-width: none;
    justify-self: stretch;
  }

  .responsive-table tr {
    border-radius: 16px;
    padding: 9px;
  }

  .responsive-table td {
    grid-template-columns: 88px minmax(0, 1fr) !important;
    gap: 8px;
    padding: 8px 4px;
  }

  .approval-actions {
    grid-template-columns: 1fr;
  }

  .table-actions button {
    min-height: 34px;
  }

  .topbar {
    border-radius: 0 0 18px 18px;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr auto auto;
    width: 100%;
  }

  .stock-alert {
    justify-content: center;
  }
}

/* =========================================================
   Final usability patch v4: vertical layout + cleaner mobile
   ========================================================= */
:root {
  --blue: #2f8cff;
  --blue-2: #1d6ff2;
  --card: #121b2c;
  --card-soft: #17243a;
  --border: #28405f;
  --border-soft: #1d3150;
}

.light-theme {
  --bg: #eef4fb;
  --bg-deep: #e8f0fa;
  --card: #fbfdff;
  --card-soft: #f1f6fc;
  --border: #cfdded;
  --border-soft: #dce8f6;
  --blue: #236ff2;
  --blue-2: #1c5bd4;
}

/* Hilangkan Audit Log untuk user tanpa akses, termasuk sebelum render ulang selesai */
body.cannot-audit .requires-audit,
.requires-audit[hidden] {
  display: none !important;
}

.view {
  width: 100%;
  max-width: 1580px;
  margin: 0 auto;
}

.feature-guide {
  margin-bottom: 14px;
  background: linear-gradient(135deg, rgba(47, 140, 255, .18), rgba(47, 140, 255, .06));
  border-color: rgba(47, 140, 255, .35);
}

.card {
  background: linear-gradient(180deg, rgba(18, 27, 44, .98), rgba(15, 23, 39, .98));
  border-color: rgba(79, 148, 255, .22);
  box-shadow: 0 16px 42px rgba(0, 0, 0, .20);
}

.light-theme .card {
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  box-shadow: 0 16px 36px rgba(51, 92, 140, .10);
}

/* Semua menu dibuat satu alur: form/aksi di atas, data di bawah. */
#approval-view .content-grid,
#master-stock-view .content-grid,
#department-stock-view .content-grid,
#master-data-view .content-grid,
#employees-view .content-grid,
#users-view .content-grid {
  display: flex !important;
  flex-direction: column !important;
  grid-template-columns: none !important;
  gap: 14px !important;
  align-items: stretch !important;
}

#approval-view .card,
#master-stock-view .card,
#department-stock-view .card,
#master-data-view .card,
#employees-view .card,
#users-view .card,
#audit-view .card {
  width: 100% !important;
  max-width: none !important;
}

/* Form dibuat compact namun tetap rapi. */
.form-card,
.compact-form {
  padding: 14px 16px !important;
}

#approval-view .form-grid,
#master-stock-view .master-stock-form,
#department-stock-view .form-grid,
#employees-view .form-grid,
#users-view .form-grid,
#master-data-view .inline-form,
#master-data-view .inline-form.two-inputs {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)) !important;
  gap: 10px !important;
  align-items: end !important;
}

#approval-view .form-grid .full,
#master-stock-view .master-stock-form .full,
#department-stock-view .form-grid .full,
#employees-view .form-grid .full,
#users-view .form-grid .full {
  grid-column: auto !important;
}

#approval-view textarea,
#department-stock-view textarea {
  min-height: 38px;
  height: 38px;
}

.form-grid button,
.inline-form button,
.table-tools button,
.file-btn {
  min-height: 38px;
}

/* Toolbar filter selalu turun ke bawah judul dan tidak bertabrakan. */
.card-toolbar,
.stacked-toolbar,
.master-toolbar,
.approval-toolbar {
  display: grid !important;
  grid-template-columns: 1fr !important;
  gap: 12px !important;
  align-items: start !important;
}

.table-tools,
.filter-tools {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) !important;
  gap: 10px !important;
  width: 100% !important;
  max-width: none !important;
  align-items: center !important;
}

.table-tools .search,
.table-tools .small-select,
.table-tools .small-action,
.table-tools .file-btn,
#approval-view .approval-toolbar .small-select {
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  justify-self: stretch !important;
}

/* Tabel dibuat mudah dibaca, aksi terlihat tanpa membuat konten terpotong. */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: 14px;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

table th,
table td {
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.responsive-table .table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-start !important;
}

.responsive-table .table-actions button,
.approval-actions button {
  min-height: 30px;
  padding: 0 9px;
  border-radius: 8px;
}

#requestTable,
#itemTable,
#employeeTable,
#categoryTable,
#departmentTable,
#userTable,
#picTable,
#departmentMovementTable,
#auditTable {
  table-layout: auto !important;
  min-width: 920px;
}

#requestTable .action-cell,
#requestTable th:first-child,
#itemTable .action-cell,
#itemTable th:last-child {
  position: sticky;
  background: var(--card) !important;
  z-index: 3;
}

#requestTable .action-cell,
#requestTable th:first-child {
  left: 0;
  box-shadow: 12px 0 22px rgba(0, 0, 0, .16);
}

#itemTable .action-cell,
#itemTable th:last-child {
  right: 0;
  box-shadow: -12px 0 22px rgba(0, 0, 0, .16);
}

.light-theme #requestTable .action-cell,
.light-theme #requestTable th:first-child,
.light-theme #itemTable .action-cell,
.light-theme #itemTable th:last-child {
  background: var(--card) !important;
}

/* Department stock lebih rapi: form atas-bawah dan kartu departemen full width. */
.department-groups {
  display: grid;
  gap: 14px;
}

.dept-group-card {
  overflow: hidden;
}

.dept-inner-table table {
  min-width: 820px;
}

/* Pengguna: password, kelola user, PIC, dan tabel selalu bertumpuk rapi. */
#users-view #picTableCard,
#users-view #userTableCard {
  margin-top: 14px;
}

/* Dashboard tetap futuristik tapi compact. */
.dashboard-hero,
.dashboard-metrics-grid,
.mini-grid,
.bottom-grid {
  gap: 14px;
}

.kpi-card,
.quick-action,
.cta-row,
.status-tile,
.trend-row {
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}

.kpi-card:hover,
.quick-action:hover,
.cta-row:hover,
.status-tile:hover,
.trend-row:hover {
  transform: translateY(-1px);
  border-color: rgba(47, 140, 255, .45);
}

/* Mobile: sidebar menjadi bar horizontal, tabel jadi kartu, tidak melenceng. */
@media (max-width: 760px) {
  body {
    min-width: 0;
    overflow-x: hidden;
  }

  .sidebar {
    position: sticky !important;
    top: 0;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    display: block !important;
    border-right: 0;
    border-bottom: 1px solid var(--border-soft);
    z-index: 20;
  }

  .brand {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-soft);
  }

  .brand-title {
    font-size: 15px;
  }

  .role-badge {
    margin-top: 6px;
    font-size: 9px;
    padding: 4px 7px;
  }

  .nav {
    display: flex !important;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 12px;
    max-height: none !important;
    scroll-snap-type: x proximity;
  }

  .nav p {
    display: none !important;
  }

  .nav-item {
    flex: 0 0 auto;
    width: auto !important;
    min-width: max-content;
    padding: 9px 12px;
    border-left: 0;
    border-radius: 12px;
    border: 1px solid var(--border-soft);
    background: rgba(47, 140, 255, .06);
    scroll-snap-align: start;
  }

  .nav-item.active {
    border-color: rgba(47, 140, 255, .55);
    background: rgba(47, 140, 255, .18);
  }

  .profile {
    display: none !important;
  }

  .main {
    margin-left: 0 !important;
    width: 100%;
  }

  .topbar {
    position: sticky;
    top: 96px;
    z-index: 12;
    height: auto;
    padding: 10px 12px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .topbar h1 {
    font-size: 16px;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 8px;
    width: 100%;
  }

  .view {
    padding: 12px !important;
  }

  .feature-guide {
    grid-template-columns: 38px 1fr;
    padding: 12px;
    border-radius: 16px;
  }

  .feature-guide p,
  .helper-text {
    font-size: 12px;
    line-height: 1.45;
  }

  .card,
  .form-card,
  .table-card,
  .compact-form {
    padding: 12px !important;
    border-radius: 16px !important;
  }

  #approval-view .form-grid,
  #master-stock-view .master-stock-form,
  #department-stock-view .form-grid,
  #employees-view .form-grid,
  #users-view .form-grid,
  #master-data-view .inline-form,
  #master-data-view .inline-form.two-inputs {
    grid-template-columns: 1fr !important;
  }

  #approval-view textarea,
  #department-stock-view textarea {
    height: 64px;
  }

  .table-tools,
  .filter-tools {
    grid-template-columns: 1fr !important;
  }

  .table-wrap {
    overflow: visible;
  }

  .responsive-table,
  .responsive-table thead,
  .responsive-table tbody,
  .responsive-table tr,
  .responsive-table td {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  .responsive-table {
    min-width: 0 !important;
    border-collapse: separate;
  }

  .responsive-table thead {
    display: none !important;
  }

  .responsive-table tr {
    margin: 0 0 12px;
    padding: 10px;
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    background: rgba(12, 18, 31, .72);
  }

  .light-theme .responsive-table tr {
    background: #ffffff;
  }

  .responsive-table td {
    display: grid !important;
    grid-template-columns: 96px minmax(0, 1fr) !important;
    gap: 8px;
    padding: 8px 0 !important;
    border-bottom: 1px dashed var(--border-soft) !important;
  }

  .responsive-table td:last-child {
    border-bottom: 0 !important;
  }

  .responsive-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .04em;
  }

  .responsive-table .action-cell,
  #requestTable .action-cell,
  #requestTable th:first-child,
  #itemTable .action-cell,
  #itemTable th:last-child {
    position: static !important;
    left: auto !important;
    right: auto !important;
    box-shadow: none !important;
    background: transparent !important;
  }

  .approval-actions,
  .table-actions {
    display: grid !important;
    grid-template-columns: 1fr !important;
    width: 100%;
  }

  .approval-actions button,
  .table-actions button,
  .table-actions .badge {
    width: 100%;
  }

  .dept-inner-table {
    overflow: visible !important;
  }

  .dept-inner-table table,
  .dept-inner-table thead,
  .dept-inner-table tbody,
  .dept-inner-table tr,
  .dept-inner-table td {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  .dept-inner-table thead {
    display: none !important;
  }

  .dept-inner-table tr {
    padding: 10px;
    margin-top: 10px;
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    background: rgba(9, 12, 18, .30);
  }

  .dept-inner-table td {
    padding: 7px 0 !important;
    border-bottom: 1px dashed var(--border-soft);
  }

  .dept-inner-table td:last-child {
    border-bottom: 0;
  }
}

@media (max-width: 420px) {
  .top-actions {
    grid-template-columns: 1fr 42px 76px;
  }

  .stock-alert {
    padding-inline: 8px;
    font-size: 11px;
  }

  .responsive-table td {
    grid-template-columns: 82px minmax(0, 1fr) !important;
  }
}

/* Request/master-data restructuring + export/search polish */
.content-grid.approval-stack,
.content-grid.master-stack,
#department-stock-view .content-grid,
#master-data-view .content-grid,
#users-view .content-grid {
  grid-template-columns: 1fr !important;
}

.approval-form-card,
.master-form-card,
#department-stock-view .form-card,
#master-data-view .card,
#users-view .form-card,
#users-view .table-card {
  width: 100%;
  max-width: 100%;
}

.approval-form-card .form-grid,
.master-stock-form,
#department-stock-view .form-grid,
#master-data-view .inline-form,
#users-view .form-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr));
  align-items: end;
}

.request-item-field {
  position: relative;
}

.field-hint {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 700;
}

.export-filter-tools {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  width: min(100%, 920px);
  gap: 10px;
  align-items: center;
}

.mini-input,
.export-filter-tools input,
.export-filter-tools select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0 12px;
  color: var(--text);
  background: var(--bg);
  outline: none;
}

.export-filter-tools .primary-btn,
.export-filter-tools .ghost-btn {
  min-height: 42px;
  justify-content: center;
}

#requestTable th:first-child,
#requestTable td:first-child {
  width: 170px;
  min-width: 170px;
}

#requestTable .approval-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

#requestTable .approval-actions button {
  min-height: 32px;
  padding: 7px 9px;
}

.dept-group-card {
  width: 100%;
}

.table-card .card-toolbar {
  align-items: flex-start;
}

@media (max-width: 900px) {
  .approval-form-card .form-grid,
  .master-stock-form,
  #department-stock-view .form-grid,
  #master-data-view .inline-form,
  #users-view .form-grid {
    grid-template-columns: 1fr !important;
  }

  .export-filter-tools {
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .table-wrap table.responsive-table,
  .table-wrap table {
    min-width: 0;
  }
}

@media (max-width: 760px) {
  body {
    background: var(--bg-deep);
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    border-right: 0;
    border-bottom: 1px solid var(--border-soft);
  }

  .brand {
    padding: 14px 16px;
  }

  .nav {
    display: flex !important;
    overflow-x: auto;
    overflow-y: hidden;
    max-height: none !important;
    padding: 8px 12px 12px;
    gap: 8px;
    scroll-snap-type: x mandatory;
  }

  .nav p {
    display: none;
  }

  .nav-item {
    flex: 0 0 auto;
    width: auto;
    min-width: 134px;
    border-left: 0;
    border-radius: 14px;
    padding: 10px 12px;
    background: rgba(75, 141, 255, .08);
    scroll-snap-align: start;
  }

  .nav-item.active {
    border-left-color: transparent;
    box-shadow: inset 0 0 0 1px rgba(75, 141, 255, .32);
  }

  .profile {
    display: none;
  }

  .topbar {
    gap: 10px;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr auto auto;
    width: 100%;
  }

  .view {
    padding: 14px;
  }

  .feature-guide,
  .dashboard-hero,
  .card {
    border-radius: 16px;
  }

  .export-filter-tools {
    grid-template-columns: 1fr;
  }

  .responsive-table,
  .responsive-table thead,
  .responsive-table tbody,
  .responsive-table th,
  .responsive-table td,
  .responsive-table tr {
    display: block;
    width: 100%;
  }

  .responsive-table thead {
    display: none;
  }

  .responsive-table tbody {
    display: grid;
    gap: 12px;
  }

  .responsive-table tr {
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    padding: 10px;
    background: color-mix(in srgb, var(--card) 90%, var(--blue) 10%);
  }

  .responsive-table td {
    border: 0 !important;
    padding: 8px 4px !important;
    min-height: 34px;
  }

  .responsive-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
  }

  #requestTable td:first-child {
    width: 100%;
    min-width: 0;
  }

  #requestTable .approval-actions,
  .table-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
    gap: 8px;
  }

  .table-actions button,
  #requestTable .approval-actions button {
    width: 100%;
  }

  .department-groups {
    gap: 14px;
  }

  .dept-group-head {
    align-items: flex-start;
  }
}

/* Batch request, access cleanup, and mobile polish v4 */
[hidden] { display: none !important; }

#approval-view .approval-form-card .request-form-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  align-items: end;
  gap: 14px;
}

.request-items-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--border) 78%, var(--blue) 22%);
  border-radius: 16px;
  background: color-mix(in srgb, var(--card-soft) 72%, var(--blue) 8%);
}

.inline-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.inline-section-head strong {
  display: block;
  margin-top: 4px;
  font-size: 15px;
}

.mini-label {
  display: inline-block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.request-lines {
  display: grid;
  gap: 10px;
}

.request-line {
  display: grid;
  grid-template-columns: 38px minmax(320px, 1fr) minmax(100px, 130px) auto;
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg) 88%, var(--blue) 7%);
}

.request-line-number {
  width: 32px;
  height: 32px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  background: linear-gradient(135deg, var(--blue), #19b8ff);
  box-shadow: 0 10px 24px rgba(37, 99, 235, .22);
  margin-top: 22px;
}

.request-line label {
  min-width: 0;
}

.request-line-search {
  min-width: 0;
  width: 100%;
}

.request-line-qty-wrap input {
  text-align: center;
  font-weight: 800;
}

.request-line-remove {
  align-self: center;
  min-height: 42px;
  padding-inline: 14px;
}

.field-hint.error-hint {
  color: var(--red);
  font-weight: 800;
}

.note-field-large textarea,
#requestNotes {
  min-height: 124px;
  font-size: 14px;
  line-height: 1.55;
  resize: vertical;
}

#approval-view .approval-form-card .primary-btn.full {
  min-height: 48px;
}

body.cannot-transfer .requires-transfer,
body.cannot-manage-master .requires-master,
body.cannot-users .requires-users {
  display: none !important;
}

#master-stock-view .master-stock-data,
#department-stock-view .span-two,
#approval-view .approval-data-card {
  width: 100%;
}

#requestTable td:nth-child(3) strong {
  display: block;
  max-width: 320px;
  white-space: normal;
  line-height: 1.35;
}

@media (max-width: 980px) {
  #approval-view .approval-form-card .request-form-grid {
    grid-template-columns: 1fr 1fr !important;
  }
  #approval-view .approval-form-card .request-form-grid .full {
    grid-column: 1 / -1 !important;
  }
  .request-line {
    grid-template-columns: 34px minmax(0, 1fr) 108px;
  }
  .request-line-remove {
    grid-column: 2 / -1;
    width: 100%;
  }
}

@media (max-width: 640px) {
  #approval-view .approval-form-card .request-form-grid {
    grid-template-columns: 1fr !important;
  }
  .inline-section-head {
    display: grid;
  }
  .inline-section-head .small-action {
    width: 100%;
  }
  .request-line {
    grid-template-columns: 1fr;
  }
  .request-line-number {
    margin-top: 0;
    width: 100%;
    height: 30px;
  }
  .request-line-remove {
    grid-column: auto;
  }
  .note-field-large textarea,
  #requestNotes {
    min-height: 150px;
  }
}

/* Approval request form usability polish v5: clean vertical layout */
#approval-view .approval-form-card {
  padding: 18px !important;
  overflow: visible;
}

#requestForm.request-form-clean {
  display: grid !important;
  grid-template-columns: 1fr !important;
  gap: 16px !important;
  width: 100%;
  align-items: stretch !important;
}

#requestForm.request-form-clean .request-items-panel {
  grid-column: 1 / -1 !important;
  width: 100%;
  min-width: 0;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid color-mix(in srgb, var(--border) 72%, var(--blue) 28%);
  background:
    radial-gradient(circle at top left, color-mix(in srgb, var(--blue) 20%, transparent), transparent 36%),
    color-mix(in srgb, var(--card-soft) 88%, var(--blue) 6%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04);
}

.request-items-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-soft);
}

.request-items-head .helper-text {
  max-width: 780px;
}

#requestLines.request-lines {
  display: grid;
  gap: 12px;
  margin-top: 2px;
}

#requestLines .request-line {
  width: 100%;
  min-width: 0;
  display: grid !important;
  grid-template-columns: 42px minmax(420px, 1fr) minmax(110px, 140px) minmax(86px, auto) !important;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--border-soft) 82%, var(--blue) 18%);
  background: color-mix(in srgb, var(--bg) 80%, var(--blue) 7%);
}

#requestLines .request-line-number {
  margin-top: 0 !important;
  align-self: center;
  width: 36px;
  height: 36px;
  border-radius: 13px;
  font-size: 14px;
}

#requestLines .request-line-item {
  min-width: 0;
}

#requestLines .request-line-search {
  min-height: 44px;
  width: 100%;
  font-size: 14px;
  font-weight: 800;
}

#requestLines .request-line-qty-wrap input {
  min-height: 44px;
  text-align: center;
  font-size: 15px;
  font-weight: 900;
}

#requestLines .request-line-info {
  display: block;
  min-height: 18px;
  overflow-wrap: anywhere;
}

#requestLines .request-line-remove {
  align-self: end;
  min-height: 44px;
  white-space: nowrap;
}

.request-meta-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(240px, 1.1fr) minmax(320px, 2fr) minmax(170px, .8fr);
  gap: 14px;
  align-items: end;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--border-soft);
  background: color-mix(in srgb, var(--bg) 84%, var(--blue) 5%);
}

.request-meta-panel label {
  min-width: 0;
}

.request-meta-panel input,
.request-meta-panel select,
.request-meta-panel textarea {
  min-height: 44px !important;
  border-radius: 12px;
  font-size: 13px;
}

.request-meta-panel .note-field-large textarea,
#requestNotes {
  min-height: 76px !important;
  height: 76px;
  resize: vertical;
  line-height: 1.5;
  font-size: 14px;
  padding-block: 12px;
}

.request-submit-btn {
  min-height: 52px !important;
  width: 100%;
  border-radius: 14px !important;
  font-size: 14px;
  font-weight: 900;
}

.request-form-note {
  margin-top: 12px !important;
  padding: 10px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--blue) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--border) 70%, var(--blue) 30%);
}

#approval-view .approval-data-card {
  margin-top: 12px;
}

#approval-view .approval-toolbar .export-filter-tools {
  grid-template-columns: minmax(170px, 1.1fr) minmax(150px, .9fr) minmax(120px, .7fr) minmax(120px, .7fr) minmax(120px, .7fr) minmax(150px, .9fr);
}

@media (max-width: 1120px) {
  #requestLines .request-line {
    grid-template-columns: 38px minmax(0, 1fr) minmax(104px, 130px) minmax(82px, auto) !important;
  }
  .request-meta-panel {
    grid-template-columns: 1fr 1fr;
  }
  .request-meta-panel .note-field-large {
    grid-column: 1 / -1;
  }
  .request-submit-btn {
    grid-column: 1 / -1;
  }
  #approval-view .approval-toolbar .export-filter-tools {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  #approval-view .approval-form-card {
    padding: 14px !important;
  }
  .request-items-head {
    grid-template-columns: 1fr;
  }
  .request-items-head .small-action {
    width: 100%;
    min-height: 44px;
  }
  #requestLines .request-line {
    grid-template-columns: 1fr !important;
    padding: 12px;
  }
  #requestLines .request-line-number {
    width: 100%;
    height: 32px;
  }
  #requestLines .request-line-remove {
    width: 100%;
  }
  .request-meta-panel {
    grid-template-columns: 1fr;
    padding: 14px;
  }
  .request-meta-panel .note-field-large,
  .request-submit-btn {
    grid-column: auto;
  }
  .request-meta-panel .note-field-large textarea,
  #requestNotes {
    min-height: 140px !important;
    height: 140px;
  }
  #approval-view .approval-toolbar .export-filter-tools {
    grid-template-columns: 1fr;
  }
}


/* Domain/LAN + mobile notification polish v6 */
/* Toast/notifikasi kecil dibuat muncul di atas, bukan di bawah layar HP. */
.toast {
  top: 76px !important;
  right: 18px !important;
  bottom: auto !important;
  left: auto !important;
  z-index: 1200 !important;
  max-width: min(420px, calc(100vw - 28px)) !important;
  transform: translateY(-12px) !important;
}

.toast.show {
  transform: translateY(0) !important;
}

.notification-modal {
  z-index: 1300 !important;
  align-items: flex-start !important;
  justify-content: flex-end !important;
  padding-top: 64px !important;
}

.notification-modal .modal-panel {
  max-height: calc(100dvh - 84px) !important;
}

@media (max-width: 760px) {
  .topbar {
    position: sticky;
    top: 0;
    z-index: 80;
  }

  .toast {
    top: calc(env(safe-area-inset-top, 0px) + 10px) !important;
    left: 10px !important;
    right: 10px !important;
    bottom: auto !important;
    width: auto !important;
    max-width: none !important;
    border-radius: 16px !important;
    padding: 12px 14px !important;
    font-size: 13px !important;
    line-height: 1.45 !important;
  }

  .notification-modal {
    justify-content: center !important;
    align-items: flex-start !important;
    padding: calc(env(safe-area-inset-top, 0px) + 10px) 10px 10px !important;
  }

  .notification-modal .modal-panel {
    width: 100% !important;
    max-height: calc(100dvh - 20px - env(safe-area-inset-top, 0px)) !important;
    border-radius: 18px !important;
  }

  .notification-list {
    max-height: calc(100dvh - 116px - env(safe-area-inset-top, 0px));
    overflow: auto;
  }

  .notification-item {
    padding: 12px !important;
    border-radius: 14px !important;
  }

  .notification-text span {
    white-space: normal !important;
    overflow-wrap: anywhere !important;
  }
}


/* ARBECEL official logo fit for cPanel package */
.brand-mark.logo img { object-fit: contain; background: transparent; }
.auth-card .brand-mark.logo { width: 52px; height: 52px; }
.auth-card .brand-mark.logo img { width: 100%; height: 100%; object-fit: contain; }
