@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

:root {
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-200: #bfdbfe;
  --blue-400: #60a5fa;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --blue-800: #1e40af;
  --blue-900: #1e3a8a;
  --white: #ffffff;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --success: #10b981;
  --success-light: #ecfdf5;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.10), 0 4px 8px rgba(0,0,0,0.06);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.app-shell { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

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

.topbar-brand .brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--blue-600), var(--blue-800));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 15px;
}

.topbar-brand .brand-text {
  font-size: 13px;
  font-weight: 700;
  color: var(--blue-800);
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.topbar-brand .brand-sub {
  font-size: 10px;
  font-weight: 400;
  color: var(--gray-400);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.topbar-nav {
  display: flex;
  gap: 4px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--gray-500);
  background: transparent;
}

.nav-btn:hover { background: var(--blue-50); color: var(--blue-600); }

.nav-btn.active {
  background: var(--blue-600);
  color: white;
}

.main-content { flex: 1; padding: 28px 24px; max-width: 1100px; margin: 0 auto; width: 100%; }

.page { display: none; }
.page.active { display: block; }

.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-800);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .icon {
  width: 28px;
  height: 28px;
  background: var(--blue-50);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--blue-600);
  font-size: 13px;
}

.card-body { padding: 20px 24px; }

.form-row { display: grid; grid-template-columns: 1fr 200px; gap: 12px; align-items: end; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--gray-600); letter-spacing: 0.02em; text-transform: uppercase; }

.form-input {
  padding: 9px 13px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  color: var(--gray-800);
  background: var(--white);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.form-input:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-primary { background: var(--blue-600); color: white; }
.btn-primary:hover { background: var(--blue-700); }

.btn-danger { background: var(--danger-light); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: white; }

.btn-ghost { background: transparent; color: var(--gray-500); border: 1.5px solid var(--gray-200); }
.btn-ghost:hover { border-color: var(--blue-400); color: var(--blue-600); background: var(--blue-50); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 7px; }

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

table { width: 100%; border-collapse: collapse; }

th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

td {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--blue-50); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}

.badge-blue { background: var(--blue-100); color: var(--blue-700); }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
  transform: translateY(10px);
  transition: transform 0.2s;
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title { font-size: 15px; font-weight: 700; color: var(--gray-800); }

.modal-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; }

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--gray-100);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.close-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-400);
  font-size: 18px;
  line-height: 1;
  padding: 2px;
  transition: color 0.15s;
}
.close-btn:hover { color: var(--gray-700); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

.price-display {
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  font-weight: 500;
  color: var(--blue-700);
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-400);
}

.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 13px; }

.nota-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.nota-page-title { font-size: 18px; font-weight: 700; color: var(--gray-800); }

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

.product-section {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.product-section-header {
  padding: 12px 18px;
  background: var(--blue-600);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.product-section-title {
  font-size: 14px;
  font-weight: 700;
  color: white;
  display: flex;
  align-items: center;
  gap: 10px;
}

.product-price-tag {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  background: rgba(255,255,255,0.2);
  color: white;
  padding: 3px 9px;
  border-radius: 99px;
  transition: opacity 0.2s;
}

.product-price-tag.hidden { opacity: 0; pointer-events: none; }

.product-section-header-right { display: flex; align-items: center; gap: 8px; }

.hide-price-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 6px;
  color: white;
  cursor: pointer;
  padding: 5px 8px;
  font-size: 14px;
  transition: background 0.15s;
  line-height: 1;
}
.hide-price-btn:hover { background: rgba(255,255,255,0.25); }

.remove-product-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 6px;
  color: white;
  cursor: pointer;
  padding: 5px 8px;
  font-size: 13px;
  transition: background 0.15s;
  line-height: 1;
}
.remove-product-btn:hover { background: rgba(239,68,68,0.4); }

.kg-grid-wrap { padding: 16px 18px; }

.kg-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}

.kg-cell {
  padding: 7px 8px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  text-align: center;
  color: var(--gray-800);
  background: var(--gray-50);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  width: 100%;
}

.kg-cell:focus {
  border-color: var(--blue-500);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.kg-cell.has-value { background: var(--blue-50); border-color: var(--blue-200); color: var(--blue-800); }

.product-summary {
  border-top: 1px solid var(--gray-100);
  padding: 10px 18px;
  display: flex;
  gap: 20px;
  background: var(--gray-50);
}

.product-summary-item { font-size: 12px; color: var(--gray-500); }
.product-summary-item strong { color: var(--gray-800); font-weight: 600; }
.product-summary-item .mono { font-family: 'DM Mono', monospace; }

.subtotal-card {
  background: var(--white);
  border: 1.5px solid var(--blue-200);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}

.subtotal-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--blue-700);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--blue-100);
}

.subtotal-products { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }

.subtotal-product-badge {
  background: var(--blue-50);
  border: 1px solid var(--blue-200);
  border-radius: 8px;
  padding: 7px 13px;
  font-size: 12px;
  color: var(--blue-700);
}

.subtotal-product-badge .sbname { font-weight: 600; margin-bottom: 2px; }
.subtotal-product-badge .sbval { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--blue-500); }

.subtotal-total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--blue-100);
}

.subtotal-label { font-size: 13px; font-weight: 700; color: var(--gray-700); }

.subtotal-amount-wrap { display: flex; align-items: center; gap: 10px; }

.subtotal-amount {
  font-family: 'DM Mono', monospace;
  font-size: 20px;
  font-weight: 700;
  color: var(--blue-700);
}

.adj-btns { display: flex; gap: 4px; }

.adj-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1.5px solid var(--gray-200);
  background: var(--white);
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-600);
  transition: all 0.15s;
  line-height: 1;
}

.adj-btn:hover { border-color: var(--blue-400); color: var(--blue-600); background: var(--blue-50); }

.adj-indicator {
  font-size: 11px;
  font-family: 'DM Mono', monospace;
  color: var(--gray-400);
  min-width: 60px;
  text-align: center;
}

.product-picker-list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; }

.product-picker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  background: var(--white);
}

.product-picker-item:hover { border-color: var(--blue-400); background: var(--blue-50); }
.product-picker-item.already-added { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

.product-picker-item .pname { font-size: 13px; font-weight: 600; color: var(--gray-800); }
.product-picker-item .pprice { font-family: 'DM Mono', monospace; font-size: 12px; color: var(--blue-600); }

.riwayat-list { display: flex; flex-direction: column; gap: 8px; }

.riwayat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--white);
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: var(--shadow-sm);
}

.riwayat-item:hover { border-color: var(--blue-300); box-shadow: var(--shadow-md); transform: translateY(-1px); }

.riwayat-item-left {}
.riwayat-item-id { font-family: 'DM Mono', monospace; font-size: 13px; font-weight: 600; color: var(--blue-700); margin-bottom: 3px; }
.riwayat-item-date { font-size: 11px; color: var(--gray-400); }

.riwayat-item-right { text-align: right; }
.riwayat-item-total { font-family: 'DM Mono', monospace; font-size: 14px; font-weight: 700; color: var(--gray-800); }
.riwayat-item-count { font-size: 11px; color: var(--gray-400); margin-top: 2px; }

.detail-modal { max-width: 520px; }

.detail-product-row {
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13px;
}
.detail-product-row:last-child { border-bottom: none; }
.detail-product-name { font-weight: 600; color: var(--gray-800); margin-bottom: 4px; }
.detail-product-values { display: flex; gap: 16px; color: var(--gray-500); font-family: 'DM Mono', monospace; font-size: 12px; }

.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: none;
}

.alert.show { display: block; }
.alert-danger { background: var(--danger-light); color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: var(--success-light); color: var(--success); border: 1px solid #a7f3d0; }

.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }

.nota-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 72px 24px;
  text-align: center;
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius-lg);
  background: var(--white);
}

.nota-empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.nota-empty h3 { font-size: 15px; font-weight: 600; color: var(--gray-600); margin-bottom: 6px; }
.nota-empty p { font-size: 13px; color: var(--gray-400); }

@media (max-width: 640px) {
  .topbar { padding: 0 14px; }
  .main-content { padding: 16px 14px; }
  .form-row { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .nav-btn span.label { display: none; }
  .kg-grid { gap: 4px; }
  .kg-cell { font-size: 12px; padding: 6px 4px; }
  .subtotal-amount { font-size: 16px; }
}

@media print {
  .topbar, .nota-actions, .product-section-header-right, .adj-btns, .adj-indicator,
  .remove-product-btn, .hide-price-btn { display: none !important; }
  body { background: white; }
  .main-content { padding: 0; max-width: 100%; }
  .product-section { break-inside: avoid; box-shadow: none; border: 1px solid #ddd; }
  .subtotal-card { break-inside: avoid; box-shadow: none; }
  .product-section-header { background: #1d4ed8 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
