:root {
  --paper: #F1EFE4;
  --paper-raised: #FAF8F0;
  --ink: #211F1A;
  --ink-soft: #5B584D;
  --teal: #17332C;
  --teal-soft: #24473D;
  --gold: #C8963E;
  --gold-soft: #E9C888;
  --line: #D9D4C2;
  --danger: #A23B2E;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(23, 51, 44, 0.08);
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px);
  background-size: 100% 34px;
  background-attachment: local;
}

h1, h2 { font-family: var(--font-display); margin: 0; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------- Header ---------- */
.app-header {
  background: var(--teal);
  color: #fff;
  padding: 22px 0;
  box-shadow: var(--shadow);
}
.header-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  background: var(--gold);
  color: var(--teal);
  border-radius: 8px;
  font-weight: 700;
  font-size: 20px;
  font-family: var(--font-display);
}
.app-header h1 { font-size: 22px; letter-spacing: -0.01em; }
.tagline { margin: 2px 0 0; font-size: 13px; color: #C9D6D0; }

/* ---------- Layout ---------- */
.container { max-width: 980px; margin: 0 auto; padding: 28px 24px 60px; }

/* ---------- Receipt summary card (signature element) ---------- */
.receipt-card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px 30px;
  position: relative;
  margin-bottom: 24px;
  overflow: hidden;
}
.receipt-row.receipt-title {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
  padding-bottom: 12px;
  margin-bottom: 16px;
  border-bottom: 1px dashed var(--line);
}
.receipt-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.receipt-item { display: flex; flex-direction: column; gap: 6px; }
.receipt-label { font-size: 12px; color: var(--ink-soft); }
.receipt-value { font-size: 20px; font-weight: 600; color: var(--teal); }
.receipt-item-total .receipt-value { color: var(--gold); font-size: 24px; }
.receipt-tear {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 12px;
  background:
    radial-gradient(circle at 8px 0, transparent 7px, var(--paper) 7.5px) repeat-x;
  background-size: 16px 12px;
}

/* ---------- Stamp badge ---------- */
.stamp-badge {
  position: fixed;
  top: 100px;
  right: -14px;
  width: 108px;
  height: 108px;
  border: 3px solid var(--gold);
  border-radius: 50%;
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  line-height: 1.3;
  transform: rotate(-14deg);
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
}
@media (max-width: 900px) { .stamp-badge { display: none; } }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.filter-group { display: flex; gap: 10px; flex-wrap: wrap; }

.input {
  font-family: var(--font-body);
  font-size: 14px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper-raised);
  color: var(--ink);
}
.input:focus { outline: 2px solid var(--gold-soft); outline-offset: 1px; }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 7px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.05s ease, opacity 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--gold); color: var(--teal); }
.btn-primary:hover { opacity: 0.9; }
.btn-outline { background: transparent; border-color: var(--teal); color: var(--teal); }
.btn-outline:hover { background: var(--teal); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { color: var(--ink); }

/* ---------- Table ---------- */
.table-wrap {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.table-penjualan { width: 100%; border-collapse: collapse; font-size: 14px; }
.table-penjualan th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: #EAE6D6;
  padding: 12px 16px;
}
.table-penjualan td { padding: 12px 16px; border-top: 1px solid var(--line); }
.table-penjualan th.num, .table-penjualan td.num { text-align: right; font-family: var(--font-mono); }
.table-penjualan th.aksi, .table-penjualan td.aksi { text-align: right; width: 110px; }
.table-penjualan tbody tr:hover { background: rgba(200, 150, 62, 0.06); }

.link-btn {
  background: none; border: none; cursor: pointer;
  font-size: 13px; font-weight: 600; padding: 4px 6px;
  color: var(--teal);
}
.link-btn.danger { color: var(--danger); }
.link-btn:hover { text-decoration: underline; }

.state-kosong {
  padding: 40px 24px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(23, 51, 44, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 10;
}
.modal {
  background: var(--paper-raised);
  border-radius: var(--radius);
  width: 100%; max-width: 420px;
  padding: 24px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.btn-close {
  background: none; border: none; font-size: 22px; line-height: 1;
  cursor: pointer; color: var(--ink-soft);
}
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-soft); margin-bottom: 14px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.total-preview {
  flex-direction: row; align-items: center; justify-content: space-between;
  background: #EAE6D6; border-radius: 7px; padding: 10px 14px;
  font-size: 14px; color: var(--ink);
}
.total-preview .mono { font-size: 18px; font-weight: 600; color: var(--teal); }
.form-error {
  background: #F4E3E0; color: var(--danger);
  border-radius: 6px; padding: 8px 12px; font-size: 13px;
  margin: 0 0 12px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

@media (max-width: 560px) {
  .receipt-grid { grid-template-columns: 1fr; }
  .field-row { flex-direction: column; gap: 0; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .filter-group { flex-direction: column; }
}

/* ---------- Header: info pengguna ---------- */
.header-actions { display: flex; align-items: center; gap: 14px; }
.user-chip {
  display: flex; flex-direction: column; align-items: flex-end;
  font-size: 12px; color: #C9D6D0; line-height: 1.4;
}
.user-chip strong { color: #fff; font-size: 14px; }
.btn-header-outline {
  background: transparent; border: 1px solid rgba(255,255,255,0.4); color: #fff;
}
.btn-header-outline:hover { background: rgba(255,255,255,0.12); }

/* ---------- Halaman login ---------- */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--teal);
  background-image: none;
}
.login-card {
  background: var(--paper-raised);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  padding: 32px;
  width: 100%; max-width: 380px;
}
.login-brand { margin-bottom: 24px; }
.tagline.dark { color: var(--ink-soft); }
.btn-block { width: 100%; margin-top: 6px; }
.login-hint { font-size: 12px; color: var(--ink-soft); margin: 18px 0 0; text-align: center; }

/* ---------- Modal kelola pengguna ---------- */
.modal-wide { max-width: 520px; }
.user-list { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; }
.user-list li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.user-list .user-meta { display: flex; flex-direction: column; }
.user-list .user-name { font-weight: 600; font-size: 14px; }
.user-list .user-role { font-size: 12px; color: var(--ink-soft); }
.role-badge {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em;
  padding: 2px 8px; border-radius: 20px; text-transform: uppercase;
  background: var(--gold-soft); color: var(--teal); margin-left: 8px;
}
.divider-form { border: none; border-top: 1px dashed var(--line); margin: 18px 0; }
