/* =========================================================================
   PackApp Pro — Unified UI Stylesheet
   Satu sistem konsisten untuk seluruh tampilan. Tidak ada elemen yang melebar.
   ========================================================================= */

/* ---- CSS Variables (dark default) ---- */
:root {
  /* Layout */
  --sidebar-width: 260px;
  --sidebar-collapsed: 70px;
  --topbar-height: 64px;

  /* Colors — dark theme */
  --bg-dark: #0f0f23;
  --bg-card: #1a1a2e;
  --bg-card-light: #16213e;
  --bg-surface: #12122a;
  --bg-secondary: #0f0f23;

  --accent: #7c3aed;
  --accent-light: #a78bfa;
  --accent-glow: rgba(124, 58, 237, 0.35);

  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.15);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.15);
  --info: #3b82f6;
  --info-soft: rgba(59, 130, 246, 0.15);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --border: rgba(255, 255, 255, 0.08);
  --border-soft: rgba(255, 255, 255, 0.04);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.5);
  --shadow-3d: 0 15px 35px rgba(124, 58, 237, 0.3), 0 5px 15px rgba(0, 0, 0, 0.4);

  /* Spacing */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-6: 24px;
  --s-8: 32px;
  --s-12: 48px;

  /* Radius */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-full: 9999px;

  /* Font size */
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-md: 16px;
  --text-lg: 18px;
  --text-xl: 20px;
  --text-2xl: 24px;

  /* Transition */
  --dur: 0.25s;
  --ease: ease;
}

/* ---- Light theme overrides ---- */
[data-theme="light"] {
  --bg-dark: #f3f4f8;
  --bg-card: #ffffff;
  --bg-card-light: #f5f7ff;
  --bg-surface: #f8fafc;

  --accent: #6d28d9;
  --accent-light: #8b5cf6;
  --accent-glow: rgba(109, 40, 217, 0.2);

  --success: #059669;
  --success-soft: rgba(5, 150, 105, 0.12);
  --warning: #d97706;
  --warning-soft: rgba(217, 119, 6, 0.12);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.12);
  --info: #2563eb;
  --info-soft: rgba(37, 99, 235, 0.12);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --border: rgba(0, 0, 0, 0.08);
  --border-soft: rgba(0, 0, 0, 0.04);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.08);
  --shadow-xl: 0 20px 50px rgba(0, 0, 0, 0.1);
  --shadow-3d: 0 15px 35px rgba(109, 40, 217, 0.2), 0 5px 15px rgba(0, 0, 0, 0.08);
}

/* ---- Reset ---- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  height: 100%;
  width: 100%;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Roboto", sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;      /* mencegah horizontal scroll / melebar */
  overflow-y: auto;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---- Background glow (non-intrusive) ---- */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 20% 50%, rgba(124, 58, 237, 0.12) 0%, transparent 45%),
    radial-gradient(circle at 80% 20%, rgba(59, 130, 246, 0.10) 0%, transparent 45%);
  pointer-events: none;
  z-index: 0;
}

[data-theme="light"] body::before {
  background:
    radial-gradient(circle at 20% 50%, rgba(109, 40, 217, 0.06) 0%, transparent 45%),
    radial-gradient(circle at 80% 20%, rgba(59, 130, 246, 0.04) 0%, transparent 45%);
}

/* =========================================================================
   Login Screen
   ========================================================================= */
.login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 48px 40px;
  width: 420px;
  max-width: 92vw;
  max-height: 92vh;
  overflow-y: auto;
  text-align: center;
  box-shadow: var(--shadow-xl);
  animation: fadeIn 0.5s ease;
}

.login-logo {
  font-size: 56px;
  margin-bottom: 16px;
  filter: drop-shadow(0 0 12px var(--accent-glow));
  display: inline-block;
}

.login-title {
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-light), var(--text-primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 28px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  margin-top: 4px;
}

/* =========================================================================
   Shell Layout (Sidebar + Main)
   ========================================================================= */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-card-light) 100%);
  border-right: 1px solid var(--border);
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transition: width var(--dur) var(--ease);
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-header {
  padding: 16px var(--s-4);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: var(--topbar-height);
  flex-shrink: 0;
}

.sidebar-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent), #5b21b6);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: var(--shadow-3d);
  flex-shrink: 0;
}

.sidebar.collapsed .sidebar-logo {
  width: 36px;
  height: 36px;
  font-size: 16px;
}

.sidebar-title {
  font-size: 17px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-light), #fff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.sidebar.collapsed .sidebar-title {
  display: none;
}

.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: rgba(124, 58, 237, 0.1);
  color: var(--accent-light);
  font-size: 15px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.theme-toggle:hover {
  background: rgba(124, 58, 237, 0.25);
  transform: rotate(30deg) scale(1.05);
}

[data-theme="light"] .theme-toggle {
  background: rgba(109, 40, 217, 0.1);
  color: var(--accent);
  border-color: rgba(109, 40, 217, 0.2);
}

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

.nav-section {
  margin-bottom: 8px;
}

.nav-section-title {
  padding: 10px var(--s-4) 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sidebar.collapsed .nav-section-title {
  display: none;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px var(--s-4);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item:hover {
  background: rgba(124, 58, 237, 0.1);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(124, 58, 237, 0.15);
  color: var(--accent-light);
  border-left-color: var(--accent);
  box-shadow: inset 0 0 20px rgba(124, 58, 237, 0.1);
}

.sidebar.collapsed .nav-item {
  padding: 11px var(--s-3);
  justify-content: center;
  gap: 0;
}

.sidebar.collapsed .nav-item span {
  display: none;
}

.nav-item .icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar.collapsed .nav-item .icon {
  width: auto;
  margin: 0;
}

.sidebar-footer {
  padding: 16px var(--s-4);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.sidebar.collapsed .sidebar-footer {
  flex-direction: column;
  padding: 12px var(--s-3);
  gap: 8px;
  text-align: center;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #5b21b6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 4px 12px var(--accent-glow);
  flex-shrink: 0;
}

.sidebar.collapsed .avatar {
  width: 32px;
  height: 32px;
  font-size: 12px;
}

.sidebar-footer > span {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.sidebar.collapsed .sidebar-footer > span {
  display: none;
}

/* Main content wrapper */
.main-content {
  position: absolute;
  left: var(--sidebar-width);
  right: 0;
  top: 0;
  bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg-dark);
  transition: left var(--dur) var(--ease);
}

.sidebar.collapsed ~ .main-content,
body:has(.sidebar.collapsed) .main-content {
  left: var(--sidebar-collapsed);
}

.main-content.collapsed {
  left: var(--sidebar-collapsed);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px var(--s-8);
  height: var(--topbar-height);
  flex-shrink: 0;
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border);
}

.page-title {
  font-size: 26px;
  font-weight: 700;
  background: linear-gradient(135deg, #fff, var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.3px;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 2px;
}

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

/* Content area — full width within sidebar, never overflows */
.content-area {
  flex: 1;
  padding: var(--s-6) var(--s-8) var(--s-12);
  width: 100%;
  min-width: 0;
  overflow: visible;
}

/* =========================================================================
   App root & page views
   ========================================================================= */
#app-root {
  width: 100%;
  min-width: 0;
  visibility: hidden;
}

#app-root.ready {
  visibility: visible;
}

.page-view {
  display: none;
  width: 100%;
  min-width: 0;
}

.page-view.active {
  display: block;
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =========================================================================
   Cards
   ========================================================================= */
.card {
  background: linear-gradient(145deg, var(--bg-card) 0%, var(--bg-card-light) 100%);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  margin-bottom: var(--s-6);
  box-shadow: var(--shadow-md);
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
  width: 100%;
  min-width: 0;
}

.card:hover {
  box-shadow: var(--shadow-lg);
  border-color: rgba(124, 58, 237, 0.25);
}

.card-body {
  padding: var(--s-6);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--s-4);
  padding-bottom: var(--s-3);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 10px;
}

.card-header-actions {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.card-title {
  font-size: 17px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

.card-title .icon {
  font-size: 20px;
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-4);
  padding-bottom: var(--s-3);
  border-bottom: 1px solid var(--border);
}

.card__title {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--text-primary);
}

.card__subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* =========================================================================
   Stats Grid
   ========================================================================= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--s-4);
  margin-bottom: var(--s-6);
  width: 100%;
}

.stat-card {
  background: linear-gradient(145deg, var(--bg-card) 0%, var(--bg-card-light) 100%);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-4);
  display: flex;
  align-items: center;
  gap: var(--s-3);
  box-shadow: var(--shadow-md);
  transition: all 0.25s ease;
  min-width: 0;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: rgba(124, 58, 237, 0.12);
  border: 1px solid rgba(124, 58, 237, 0.25);
  flex-shrink: 0;
}

.stat-value {
  font-size: var(--text-2xl);
  font-weight: 800;
  line-height: 1;
  color: var(--text-primary);
  min-width: 0;
}

.stat-label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-top: var(--s-1);
  line-height: 1.3;
}

.stat-card__value {
  font-size: var(--text-2xl);
  font-weight: 800;
  line-height: 1;
  color: var(--text-primary);
  min-width: 0;
}

.stat-card__label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-top: var(--s-1);
  line-height: 1.3;
}

.stat-card__delta {
  font-size: var(--text-xs);
  margin-top: var(--s-1);
}

.stat-card__delta.up {
  color: var(--success);
}

.stat-card__delta.down {
  color: var(--danger);
}

/* Aliases without BEM prefix for compatibility with dashboard markup */
.stat-card__value, .stat-value { font-size: var(--text-2xl); font-weight: 800; line-height: 1; color: var(--text-primary); min-width: 0; }
.stat-card__label, .stat-label { font-size: var(--text-xs); color: var(--text-secondary); margin-top: var(--s-1); line-height: 1.3; }

/* =========================================================================
   Tables
   ========================================================================= */
.data-table,
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
  min-width: 0;
}

.data-table th,
.table th,
.data-table td,
.table td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-primary);
}

/* Allow horizontal scroll inside cards so wide tables never break the layout */
.card > .data-table,
.card > .table {
  display: block;
  width: 100%;
  overflow-x: auto;
  min-width: 0;
}

/* =========================================================================
   Badges
   ========================================================================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--r-full);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.badge-success {
  background: var(--success-soft);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge-info {
  background: var(--info-soft);
  color: var(--info);
}

.badge-accent {
  background: rgba(124, 58, 237, 0.15);
  color: var(--accent-light);
}

.badge--success {
  background: var(--success-soft);
  color: var(--success);
}

.badge--warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge--danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge--info {
  background: var(--info-soft);
  color: var(--info);
}

/* =========================================================================
   Buttons
   ========================================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--r-md);
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #5b21b6);
  color: #fff;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px var(--accent-glow);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
}

.btn-success {
  background: linear-gradient(135deg, var(--success), #059669);
  color: #fff;
}

.btn-success:hover:not(:disabled) {
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #dc2626);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35);
}

.btn-warning {
  background: linear-gradient(135deg, var(--warning), #d97706);
  color: #fff;
}

.btn-warning:hover:not(:disabled) {
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
}

.btn-info {
  background: linear-gradient(135deg, var(--info), #2563eb);
  color: #fff;
}

.btn-info:hover:not(:disabled) {
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
}

.btn-lg {
  padding: 12px 26px;
  font-size: 16px;
}

.btn-full,
.btn-block,
.btn--block {
  width: 100%;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
}

.btn--primary:hover:not(:disabled) {
  background: var(--accent-light);
}

.btn--secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.btn--sm {
  padding: 6px 12px;
  font-size: var(--text-xs);
}

.btn--lg {
  padding: 12px 24px;
  font-size: var(--text-md);
}

/* =========================================================================
   Forms
   ========================================================================= */
.form-group {
  margin-bottom: var(--s-3);
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--s-1);
}

.form-control {
  width: 100%;
  min-width: 0;
  padding: 10px 14px;
  background: rgba(15, 15, 35, 0.5);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: all 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

.form-control::placeholder {
  color: var(--text-secondary);
  opacity: 0.5;
}

select.form-control {
  cursor: pointer;
}

select.form-control option {
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 10px 14px;
}

select.form-control option[value=""] {
  color: var(--text-secondary);
  font-style: italic;
}

[data-theme="light"] .form-control {
  background: #f8fafc;
  border-color: rgba(0, 0, 0, 0.08);
  color: var(--text-primary);
}

[data-theme="light"] .form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(109, 40, 217, 0.15);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--s-3);
  align-items: end;
}

.form-help {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--s-1);
}

/* =========================================================================
   Modals
   ========================================================================= */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  padding: var(--s-4);
  overflow-y: auto;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: linear-gradient(145deg, var(--bg-card) 0%, var(--bg-card-light) 100%);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(124, 58, 237, 0.15);
  transform: scale(0.96);
  animation: modalEnter 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

@keyframes modalEnter {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  padding: var(--s-4);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: linear-gradient(145deg, var(--bg-card) 0%, var(--bg-card-light) 100%);
  z-index: 1;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}

.modal-title {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  background: rgba(124, 58, 237, 0.1);
  border: none;
  color: var(--accent-light);
  font-size: 22px;
  cursor: pointer;
  width: 34px;
  height: 34px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: rgba(124, 58, 237, 0.25);
  color: #fff;
  transform: scale(1.05);
}

.modal-body {
  padding: var(--s-6);
  overflow-y: auto;
  max-height: calc(90vh - 120px);
  min-width: 0;
}

.modal-footer {
  padding: var(--s-4);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--s-2);
  position: sticky;
  bottom: 0;
  background: linear-gradient(145deg, var(--bg-card) 0%, var(--bg-card-light) 100%);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

[data-theme="light"] .modal {
  background: rgba(0, 0, 0, 0.35);
}

[data-theme="light"] .modal-content {
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.15),
    0 0 0 1px rgba(109, 40, 217, 0.1);
}

/* =========================================================================
   Recipe / Ingredient items
   ========================================================================= */
.recipe-card {
  background: linear-gradient(145deg, var(--bg-card) 0%, var(--bg-card-light) 100%);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  margin-bottom: var(--s-6);
  box-shadow: var(--shadow-md);
  transition: all 0.25s ease;
  min-width: 0;
}

.recipe-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--s-4);
  padding-bottom: var(--s-3);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: var(--s-2);
}

.recipe-name {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
}

.recipe-name small {
  display: block;
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--text-secondary);
  margin-top: var(--s-1);
}

.recipe-meta {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
}

.ingredient-item {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  background: rgba(15, 15, 35, 0.4);
  border-radius: var(--r-md);
  margin-bottom: var(--s-2);
  border: 1px solid var(--border);
  flex-wrap: wrap;
  min-width: 0;
}

.ingredient-name {
  font-weight: 500;
  flex: 1;
  min-width: 110px;
  color: var(--text-primary);
}

.ingredient-qty {
  color: var(--accent-light);
  font-weight: 600;
  white-space: nowrap;
}

.ingredient-unit {
  color: var(--text-secondary);
  font-size: var(--text-xs);
  margin-left: 4px;
  white-space: nowrap;
}

/* =========================================================================
   Calculator
   ========================================================================= */
.calc-container {
  background: linear-gradient(145deg, var(--bg-card) 0%, var(--bg-card-light) 100%);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  box-shadow: var(--shadow-md);
  min-width: 0;
}

.calc-actions {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  margin-top: var(--s-3);
}

.calc-actions .btn {
  width: 100%;
}

.calc-result {
  background: rgba(15, 15, 35, 0.5);
  border-radius: var(--r-md);
  padding: var(--s-4);
  margin-top: var(--s-4);
  border: 1px solid var(--border);
}

.calc-result-item {
  display: flex;
  justify-content: space-between;
  padding: var(--s-1) 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.calc-result-item:last-child {
  border-bottom: none;
}

.calc-total {
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--accent-light);
  margin-top: var(--s-3);
  padding-top: var(--s-3);
  border-top: 2px solid var(--accent);
}

/* =========================================================================
   Empty states
   ========================================================================= */
.empty {
  text-align: center;
  padding: var(--s-12) var(--s-4);
  color: var(--text-secondary);
}

.empty__icon {
  font-size: 48px;
  margin-bottom: var(--s-3);
  display: block;
}

.empty__title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--s-2);
}

.empty__desc {
  font-size: var(--text-sm);
}

/* =========================================================================
   Stock indicators
   ========================================================================= */
.stock-low {
  color: var(--danger);
  font-weight: 600;
}

.stock-ok {
  color: var(--success);
}

.stock-warning {
  color: var(--warning);
}

/* =========================================================================
   Grid & layout utilities
   ========================================================================= */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-4);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-4);
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s-4);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

.stack--sm {
  gap: var(--s-2);
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-2 {
  gap: var(--s-2);
}

.gap-3 {
  gap: var(--s-3);
}

.gap-4 {
  gap: var(--s-4);
}

.mb-2 {
  margin-bottom: var(--s-2);
}

.mb-3 {
  margin-bottom: var(--s-3);
}

.mb-4 {
  margin-bottom: var(--s-4);
}

.mt-2 {
  margin-top: var(--s-2);
}

.mt-3 {
  margin-top: var(--s-3);
}

.mt-4 {
  margin-top: var(--s-4);
}

.text-sm {
  font-size: var(--text-sm);
}

.text-xs {
  font-size: var(--text-xs);
}

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

.text-soft {
  color: var(--text-secondary);
}

.font-bold {
  font-weight: 700;
}

.w-full {
  width: 100%;
}

.overflow-hidden {
  overflow: hidden;
}

.text-right {
  text-align: right;
}

/* =========================================================================
   Toast
   ========================================================================= */
.toast {
  position: fixed;
  top: var(--s-4);
  right: var(--s-4);
  padding: var(--s-2) var(--s-4);
  border-radius: var(--r-md);
  color: #fff;
  z-index: 9999;
  font-size: var(--text-sm);
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  min-width: 0;
  max-width: 90vw;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.toast.success {
  background: var(--success);
}

.toast.danger {
  background: var(--danger);
}

.toast.warning {
  background: var(--warning);
}

.toast.info {
  background: var(--info);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* =========================================================================
   Scrollbar
   ========================================================================= */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

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

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

.sidebar-nav::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}

/* =========================================================================
   Responsive — mencegah melebar pada layar kecil
   ========================================================================= */
@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }

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

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

  .topbar {
    padding: 14px var(--s-6);
  }

  .content-area {
    padding: var(--s-4) var(--s-6) var(--s-8);
  }
}

@media (max-width: 768px) {
  .sidebar {
    width: var(--sidebar-collapsed);
    z-index: 110;
  }

  .sidebar.collapsed {
    width: var(--sidebar-collapsed);
  }

  .sidebar-title,
  .nav-section-title,
  .nav-item span,
  .sidebar-footer > span {
    display: none;
  }

  .nav-item {
    justify-content: center;
    padding: 11px var(--s-3);
    gap: 0;
  }

  .main-content,
  .main-content.collapsed {
    left: var(--sidebar-collapsed);
  }

  .topbar {
    padding: 12px var(--s-4);
  }

  .page-title {
    font-size: 20px;
  }

  .content-area {
    padding: var(--s-4) var(--s-4) var(--s-8);
  }

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

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .modal-content {
    max-width: 95vw;
    max-height: 95vh;
    margin: var(--s-2);
  }

  .modal-body {
    max-height: calc(95vh - 140px);
  }

  .login-card {
    width: 92vw;
    padding: 32px 24px;
    max-height: 95vh;
  }

  .table-wrapper {
    overflow-x: auto;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--s-2);
  }
}

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

  .content-area {
    padding: var(--s-2) var(--s-3) var(--s-6);
  }

  .stat-card {
    padding: var(--s-3);
  }

  .card {
    padding: var(--s-4);
  }

  .modal-content {
    border-radius: var(--r-md);
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding: var(--s-4);
  }

  .btn {
    padding: 10px 16px;
    font-size: 13px;
  }
}

/* =========================================================================
   Print-friendly tweaks
   ========================================================================= */
@media print {
  body::before {
    display: none;
  }
  .sidebar,
  .topbar,
  .btn,
  .modal,
  .toast {
    display: none !important;
  }
  .content-area {
    padding: 0;
  }
}