/* Joseph's Tire Sets invoices — mobile-first styles. */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f4f4f2;
  color: #111;
}
a { color: #c2410c; }
.topbar {
  background: #111;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  font-size: 17px;
  white-space: nowrap;
}
.topnav { display: flex; gap: 12px; align-items: center; }
.topnav a { color: #fff; text-decoration: none; font-size: 14px; }
.linklike {
  background: none;
  border: none;
  color: #fff;
  font-size: 14px;
  padding: 0;
  cursor: pointer;
}
.wrap { max-width: 560px; margin: 0 auto; padding: 16px; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 24px 0 8px; }
.card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  margin-bottom: 16px;
}
label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 4px; color: #444; }
input[type="text"], input[type="tel"], input[type="password"], input[type="number"], select, textarea {
  width: 100%;
  padding: 12px;
  font-size: 16px; /* 16px+ prevents iOS auto-zoom on focus */
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #fff;
}
textarea { min-height: 64px; resize: vertical; }
.btn {
  display: inline-block;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  font-size: 16px;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  background: #f97316;
  color: #fff;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}
.btn.secondary { background: #fff; color: #111; border: 1px solid #ccc; }
.btn.danger { background: #fff; color: #b91c1c; border: 1px solid #fca5a5; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }
.error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}
.notice {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}
.ok { color: #15803d; font-weight: 600; font-size: 14px; }
.stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.stat { background: #fff; border-radius: 12px; padding: 12px 8px; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.stat .label { font-size: 12px; color: #666; display: block; }
.stat .value { font-size: 17px; font-weight: 800; }
.inv-row {
  display: block;
  background: #fff;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  text-decoration: none;
  color: #111;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.inv-row .top { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; }
.inv-row .sub { color: #555; font-size: 14px; margin-top: 4px; }
.badge { font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.badge.paid { background: #dcfce7; color: #166534; }
.badge.unpaid { background: #fef9c3; color: #854d0e; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip {
  border: 1px solid #ccc;
  background: #fff;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
}
.item-row {
  display: grid;
  grid-template-columns: 1fr 56px 96px 28px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.item-row input { min-width: 0; }
.rm-btn { border: none; background: none; font-size: 20px; cursor: pointer; color: #999; padding: 8px 0; }
.totals { margin-top: 16px; border-top: 1px solid #eee; padding-top: 12px; }
.totals .line { display: flex; justify-content: space-between; padding: 4px 0; font-size: 15px; }
.totals .line.total { font-size: 20px; font-weight: 800; border-top: 2px solid #111; margin-top: 8px; padding-top: 10px; }
/* Receipt */
.receipt { background: #fff; border-radius: 12px; padding: 20px 16px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.receipt-head { display: flex; gap: 12px; align-items: flex-start; }
.receipt-logo { width: 72px; height: auto; flex-shrink: 0; }
.receipt-shop { font-size: 22px; font-weight: 900; line-height: 1.1; }
.receipt-meta { font-size: 13px; color: #444; line-height: 1.5; }
.receipt-num { margin-left: auto; text-align: right; flex-shrink: 0; }
.receipt-num .tag { color: #f97316; font-weight: 800; letter-spacing: 1px; font-size: 13px; }
.receipt-num .num { font-size: 26px; font-weight: 900; }
.receipt hr { border: none; border-top: 3px solid #111; margin: 16px 0; }
.receipt table { width: 100%; border-collapse: collapse; }
.receipt th { text-align: left; font-size: 12px; letter-spacing: 1px; padding-bottom: 6px; border-bottom: 2px solid #111; }
.receipt td { padding: 8px 0; border-bottom: 1px solid #eee; vertical-align: top; }
.receipt td.num, .receipt th.num { text-align: right; }
.receipt .kv { display: flex; justify-content: space-between; padding: 3px 0; font-size: 15px; }
.receipt .kv.total { font-size: 22px; font-weight: 900; border-top: 2px solid #111; margin-top: 8px; padding-top: 10px; }
.receipt .foot { text-align: center; margin-top: 20px; font-size: 13px; color: #444; line-height: 1.5; }
.receipt .fineprint { font-size: 10px; line-height: 1.4; color: #555; }
.receipt .sig-block { margin-top: 16px; border-top: 1px solid #eee; padding-top: 10px; }
.receipt .sig-label { font-size: 11px; letter-spacing: 1px; color: #666; margin-bottom: 4px; }
.receipt .sig-img { max-width: 300px; max-height: 100px; display: block; }
.sig-pad { width: 100%; height: 160px; border: 1px solid #ccc; border-radius: 8px; background: #fff; touch-action: none; display: block; }
.btn.small { width: auto; min-height: 40px; padding: 8px 14px; font-size: 14px; margin-top: 8px; }
.muted { color: #666; font-size: 14px; }
/* Print: only the receipt prints. This runs in a real browser, where
   window.print() works (unlike inside an in-app webview). */
@media print {
  body * { visibility: hidden; }
  #receipt-card, #receipt-card * { visibility: visible; }
  #receipt-card {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    box-shadow: none;
    border-radius: 0;
    padding: 0;
  }
  .wrap { max-width: none; padding: 0; }
  .receipt .fineprint { font-size: 8pt; }
}
@page { margin: 0.5in; }
