/* Direction, palette, and contrast evidence: DESIGN.md */
:root {
  --bg: #faf9f6;
  --surface: #ffffff;
  --ink: #1f2a21;
  --muted: #56635a;
  --brand: #156a4b;
  --brand-deep: #0e4f37;
  --brand-soft: #e3efe6;
  --line: #e2ded3;
  --input-border: #847f72;
  --btn-light-bg: #edeae0;
  --btn-light-ink: #3f4a40;
  --danger: #b42318;
  --danger-soft: #fdf1ef;
  --ok-ink: #0a5c3c;
  --ok-soft: #e8f5ec;
}

* { box-sizing: border-box }
body {
  margin: 0;
  font: 16px/1.6 "Plus Jakarta Sans", -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
.layout { display: flex; min-height: 100vh; min-height: 100dvh }

:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px }

.side {
  width: 236px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 24px 14px calc(18px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 800; letter-spacing: -.01em; padding: 0 8px 22px }
.brand .mark { width: 34px; height: 34px; flex: none; border-radius: 8px; background: var(--brand); display: flex; align-items: center; justify-content: center; color: #fff }
.brand .mark svg { width: 19px; height: 19px }
.side button {
  display: flex; align-items: center; gap: 11px;
  width: 100%; min-height: 48px; text-align: left; border: 0; background: transparent;
  padding: 11px 12px; border-radius: 8px; cursor: pointer;
  color: var(--muted); font: inherit; font-weight: 600;
  transition: background-color .15s, color .15s;
}
.side button svg { width: 19px; height: 19px; flex: none }
.side button:hover { background: var(--bg); color: var(--ink) }
.side button.active { background: var(--brand-soft); color: var(--brand-deep) }
.side .logout { margin-top: auto; color: var(--danger) }
.side .logout:hover { background: var(--danger-soft); color: var(--danger) }

.main { flex: 1; padding: 32px; max-width: 1140px; width: 100% }
.top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; gap: 10px }
.top h1 { margin: 0 0 4px; font-size: 27px; font-weight: 800; letter-spacing: -.01em }
.muted { color: var(--muted) }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px;
  margin-bottom: 18px;
}
.card h3 { margin-top: 0; font-size: 18px }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px }
.stat span { color: var(--muted); font-size: 15px; font-weight: 600 }
.stat b { display: block; font-size: 30px; font-weight: 800; letter-spacing: -.01em; margin-top: 6px; font-variant-numeric: tabular-nums }

label { font-weight: 700; font-size: 15px }
input, select {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border: 1.5px solid var(--input-border); border-radius: 8px;
  margin-top: 6px; font: inherit; background: #fff; color: var(--ink);
  transition: border-color .15s;
}
input:focus { outline: 3px solid var(--brand); outline-offset: 1px; border-color: var(--brand) }
input::placeholder { color: var(--muted) }

.btn {
  border: 0; border-radius: 8px; min-height: 48px; padding: 11px 18px; cursor: pointer;
  font: inherit; font-weight: 700;
  transition: background-color .15s;
}
.dark { background: var(--brand); color: #fff }
.dark:hover { background: var(--brand-deep) }
.light { background: var(--btn-light-bg); color: var(--btn-light-ink) }
.light:hover { background: #e2ded3 }
.danger { color: var(--danger) }
.actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap }

table { width: 100%; border-collapse: collapse }
th, td { padding: 12px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle }
th { font-size: 14px; color: var(--muted); font-weight: 700 }
td { font-variant-numeric: tabular-nums }
.num { width: 120px }
.right { text-align: right }

.total { text-align: right; max-width: 360px; margin: 18px 0 0 auto }
.total div { display: flex; justify-content: space-between; align-items: center; padding: 7px; gap: 10px; font-variant-numeric: tabular-nums }
.grand { border-top: 2px solid var(--ink); font-size: 21px; font-weight: 800; margin-top: 5px }
.grand b { color: var(--brand-deep) }

.search { max-width: 400px; margin-bottom: 16px }
.notice { padding: 13px 15px; border-radius: 8px; background: var(--danger-soft); color: var(--danger); margin-bottom: 14px; font-weight: 600 }
.ok { background: var(--ok-soft); color: var(--ok-ink) }
.hidden { display: none !important }
.row-actions { display: flex; gap: 8px; justify-content: flex-end }
.row-actions .btn { min-height: 44px; padding: 8px 14px; font-size: 15px }
.linklike { background: none; border: 0; padding: 0; color: var(--brand-deep); font-weight: 700; cursor: pointer; font: inherit; text-decoration: underline; text-underline-offset: 3px }

.product-form { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 14px; align-items: end }

.login-wrap {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: var(--bg);
}
.login-card { width: 100%; max-width: 380px; padding: 30px 28px }
.login-card .brand { flex-direction: column; text-align: center; gap: 12px; padding-bottom: 6px; font-size: 23px }
.login-card .brand .mark { width: 56px; height: 56px; border-radius: 12px }
.login-card .brand .mark svg { width: 30px; height: 30px }
.login-sub { text-align: center; color: var(--muted); margin: 0 0 20px }
.install-btn { width: 100%; margin-top: 14px; background: var(--surface); border: 1.5px solid var(--brand); color: var(--brand-deep); display: flex; align-items: center; justify-content: center; gap: 9px }
.install-btn:hover { background: var(--brand-soft) }
.install-btn svg { width: 18px; height: 18px }

.modal-back { position: fixed; inset: 0; background: rgba(31, 42, 33, .55); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50 }
/* the modal is the one genuinely elevated surface, so it alone carries a shadow */
.modal { background: var(--surface); border-radius: 12px; padding: 26px; width: 100%; max-width: 640px; max-height: 90vh; overflow: auto; box-shadow: 0 20px 50px -20px rgba(31, 42, 33, .4) }
.install-steps { margin: 16px 0 4px; padding: 0; list-style: none; counter-reset: step }
.install-steps li { counter-increment: step; display: flex; gap: 12px; align-items: flex-start; padding: 10px 0 }
.install-steps li::before { content: counter(step); flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-deep); font-weight: 800; font-size: 15px; display: flex; align-items: center; justify-content: center }

#printArea { display: none }

@media (max-width: 700px) {
  .layout { display: block }
  .side { width: 100%; flex-direction: row; align-items: center; gap: 4px; padding: 8px 10px; padding-top: calc(8px + env(safe-area-inset-top)); flex-wrap: wrap; position: sticky; top: 0; z-index: 20; border-right: 0; border-bottom: 1px solid var(--line) }
  .brand { padding: 6px; margin-right: auto }
  .side button { width: auto; min-height: 44px; padding: 9px 12px }
  .side button svg { display: none }
  .side .logout { margin-top: 0 }
  .main { padding: 16px; padding-bottom: calc(24px + env(safe-area-inset-bottom)) }
  .card { padding: 16px }
  .stats, .grid { grid-template-columns: 1fr }
  .top { align-items: flex-start }
  .top .btn { white-space: nowrap }
  .top h1 { font-size: 23px }
  .num { width: 100% }
  .total { max-width: none }
  .total .num { width: 90px }

  .items-table thead { display: none }
  .items-table, .items-table tbody { display: block }
  .items-table tr { display: grid; grid-template-columns: 1fr 1.3fr auto; gap: 8px 10px; align-items: end; border-bottom: 1px solid var(--line); padding: 14px 0 }
  .items-table td { display: block; border: 0; padding: 0 }
  .items-table td input { margin-top: 4px }
  .cell-name { grid-column: 1 / 3 }
  .cell-del { grid-column: 3; grid-row: 1; justify-self: end }
  .cell-del .btn { min-height: 48px; min-width: 48px }
  .cell-qty { grid-column: 1; grid-row: 2 }
  .cell-price { grid-column: 2; grid-row: 2 }
  .cell-amt { grid-column: 3; grid-row: 2; text-align: right; font-weight: 800; padding-bottom: 12px }
  .cell-qty::before, .cell-price::before, .cell-amt::before { content: ""; display: block; font-size: 14px; font-weight: 600; color: var(--muted) }
  .cell-qty::before { content: "Jumlah" }
  .cell-price::before { content: "Harga" }
  .cell-amt::before { content: "Total" }

  .product-form { grid-template-columns: 1fr 1fr }
  .product-form label:first-child, .product-form label:nth-child(4), .product-form .btn { grid-column: 1 / -1 }
}

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px }
@media (max-width: 700px) { .grid { grid-template-columns: 1fr } }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important }
}

@media print {
  body * { visibility: hidden }
  #printArea, #printArea * { visibility: visible }
  #printArea { display: block; position: absolute; inset: 0; padding: 0; background: #fff }
}
.print-doc { font: 13px/1.5 "Plus Jakarta Sans", Arial, sans-serif; color: #000; max-width: 780px; margin: 0 auto; padding: 24px }
.print-doc .head { display: flex; justify-content: space-between; border-bottom: 3px solid #000; padding-bottom: 14px; margin-bottom: 18px }
.print-doc h2 { margin: 0 0 4px; font-size: 24px }
.print-doc .inv-title { text-align: right }
.print-doc .inv-title h3 { margin: 0 0 4px; font-size: 20px; letter-spacing: 2px }
.print-doc table { width: 100%; border-collapse: collapse; margin-top: 14px }
.print-doc th { border-bottom: 2px solid #000; font-size: 12px; padding: 8px 6px; color: #000 }
.print-doc td { border-bottom: 1px solid #ccc; padding: 8px 6px }
.print-doc .totals { max-width: 300px; margin-left: auto; margin-top: 14px }
.print-doc .totals div { display: flex; justify-content: space-between; padding: 4px 6px }
.print-doc .totals .g { border-top: 2px solid #000; font-weight: bold; font-size: 16px; margin-top: 4px; padding-top: 8px }
.print-doc .thanks { margin-top: 40px; text-align: center; color: #444 }
