:root {
  --bg: #f8f3ee;
  --bg-soft: #fffdfb;
  --surface: rgba(255, 252, 249, 0.92);
  --surface-strong: #fffaf6;
  --line: #eadfd7;
  --line-strong: #dcc9bf;
  --text: #4b342f;
  --text-soft: #7f655d;
  --heading: #2f211f;
  --accent: #b77d84;
  --accent-deep: #9b6168;
  --accent-soft: #f4dfe0;
  --accent-wash: #f8ece7;
  --success: #5c7b60;
  --warning: #ba8f4e;
  --danger: #b45f58;
  --shadow: 0 18px 55px rgba(106, 74, 66, 0.12);
  --shadow-soft: 0 10px 30px rgba(106, 74, 66, 0.08);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --container: 1240px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Plus Jakarta Sans", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(244, 223, 224, 0.65), transparent 28%),
    radial-gradient(circle at right 15%, rgba(233, 214, 200, 0.55), transparent 22%),
    linear-gradient(180deg, #fbf8f5 0%, #f6eee8 100%);
}

img {
  display: block;
  max-width: 100%;
}

button,
input,
textarea {
  font: inherit;
}

.page-shell {
  width: min(calc(100% - 32px), var(--container));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px 24px;
  margin-bottom: 24px;
  border: 1px solid rgba(234, 223, 215, 0.8);
  border-radius: var(--radius-xl);
  background: rgba(255, 250, 246, 0.78);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-soft);
}

.brand-mark {
  width: 78px;
  height: 78px;
  padding: 12px;
  border-radius: 24px;
  background: linear-gradient(180deg, #fff7f3 0%, #f7ebe6 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.brand-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-copy h1,
.panel-heading h2,
.empty-preview-card h3,
.nota-header h3 {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  color: var(--heading);
}

.brand-copy h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 0.95;
}

.eyebrow,
.section-kicker,
.nota-label,
.empty-tag {
  margin: 0 0 6px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-deep);
}

.subtitle,
.merchant-address,
.section-header p,
.footer-note,
.empty-preview-card p,
.nota-header p,
.meta-row span,
.summary-row span {
  margin: 0;
  color: var(--text-soft);
}

.app-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(360px, 0.96fr);
  gap: 24px;
  align-items: start;
}

.panel {
  border: 1px solid rgba(234, 223, 215, 0.86);
  border-radius: var(--radius-xl);
  background: var(--surface);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.form-panel,
.preview-panel {
  padding: 24px;
}

.panel-heading,
.section-header,
.actions,
.payment-grid,
.nota-header,
.nota-meta,
.nota-footer {
  display: flex;
  gap: 16px;
}

.panel-heading,
.section-header {
  justify-content: space-between;
  align-items: flex-start;
}

.panel-heading {
  margin-bottom: 22px;
}

.panel-heading h2 {
  font-size: 2rem;
  line-height: 1;
}

.badge-soft {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--accent-wash);
  color: var(--accent-deep);
  font-size: 0.82rem;
  font-weight: 700;
}

.alert-box {
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid rgba(180, 95, 88, 0.22);
  border-radius: var(--radius-md);
  background: rgba(255, 239, 237, 0.9);
  color: #8b3f39;
  font-size: 0.95rem;
  line-height: 1.55;
}

.success-box {
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid rgba(92, 123, 96, 0.22);
  border-radius: var(--radius-md);
  background: rgba(237, 248, 238, 0.95);
  color: var(--success);
  font-size: 0.95rem;
  line-height: 1.55;
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.top-nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 250, 246, 0.84);
  color: var(--text-soft);
  text-decoration: none;
  font-weight: 700;
  transition: transform 0.2s ease, border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.top-nav-link:hover,
.top-nav-link.is-active {
  transform: translateY(-1px);
  border-color: var(--accent);
  color: var(--accent-deep);
  background: var(--accent-wash);
}

.stack-layout {
  display: grid;
  gap: 24px;
}

.page-panel {
  padding: 24px;
}

.merchant-card,
.items-card,
.payment-card,
.summary-card,
.empty-preview-card,
.nota-paper {
  border: 1px solid rgba(234, 223, 215, 0.92);
  border-radius: var(--radius-lg);
  background: var(--bg-soft);
}

.merchant-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  margin-bottom: 18px;
}

.merchant-logo {
  width: 62px;
  height: 62px;
  object-fit: contain;
  flex-shrink: 0;
  padding: 8px;
  border-radius: 18px;
  background: linear-gradient(180deg, #fff6f1 0%, #f8ece7 100%);
}

.merchant-title {
  margin: 0 0 4px;
  font-weight: 700;
  color: var(--heading);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

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

.field span {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--heading);
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--text);
  padding: 14px 16px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(183, 125, 132, 0.12);
  transform: translateY(-1px);
}

.item-qty {
  text-align: center;
}

.item-qty::-webkit-outer-spin-button,
.item-qty::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.qty-stepper {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #fff;
}

.qty-stepper .item-qty {
  border: 0;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  border-radius: 0;
  padding: 14px 8px;
  box-shadow: none;
  transform: none;
}

.qty-stepper .item-qty:focus {
  box-shadow: none;
  transform: none;
}

.qty-btn {
  min-height: 50px;
  border: 0;
  background: var(--accent-wash);
  color: var(--accent-deep);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.qty-btn:hover {
  background: var(--accent-soft);
}

.field textarea {
  resize: vertical;
  min-height: 96px;
}

.field-full {
  grid-column: 1 / -1;
}

.items-card,
.payment-card {
  margin-top: 20px;
  padding: 18px;
}

.section-header {
  margin-bottom: 14px;
}

.section-header h3 {
  margin: 0 0 4px;
  color: var(--heading);
}

.section-header.compact {
  margin-bottom: 16px;
}

.items-footer-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.items-list-header,
.item-row {
  display: grid;
  grid-template-columns: minmax(220px, 2.2fr) minmax(82px, 0.65fr) minmax(160px, 1.2fr) minmax(160px, 1.2fr) 92px;
  gap: 12px;
  align-items: end;
}

.items-list-header {
  padding: 0 4px 10px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.item-rows {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.item-row {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(255, 250, 246, 0.96), rgba(255, 255, 255, 0.96));
  animation: fadeInUp 0.25s ease;
}

.item-row .field {
  min-width: 0;
}

.mobile-label {
  display: none;
}

.subtotal-box {
  display: flex;
  align-items: center;
  min-height: 50px;
  padding: 0 16px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--accent-wash);
  font-weight: 700;
  color: var(--heading);
}

.button,
.button-icon {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.button:hover,
.button-icon:hover {
  transform: translateY(-1px);
}

.button {
  padding: 13px 18px;
  font-weight: 700;
}

.button-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: #fff;
  box-shadow: 0 10px 20px rgba(155, 97, 104, 0.24);
}

.button-secondary {
  background: var(--accent-wash);
  color: var(--accent-deep);
}

.button-outline {
  background: #fff;
  color: var(--heading);
  border: 1px solid var(--line-strong);
}

.button-accent {
  background: linear-gradient(135deg, #c5898d 0%, #a2676f 100%);
  color: #fff;
  box-shadow: 0 10px 20px rgba(155, 97, 104, 0.24);
}

.button-ghost {
  background: transparent;
  color: var(--text-soft);
  border: 1px dashed var(--line-strong);
}

.button-danger {
  background: rgba(180, 95, 88, 0.12);
  color: var(--danger);
  border: 1px solid rgba(180, 95, 88, 0.18);
}

.button-small {
  padding: 10px 14px;
  font-size: 0.86rem;
}

.button-icon {
  min-height: 50px;
  padding: 0 14px;
  background: rgba(180, 95, 88, 0.1);
  color: var(--danger);
  font-weight: 700;
}

.payment-grid {
  align-items: stretch;
}

.payment-grid > .field {
  flex: 1 1 220px;
}

.summary-card {
  flex: 1 1 280px;
  padding: 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.summary-line,
.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.summary-line + .summary-line,
.summary-row + .summary-row {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 116px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.status-pill.pending {
  background: rgba(180, 95, 88, 0.12);
  color: var(--danger);
}

.status-pill.dp {
  background: rgba(186, 143, 78, 0.14);
  color: var(--warning);
}

.status-pill.lunas {
  background: rgba(92, 123, 96, 0.14);
  color: var(--success);
}

.actions {
  flex-wrap: wrap;
  margin-top: 22px;
}

.empty-preview {
  min-height: 100%;
  display: flex;
}

.empty-preview-card {
  width: 100%;
  min-height: 560px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 28px;
  background:
    linear-gradient(180deg, rgba(255, 252, 249, 0.96), rgba(248, 240, 236, 0.96)),
    radial-gradient(circle at top, rgba(244, 223, 224, 0.4), transparent 40%);
}

.empty-preview-card > * {
  max-width: 430px;
}

.empty-preview-card h3 {
  font-size: 2.1rem;
  margin-bottom: 10px;
}

.nota-preview {
  animation: fadeInUp 0.3s ease;
}

.nota-paper {
  padding: 28px;
  box-shadow: 0 24px 50px rgba(106, 74, 66, 0.1);
}

.nota-header {
  justify-content: space-between;
  align-items: center;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.nota-brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.nota-logo {
  width: 68px;
  height: 68px;
  object-fit: contain;
  padding: 8px;
  border-radius: 18px;
  background: linear-gradient(180deg, #fff7f3 0%, #f7ebe6 100%);
}

.nota-header h3 {
  font-size: 2rem;
  line-height: 0.9;
  margin-bottom: 4px;
}

.nota-title-wrap {
  text-align: right;
}

.nota-caption {
  font-size: 0.92rem;
}

.nota-meta {
  justify-content: space-between;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.meta-group {
  flex: 1;
  min-width: 0;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
}

.meta-row strong,
.summary-row strong,
.summary-line strong {
  color: var(--heading);
}

.nota-table-wrap {
  padding: 18px 0;
  overflow-x: auto;
}

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

.nota-table th,
.nota-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 0.94rem;
}

.nota-table th {
  font-size: 0.82rem;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.nota-table td:nth-child(1),
.nota-table td:nth-child(3) {
  width: 64px;
}

.nota-table td:nth-child(3) {
  text-align: center;
}

.nota-table td:nth-child(4),
.nota-table td:nth-child(5),
.nota-table th:nth-child(4),
.nota-table th:nth-child(5) {
  text-align: right;
}

.nota-summary {
  display: flex;
  justify-content: flex-end;
}

.summary-box {
  width: min(100%, 340px);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, #fffaf7 0%, #fff 100%);
}

.summary-row.highlight strong {
  color: var(--accent-deep);
}

.summary-row.highlight strong.pending {
  color: var(--danger);
}

.summary-row.highlight strong.dp {
  color: var(--warning);
}

.summary-row.highlight strong.lunas {
  color: var(--success);
}

.nota-note {
  margin-top: 18px;
  padding: 18px;
  border-radius: var(--radius-lg);
  background: var(--accent-wash);
}

.nota-note h4 {
  margin: 0 0 8px;
  color: var(--heading);
}

.nota-note p {
  margin: 0;
  line-height: 1.7;
}

.nota-footer {
  align-items: center;
  padding-top: 22px;
  margin-top: 22px;
  border-top: 1px solid var(--line);
}

.qr-wrap {
  flex-shrink: 0;
}

.qrcode-box {
  width: 124px;
  height: 124px;
  display: grid;
  place-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}

.qrcode-box img,
.qrcode-box canvas {
  width: 100% !important;
  height: 100% !important;
}

.footer-copy {
  display: grid;
  gap: 8px;
}

.thank-you {
  margin: 0;
  font-weight: 700;
  color: var(--heading);
}

.footer-contact {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text-soft);
}

.payment-info {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--heading);
}

.desktop-only {
  display: grid;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.stats-card {
  padding: 18px;
  border: 1px solid rgba(234, 223, 215, 0.92);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255, 250, 246, 0.96), rgba(255, 255, 255, 0.96));
}

.stats-card span {
  display: block;
  font-size: 0.9rem;
  color: var(--text-soft);
}

.stats-card strong {
  display: block;
  margin-top: 8px;
  color: var(--heading);
  font-size: 1.3rem;
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(220px, 1fr) auto;
  gap: 16px;
  align-items: end;
  margin-bottom: 22px;
}

.select-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--text);
  padding: 14px 16px;
  outline: none;
}

.filter-actions,
.inline-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.table-card {
  overflow-x: auto;
  border: 1px solid rgba(234, 223, 215, 0.92);
  border-radius: var(--radius-lg);
  background: var(--bg-soft);
}

.table-card.compact {
  border-radius: var(--radius-md);
}

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

.rekap-table th,
.rekap-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.rekap-table th {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-soft);
}

.empty-table {
  text-align: center !important;
  color: var(--text-soft);
  padding: 24px !important;
}

.table-actions {
  min-width: 140px;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.9fr);
  gap: 24px;
}

.detail-card {
  padding: 20px;
}

.detail-card-full {
  grid-row: span 3;
}

.detail-paper {
  box-shadow: none;
}

.stack-form {
  display: grid;
  gap: 14px;
}

.danger-card {
  border-color: rgba(180, 95, 88, 0.2);
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1100px) {
  .app-grid {
    grid-template-columns: 1fr;
  }

  .detail-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .detail-card-full {
    grid-row: auto;
  }

  .empty-preview-card {
    min-height: 320px;
  }
}

@media (max-width: 760px) {
  .page-shell {
    width: min(calc(100% - 20px), var(--container));
    padding-top: 18px;
  }

  .page-panel,
  .app-header,
  .form-panel,
  .preview-panel,
  .nota-paper {
    padding: 18px;
  }

  .app-header {
    align-items: flex-start;
  }

  .form-grid,
  .payment-grid,
  .filter-bar {
    grid-template-columns: 1fr;
    display: grid;
  }

  .items-list-header.desktop-only {
    display: none;
  }

  .item-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .mobile-label {
    display: inline;
  }

  .row-actions {
    display: flex;
    justify-content: flex-end;
  }

  .items-footer-actions .button {
    width: 100%;
  }

  .actions {
    flex-direction: column;
  }

  .actions .button {
    width: 100%;
  }

  .filter-actions .button,
  .inline-actions .button,
  .inline-actions a {
    width: 100%;
  }

  .nota-header,
  .nota-meta,
  .nota-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .nota-title-wrap {
    text-align: left;
  }

  .meta-row {
    flex-direction: column;
    gap: 2px;
  }

  .nota-table th,
  .nota-table td {
    padding: 10px 8px;
    font-size: 0.88rem;
  }

  .brand-copy h1 {
    line-height: 1;
  }
}

@media print {
  @page {
    size: A4;
    margin: 12mm;
  }

  body {
    background: #fff;
  }

  .app-header,
  .top-nav,
  .form-panel,
  .panel-heading,
  #emptyPreview,
  .stats-grid,
  .filter-bar,
  .detail-card:not(.detail-card-full) {
    display: none !important;
  }

  .page-shell,
  .app-grid,
  .preview-panel,
  .nota-preview,
  .nota-paper {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    background: #fff !important;
  }

  .preview-panel {
    overflow: visible !important;
  }

  .nota-paper {
    display: block !important;
  }

  .nota-note,
  .summary-box,
  .qrcode-box,
  .nota-paper,
  .merchant-card {
    break-inside: avoid;
  }
}
