/* ============================================================
   TOKO MAKMUR — KASIR DIGITAL
   Design System: Light Blue Modern Theme
   ============================================================ */

:root {
  --ink: #1A2B4A;
  --paper: #EBF4FF;
  --paper-dark: #D5E8FA;
  --brass: #2563EB;
  --brass-dark: #1D4ED8;
  --stamp: #DC2626;
  --green: #16A34A;
  --blue: #2563EB;
  --line: #BFDBFE;
  --white: #F0F7FF;
  --sidebar-bg: #1E3A5F;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Work Sans', sans-serif;
  background: var(--paper-dark);
  color: var(--ink);
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */

#login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(135deg, #1E3A5F 0%, #2563EB 50%, #60A5FA 100%);
}

.login-box {
  background: var(--white);
  border-radius: 14px;
  padding: 44px 40px 36px;
  width: 380px;
  box-shadow: 0 24px 80px rgba(0,0,0,.6);
  text-align: center;
}

.login-logo {
  font-size: 48px;
  margin-bottom: 10px;
  animation: pop .5s ease;
}

@keyframes pop {
  0% { transform: scale(.5); opacity: 0; }
  70% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

.login-brand {
  font-family: 'Fraunces', serif;
  font-size: 30px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
}

.login-sub {
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--brass);
  margin-bottom: 28px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}

.login-hint {
  font-size: 11.5px;
  color: #9C8F76;
  margin-top: 18px;
}

/* ============================================================
   APP LAYOUT
   ============================================================ */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: linear-gradient(180deg, #1E3A5F 0%, #1A3354 60%, #152C47 100%);
  color: var(--white);
  display: flex;
  flex-direction: column;
  padding: 28px 20px;
  position: relative;
}

.sidebar::after {
  content: "";
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, #60A5FA, #2563EB);
}

.brand {
  font-family: 'Fraunces', serif;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: 2px;
  color: #FFFFFF;
}

.brand-sub {
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #93C5FD;
  margin-bottom: 30px;
}

.nav { display: flex; flex-direction: column; gap: 3px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: #BFDBFE;
  transition: background .15s ease, color .15s ease;
  user-select: none;
}

.nav-item:hover { background: rgba(96,165,250,.2); }
.nav-item.active { background: #2563EB; color: #fff; font-weight: 600; }
.nav-icon { font-size: 15px; width: 18px; text-align: center; }

.sidebar-foot {
  margin-top: auto;
  font-size: 11px;
  color: #7EB2D8;
  line-height: 1.5;
  border-top: 1px solid rgba(255,255,255,.15);
  padding-top: 14px;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  background-image: linear-gradient(rgba(191,219,254,0.5) 1px, transparent 1px);
  background-size: 100% 34px;
  min-height: 100vh;
  overflow-x: hidden;
}

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 26px 40px 14px;
  background: var(--paper);
}

.topbar h1 {
  font-family: 'Fraunces', serif;
  font-size: 28px;
  margin: 0;
  font-weight: 600;
}

.topbar .meta {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12.5px;
  color: #4A7DB5;
}

.content { padding: 6px 40px 40px; flex: 1; }

/* ============================================================
   PANELS & TABLES
   ============================================================ */

.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  margin-bottom: 22px;
  box-shadow: 0 1px 0 rgba(0,0,0,.03);
}

.panel h2 {
  font-family: 'Fraunces', serif;
  font-size: 18px;
  margin: 0 0 16px;
  font-weight: 600;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }

th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #8A806A;
  padding: 0 10px 10px;
  border-bottom: 1px solid var(--line);
}

td {
  padding: 11px 10px;
  border-bottom: 1px solid #EDE4CE;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13.5px;
}

td.nm, th.nm { font-family: 'Work Sans', sans-serif; }
tr:last-child td { border-bottom: none; }

.stok-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  font-family: 'Work Sans', sans-serif;
  font-weight: 600;
}

.stok-ok { background: #E4EEE3; color: var(--green); }
.stok-low { background: #F5E1DF; color: var(--stamp); }
.stok-low-text { color: var(--stamp) !important; font-weight: 600; }

.kategori-badge {
  background: #DBEAFE;
  color: #1E40AF;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-family: 'Work Sans', sans-serif;
}

.margin-badge {
  background: #D1FAE5;
  color: #065F46;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-family: 'Work Sans', sans-serif;
  font-weight: 600;
}

/* ============================================================
   INPUTS & FORMS
   ============================================================ */

input, select {
  font-family: 'Work Sans', sans-serif;
  font-size: 13.5px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  width: 100%;
  transition: border-color .12s ease, outline .12s ease;
}

input:focus, select:focus {
  outline: 2px solid var(--brass);
  outline-offset: 1px;
  border-color: var(--brass);
}

label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #8A806A;
  display: block;
  margin-bottom: 5px;
}

.form-grid-barang {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr 1fr auto;
  gap: 10px;
  align-items: end;
}

.form-hutang {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr auto;
  gap: 10px;
  align-items: end;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  font-family: 'Work Sans', sans-serif;
  font-weight: 600;
  font-size: 13.5px;
  padding: 10px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: transform .08s ease, opacity .15s ease, background .12s ease;
  white-space: nowrap;
}

.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:active { transform: scale(.97); }
.btn-brass { background: var(--brass); color: #fff; }
.btn-brass:hover:not(:disabled) { background: var(--brass-dark); }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover:not(:disabled) { background: #F1EAD8; }
.btn-stamp { background: var(--stamp); color: #fff; }
.btn-stamp:hover:not(:disabled) { opacity: .88; }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.row-actions { display: flex; gap: 8px; }
.empty { text-align: center; padding: 36px 10px; color: #8A806A; font-size: 14px; }

/* ============================================================
   KASIR
   ============================================================ */

.kasir-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 22px;
  align-items: start;
}

.kasir-filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-wrap { flex: 1; min-width: 180px; position: relative; }
.search-wrap .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  pointer-events: none;
}
.search-wrap input { padding-left: 32px; }
.kasir-filter-bar select { width: auto; min-width: 140px; }

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 12px;
}

.product-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  cursor: pointer;
  transition: border-color .12s ease, transform .1s ease, box-shadow .1s ease;
  position: relative;
  user-select: none;
}

.product-card:hover {
  border-color: var(--brass);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37,99,235,.15);
}

.product-card.disabled { opacity: .4; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

.product-swatch {
  width: 100%;
  height: 80px;
  border-radius: 6px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #fff;
}

.product-name { font-size: 13px; font-weight: 600; margin-bottom: 2px; line-height: 1.3; }
.product-category { font-size: 10px; color: #8A806A; margin-bottom: 3px; }
.product-price { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: #6B6350; }
.product-stock { font-size: 11px; color: #8A806A; margin-top: 4px; }

.cart-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #2563EB;
  color: #fff;
  border-radius: 50%;
  width: 21px;
  height: 21px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(37,99,235,.4);
  animation: badgePop .2s ease;
}

@keyframes badgePop {
  0% { transform: scale(0); }
  80% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.cart {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.cart h2 { font-family: 'Fraunces', serif; font-size: 17px; margin: 0 0 14px; }

.cart-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
  gap: 8px;
}

.cart-item .qty-ctrl { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.qty-btn {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  font-family: 'IBM Plex Mono', monospace;
  line-height: 1;
  font-size: 14px;
  transition: background .1s ease;
}
.qty-btn:hover { background: var(--paper); }

.cart-total {
  display: flex;
  justify-content: space-between;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 15px;
  font-weight: 600;
  margin: 14px 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

/* ============================================================
   MODAL
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(36,48,74,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
  backdrop-filter: blur(2px);
  animation: fadeIn .15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-box {
  background: var(--white);
  border-radius: 10px;
  padding: 28px;
  width: 520px;
  max-width: 95vw;
  position: relative;
  box-shadow: 0 24px 60px rgba(0,0,0,.4);
  max-height: 92vh;
  overflow-y: auto;
  animation: slideUp .2s ease;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.close-x {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #999;
  transition: color .1s ease;
  line-height: 1;
  padding: 4px;
}
.close-x:hover { color: var(--stamp); }

/* ============================================================
   RECEIPT / STRUK
   ============================================================ */

.receipt {
  background: #FEFCF6;
  width: 310px;
  max-height: 88vh;
  overflow-y: auto;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12.5px;
  color: #2B2B2B;
  padding: 26px 22px 30px;
  position: relative;
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
  animation: slideUp .2s ease;
}

.receipt-center { text-align: center; }
.receipt-shop { font-family: 'Fraunces', serif; font-size: 18px; font-weight: 700; }
.receipt-line { border-top: 1px dashed #999; margin: 10px 0; }
.receipt-row { display: flex; justify-content: space-between; margin: 3px 0; }

.stamp {
  position: absolute;
  top: 38%;
  right: 18px;
  transform: rotate(-16deg);
  border: 3px solid var(--stamp);
  color: var(--stamp);
  font-family: 'Work Sans', sans-serif;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: .08em;
  padding: 4px 10px;
  border-radius: 6px;
  opacity: .82;
  pointer-events: none;
}

/* ============================================================
   DASHBOARD
   ============================================================ */

.dashboard-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #8A806A;
  margin-bottom: 10px;
  margin-top: 4px;
}

.dash-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.dash-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px 16px;
  position: relative;
  overflow: hidden;
  transition: transform .1s ease, box-shadow .1s ease;
}

.dash-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0,0,0,.08);
}

.dash-card::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: var(--line);
}

.dash-card-green::after { background: var(--green); }
.dash-card-blue::after { background: var(--blue); }
.dash-card-gold::after { background: var(--brass); }
.dash-card-red::after { background: var(--stamp); }

.dash-card-icon { font-size: 24px; margin-bottom: 10px; }
.dash-card-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: #8A806A; margin-bottom: 5px; }
.dash-card-value { font-family: 'IBM Plex Mono', monospace; font-size: 17px; font-weight: 700; color: var(--ink); word-break: break-all; }

.dash-bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}

/* BAR CHART */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 160px;
  padding-top: 28px;
}

.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}

.bar-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
}

.bar-fill {
  width: 100%;
  background: linear-gradient(to top, #1D4ED8, #60A5FA);
  border-radius: 4px 4px 0 0;
  transition: height .4s ease;
  min-height: 4px;
}

.bar-label-top {
  font-size: 8.5px;
  font-family: 'IBM Plex Mono', monospace;
  color: #8A806A;
  text-align: center;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.bar-label-bottom {
  font-size: 9.5px;
  color: #8A806A;
  text-align: center;
  margin-top: 6px;
  white-space: nowrap;
}

/* STOK ALERT */
.stok-alert-list { display: flex; flex-direction: column; gap: 8px; }

.stok-alert-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: #FFF5F5;
  border-radius: 6px;
  border-left: 3px solid var(--stamp);
  transition: background .1s ease;
}

.stok-alert-item:hover { background: #FEEAEA; }
.stok-alert-ikon { font-size: 18px; }
.stok-alert-nama { flex: 1; font-size: 13.5px; font-weight: 500; }

/* ============================================================
   KELOLA BARANG: KATEGORI CHIPS
   ============================================================ */

.kategori-chips { display: flex; flex-wrap: wrap; gap: 8px; }

.kategori-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #DBEAFE;
  border-radius: 20px;
  padding: 5px 8px 5px 12px;
  font-size: 13px;
  color: var(--ink);
  border: 1px solid #BFDBFE;
}

.kategori-chip button {
  background: none;
  border: none;
  cursor: pointer;
  color: #8A806A;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background .1s ease, color .1s ease;
}

.kategori-chip button:hover { background: rgba(166,61,64,.15); color: var(--stamp); }

/* ============================================================
   LAPORAN
   ============================================================ */

.summary-row {
  display: flex;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.summary-card {
  flex: 1;
  min-width: 140px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 18px;
}

.summary-card .label {
  font-size: 11px;
  text-transform: uppercase;
  color: #8A806A;
  letter-spacing: .05em;
  margin-bottom: 0;
}

.summary-card .value {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 20px;
  font-weight: 600;
  margin-top: 6px;
}

.trx-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 10px;
  overflow: hidden;
  transition: border-color .12s ease;
}

.trx-item:hover { border-color: var(--brass); }

.trx-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 16px;
  background: var(--white);
  transition: background .1s ease;
}

.trx-head:hover { background: #F7F1E1; }

.trx-body {
  padding: 12px 16px 14px;
  background: var(--white);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12.5px;
  border-top: 1px dashed var(--line);
}

/* ============================================================
   HUTANG
   ============================================================ */

/* (uses existing tables + summary-row styles) */

/* ============================================================
   BANNERS & ALERTS
   ============================================================ */

.error-banner {
  background: #F5E1DF;
  color: var(--stamp);
  border: 1px solid var(--stamp);
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 14px;
}

.success-banner {
  background: #E4EEE3;
  color: var(--green);
  border: 1px solid var(--green);
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 14px;
}

/* ============================================================
   SPINNER
   ============================================================ */

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--line);
  border-top: 2px solid var(--brass);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   SCROLLBAR
   ============================================================ */

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; }

/* ============================================================
   PRINT STYLES
   ============================================================ */
.print-only { display: none; }

@media print {
  .print-only { display: block !important; }
  @page { margin: 0; }
  html, body { margin: 0; padding: 0; height: auto !important; min-height: 0 !important; }
  body > *:not(#modal-root) { display: none !important; }
  #modal-root .modal-overlay {
    position: static !important;
    background: none !important;
    padding: 0 !important;
    display: block !important;
    min-height: 0 !important;
    height: auto !important;
  }
  #modal-root .close-x { display: none !important; }
  #modal-root .btn { display: none !important; }
  #modal-root .receipt {
    box-shadow: none !important;
    max-height: none !important;
    width: 100% !important;
    max-width: 80mm !important;
    padding: 0 4mm !important;
    box-sizing: border-box !important;
    font-family: 'Arial', Helvetica, sans-serif !important;
  }
  #modal-root .receipt, #modal-root .receipt * {
    color: #000 !important;
    font-weight: 700 !important;
  }
  #modal-root .receipt-shop {
    font-size: 18px !important;
    font-weight: 900 !important;
    padding-bottom: 4px !important;
    border-bottom: 2px dashed #000 !important;
    margin-bottom: 8px !important;
    display: block !important;
  }
  #modal-root .stamp { display: block !important; border-color: #000 !important; color: #000 !important; }
}

/* ============================================================
   RESPONSIVE MOBILE
   ============================================================ */
@media (max-width: 768px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; padding: 15px; flex-direction: row; flex-wrap: wrap; justify-content: space-between; align-items: center; }
  .sidebar::after { display: none; }
  .sidebar .brand, .sidebar .brand-sub, .sidebar img { margin: 0; }
  .nav { flex-direction: row; flex-wrap: wrap; gap: 5px; width: 100%; margin-top: 10px; }
  .nav-item { padding: 8px 10px; font-size: 13px; flex: 1; justify-content: center; text-align: center; }
  .sidebar-foot { display: none; }
  
  .kasir-layout { grid-template-columns: 1fr; display: flex; flex-direction: column-reverse; }
  .form-grid-barang { grid-template-columns: 1fr; }
  .summary-row { grid-template-columns: 1fr 1fr; }
  
  .topbar { padding: 12px 16px; flex-direction: column; align-items: flex-start; gap: 5px; }
  #mobile-logout { display: block !important; }
  .content { padding: 12px; }
  .modal-box { width: 90% !important; margin: 20px auto; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

.nav-icon.lucide { width: 18px; height: 18px; stroke-width: 2.2; }