:root {
  --teal: #0f766e;
  --teal-dk: #0b5a54;
  --teal-lt: #e3f2ef;
  --krem: #f6efe2;
  --krem-dk: #e7dcc7;
  --ink: #1d2a28;
  --muted: #6b746f;
  --line: #e4dccb;
  --card: #fffdf8;
  --red: #b42318;
  --red-lt: #fdecea;
  --amber: #b45309;
  --radius: 12px;
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--krem); min-height: 100vh; font-size: 15px; line-height: 1.45; }
a { color: var(--teal); }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 10px; }
small { font-size: 12px; }
.muted { color: var(--muted); font-weight: 400; }
.block { display: block; }
.nowrap { white-space: nowrap; }
.inline { display: inline; }

/* ---------- bar atas ---------- */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px; background: var(--teal); color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 800; font-size: 17px; }
.brand small { font-weight: 500; opacity: .75; margin-left: 4px; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--krem); color: var(--teal); font-weight: 800; font-size: 14px; }
.topbar nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.topbar nav a, .topbar .linkbtn { color: #fff; text-decoration: none; padding: 7px 12px; border-radius: 8px; font-weight: 600; font-size: 14px; opacity: .85; }
.topbar nav a:hover, .topbar .linkbtn:hover { background: rgba(255,255,255,.12); opacity: 1; }
.topbar nav a.on { background: var(--krem); color: var(--teal); opacity: 1; }

.wrap { max-width: 1400px; margin: 0 auto; padding: 18px 20px 40px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.narrow { max-width: 440px; margin: 40px auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }

.flash { background: var(--teal-lt); border: 1px solid #b6dcd5; color: var(--teal-dk); padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 600; }
.alert { background: var(--red-lt); border: 1px solid #f5c2bd; color: var(--red); padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 600; }
.empty { color: var(--muted); padding: 22px 8px; text-align: center; }

/* ---------- tombol & form ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; cursor: pointer; text-decoration: none;
  background: var(--teal); color: #fff; font: 700 14px inherit; font-family: inherit; padding: 10px 16px; border-radius: 10px; }
.btn:hover { background: var(--teal-dk); }
.btn:disabled { background: #a9c3bf; cursor: not-allowed; }
.btn.big { font-size: 16px; padding: 13px 20px; }
.btn.full { width: 100%; }
.btn.small { font-size: 13px; padding: 6px 10px; border-radius: 8px; }
.btn.ghost { background: transparent; color: var(--teal); border: 1px solid #b6dcd5; }
.btn.ghost:hover { background: var(--teal-lt); }
.btn.ghost.danger, .linkbtn.danger { color: var(--red); border-color: #f5c2bd; }
.linkbtn { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; font-weight: 600; color: var(--teal); }

.form { display: grid; gap: 12px; }
.form label, .filters label, .pay label { display: grid; gap: 5px; font-size: 13px; font-weight: 600; color: #3d4845; }
input, select, textarea { font: inherit; font-size: 15px; color: var(--ink); background: #fff; border: 1px solid #d7cdb8; border-radius: 9px; padding: 9px 11px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #8fd0c6; border-color: var(--teal); }
.check { display: flex !important; align-items: center; gap: 8px; font-weight: 500 !important; }
.check input { width: auto; }
.grid2 { grid-template-columns: 1fr 1fr; }
.grid2 .span2 { grid-column: 1 / -1; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.calc { border: 1px dashed #c9bda4; border-radius: 10px; padding: 10px 12px 12px; background: #fbf7ee; margin: 0; }
.calc legend { font-size: 13px; font-weight: 700; color: var(--teal-dk); padding: 0 6px; }
.calc-row { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 10px; }
.calc p { margin: 10px 0 8px; font-size: 14px; }
.margin-info { margin: 0; font-weight: 700; color: var(--teal-dk); }
.margin-info.neg, .neg { color: var(--red) !important; }
.warn { color: var(--amber); font-weight: 700; }
.danger-zone { margin-top: 14px; text-align: right; }

/* ---------- tabel ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 14px; }
.filters input[type=search] { flex: 1 1 220px; width: auto; }
.filters select { width: auto; }
.filters label input { width: auto; }
.quick-dates { display: flex; gap: 12px; flex-wrap: wrap; font-size: 14px; font-weight: 600; }
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 2px solid var(--line); }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .r { text-align: right; }
.tbl tr.batal td { color: var(--muted); text-decoration: line-through; }
.tbl tr.batal td:last-child { text-decoration: none; }
.stok-pop { display: inline-block; position: relative; }
.stok-pop summary { list-style: none; }
.stok-pop summary::-webkit-details-marker { display: none; }
.stok-pop .pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 5; width: 250px; display: grid; gap: 8px; text-align: left;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; box-shadow: 0 10px 24px rgba(0,0,0,.12); }
.stok-pop .pop label { display: grid; gap: 4px; font-size: 12px; font-weight: 600; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.stat span { display: block; font-size: 13px; color: var(--muted); font-weight: 600; }
.stat strong { display: block; font-size: 22px; font-weight: 800; color: var(--teal-dk); margin: 2px 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }

/* ---------- halaman kasir ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(360px, 1fr); gap: 16px; align-items: start; }
.pos-left { display: flex; flex-direction: column; min-height: calc(100vh - 110px); }
.pos-right { position: sticky; top: 72px; display: flex; flex-direction: column; max-height: calc(100vh - 92px); }
#cari { font-size: 18px; padding: 14px 16px; border-width: 2px; border-color: #b6dcd5; }
.results { flex: 1; overflow-y: auto; margin-top: 10px; display: grid; gap: 6px; align-content: start; max-height: calc(100vh - 230px); }
.item { display: grid; grid-template-columns: 1fr auto auto; gap: 14px; align-items: center; width: 100%; text-align: left; cursor: pointer;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: inherit; color: inherit; }
.item:hover { border-color: #8fd0c6; }
.item.sel { border-color: var(--teal); box-shadow: 0 0 0 2px #b6dcd5; background: #f7fcfb; }
.item .nm { font-weight: 700; }
.item .nm small, .item .pr small { display: block; font-weight: 500; color: var(--muted); }
.item .pr { text-align: right; font-weight: 800; color: var(--teal-dk); }
.item .pr small { display: inline; }
.tag { display: block; font-size: 11px; font-weight: 700; color: var(--amber); }
.stok { font-size: 12px; color: var(--muted); min-width: 66px; text-align: right; }
.stok.habis { color: var(--red); font-weight: 700; }
.hint { margin: 10px 0 0; font-size: 12px; color: var(--muted); }

.cart-head { display: flex; justify-content: space-between; align-items: baseline; }
.cart { flex: 1; overflow-y: auto; min-height: 120px; margin: 0 -4px; padding: 0 4px; }
.line { padding: 9px 0; border-bottom: 1px solid var(--line); }
.line-top { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; }
.line .x { border: 0; background: none; font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
.line .x:hover { color: var(--red); }
.line-bot { display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px; align-items: center; margin-top: 6px; }
.jenis { font: 700 11px inherit; font-family: inherit; text-transform: uppercase; border-radius: 6px; padding: 4px 7px; border: 1px solid; cursor: pointer; background: #fff; }
.jenis.ecer { color: var(--teal); border-color: #b6dcd5; }
.jenis.grosir { color: #fff; background: var(--amber); border-color: var(--amber); }
.jenis.static { cursor: default; opacity: .6; }
.hrg { font-size: 13px; color: var(--muted); }
.qty { justify-self: start; display: inline-flex; align-items: center; border: 1px solid #d7cdb8; border-radius: 9px; overflow: hidden; background: #fff; }
.qty button { border: 0; background: var(--krem); width: 32px; height: 34px; font-size: 18px; cursor: pointer; color: var(--teal-dk); }
.qty button:hover { background: var(--krem-dk); }
.qty input { width: 62px; border: 0; border-radius: 0; text-align: center; padding: 6px 2px; -moz-appearance: textfield; }
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.sub { min-width: 86px; text-align: right; }

.pay { border-top: 2px solid var(--line); padding-top: 12px; margin-top: 8px; display: grid; gap: 10px; }
.total-row { display: flex; justify-content: space-between; align-items: baseline; }
.total-row strong { font-size: 30px; font-weight: 800; color: var(--teal-dk); }
.total-row.kembali strong { font-size: 22px; }
.total-row.kurang strong { color: var(--red); }
.pay-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
#bayar { font-size: 20px; font-weight: 700; text-align: right; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; }
.quick button { flex: 1 1 auto; border: 1px solid #b6dcd5; background: var(--teal-lt); color: var(--teal-dk); font: 700 13px inherit; font-family: inherit; border-radius: 8px; padding: 8px 10px; cursor: pointer; }
.quick button:hover { background: #cde9e4; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; background: var(--teal-dk); color: #fff; padding: 12px 18px;
  border-radius: 10px; font-weight: 700; box-shadow: 0 10px 30px rgba(0,0,0,.2); max-width: calc(100% - 32px); }
.toast.bad { background: var(--red); }
.print-frame { position: fixed; width: 0; height: 0; border: 0; opacity: 0; pointer-events: none; }

/* ---------- login ---------- */
.login-page .wrap { display: grid; place-items: center; min-height: 100vh; }
.login .brand.big { font-size: 22px; color: var(--teal); margin-bottom: 18px; }
.login .brand-mark { background: var(--teal); color: var(--krem); }

/* ---------- HP & tablet ---------- */
@media (max-width: 1000px) {
  .pos { grid-template-columns: 1fr; }
  .pos-left { min-height: 0; }
  .results { max-height: 45vh; }
  .pos-right { position: static; max-height: none; }
  .stats { grid-template-columns: 1fr 1fr; }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .wrap { padding: 12px 12px 32px; }
  .topbar { padding: 8px 12px; flex-direction: column; align-items: stretch; gap: 6px; }
  .topbar nav { justify-content: space-between; }
  .topbar nav a, .topbar .linkbtn { padding: 6px 8px; font-size: 13px; }
  .grid2, .calc-row { grid-template-columns: 1fr 1fr; }
  .grid2 > label { grid-column: 1 / -1; }
  .item { grid-template-columns: 1fr auto; }
  .item .stok { grid-column: 1 / -1; text-align: left; }
  .line-bot { grid-template-columns: auto 1fr auto; }
  .line-bot .hrg { display: none; }
  .total-row strong { font-size: 26px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat strong { font-size: 18px; }
  .stok-pop .pop { right: -8px; }
}
