:root {
  /* BerBisnis — palet profesional corporate */
  --bg: #f7f6f2;              /* off-white warm, premium */
  --bg-deep: #ecebe5;
  --panel: #ffffff;
  --ink: #1a2238;             /* navy gelap, premium */
  --ink-soft: #5a6275;
  --line: #e3e0d6;
  --primary: #1e3a5f;         /* navy korporat */
  --primary-dark: #142944;
  --primary-light: #4d6f99;
  --accent: #c9a352;          /* emas elegant (lebih soft dari kuning) */
  --accent-dark: #a3823a;
  --revenue: #16a34a;
  --profit: #059669;
  --stock: #2563eb;
  --alert: #d97706;
  --danger: #dc2626;
  --shadow-sm: 0 1px 2px rgba(26,34,56,.04);
  --shadow-md: 0 1px 2px rgba(26,34,56,.05), 0 4px 16px rgba(26,34,56,.06);
  --shadow-lg: 0 4px 8px rgba(26,34,56,.06), 0 20px 40px rgba(26,34,56,.1);
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===================== TOPBAR ===================== */
.topbar {
  display: flex; align-items: center; gap: 28px;
  padding: 16px 28px;
  background: linear-gradient(180deg, #ffffff, #fafaf6);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
  box-shadow: 0 1px 0 rgba(0,0,0,.02);
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 220px; }
.brand-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  padding: 4px;
  box-shadow: 0 4px 14px rgba(30, 58, 95, .25), inset 0 0 0 1px rgba(255,255,255,.1);
  object-fit: contain;
  display: block;
}
.brand-title {
  font-weight: 800; font-size: 18px; letter-spacing: -.3px;
  color: var(--ink);
  display: flex; align-items: center; gap: 6px;
}
.brand-title::after {
  content: 'PRO'; font-size: 9px; font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff; padding: 2px 6px; border-radius: 4px; letter-spacing: .5px;
}
.brand-sub { font-size: 12px; color: var(--ink-soft); margin-top: 1px; }

.tabs {
  display: flex; gap: 2px; flex: 1; justify-content: center;
  background: var(--bg-deep); padding: 4px; border-radius: 12px;
}
.tab {
  background: transparent; border: none;
  padding: 9px 18px; border-radius: 8px;
  color: var(--ink-soft); font-weight: 600; cursor: pointer;
  font-size: 13px; font-family: inherit;
  transition: all .15s;
  white-space: nowrap;
}
.tab:hover { color: var(--ink); background: rgba(255,255,255,.6); }
.tab.active {
  background: #fff; color: var(--primary);
  box-shadow: 0 1px 3px rgba(26,34,56,.08), 0 0 0 1px rgba(26,34,56,.04);
}

.topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.topbar-actions #user-info {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 180px;
}
@media (max-width: 1200px) {
  .topbar-actions #user-info { max-width: 120px; font-size: 10px !important; }
}

/* ===================== BUTTONS ===================== */
.btn {
  padding: 10px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff;
  cursor: pointer; font-weight: 600; font-size: 13px; font-family: inherit;
  color: var(--ink);
  transition: all .15s;
  letter-spacing: -.1px;
}
.btn:hover { background: var(--bg-deep); border-color: var(--ink-soft); }
.btn-primary {
  background: var(--primary); color: #fff; border-color: var(--primary);
  box-shadow: 0 1px 2px rgba(30,58,95,.2), 0 4px 8px rgba(30,58,95,.15);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); transform: translateY(-1px); }
.btn-primary:disabled { background: #c4c8d0; border-color: #c4c8d0; cursor: not-allowed; box-shadow: none; transform: none; }
.btn-ghost { background: var(--bg-deep); }
.btn-ghost:hover { background: #e0ddd0; }
.btn-danger { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-gold {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff; border-color: var(--accent-dark);
}
.btn-small { padding: 6px 12px; font-size: 11px; }
.btn-large { padding: 14px 22px; font-size: 15px; }
.btn-block { width: 100%; }

/* ===================== MAIN ===================== */
main { max-width: 1440px; margin: 0 auto; padding: 24px 28px 60px; }
.tab-panel { display: none; animation: fadeUp .2s; }
.tab-panel.active { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.page-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  flex-wrap: wrap; gap: 16px; margin-bottom: 24px;
  padding-bottom: 18px; border-bottom: 1px solid var(--line);
}
.page-head h1 {
  font-size: 26px; font-weight: 800; letter-spacing: -.5px;
  display: flex; align-items: center; gap: 10px;
}
.page-head small { color: var(--ink-soft); }

.page-filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.page-filters input, .page-filters select {
  padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 10px;
  font-family: inherit; font-size: 13px; background: #fff;
  color: var(--ink); min-width: 140px;
}
.page-filters input:focus, .page-filters select:focus {
  outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary);
}

/* ===================== KPI CARDS ===================== */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.card {
  background: #fff; border-radius: 16px; padding: 20px;
  box-shadow: var(--shadow-sm); border: 1px solid var(--line);
  display: flex; gap: 14px; align-items: flex-start;
  position: relative; overflow: hidden;
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
}
.card::before {
  content: ''; position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}
.card-revenue::before { background: linear-gradient(90deg, #10b981, #34d399); }
.card-profit::before { background: linear-gradient(90deg, var(--accent), var(--accent-dark)); }
.card-stock::before { background: linear-gradient(90deg, #2563eb, #60a5fa); }
.card-alert::before { background: linear-gradient(90deg, #d97706, #fbbf24); }

.card-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center; font-size: 22px;
  flex: 0 0 auto;
  background: var(--bg-deep);
  border: 1px solid var(--line);
}
.card-revenue .card-icon { background: linear-gradient(135deg, #d1fae5, #a7f3d0); border-color: #6ee7b7; }
.card-profit .card-icon { background: linear-gradient(135deg, #fef3c7, #fde68a); border-color: #fbbf24; }
.card-stock .card-icon { background: linear-gradient(135deg, #dbeafe, #93c5fd); border-color: #60a5fa; }
.card-alert .card-icon { background: linear-gradient(135deg, #fed7aa, #fdba74); border-color: #fb923c; }

.card-body { flex: 1; min-width: 0; }
.card-label {
  font-size: 10px; font-weight: 700; letter-spacing: .8px;
  color: var(--ink-soft); text-transform: uppercase;
}
.card-value {
  font-size: 22px; font-weight: 800; margin: 4px 0 2px;
  letter-spacing: -.3px; line-height: 1.1;
}
.card-delta { font-size: 11px; color: var(--ink-soft); font-weight: 500; }

/* ===================== PANELS ===================== */
.panel {
  background: #fff; border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow-sm); border: 1px solid var(--line);
  margin-bottom: 16px;
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; flex-wrap: wrap; gap: 8px;
  padding-bottom: 12px; border-bottom: 1px solid var(--line);
}
.panel-head h3 {
  font-size: 14px; font-weight: 700;
  color: var(--ink); letter-spacing: -.2px;
  display: flex; align-items: center; gap: 8px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.chart-box { position: relative; height: 240px; }
.chart-box canvas { position: absolute !important; inset: 0 !important; width: 100% !important; height: 100% !important; }

/* ===================== TABLES ===================== */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td {
  padding: 12px 10px; border-bottom: 1px solid var(--line);
  text-align: left; vertical-align: middle;
}
.data-table thead th {
  background: var(--bg-deep);
  color: var(--ink-soft); font-size: 11px;
  font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
}
.data-table .num { text-align: right; }
.data-table tbody tr { transition: background .1s; }
.data-table tbody tr:hover { background: var(--bg); }
.data-table code {
  background: var(--bg-deep); padding: 2px 8px; border-radius: 4px;
  font-family: ui-monospace, Menlo, monospace; font-size: 11px; color: var(--ink-soft);
}

/* ===================== RANKED LIST ===================== */
.ranked, .alert-list {
  list-style: none; padding: 0; margin: 0;
}
.ranked li {
  padding: 10px 12px; display: flex; justify-content: space-between; gap: 8px;
  font-size: 13px; border-bottom: 1px solid var(--line);
  transition: background .1s;
}
.ranked li:hover { background: var(--bg); }
.ranked li:last-child { border-bottom: none; }
.alert-list li {
  background: linear-gradient(90deg, #fef3c7, #fffaf0);
  border-left: 4px solid var(--alert);
  padding: 12px 16px; border-radius: 8px; margin-bottom: 8px;
  font-size: 13px;
}
.empty {
  color: var(--ink-soft); text-align: center; padding: 30px 20px;
  font-style: italic; font-size: 13px;
}

/* ===================== ONBOARDING TOUR ===================== */
.onb-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 31, 61, .75);
  backdrop-filter: blur(4px);
  z-index: 99999;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: onb-fade-in .3s ease;
}
@keyframes onb-fade-in { from { opacity: 0; } to { opacity: 1; } }

.onb-spotlight {
  position: fixed;
  border: 3px solid var(--gold-bright, #d4af37);
  border-radius: 14px;
  box-shadow: 0 0 0 9999px rgba(15, 31, 61, .75);
  pointer-events: none;
  animation: onb-pulse 1.5s infinite;
}
@keyframes onb-pulse {
  0%, 100% { box-shadow: 0 0 0 9999px rgba(15, 31, 61, .75), 0 0 30px rgba(212, 175, 55, .5); }
  50% { box-shadow: 0 0 0 9999px rgba(15, 31, 61, .75), 0 0 50px rgba(212, 175, 55, .8); }
}

.onb-card {
  background: #fff;
  border-radius: 20px;
  padding: 28px 24px;
  max-width: 420px; width: 100%;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .35);
  position: relative;
  animation: onb-pop .3s cubic-bezier(.34,1.56,.64,1);
}
@keyframes onb-pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.onb-progress {
  display: flex; gap: 6px; justify-content: center;
  margin-bottom: 12px;
}
.onb-progress span {
  width: 32px; height: 4px;
  background: #e5e7eb;
  border-radius: 999px;
  transition: background .3s;
}
.onb-progress span.active { background: var(--gold-bright, #d4af37); }
.onb-progress span.done { background: var(--green, #10b981); }

.onb-step-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; color: var(--ink-soft);
  letter-spacing: 2px;
  text-align: center;
  margin-bottom: 12px;
  text-transform: uppercase;
}

.onb-title {
  font-size: 22px; font-weight: 800;
  color: var(--primary, #1e3a5f);
  text-align: center;
  margin-bottom: 10px;
  line-height: 1.2;
}

.onb-body {
  font-size: 14px; color: var(--ink, #4a3328);
  text-align: center;
  line-height: 1.5;
  margin-bottom: 22px;
}

.onb-actions {
  display: flex; gap: 8px; justify-content: space-between;
}
.onb-actions .btn { flex: 1; }

/* Empty State Pro — visual + CTA */
.empty-pro {
  font-style: normal !important;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 50px 24px !important;
  gap: 8px;
}
.empty-pro .empty-icon {
  font-size: 64px;
  margin-bottom: 4px;
  filter: drop-shadow(0 4px 12px rgba(30,58,95,.15));
  animation: empty-bounce 2s infinite;
}
@keyframes empty-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.empty-pro h3 {
  font-size: 18px; font-weight: 800;
  color: var(--primary, #1e3a5f);
  margin: 0;
}
.empty-pro p {
  font-size: 14px; color: var(--ink-soft);
  max-width: 360px;
  line-height: 1.5;
  margin: 4px 0 12px;
}
.empty-pro .btn {
  margin-top: 4px;
}
@media (max-width: 640px) {
  .empty-pro .empty-icon { font-size: 48px; }
  .empty-pro h3 { font-size: 16px; }
  .empty-pro p { font-size: 13px; }
}

/* ===================== BEP TRACKER ===================== */
.bep-info { padding: 4px; }
.bep-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px dashed var(--line);
  font-size: 13px;
}
.bep-row:last-child { border-bottom: none; }
.bep-row b { font-weight: 700; }
.bep-bar {
  height: 14px; background: var(--bg-deep);
  border-radius: 999px; overflow: hidden;
  margin: 14px 0; box-shadow: inset 0 1px 2px rgba(0,0,0,.06);
}
.bep-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width .6s cubic-bezier(.4,0,.2,1);
  box-shadow: 0 0 8px rgba(201,163,82,.3);
}
.bep-info small { color: var(--ink-soft); font-size: 11px; }

/* ===================== POS GRID ===================== */
.pos-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 18px; }
.pos-products { min-height: 560px; }
.pos-cart {
  display: flex; flex-direction: column; min-height: 560px;
  background: linear-gradient(180deg, #fff, #faf9f4);
}
.product-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px; max-height: 560px; overflow-y: auto;
  padding: 4px;
}
.product-card {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; cursor: pointer;
  transition: all .15s;
  display: flex; flex-direction: column; gap: 4px;
}
.product-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(30,58,95,.12);
  transform: translateY(-2px);
}
.product-card .pphoto {
  width: 100%; aspect-ratio: 1 / 1;
  border-radius: 10px;
  background: var(--bg-deep);
  object-fit: cover;
  margin-bottom: 8px;
  border: 1px solid var(--line);
}
.product-card .pphoto-empty {
  display: grid; place-items: center;
  font-size: 36px; color: var(--ink-soft);
  background: linear-gradient(135deg, var(--bg-deep), #fff);
}
.product-card .pname {
  font-weight: 600; font-size: 13px; line-height: 1.3;
  color: var(--ink); margin-bottom: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.product-card .pprice {
  color: var(--primary); font-weight: 800; font-size: 15px;
  letter-spacing: -.3px;
}
.product-card .pstok {
  font-size: 10px; color: var(--ink-soft);
  display: flex; gap: 6px; align-items: center; margin-top: 2px;
}
.product-card.out-of-stock { opacity: .45; cursor: not-allowed; }

.cart-list {
  list-style: none; flex: 1; overflow-y: auto; max-height: 420px;
  padding: 0; margin: 0;
}
.cart-item {
  display: grid; grid-template-columns: 1fr auto auto; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
  align-items: center;
}
.cart-item:last-child { border-bottom: none; }
.cart-item-name { font-weight: 600; font-size: 13px; }
.cart-item-meta { font-size: 11px; color: var(--ink-soft); margin-top: 2px; }
.cart-qty { display: flex; align-items: center; gap: 4px; }
.cart-qty button {
  width: 28px; height: 28px; border-radius: 6px;
  border: 1px solid var(--line); background: #fff; cursor: pointer;
  font-weight: 700; color: var(--ink);
}
.cart-qty button:hover { background: var(--bg-deep); }
.cart-qty input {
  width: 44px; text-align: center; padding: 4px;
  border: 1px solid var(--line); border-radius: 6px; font-family: inherit;
}

.cart-summary {
  border-top: 2px solid var(--ink); padding-top: 16px; margin-top: 12px;
}
.cart-summary .row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0; font-size: 13px;
}
.cart-summary .row.total {
  font-size: 22px; font-weight: 800; color: var(--primary);
  border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 12px;
  letter-spacing: -.5px;
}
.cart-summary input {
  width: 110px; text-align: right; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 6px; font-family: inherit;
}

/* ===================== FORMS ===================== */
.form { display: grid; gap: 14px; }
.form label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12px; color: var(--ink-soft); font-weight: 500;
}
.form input, .form select, .form textarea {
  padding: 11px 14px; border-radius: 10px;
  border: 1px solid var(--line); font-family: inherit; font-size: 13px;
  color: var(--ink); background: #fff;
  transition: all .15s;
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: 2px solid var(--primary); outline-offset: 1px;
  border-color: var(--primary);
}
.form-inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.form-inline input {
  padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px;
  flex: 1; min-width: 200px; font-family: inherit;
}

/* ===================== KATEGORI PILLS ===================== */
.kat-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.kat-pill {
  background: var(--bg-deep); border: 1px solid var(--line);
  padding: 6px 14px; border-radius: 999px;
  font-size: 12px; font-weight: 500; color: var(--ink);
  display: inline-flex; gap: 8px; align-items: center;
}
.kat-pill button {
  border: none; background: transparent; cursor: pointer;
  color: var(--ink-soft); font-size: 16px; line-height: 1;
}
.kat-pill button:hover { color: var(--danger); }

/* ===================== FOTO UPLOADER ===================== */
.product-thumb {
  width: 40px; height: 40px; border-radius: 8px;
  object-fit: cover; background: var(--bg-deep);
  border: 1px solid var(--line); display: block;
}
.product-thumb-empty {
  display: grid; place-items: center;
  font-size: 18px; color: var(--ink-soft);
  background: linear-gradient(135deg, var(--bg-deep), #fff);
}

/* === POS Category Filter Tabs === */
.pos-category-tabs {
  display: flex; gap: 6px; flex-wrap: nowrap;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding: 8px 4px; margin: 4px 0;
  scrollbar-width: thin;
}
.pos-category-tabs::-webkit-scrollbar { height: 4px; }
.pos-category-tabs::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.pos-cat-tab {
  flex-shrink: 0;
  background: #fff; color: var(--ink);
  border: 1px solid #e5e7eb; border-radius: 999px;
  padding: 6px 14px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all .15s;
  display: flex; align-items: center; gap: 4px;
  white-space: nowrap;
}
.pos-cat-tab small {
  background: #f1f5f9; color: #64748b;
  padding: 1px 6px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
}
.pos-cat-tab:hover { border-color: var(--primary, #1e3a5f); color: var(--primary, #1e3a5f); }
.pos-cat-tab.active {
  background: var(--primary, #1e3a5f); color: #fff;
  border-color: var(--primary, #1e3a5f);
  box-shadow: 0 2px 8px rgba(30,58,95,.25);
}
.pos-cat-tab.active small {
  background: rgba(255,255,255,.2); color: #fff;
}

/* === Bounce animation saat add to cart === */
@keyframes pos-card-bounce {
  0%, 100% { transform: scale(1); }
  30% { transform: scale(1.06); box-shadow: 0 4px 16px rgba(34,197,94,.35); }
  60% { transform: scale(0.97); }
}
.product-card.adding {
  animation: pos-card-bounce 0.3s ease-out;
  border-color: var(--green, #22c55e) !important;
}

/* Smooth transition untuk cart badge saat qty berubah */
.pcart-badge {
  transition: transform .15s ease, background .2s;
}
.product-card.adding .pcart-badge {
  transform: scale(1.2);
  background: var(--green, #22c55e);
}

/* === Cart badge di product card POS === */
.product-card { position: relative; }
.pcart-badge {
  position: absolute; top: 8px; right: 8px;
  background: var(--primary, #1e3a5f); color: #fff;
  font-weight: 800; font-size: 13px;
  min-width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
  z-index: 2;
}
.pstok small { color: #94a3b8; font-size: 10px; }
.pstok.pstok-low { color: #d97706; font-weight: 700; }
.pstok.pstok-zero { color: #dc2626; font-weight: 800; }

/* === Foto Uploader v2 — clean & big, satu tap === */
.foto-uploader-v2 {
  display: flex; flex-direction: column; gap: 10px;
  margin-bottom: 8px;
}
.foto-drop-zone {
  display: block; cursor: pointer;
  width: 100%; aspect-ratio: 1;
  max-width: 240px; margin: 0 auto;
  border-radius: 16px;
  background: linear-gradient(135deg, #f8fafc, #fff);
  border: 2px dashed #cbd5e1;
  position: relative; overflow: hidden;
  transition: all .15s;
}
.foto-drop-zone:hover, .foto-drop-zone:active {
  border-color: var(--primary, #1e3a5f);
  background: linear-gradient(135deg, #eff6ff, #fff);
  transform: scale(1.01);
}
.foto-drop-zone .foto-preview {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.foto-drop-zone .foto-placeholder {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 20px; text-align: center;
}
.foto-placeholder .fp-icon {
  font-size: 56px; opacity: .8;
}
.foto-placeholder .fp-text {
  font-size: 16px; font-weight: 700; color: var(--primary, #1e3a5f);
}
.foto-placeholder .fp-hint {
  font-size: 12px; color: #94a3b8;
}
.foto-loading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.9);
  font-size: 18px; font-weight: 700; color: var(--primary, #1e3a5f);
}
.foto-bottom-bar {
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
}
.foto-cam-btn { cursor: pointer; }

/* ===================== MARGIN PREVIEW ===================== */
.margin-preview {
  background: linear-gradient(135deg, #fef3c7, #fffaf0);
  border: 1px solid #fbbf24; border-radius: 10px;
  padding: 12px 16px; font-size: 13px; color: var(--ink);
}

/* ===================== MODAL ===================== */
.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(4px);
  padding: 20px;
  align-items: center; justify-content: center;
}
.modal[hidden] { display: none !important; }
.modal:not([hidden]) { display: flex; }
.modal-card {
  background: #fff; border-radius: 18px; padding: 28px;
  width: 100%; max-width: 480px; max-height: 92vh; overflow-y: auto;
  position: relative; box-shadow: var(--shadow-lg);
  animation: modalIn .25s cubic-bezier(.4,0,.2,1);
}
@keyframes modalIn { from { opacity: 0; transform: scale(.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-card.modal-large { max-width: 760px; }
.modal-close {
  position: absolute; top: 14px; right: 18px;
  border: none; background: transparent; font-size: 26px; cursor: pointer;
  color: var(--ink-soft); width: 32px; height: 32px; border-radius: 8px;
  line-height: 1;
}
.modal-close:hover { background: var(--bg-deep); color: var(--ink); }
.modal h3 { margin-bottom: 18px; font-size: 18px; letter-spacing: -.3px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }

/* ===================== CHECKOUT ===================== */
.kembalian-preview {
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  border: 1px solid #6ee7b7; border-radius: 10px;
  padding: 14px; font-size: 16px; font-weight: 800; color: #047857;
  text-align: center; letter-spacing: -.3px;
}

/* ===================== RESTOCK ===================== */
.restock-items { display: grid; gap: 10px; max-height: 340px; overflow-y: auto; padding: 8px 4px; }
.restock-item-row {
  display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 8px;
  align-items: center; padding: 4px;
}
.restock-item-row select, .restock-item-row input {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  font-family: inherit; font-size: 13px;
}
.restock-total {
  font-size: 18px; font-weight: 800; text-align: right; margin: 16px 0;
  color: var(--primary); letter-spacing: -.3px;
  padding: 14px; background: var(--bg-deep); border-radius: 10px;
}

/* ===================== RECEIPT ===================== */
.receipt {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12px;
  background: #fff; padding: 20px;
  border: 1px dashed var(--ink-soft); border-radius: 8px;
  white-space: pre-wrap; line-height: 1.4;
  max-height: 480px; overflow-y: auto;
}

/* ===================== TOAST ===================== */
.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff;
  padding: 12px 22px; border-radius: 999px;
  font-size: 13px; font-weight: 600; z-index: 200;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  animation: toastIn .2s;
}
.toast[hidden] { display: none; }
.toast.success { background: linear-gradient(135deg, #059669, #10b981); }
.toast.error { background: linear-gradient(135deg, #b91c1c, var(--danger)); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

.footer {
  text-align: center; color: var(--ink-soft); font-size: 12px;
  padding: 40px 20px;
}

/* ===================== LOGIN / AUTH SCREEN ===================== */
.login-screen {
  position: fixed; inset: 0; z-index: 200;
  background: linear-gradient(135deg, #f7f6f2 0%, #e8e4d6 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  flex-direction: column;
  overflow-y: auto;
}
.login-screen[hidden] { display: none !important; }
#app-main[hidden] { display: none !important; }
.login-card {
  background: #fff; border-radius: 22px;
  padding: 36px 30px; max-width: 420px; width: 100%;
  box-shadow: 0 20px 60px rgba(30,58,95,.12);
  text-align: center;
  animation: slideIn .3s ease-out;
}
@keyframes slideIn { from { opacity: 0; transform: translateY(15px) } to { opacity: 1; transform: translateY(0) } }
.login-logo {
  width: 80px; height: 80px; border-radius: 18px;
  margin: 0 auto 14px; object-fit: contain;
  box-shadow: 0 4px 14px rgba(30,58,95,.15);
}
.login-brand {
  font-size: 28px; font-weight: 900; letter-spacing: -.5px;
  color: var(--primary); margin-bottom: 4px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.brand-pro {
  font-size: 11px; font-weight: 800; letter-spacing: 1px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff; padding: 3px 9px; border-radius: 5px;
}
.login-tag { color: var(--ink-soft); font-size: 13px; margin-bottom: 22px; }

.login-tabs {
  display: flex; gap: 0; background: var(--bg-deep); border-radius: 10px;
  padding: 4px; margin-bottom: 18px;
}
.login-tab {
  flex: 1; background: transparent; border: none;
  padding: 9px; border-radius: 8px;
  font-weight: 600; font-size: 13px; color: var(--ink-soft);
  cursor: pointer; font-family: inherit;
}
.login-tab.active { background: #fff; color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.auth-form { display: grid; gap: 14px; text-align: left; }
.auth-form[hidden] { display: none !important; }
.auth-form label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12px; color: var(--ink-soft); font-weight: 500;
}
.auth-form input {
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  font-family: inherit; font-size: 14px;
}
.auth-form input:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
.auth-form a { font-size: 12px; color: var(--primary); text-decoration: none; text-align: center; }
.auth-form a:hover { text-decoration: underline; }

.auth-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 18px 0; color: var(--ink-soft); font-size: 12px;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--line);
}

.btn-google {
  background: #fff; color: var(--ink); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 11px;
}
.btn-google:hover { background: var(--bg-deep); border-color: var(--ink-soft); }

.auth-error, .auth-info {
  padding: 10px 14px; border-radius: 8px; font-size: 13px;
  margin-top: 12px; line-height: 1.4;
}
.auth-error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.auth-info { background: #ecfdf5; border: 1px solid #6ee7b7; color: #047857; }

.login-footer {
  margin-top: 18px; color: var(--ink-soft); font-size: 11px;
}

/* ===================== PAYWALL ===================== */
.paywall-card { max-width: 540px !important; }
.paywall-card h2 { font-size: 22px; margin-bottom: 6px; color: var(--primary); }
.paywall-prices {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin: 16px 0;
}
.price-card-pw {
  background: #fff; border: 1.5px solid var(--line); border-radius: 14px;
  padding: 20px 18px; text-align: left; position: relative;
  display: flex; flex-direction: column;
}
.price-card-pw.highlight {
  border: 2px solid var(--accent);
  box-shadow: 0 8px 24px rgba(201,163,82,.18);
}
.pw-badge {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff; font-size: 9px; font-weight: 800; letter-spacing: 1px;
  padding: 4px 10px; border-radius: 999px; white-space: nowrap;
}
.price-card-pw b { font-size: 14px; color: var(--ink); display: block; margin-bottom: 6px; }
.pw-price { font-size: 22px; font-weight: 900; color: var(--primary); margin-bottom: 12px; letter-spacing: -.5px; }
.pw-price small { font-size: 11px; font-weight: 500; color: var(--ink-soft); margin-left: 4px; }
.pw-features { list-style: none; padding: 0; margin: 0 0 14px; flex: 1; }
.pw-features li { padding: 3px 0; font-size: 12px; color: var(--ink); }
.pw-features li::before { content: '✓ '; color: var(--green); font-weight: 800; }

.payment-info {
  background: var(--bg-deep); border-radius: 12px; padding: 14px;
  margin: 14px 0; text-align: left;
}
.payment-title { font-weight: 700; font-size: 13px; margin-bottom: 8px; color: var(--primary); }
.payment-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; padding: 4px 0;
}
.payment-row code {
  background: #fff; padding: 2px 8px; border-radius: 4px;
  font-family: ui-monospace, monospace; font-size: 12px;
}
.paywall-actions { display: grid; gap: 8px; margin-top: 12px; }
.btn-wa { background: #25D366; color: #fff; border-color: #25D366; }
.btn-wa:hover { background: #1da851; border-color: #1da851; }
.paywall-note {
  font-size: 11px; color: var(--ink-soft); margin-top: 14px; line-height: 1.5;
}

@media (max-width: 600px) {
  .paywall-prices { grid-template-columns: 1fr; }
}

/* ===================== MOBILE COMPACT (< 640px) ===================== */
@media (max-width: 640px) {
  /* Container padding lebih ramping */
  body { font-size: 14px; }
  main, .container, section.tab-panel { padding: 10px !important; }
  .page-head { gap: 8px; }
  .page-head h1 { font-size: 20px; }

  /* KPI cards — 2 kolom (bukan 1) supaya muat lebih banyak di 1 layar */
  .cards {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
    margin-bottom: 14px !important;
  }
  .card {
    padding: 12px !important;
    flex-direction: column !important;
    gap: 6px !important;
    min-height: 0 !important;
  }
  .card-icon {
    width: 32px !important; height: 32px !important;
    font-size: 18px !important;
  }
  .card-label {
    font-size: 9px !important;
    letter-spacing: .5px;
  }
  .card-value {
    font-size: 15px !important;
    line-height: 1.1 !important;
    margin: 2px 0 0 !important;
    word-break: break-all;
  }
  .card-delta {
    font-size: 10px !important;
    line-height: 1.2;
  }

  /* Cash vs Tempo breakdown — 1 kolom + lebih padat */
  .cash-breakdown {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    margin: 8px 0 12px !important;
  }
  .cb-card { padding: 10px 12px !important; gap: 10px !important; }
  .cb-icon { font-size: 22px !important; }
  .cb-label { font-size: 10px !important; }
  .cb-value { font-size: 16px !important; word-break: break-all; }
  .cb-meta { font-size: 10px !important; }

  /* Trend chart — kurangi tinggi */
  .chart-box { height: 200px !important; }
  .panel { padding: 12px !important; }
  .panel-head h3 { font-size: 14px !important; }

  /* Tab nav — bisa scroll horizontal, padding kecil */
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap !important;
    gap: 4px !important;
  }
  .tab {
    flex-shrink: 0;
    font-size: 12px !important;
    padding: 6px 10px !important;
  }

  /* Header */
  .app-header { padding: 8px 10px !important; gap: 8px !important; }
  .app-header img { width: 32px !important; height: 32px !important; }
  .app-header .app-title { font-size: 15px !important; }

  /* Tabel data: scroll horizontal supaya tidak kepotong */
  .panel { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table {
    font-size: 12px !important;
    min-width: 600px; /* paksa lebar minimum biar muat columns */
  }
  .data-table th, .data-table td {
    padding: 6px 8px !important;
    white-space: nowrap; /* jangan pecah ke baris baru */
  }
  /* Sembunyikan kolom non-essential di tabel Stok */
  #stok-body tr td:nth-child(2),  /* SKU */
  #stok-body tr td:nth-child(6),  /* H. Modal */
  #stok-body tr td:nth-child(8),  /* Margin */
  .panel:has(#stok-body) thead th:nth-child(2),
  .panel:has(#stok-body) thead th:nth-child(6),
  .panel:has(#stok-body) thead th:nth-child(8) {
    display: none;
  }
  /* Setelah hide columns, min-width bisa lebih kecil */
  .panel:has(#stok-body) .data-table { min-width: 0; }

  /* Summary card piutang/PO/pelanggan jadi 2 kolom kecil */
  .piutang-summary, .po-summary, .pelanggan-summary {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }
  .psum-card { padding: 10px 12px !important; }
  .psum-label { font-size: 9px !important; }
  .psum-value { font-size: 14px !important; word-break: break-all; }
  .psum-meta { font-size: 10px !important; }

  /* Product card di kasir */
  .product-card { padding: 8px !important; }
  .pname { font-size: 12px !important; }
  .pprice { font-size: 13px !important; }
  .pstok { font-size: 11px !important; }

  /* Modal lebih ramping */
  .modal-card { padding: 16px !important; }
  .form label { font-size: 13px; }
  .modal-actions { gap: 6px; }
  .modal-actions .btn { font-size: 13px; padding: 8px 12px; }

  /* Logout/export buttons di header */
  .header-actions {
    flex-wrap: wrap;
    gap: 4px !important;
  }
  .header-actions .btn {
    font-size: 11px !important;
    padding: 6px 10px !important;
  }
}

/* Extra-small phones (< 380px iPhone SE) */
@media (max-width: 380px) {
  .cards { grid-template-columns: 1fr !important; }
  .piutang-summary, .po-summary, .pelanggan-summary { grid-template-columns: 1fr !important; }
  .card-value { font-size: 18px !important; }
}

/* ===================== ADMIN PANEL ===================== */
#tab-admin { background: linear-gradient(135deg, rgba(201,163,82,.04), transparent); }
#tab-btn-admin { background: linear-gradient(135deg, var(--accent), var(--accent-dark)); color: #fff !important; }
#tab-btn-admin.active { background: #fff; color: var(--accent-dark) !important; }

/* ===================== TAGIHAN INFO (saat metode tempo) ===================== */
.tagihan-info {
  background: linear-gradient(135deg, #fef3c7, #fffaf0);
  border: 1px solid #fbbf24; border-radius: 10px;
  padding: 12px 16px; font-size: 13px; color: #78350f;
  font-weight: 600; line-height: 1.4;
}
.tagihan-info[hidden] { display: none !important; }
.kembalian-preview[hidden] { display: none !important; }

/* ===================== PIUTANG / TEMPO TAB ===================== */
.piutang-summary {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
  margin-bottom: 18px;
}
.psum-card {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;
  padding: 14px 16px; box-shadow: 0 1px 3px rgba(0,0,0,.04);
  border-left: 4px solid #94a3b8;
}
.psum-card.psum-belum { border-left-color: #f59e0b; }
.psum-card.psum-overdue { border-left-color: #dc2626; background: linear-gradient(135deg, #fff, #fef2f2); }
.psum-card.psum-lunas { border-left-color: #16a34a; }
.psum-label { font-size: 12px; color: #64748b; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.psum-value { font-size: 22px; font-weight: 700; color: #1e293b; margin-top: 4px; }
.psum-overdue .psum-value { color: #dc2626; }
.psum-meta { font-size: 12px; color: #64748b; margin-top: 2px; }
@media (max-width: 640px) {
  .piutang-summary { grid-template-columns: 1fr; }
  .psum-value { font-size: 18px; }
}

tr.row-overdue { background: #fef2f2; }
tr.row-overdue td { border-bottom: 1px solid #fecaca; }

.cell-meta { font-size: 11px; color: #64748b; margin-top: 2px; }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-success { background: #16a34a; color: #fff; border-color: #15803d; }
.btn-success:hover { background: #15803d; }

/* Dashboard breakdown: Cash vs Tempo */
.cash-breakdown {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  margin: 14px 0 18px;
}
.cb-card {
  display: flex; gap: 14px; align-items: center;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;
  padding: 14px 18px; box-shadow: 0 1px 3px rgba(0,0,0,.04);
  border-left: 5px solid #94a3b8;
}
.cb-card.cb-cash { border-left-color: #16a34a; background: linear-gradient(135deg, #fff, #f0fdf4); }
.cb-card.cb-tempo { border-left-color: #f59e0b; background: linear-gradient(135deg, #fff, #fffbeb); }
.cb-icon { font-size: 32px; flex-shrink: 0; }
.cb-body { flex: 1; min-width: 0; }
.cb-label { font-size: 12px; color: #64748b; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.cb-value { font-size: 22px; font-weight: 700; color: #1e293b; margin-top: 2px; }
.cb-card.cb-cash .cb-value { color: #15803d; }
.cb-card.cb-tempo .cb-value { color: #b45309; }
.cb-meta { font-size: 12px; color: #64748b; margin-top: 2px; }
@media (max-width: 640px) {
  .cash-breakdown { grid-template-columns: 1fr; }
  .cb-value { font-size: 18px; }
}

/* ===================== PO SUPPLIER ===================== */
.po-summary {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
  margin-bottom: 18px;
}
@media (max-width: 640px) { .po-summary { grid-template-columns: 1fr; } }

.po-form .po-items {
  display: flex; flex-direction: column; gap: 10px;
  max-height: 45vh; overflow-y: auto;
  padding: 6px 4px; margin: 8px 0;
}
.po-item-row {
  display: grid;
  grid-template-columns: 70px 1.5fr 90px 130px 110px 36px;
  gap: 10px; align-items: end;
  background: #f8fafc; border: 1px solid #e5e7eb;
  border-radius: 10px; padding: 12px;
}
.po-item-row.po-item-new {
  grid-template-columns: 70px 1fr 110px 36px;
  background: linear-gradient(135deg, #fffbeb, #fff);
  border-color: #fbbf24;
}
.poi-type { display: flex; align-items: center; }
.poi-tag {
  padding: 4px 8px; border-radius: 6px;
  font-size: 10px; font-weight: 700; letter-spacing: .5px;
  white-space: nowrap;
}
.poi-tag-existing { background: #dbeafe; color: #1e40af; }
.poi-tag-new { background: #fef3c7; color: #92400e; }
.poi-field {
  display: flex; flex-direction: column; gap: 3px;
  min-width: 0;
}
.poi-field span {
  font-size: 10px; color: #64748b; font-weight: 600;
  text-transform: uppercase; letter-spacing: .3px;
}
.poi-field input, .poi-field select {
  padding: 7px 9px; font-size: 13px;
  border: 1px solid #d1d5db; border-radius: 6px;
  background: #fff;
}
.poi-new-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
}
.poi-subtotal {
  display: flex; flex-direction: column; gap: 3px;
  text-align: right; align-self: center;
}
.poi-subtotal span { font-size: 10px; color: #64748b; font-weight: 600; text-transform: uppercase; }
.poi-subtotal b { font-size: 14px; color: var(--primary, #1e3a5f); }

.po-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin: 8px 0;
}
.po-total-box {
  display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(135deg, #f1f5f9, #fff);
  border: 1px solid #e5e7eb; border-radius: 10px;
  padding: 14px 18px;
  font-size: 14px; color: #64748b; font-weight: 600;
}
.po-total-box b { font-size: 22px; color: var(--primary, #1e3a5f); }

/* Foto Surat Jalan section di modal PO */
.po-foto-section {
  background: linear-gradient(135deg, #fefce8, #fff);
  border: 1px dashed #fbbf24; border-radius: 10px;
  padding: 12px 14px; margin: 8px 0;
}
.po-foto-uploader {
  display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap;
}
.po-foto-preview-wrap {
  width: 110px; height: 110px; flex-shrink: 0;
  border-radius: 10px; overflow: hidden;
  background: #f1f5f9; border: 1px solid #e5e7eb;
  display: flex; align-items: center; justify-content: center;
}
.po-foto-preview { width: 100%; height: 100%; object-fit: cover; cursor: pointer; }
.po-foto-placeholder { font-size: 38px; color: #cbd5e1; }
.po-foto-actions {
  flex: 1; min-width: 200px;
  display: flex; flex-direction: column; gap: 6px;
}
.po-foto-actions > div { display: flex; gap: 6px; flex-wrap: wrap; }

/* Thumbnail di list PO */
.po-thumb {
  width: 44px; height: 44px; border-radius: 6px;
  object-fit: cover; cursor: pointer;
  border: 1px solid #e5e7eb;
  transition: transform .15s, border-color .15s;
}
.po-thumb:hover {
  transform: scale(1.1);
  border-color: var(--primary, #1e3a5f);
}

/* Foto lightbox modal */
.foto-lightbox-card { max-width: 90vw; }
.foto-lightbox-wrap {
  display: flex; align-items: center; justify-content: center;
  max-height: 80vh; overflow: auto;
  background: #f1f5f9; border-radius: 8px;
  padding: 12px;
}
.foto-lightbox-wrap img {
  max-width: 100%; max-height: 75vh;
  object-fit: contain;
  border-radius: 4px;
}

@media (max-width: 768px) {
  .po-item-row,
  .po-item-row.po-item-new {
    grid-template-columns: 1fr 36px;
    gap: 8px;
  }
  .poi-type { grid-column: 1 / -1; }
  .poi-field-product { grid-column: 1 / -1; }
  .poi-new-grid { grid-template-columns: 1fr 1fr; }
  .poi-subtotal { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; }
  .r-rm { grid-row: 1; grid-column: 2; }
}

/* Laporan tabel per item */
.lap-item-table tfoot tr.lap-item-total td {
  background: linear-gradient(135deg, #f1f5f9, #fff);
  border-top: 2px solid var(--primary, #1e3a5f);
  padding: 10px 8px;
  font-size: 14px;
}
.lap-item-table th, .lap-item-table td { white-space: nowrap; }
.panel-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }

/* Laporan filter — custom date/month/year/range */
.laporan-filters {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}
.laporan-filters input,
.laporan-filters select {
  padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 8px;
  font-size: 14px; background: #fff;
}
.laporan-filters [hidden] { display: none !important; }
.laporan-range-wrap {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
}
.laporan-range-wrap span { font-size: 13px; color: #64748b; }
.laporan-period-label {
  margin: 8px 0 14px; padding: 8px 14px;
  background: linear-gradient(135deg, #f1f5f9, #fff);
  border-left: 4px solid var(--primary, #1e3a5f);
  border-radius: 6px;
  font-size: 14px; font-weight: 600; color: #1e293b;
}

/* Customer input row (nama + tombol picker) */
.customer-input-row {
  display: flex; gap: 6px; align-items: stretch;
}
.customer-input-row input { flex: 1; }
.customer-input-row .btn { padding: 8px 12px; font-size: 16px; }

/* Customer picker modal list */
.customer-picker-list {
  max-height: 50vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px;
}
.customer-picker-item {
  display: flex; gap: 12px; align-items: center;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
  padding: 10px 12px; text-align: left; cursor: pointer;
  width: 100%; transition: background .15s;
}
.customer-picker-item:hover { background: #f8fafc; border-color: var(--primary, #1e3a5f); }
.cpi-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary, #1e3a5f), var(--accent, #c9a352));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0;
}
.cpi-info { flex: 1; min-width: 0; }
.cpi-nama { font-weight: 700; font-size: 14px; color: #1e293b; }
.cpi-meta { font-size: 12px; color: #64748b; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cpi-stat { font-size: 11px; color: #94a3b8; margin-top: 2px; }

/* Edit Sale form — items list */
.edit-items-list {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 35vh; overflow-y: auto;
  padding: 4px;
}
.edit-item-row {
  display: grid;
  grid-template-columns: 1.5fr 80px 110px 100px 36px;
  gap: 8px; align-items: end;
  background: #f8fafc; border: 1px solid #e5e7eb;
  border-radius: 8px; padding: 8px 10px;
}
.ei-nama { min-width: 0; }
.ei-nama b { display: block; font-size: 13px; line-height: 1.2; }
.ei-field { display: flex; flex-direction: column; gap: 2px; }
.ei-field span { font-size: 10px; color: #64748b; font-weight: 600; text-transform: uppercase; }
.ei-field input { padding: 5px 8px; font-size: 13px; border: 1px solid #d1d5db; border-radius: 6px; }
.ei-subtotal { font-size: 13px; font-weight: 700; color: var(--primary, #1e3a5f); text-align: right; align-self: center; }
@media (max-width: 640px) {
  .edit-item-row {
    grid-template-columns: 1fr 60px 90px;
    grid-template-areas:
      "nama nama nama"
      "qty harga sub"
      "rm rm rm";
  }
  .ei-nama { grid-area: nama; }
  .edit-item-row > [data-rm-i] { grid-area: rm; justify-self: end; }
}
.edit-total-display {
  background: #f1f5f9; border-radius: 8px; padding: 10px 12px;
  text-align: right; align-self: end;
}

/* ===================== PELANGGAN TAB ===================== */
.pelanggan-summary {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
  margin-bottom: 18px;
}
.psum-card.psum-info { border-left-color: #3b82f6; }
@media (max-width: 640px) {
  .pelanggan-summary { grid-template-columns: 1fr; }
}

#pelanggan-search {
  padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 8px;
  font-size: 14px; min-width: 220px;
}

/* Customer detail modal */
.cust-detail-head {
  display: flex; gap: 16px; align-items: flex-start;
  padding-bottom: 16px; border-bottom: 1px solid #e5e7eb;
  margin-bottom: 16px;
}
.cust-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary, #1e3a5f), var(--accent, #c9a352));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700; flex-shrink: 0;
}
.cust-info h2 { margin: 0 0 4px; font-size: 22px; }
.cust-meta { font-size: 13px; color: #64748b; margin-top: 2px; }
.cust-actions { margin-top: 8px; display: flex; gap: 8px; }

.cust-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  margin-bottom: 8px;
}
.cstat {
  background: #f8fafc; border: 1px solid #e5e7eb;
  border-radius: 10px; padding: 10px 12px;
}
.cstat.cstat-warn { background: #fff7ed; border-color: #fed7aa; }
.cstat-label { font-size: 11px; color: #64748b; font-weight: 600; text-transform: uppercase; }
.cstat-value { font-size: 16px; font-weight: 700; color: #1e293b; margin-top: 2px; }
.cstat-warn .cstat-value { color: #c2410c; }
@media (max-width: 640px) {
  .cust-stats { grid-template-columns: repeat(2, 1fr); }
  .cust-detail-head { flex-direction: column; align-items: center; text-align: center; }
}

.cust-history {
  display: flex; flex-direction: column; gap: 12px;
  max-height: 50vh; overflow-y: auto;
}
.hist-card {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
  padding: 12px 14px;
}
.hist-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; flex-wrap: wrap; margin-bottom: 8px;
}
.hist-head .cell-meta { display: block; }
.hist-status { display: flex; gap: 6px; flex-wrap: wrap; }
.hist-items {
  list-style: none; padding: 8px 12px; margin: 0;
  background: #f8fafc; border-radius: 8px;
  font-size: 13px;
}
.hist-items li { padding: 2px 0; }
.hist-foot {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 10px; padding-top: 10px; border-top: 1px dashed #e5e7eb;
  flex-wrap: wrap; gap: 8px;
}
.hist-total { display: flex; align-items: center; gap: 8px; }
.hist-total b { font-size: 16px; color: var(--primary, #1e3a5f); }

/* ===================== INVOICE A4 (3-PLY) ===================== */
.invoice-3ply {
  display: flex; flex-direction: column;
  gap: 24px;
  background: #e5e5e5;
  padding: 20px 0;
  max-height: 75vh; overflow-y: auto;
}
.invoice-ply {
  width: 21cm; min-height: 29.7cm;
  margin: 0 auto;
  background: #fff;
  padding: 1.6cm 1.4cm;
  font-family: 'Inter', sans-serif;
  color: #111;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
  position: relative;
  font-size: 11pt;
}
.ply-stamp {
  position: absolute; top: 0.6cm; left: 50%;
  transform: translateX(-50%);
  font-size: 9pt; font-weight: 800; letter-spacing: 2px;
  padding: 4px 14px; border-radius: 999px;
  background: #f3f4f6; border: 2px solid currentColor;
  white-space: nowrap;
}
.invoice-ply .inv-title {
  text-align: center; font-size: 24pt; font-weight: 900;
  letter-spacing: 4px; margin-bottom: 18px;
  color: #1a2238;
}
.invoice-ply .inv-header-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
  margin-bottom: 28px;
}
.invoice-ply .inv-company h2 {
  font-size: 13pt; font-weight: 800; margin-bottom: 4px;
  color: #1a2238; letter-spacing: -.2px;
}
.invoice-ply .inv-company p {
  font-size: 10pt; line-height: 1.4; margin-bottom: 2px; color: #444;
}
.invoice-ply .inv-meta { font-size: 10pt; }
.invoice-ply .meta-row {
  display: flex; padding: 2px 0;
  align-items: baseline;
}
.invoice-ply .meta-row span {
  display: inline-block; min-width: 95px; color: #555;
}
.invoice-ply .inv-customer {
  margin-bottom: 16px; padding: 8px 0;
  border-top: 1px dashed #ccc;
}
.invoice-ply .kepada-label { font-size: 10pt; color: #555; margin-bottom: 2px; }
.invoice-ply .inv-customer h3 {
  font-size: 12pt; font-weight: 800; margin: 2px 0;
  color: #1a2238;
}
.invoice-ply .inv-customer p {
  font-size: 10pt; line-height: 1.4; color: #444;
}
.invoice-ply .inv-table {
  width: 100%; border-collapse: collapse;
  margin-bottom: 20px; font-size: 10pt;
}
.invoice-ply .inv-table thead th {
  background: #1e3a5f; color: #fff;
  padding: 10px 6px; font-weight: 700;
  text-align: left; vertical-align: middle;
  border: 1px solid #1e3a5f;
}
.invoice-ply .inv-table thead th.r { text-align: right; padding-right: 10px; }
.invoice-ply .inv-table tbody td {
  padding: 6px 8px; border: 1px solid #ccc;
  font-size: 10pt; height: 32px;
}
.invoice-ply .inv-table tbody td.c { text-align: center; }
.invoice-ply .inv-table tbody td.r { text-align: right; }
.invoice-ply .inv-table tbody tr.subtotal-row td {
  background: #f9f8f3; font-weight: 600;
}
.invoice-ply .inv-table tbody tr.discount-row td {
  background: #fef9f3; color: #c44848;
}
.invoice-ply .inv-bottom {
  display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px;
  margin-bottom: 28px;
}
.invoice-ply .inv-terbilang { font-size: 10pt; }
.invoice-ply .terbilang-label { color: #555; margin-bottom: 4px; }
.invoice-ply .terbilang-box {
  border: 1px solid #999; padding: 10px 14px;
  border-radius: 4px; min-height: 50px;
  background: #fafafa; font-size: 10pt;
  line-height: 1.5;
}
.invoice-ply .inv-total {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: #1e3a5f; color: #fff;
  border-radius: 4px; min-height: 60px;
}
.invoice-ply .inv-total .total-label {
  font-size: 11pt; font-weight: 600;
}
.invoice-ply .inv-total .total-amount {
  font-size: 14pt; font-weight: 900; letter-spacing: -.3px;
}
.invoice-ply .inv-signatures {
  display: grid; grid-template-columns: 1fr 1fr; gap: 60px;
  margin-bottom: 16px;
  font-size: 10pt;
}
.invoice-ply .sign-box { text-align: center; }
.invoice-ply .sign-box p { margin-bottom: 4px; color: #444; }
.invoice-ply .sign-space { height: 50px; }
.invoice-ply .sign-line { color: #333; font-size: 9pt; }
.invoice-ply .inv-footer-note {
  border-top: 1px dashed #ccc; padding-top: 8px;
  font-size: 9pt; color: #888;
  display: flex; justify-content: space-between;
}
.invoice-ply .powered { font-style: italic; }

@media print {
  /* Hide everything except invoice content */
  body * { visibility: hidden; }
  .modal#modal-invoice, .modal#modal-invoice * { visibility: visible; }
  .modal#modal-invoice {
    position: absolute; inset: 0; background: #fff !important;
    backdrop-filter: none !important;
  }
  .modal-card.modal-large {
    box-shadow: none; border-radius: 0;
    padding: 0; max-width: none; width: 100%;
    max-height: none; overflow: visible;
  }
  .modal-close, .modal-actions, .no-print { display: none !important; }
  .invoice-3ply {
    background: #fff; padding: 0; gap: 0;
    max-height: none; overflow: visible;
  }
  .invoice-ply {
    box-shadow: none; padding: 1.5cm 1.4cm;
    page-break-after: always;
    break-after: page;
    margin: 0;
    width: 100%; min-height: auto;
  }
  .invoice-ply:last-child {
    page-break-after: auto;
    break-after: auto;
  }
  @page { size: A4; margin: 0; }
}

@media (max-width: 1100px) {
  .invoice-ply {
    transform: scale(0.5); transform-origin: top center;
    margin-bottom: -50%;
  }
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 1100px) {
  .topbar { padding: 12px 16px; gap: 14px; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-2-form { grid-template-columns: 1fr; }
  .pos-grid { grid-template-columns: 1fr; }
  .tabs { font-size: 12px; padding: 3px; }
  .tab { padding: 6px 12px; }
}
@media (max-width: 700px) {
  main { padding: 16px 14px 50px; }
  .cards { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: stretch; padding: 14px 16px; }
  .brand { min-width: auto; }
  .tabs { justify-content: flex-start; overflow-x: auto; }
  .tab { white-space: nowrap; }
  .topbar-actions { justify-content: flex-end; }
}
