:root{
  --ink:#17202b;
  --muted:#5b6675;
  --paper:#eef1f5;
  --header-blue:#122f52;      /* dark blue table header */
  --header-blue-2:#1c4a80;
  --accent:#0d8a68;
  --accent-dark:#0a6b51;
  --gold:#c99b3f;
  --row-alt:#f2f6fb;
  --danger:#b3261e;
  --radius:16px;
}
*{box-sizing:border-box;margin:0;padding:0}
html{scroll-behavior:smooth}
body{
  font-family:"Inter", "Segoe UI", sans-serif;
  color:var(--ink);
  min-height:100vh;
  padding-bottom:80px;
  background:
    linear-gradient(180deg, rgba(18,47,82,.06) 0%, transparent 260px),
    radial-gradient(circle at 90% 10%, rgba(13,138,104,.08) 0, transparent 45%),
    var(--paper);
}

/* ---------- Header ---------- */
header{
  background:linear-gradient(120deg, var(--header-blue) 0%, var(--header-blue-2) 70%);
  color:#fff;
  padding:36px 20px;
  border-bottom:5px solid var(--gold);
  box-shadow:0 6px 24px rgba(18,47,82,.28);
}
.header-inner{
  max-width:800px;
  margin:0 auto;
  display:flex;
  align-items:center;
  gap:18px;
}
.logo-badge{
  width:62px;height:62px;
  flex:0 0 62px;
  display:grid;place-items:center;
  font-family:"Fraunces", serif;
  font-size:2rem;font-weight:700;
  color:var(--header-blue);
  background:linear-gradient(145deg, #ffffff, #d9e4f2);
  border-radius:50%;
  box-shadow:inset 0 -3px 6px rgba(0,0,0,.12), 0 4px 10px rgba(0,0,0,.25);
}
header h1{
  font-family:"Fraunces", serif;
  font-size:1.75rem;
  font-weight:700;
  letter-spacing:.3px;
}
header p{
  margin-top:4px;
  font-size:.9rem;
  color:#cdd9ea;
}

/* ---------- Card ---------- */
main{padding:0 16px}
.card{
  max-width:800px;              /* required max width */
  margin:34px auto 0;
  background:#fff;
  border-radius:var(--radius);
  border:1px solid #e2e8f0;
  box-shadow:0 18px 40px rgba(18,47,82,.10);
  overflow:hidden;
}
.card-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:18px 22px;
  border-bottom:1px solid #e9edf3;
}
.card-head h2{
  font-family:"Fraunces", serif;
  font-size:1.15rem;
  color:var(--header-blue);
}
.live-total{
  font-family:"JetBrains Mono", monospace;
  font-size:.85rem;
  font-weight:700;
  color:var(--accent-dark);
  background:rgba(13,138,104,.09);
  border:1px solid rgba(13,138,104,.25);
  padding:6px 14px;
  border-radius:999px;
  transition:transform .2s;
}
.live-total.bump{transform:scale(1.08)}

/* ---------- Product table ---------- */
table{width:100%;border-collapse:collapse}
#productTable thead th{
  background:var(--header-blue);   /* dark blue header */
  color:#fff;
  padding:14px 22px;
  text-align:left;
  font-size:.78rem;
  font-weight:600;
  text-transform:uppercase;
  letter-spacing:1.2px;
}
#productTable tbody tr{transition:background .15s}
#productTable tbody tr:nth-child(even){background:var(--row-alt)}  /* alternating rows */
#productTable tbody tr:hover{background:#e8f2ee}
#productTable td{
  padding:14px 22px;
  border-bottom:1px solid #eef1f5;
  font-size:.95rem;
}
.pname{font-weight:600}
.pname .icon{margin-right:10px}
.pname .p-icon{vertical-align:-4px}
.price{
  font-family:"JetBrains Mono", monospace;
  font-weight:700;
  color:var(--header-blue);
}
.qty-wrap{display:flex;align-items:center;gap:8px}
.stepper{
  width:30px;height:30px;
  border-radius:8px;
  border:1.5px solid #cbd5e1;
  background:#fff;
  font-size:1rem;
  font-weight:700;
  color:var(--header-blue);
  cursor:pointer;
  line-height:1;
  transition:all .15s;
}
.stepper:hover{background:var(--header-blue);color:#fff;border-color:var(--header-blue)}
#productTable input[type=number]{
  width:64px;
  padding:8px 4px;
  text-align:center;
  border:1.5px solid #cbd5e1;
  border-radius:8px;
  font-family:"JetBrains Mono", monospace;
  font-size:1rem;
  font-weight:700;
  transition:border-color .2s, box-shadow .2s;
}
#productTable input[type=number]:focus{
  outline:none;
  border-color:var(--accent);
  box-shadow:0 0 0 3px rgba(13,138,104,.18);
}

/* ---------- Buttons ---------- */
.btn-row{
  display:flex;
  justify-content:center;
  gap:14px;
  padding:24px;
  background:#fafbfd;
  border-top:1px solid #eef1f5;
}
button{font-family:inherit;cursor:pointer}
#generateBtn, #resetBtn, .print-btn{
  padding:13px 34px;
  font-size:.95rem;
  font-weight:600;
  border:none;
  border-radius:12px;
  transition:transform .15s, box-shadow .2s, background .2s;
}
#generateBtn{
  background:linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color:#fff;
  box-shadow:0 6px 18px rgba(13,138,104,.35);
}
#generateBtn:hover{transform:translateY(-2px);box-shadow:0 10px 22px rgba(13,138,104,.4)}
#generateBtn:active{transform:translateY(0) scale(.98)}
#resetBtn{
  background:#fff;
  color:var(--danger);
  border:1.5px solid var(--danger);
}
#resetBtn:hover{background:var(--danger);color:#fff}

.error{
  color:var(--danger);
  text-align:center;
  padding:14px 20px 0;
  font-weight:600;
  font-size:.92rem;
  display:none;
  animation:shake .3s;
}
@keyframes shake{
  0%,100%{transform:translateX(0)}
  25%{transform:translateX(-6px)}
  75%{transform:translateX(6px)}
}

/* ---------- Bill (cash-memo style) ---------- */
#billArea{
  max-width:520px;
  margin:40px auto 0;
  display:none;
  animation:slideUp .45s ease;
}
@keyframes slideUp{
  from{opacity:0;transform:translateY(24px)}
  to{opacity:1;transform:translateY(0)}
}
.receipt{
  background:#fffdf6;
  border:1px solid #ddd6c2;
  box-shadow:0 20px 45px rgba(0,0,0,.18);
  font-family:"JetBrains Mono", monospace;
  padding:28px 26px 36px;
  position:relative;
}
.receipt::after{
  content:"";
  position:absolute;left:0;right:0;bottom:-10px;height:10px;
  background:
    linear-gradient(45deg, transparent 33.333%, #fffdf6 33.333%, #fffdf6 66.667%, transparent 66.667%),
    linear-gradient(-45deg, transparent 33.333%, #fffdf6 33.333%, #fffdf6 66.667%, transparent 66.667%);
  background-size:16px 20px;
}
.receipt-top{text-align:center}
.receipt-brand{
  font-size:.75rem;
  letter-spacing:4px;
  color:#8a8266;
}
.receipt-brand span{color:var(--accent-dark);font-weight:700}
.receipt h2{
  font-size:1.2rem;
  letter-spacing:3px;
  margin:6px 0 8px;
  border-bottom:2px dashed #b3ab92;
  padding-bottom:10px;
}
.receipt .meta{
  font-size:.75rem;
  color:#6b6450;
  margin-top:4px;
}
.receipt table{margin-top:14px;border:1px solid #4a4534}  /* bordered bill table */
.receipt th, .receipt td{
  border:1px solid #4a4534;
  padding:7px 8px;
  font-size:.8rem;
}
.receipt th{background:#efe8d3;text-align:left}
.receipt td.num{text-align:right}

.summary{
  margin-top:16px;
  border-top:2px dashed #b3ab92;
  padding-top:12px;
  font-size:.85rem;
}
.summary .line{
  display:flex;
  justify-content:space-between;
  padding:4px 2px;
}
.summary .savings span:last-child{color:var(--accent-dark);font-weight:700}
.summary .final{
  margin-top:10px;
  border-top:2px solid #4a4534;
  border-bottom:2px solid #4a4534;
  padding:9px 4px;
  font-weight:700;
  font-size:1rem;
  background:#f3ecd7;
}
.receipt-footer{margin-top:18px;text-align:center}
.barcode{
  height:38px;
  margin:0 auto 10px;
  width:70%;
  background:repeating-linear-gradient(
    90deg,
    #2b2820 0 2px, transparent 2px 4px,
    #2b2820 4px 7px, transparent 7px 9px,
    #2b2820 9px 10px, transparent 10px 14px
  );
}
.thanks{
  font-size:.75rem;
  letter-spacing:1.5px;
  color:#6b6450;
}
.print-btn{
  display:block;
  margin:18px auto 0;
  background:#fff;
  color:var(--header-blue);
  border:1.5px solid var(--header-blue);
}
.print-btn:hover{background:var(--header-blue);color:#fff}

/* ---------- Print: only the receipt ---------- */
@media print{
  header, .card, .print-btn{display:none !important}
  body{background:#fff;padding:0}
  #billArea{margin:0 auto;box-shadow:none}
  .receipt{box-shadow:none}
}

@media (max-width:600px){
  header h1{font-size:1.25rem}
  .logo-badge{width:50px;height:50px;flex-basis:50px;font-size:1.5rem}
  #productTable th, #productTable td{padding:11px 12px}
  #productTable input[type=number]{width:52px}
  .stepper{width:26px;height:26px}
}
@media (prefers-reduced-motion: reduce){
  *{animation:none !important;transition:none !important}
}
