:root {
  --bg: #f3f8fc;
  --surface: #ffffff;
  --surface-2: #f7fbfe;
  --surface-3: #ebf3f9;
  --border: #dbe6ef;
  --border-strong: #c3d3e0;
  --text: #0f1d2a;
  --text-2: #475a6b;
  --muted: #7a8b9b;

  /* Biru muda (brand) + biru yang lebih tegas untuk tombol agar teks putih tetap terbaca */
  --brand-light: #cdeafc;
  --brand-mid: #7cc8f5;
  --brand-ink: #0c3550;
  --primary: #0277bd;
  --primary-hover: #01659f;
  --primary-soft: #e1f2fd;
  --primary-ink: #075985;

  --danger: #b42318;
  --danger-soft: #fdecea;
  --warning: #9a5b00;
  --warning-soft: #fff4dc;
  --success: #1a7f37;
  --success-soft: #e6f4ea;
  --info-soft: #e8f0fb;

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --grid: #e2e8ee;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(12, 53, 80, .06), 0 1px 1px rgba(12, 53, 80, .04);
  --shadow-lg: 0 18px 50px rgba(12, 53, 80, .18);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sidebar-w: 236px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.row-flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1 1 auto; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: linear-gradient(180deg, var(--brand-light) 0%, #e6f4fd 42%, #ffffff 100%);
  border-right: 1px solid #d3e6f3;
  color: var(--brand-ink);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; }
.brand-mark { width: 38px; height: 38px; flex: none; display: block; }
.brand-name { font-weight: 750; font-size: 17px; color: var(--brand-ink); letter-spacing: .1px; }
.brand-sub { font-size: 11.5px; color: #4f7ea3; }
.nav { flex: 1; overflow-y: auto; padding: 6px 10px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #5a87a8; font-weight: 600; padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; margin: 1px 0;
  color: #24445e; border-radius: 8px;
  text-decoration: none; font-weight: 500;
}
.nav a svg { width: 18px; height: 18px; flex: none; color: #4d7ea3; }
.nav a:hover { background: rgba(255, 255, 255, .7); color: var(--brand-ink); text-decoration: none; }
.nav a.active { background: #ffffff; color: var(--primary-ink); font-weight: 650; box-shadow: 0 1px 3px rgba(12, 53, 80, .12); }
.nav a.active svg { color: var(--primary); }
.sidebar-foot { border-top: 1px solid #dbe9f3; padding: 12px 14px; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand-light); color: var(--primary-ink); display: grid; place-items: center;
  font-weight: 700; font-size: 13px; flex: none;
}
.user-chip .name { color: var(--brand-ink); font-weight: 600; font-size: 13px; }
.user-chip .role { color: #5a87a8; font-size: 11.5px; text-transform: capitalize; }
.sidebar-foot .links { display: flex; gap: 6px; margin-top: 10px; }
.sidebar-foot .links button {
  flex: 1; background: #fff; border: 1px solid #d3e3ef; color: #24445e;
  padding: 7px 8px; border-radius: 7px; cursor: pointer; font-size: 12.5px; font-weight: 550;
}
.sidebar-foot .links button:hover { background: var(--primary-soft); border-color: #a9d4f0; color: var(--primary-ink); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: none; align-items: center; gap: 10px;
  padding: 10px 16px; background: linear-gradient(90deg, var(--brand-light), #ffffff); color: var(--brand-ink);
  border-bottom: 1px solid #d3e6f3; position: sticky; top: 0; z-index: 30;
}
.topbar .brand-name { font-size: 16px; }
.topbar .brand-mark { width: 30px; height: 30px; }
.icon-btn {
  background: transparent; border: 0; cursor: pointer; padding: 6px;
  border-radius: 8px; color: inherit; display: inline-grid; place-items: center;
}
.icon-btn:hover { background: rgba(0, 0, 0, .06); }
.topbar .icon-btn:hover { background: rgba(255, 255, 255, .8); }
.icon-btn svg { width: 20px; height: 20px; }

.page { padding: 22px 26px 40px; max-width: 1400px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 22px; font-weight: 700; }
.page-head .sub { color: var(--muted); margin-top: 3px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.backdrop { display: none; }

@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s ease; }
  .app.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .app.nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 35; }
  .topbar { display: flex; }
  .page { padding: 16px 16px 32px; }
}

/* ---------- Cards, tiles ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 16px 18px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 18px 0;
}
.card-head h3 { font-size: 15px; font-weight: 650; }
.card-head .hint { color: var(--muted); font-size: 12.5px; }
.card-body { padding: 12px 18px 16px; }

.grid { display: grid; gap: 14px; }
.grid > * { min-width: 0; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-tiles { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 900px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

.tile { padding: 14px 16px; }
.tile .label { color: var(--text-2); font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.tile .value { font-size: 24px; font-weight: 650; margin-top: 4px; letter-spacing: -.2px; }
.tile .meta { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.tile.hero .value { font-size: 28px; }
.delta { font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; margin-top: 8px; }
.delta.up { color: var(--success); }
.delta.down { color: var(--danger); }
.delta.flat { color: var(--muted); }
.delta .vs { color: var(--muted); font-weight: 400; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface);
  cursor: pointer; font-weight: 550; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #941d14; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-lg { padding: 12px 18px; font-size: 16px; }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary); cursor: pointer; font-weight: 550; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field .help { font-size: 12px; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; padding: 8px 11px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); outline: none;
  transition: border-color .12s, box-shadow .12s;
}
textarea.input { resize: vertical; min-height: 64px; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(2, 119, 189, .18); }
.input.money { text-align: right; font-variant-numeric: tabular-nums; }
.input-group { display: flex; }
.input-group .input { border-radius: 0; }
.input-group > :first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group > :last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.input-group > * + * { margin-left: -1px; }
.addon {
  padding: 8px 10px; background: var(--surface-3); border: 1px solid var(--border-strong);
  color: var(--text-2); font-size: 13px; display: flex; align-items: center; white-space: nowrap;
}
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.form-grid .span-2 { grid-column: span 2; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } .form-grid .span-2 { grid-column: auto; } }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }

.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 7px 12px; cursor: pointer; font-weight: 550; color: var(--text-2); }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button.on { background: var(--primary); color: #fff; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters .input { width: auto; }
.filters .search { min-width: 220px; flex: 1 1 220px; max-width: 360px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tbody tr:hover { background: var(--surface-2); }
.table tr.void td { color: var(--muted); }
.table tr.void td.strike { text-decoration: line-through; }
.table tfoot td { font-weight: 650; background: var(--surface-2); }
.table .actions { white-space: nowrap; text-align: right; }
.table .actions > * + * { margin-left: 10px; }
.empty { padding: 34px 16px; text-align: center; color: var(--muted); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.badge.green { background: var(--success-soft); color: var(--success); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.amber { background: var(--warning-soft); color: var(--warning); }
.badge.teal { background: var(--primary-soft); color: var(--primary-ink); }
.badge.blue { background: var(--info-soft); color: #1c5cab; }

.alert { padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; display: flex; gap: 10px; align-items: flex-start; }
.alert.warn { background: var(--warning-soft); color: #6b3f00; border: 1px solid #f3d9a4; }
.alert.info { background: var(--info-soft); color: #1d3f6e; border: 1px solid #c9dbf3; }
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }

/* ---------- Bar list (dashboard) ---------- */
.barlist { list-style: none; margin: 0; padding: 0; }
.barlist li { padding: 7px 0; }
.barlist li + li { border-top: 1px solid var(--surface-3); }
.barlist .top { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.barlist .top .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barlist .top .vl { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.barlist .sub { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 10px; }
.barlist .track { height: 6px; border-radius: 3px; background: transparent; margin: 5px 0 3px; }
.barlist .fill { height: 6px; border-radius: 0 3px 3px 0; background: var(--series-1); min-width: 2px; }
.barlist .rank { display: inline-block; width: 20px; color: var(--muted); font-variant-numeric: tabular-nums; }

.chart-box { position: relative; height: 280px; }
.chart-box.short { height: 200px; }

/* ---------- Modal ---------- */
dialog.modal {
  border: 0; padding: 0; border-radius: 14px; box-shadow: var(--shadow-lg);
  width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
  background: var(--surface); color: var(--text);
}
dialog.modal.lg { width: min(860px, calc(100vw - 24px)); }
dialog.modal.sm { width: min(420px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgba(20, 18, 12, .45); }
.modal-inner { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 6px; }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 10px 20px 8px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--border); margin-top: 8px; }

/* ---------- Toast ---------- */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; }
.toast {
  background: #0f2a40; color: #fff; padding: 10px 14px; border-radius: 9px;
  box-shadow: var(--shadow-lg); max-width: 380px; font-weight: 500;
  animation: toast-in .18s ease-out;
}
.toast.error { background: var(--danger); }
.toast.success { background: #146c43; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* ---------- Autocomplete ---------- */
.ac { position: relative; }
.ac-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 60;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); max-height: 300px; overflow-y: auto; min-width: 280px;
}
.ac-item { padding: 8px 11px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.ac-item:hover, .ac-item.hl { background: var(--primary-soft); }
.ac-item .code { color: var(--muted); font-size: 12px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(165deg, #bfe4fb 0%, #e2f3fd 45%, #ffffff 100%); }
.login-card { width: min(380px, 100%); padding: 28px 26px; box-shadow: 0 12px 40px rgba(12, 53, 80, .12); }
.login-logo { display: block; width: 190px; height: auto; margin: 0 auto 6px; }
.login-sub { text-align: center; color: var(--muted); margin-bottom: 20px; }

/* ---------- POS ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 14px; height: calc(100vh - 44px); }
.pos-products { display: flex; flex-direction: column; min-height: 0; }
.pos-search { display: flex; gap: 8px; margin-bottom: 10px; }
.pos-search .input { font-size: 16px; padding: 11px 13px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { border: 1px solid var(--border-strong); background: var(--surface); padding: 5px 12px; border-radius: 999px; cursor: pointer; font-weight: 550; font-size: 13px; color: var(--text-2); }
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.pgrid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); grid-auto-rows: max-content; gap: 10px; align-content: start; padding: 2px 2px 12px; }
.pcard {
  text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 11px 12px; cursor: pointer; display: grid; grid-template-rows: auto 1fr auto auto; gap: 4px; min-height: 104px;
  box-shadow: var(--shadow); transition: border-color .1s, transform .05s;
}
.pcard:hover { border-color: var(--primary); }
.pcard:active { transform: scale(.98); }
.pcard:disabled { opacity: .5; cursor: not-allowed; }
.pcard .nm { font-weight: 600; line-height: 1.3; }
.pcard .cd { font-size: 11.5px; color: var(--muted); }
.pcard .pr { font-weight: 700; color: var(--primary-ink); font-variant-numeric: tabular-nums; }
.pcard .st { font-size: 12px; color: var(--muted); }
.pcard .st.low { color: var(--warning); font-weight: 600; }
.pcard .st.out { color: var(--danger); font-weight: 600; }

.cart { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.cart-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.cart-head h3 { font-size: 15px; }
.cart-items { flex: 1; overflow-y: auto; min-height: 120px; }
.cart-item { padding: 10px 14px; border-bottom: 1px solid var(--surface-3); display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; }
.cart-item .nm { font-weight: 600; line-height: 1.3; }
.cart-item .pr { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cart-item .tot { font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; }
.cart-item .ctl { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: 7px; overflow: hidden; }
.qty button { border: 0; background: var(--surface-3); width: 28px; height: 28px; cursor: pointer; font-size: 16px; font-weight: 700; color: var(--text-2); }
.qty button:hover { background: var(--border); }
.qty input { width: 44px; height: 28px; border: 0; text-align: center; outline: none; font-variant-numeric: tabular-nums; }
.cart-empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.cart-foot { border-top: 1px solid var(--border); padding: 12px 14px; background: var(--surface-2); }
.sum-row { display: flex; justify-content: space-between; align-items: center; padding: 3px 0; font-variant-numeric: tabular-nums; }
.sum-row.total { font-size: 22px; font-weight: 750; padding: 8px 0 4px; }
.pay-methods { display: grid; grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); gap: 6px; margin: 8px 0; }
.pay-methods button { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 7px; padding: 7px 4px; cursor: pointer; font-weight: 600; font-size: 13px; }
.pay-methods button.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-ink); }
.quick-cash { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.quick-cash button { border: 1px dashed var(--border-strong); background: var(--surface); border-radius: 7px; padding: 4px 9px; cursor: pointer; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.quick-cash button:hover { border-color: var(--primary); color: var(--primary-ink); }
.kbd { font-size: 11px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; color: var(--muted); background: var(--surface); }

.success-box { text-align: center; padding: 8px 0 4px; }
.success-box .ok { width: 54px; height: 54px; border-radius: 50%; background: var(--success-soft); color: var(--success); display: grid; place-items: center; margin: 0 auto 10px; }
.success-box .ok svg { width: 30px; height: 30px; }
.success-box .big { font-size: 30px; font-weight: 750; font-variant-numeric: tabular-nums; }

@media (max-width: 1100px) {
  .pos { grid-template-columns: minmax(0, 1fr) 340px; }
}
@media (max-width: 900px) {
  .pos { grid-template-columns: 1fr; height: auto; }
  .pgrid { max-height: 55vh; }
  .kbd-hint { display: none; }
  .cart-items { max-height: 50vh; }
}

/* ---------- Purchase form ---------- */
.line-table td { padding: 6px 8px; }
.line-table .input { padding: 6px 9px; }
.line-table td.w-qty { width: 110px; }
.line-table td.w-price { width: 170px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 9px 12px; cursor: pointer; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.tabs button.on { color: var(--primary-ink); border-bottom-color: var(--primary); }

/* ---------- Print (laporan A4) ---------- */
@media print {
  .sidebar, .topbar, .no-print, #toasts { display: none !important; }
  body { background: #fff; }
  .page { padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
}
