/* DG Art Billing — counter tool.
   Built mobile-first: the people using this are standing behind a counter with a phone in
   one hand during the Ganpati rush, not sitting at a desk. Deliberately self-contained —
   the shop's internet drops, so there is no CDN dependency for CSS or fonts. */

:root {
  --ink:     #1F1A17;
  --ink-60:  #6B615A;
  --paper:   #FDFBF6;
  --panel:   #FFFFFF;
  --rule:    #E0D9CC;
  --sindoor: #A32B1E;
  --brass:   #A67B2E;
  --paid:    #2F6B4F;
  --radius:  4px;
  --tap:     46px;          /* minimum comfortable tap target */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Noto Sans", "Noto Sans Devanagari", "Nirmala UI", sans-serif;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;   /* stop iOS inflating text in landscape */
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;                  /* 16px minimum stops iOS zooming on focus */
  line-height: 1.45;
  color: var(--ink);
  background: var(--paper);
  overflow-wrap: break-word;        /* long addresses must not force sideways scroll */
}

a { color: var(--sindoor); }

/* ---------- Top bar ---------- */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 14px;
  background: var(--ink); color: var(--paper);
  position: sticky; top: 0; z-index: 20;
}
.topbar .brand { font-size: 18px; font-weight: 700; letter-spacing: .03em; min-width: 0; }
.topbar .brand small {
  display: block; font-size: 10px; letter-spacing: .06em; font-weight: 400; opacity: .75;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar nav { display: flex; gap: 6px; flex-shrink: 0; }
.topbar nav a, .linkbtn {
  color: var(--paper); text-decoration: none; font: inherit; font-size: 14px;
  padding: 10px 12px; min-height: var(--tap);
  display: inline-flex; align-items: center;
  border: 1px solid rgba(253,251,246,.3); border-radius: var(--radius);
  background: none; cursor: pointer; white-space: nowrap;
}
.topbar nav a:hover, .linkbtn:hover,
.topbar nav a[aria-current="page"] { background: rgba(253,251,246,.15); }

/* Below 720px the bar stacks and the links scroll sideways rather than wrapping into
   a tall block that eats the screen. */
@media (max-width: 720px) {
  .topbar { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 12px; }
  .topbar nav {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; padding-bottom: 2px;
  }
  .topbar nav::-webkit-scrollbar { display: none; }
  .topbar nav a, .topbar nav form { flex: 0 0 auto; }
}

.wrap { max-width: 900px; margin: 0 auto; padding: 16px; }
@media (max-width: 560px) { .wrap { padding: 12px; } }

/* ---------- Surfaces ---------- */

.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; font-size: 15px; }
.flash-ok  { background: #E8F1EC; border-left: 4px solid var(--paid); }
.flash-bad { background: #F7E7E4; border-left: 4px solid var(--sindoor); }

.card {
  background: var(--panel); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
@media (max-width: 560px) { .card { padding: 13px; } }
.card h2 {
  margin: 0 0 12px; font-size: 15px; text-transform: uppercase;
  letter-spacing: .1em; color: var(--ink-60);
}

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

/* ---------- Fields ---------- */

label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-60); margin-bottom: 4px; }

input[type=text], input[type=date], input[type=number], input[type=tel],
input[type=email], input[type=password], select, textarea {
  width: 100%; padding: 11px 12px; font: inherit; font-size: 16px; color: var(--ink);
  background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius);
  min-height: var(--tap);
}
input:focus-visible, select:focus-visible, textarea:focus-visible,
button:focus-visible, a:focus-visible {
  outline: 2px solid var(--sindoor); outline-offset: 2px;
}
input[type=number] { text-align: right; }
input[type=file] {
  width: 100%; padding: 10px; font: inherit; font-size: 14px;
  border: 1px solid var(--rule); border-radius: var(--radius); background: var(--panel);
}

.item-row { display: grid; grid-template-columns: 1fr 130px; gap: 12px; align-items: end; }
@media (max-width: 480px) { .item-row { grid-template-columns: 1fr 100px; gap: 8px; } }

.ticks { display: flex; flex-wrap: wrap; gap: 8px; }
.tick {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 10px 14px; border: 1px solid var(--rule); border-radius: var(--radius);
  font-weight: 600; font-size: 15px; background: var(--panel); min-height: var(--tap);
}
.tick input { width: 20px; height: 20px; min-height: 0; margin: 0; accent-color: var(--sindoor); }
.tick:has(input:checked) { border-color: var(--brass); background: #FBF6EA; }

/* ---------- Option rows ---------- */

.options { display: flex; flex-direction: column; gap: 8px; }
.option-row { display: grid; grid-template-columns: 150px 1fr; gap: 10px; align-items: start; }
.option-row .tick { margin: 0; }
.option-detail { min-width: 0; display: grid; grid-template-columns: 1fr 120px; gap: 8px; }
.option-detail .field-error { grid-column: 1 / -1; }
.option-detail.is-hidden { display: none; }

@media (max-width: 620px) {
  .option-row {
    grid-template-columns: 1fr; gap: 8px;
    border: 1px solid var(--rule); border-radius: var(--radius); padding: 8px;
  }
  .option-row .tick { border: 0; padding: 4px 2px; min-height: 32px; }
  .option-row:has(input[type=checkbox]:checked) { border-color: var(--brass); background: #FBF6EA; }
  .option-row:has(input[type=checkbox]:checked) .tick { background: transparent; }
  /* Detail above, price below — 120px is unusably narrow on a phone. */
  .option-detail { grid-template-columns: 1fr; }
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; min-height: var(--tap); font: inherit; font-weight: 600;
  border-radius: var(--radius); border: 1px solid var(--ink);
  background: var(--panel); color: var(--ink); text-decoration: none; cursor: pointer;
}
.btn-primary { background: var(--sindoor); border-color: var(--sindoor); color: #fff; }
.btn-wa      { background: #128C7E; border-color: #128C7E; color: #fff; font-size: 17px; width: 100%; }
.btn-wa[disabled] { opacity: .55; cursor: progress; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
@media (max-width: 480px) {
  .btn-row .btn { flex: 1 1 100%; }        /* full-width, thumb-reachable */
  .btn-row form { flex: 1 1 100%; display: flex; }
  .btn-row form .btn { width: 100%; }
}

/* Save bar pinned to the bottom on phones: the bill form is long and the counter should
   never have to scroll to the end to commit. */
.action-bar { margin-top: 14px; }
@media (max-width: 620px) {
  .action-bar {
    position: sticky; bottom: 0; z-index: 15;
    background: var(--paper); border-top: 1px solid var(--rule);
    padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
    margin: 14px -12px 0; padding-left: 12px; padding-right: 12px;
  }
}

/* ---------- Totals ---------- */

.totals { border-top: 2px solid var(--ink); margin-top: 12px; padding-top: 10px; }
.totals div { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 16px; }
.totals .due {
  border-top: 1px solid var(--rule); margin-top: 4px; padding-top: 8px;
  font-size: 21px; font-weight: 700; color: var(--sindoor);
}

/* ---------- Tables -> cards on small screens ---------- */

table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--rule); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-60); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr .due-amt { color: var(--sindoor); font-weight: 700; }
tr .clear-amt { color: var(--paid); }

/* A six-column bill list cannot be read on a phone, and horizontal scrolling hides the
   balance — the one number the counter is looking for. Each row becomes a card instead,
   with the column heading rendered from data-label. */
@media (max-width: 700px) {
  table, thead, tbody, tr, th, td { display: block; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  tr {
    border: 1px solid var(--rule); border-radius: var(--radius);
    margin-bottom: 10px; padding: 4px 10px; background: var(--panel);
  }
  td {
    border: 0; border-bottom: 1px dashed var(--rule); padding: 8px 0;
    display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  }
  tr td:last-child { border-bottom: 0; }
  td::before {
    content: attr(data-label);
    font-size: 12px; text-transform: uppercase; letter-spacing: .07em;
    color: var(--ink-60); flex: 0 0 auto;
  }
  td.num { text-align: right; }
  td[data-label=""]::before, td:not([data-label])::before { content: none; }
  td .btn-row { justify-content: flex-end; }
}

/* ---------- Pills, stats ---------- */

.pill { font-size: 12px; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--rule); }
.pill-booked { background: #FBF6EA; border-color: var(--brass); }
.pill-ready { background: #EAF0FB; }
.pill-delivered { background: #E8F1EC; border-color: var(--paid); }
.pill-cancelled { background: #F7E7E4; border-color: var(--sindoor); color: var(--sindoor); }

.stat-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.stat {
  flex: 1 1 150px; background: var(--panel); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 12px 14px;
}
.stat span { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-60); }
.stat strong { font-size: 22px; font-variant-numeric: tabular-nums; }
@media (max-width: 480px) {
  .stat-row { gap: 8px; }
  .stat { flex: 1 1 calc(50% - 4px); padding: 10px 12px; }
  .stat strong { font-size: 19px; }
}

/* ---------- Notes box on the details screen ---------- */

/* Mirrors the outlined box the PDF prints, so the screen reads like the bill. */
.note-box {
  border: 1px solid var(--ink); border-radius: var(--radius);
  padding: 10px 12px; background: var(--paper); font-size: 15px;
}

/* ---------- Header zone diagram ---------- */

.header-zones {
  display: grid; grid-template-columns: 78px 1fr 90px; gap: 0;
  border: 1px solid var(--ink); border-radius: var(--radius);
  background: var(--paper); overflow: hidden;
}
.header-zones .zone {
  border: 1px dashed var(--rule); border-radius: 2px;
  min-height: 62px; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-size: 11px; color: var(--ink-60); text-align: center; line-height: 1.3;
}
.header-zones .zone small { font-size: 10px; opacity: .75; }
.header-zones .zone-idol {
  border: 0; border-right: 1px dashed var(--rule);
  background: #F4EFE4; aspect-ratio: 1 / 1;
}
.header-zones .zone-centre { gap: 4px; margin: 6px; }
.header-zones .zone-centre .zone-top {
  font-size: 10px; border-bottom: 1px dashed var(--rule); width: 80%; padding-bottom: 2px;
}
.header-zones .zone-centre .zone-top-2 { font-size: 9px; opacity: .8; }
.header-zones .zone-centre strong { font-size: 13px; color: var(--ink); }
.header-zones .zone-mobile {
  margin: 5px 6px auto 6px; justify-content: flex-start;
  border-style: solid; border-color: var(--brass); min-height: 0; padding: 4px;
}
@media (max-width: 480px) {
  .header-zones { grid-template-columns: 54px 1fr 64px; }
  .header-zones .zone { font-size: 10px; min-height: 54px; }
  .header-zones .zone-centre strong { font-size: 11px; }
}

.art-preview {
  display: block; max-width: 100%; max-height: 80px;
  border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 4px; background: #fff; margin-bottom: 8px;
}
.art-preview.art-square { width: 80px; height: 80px; object-fit: contain; }

/* ---------- Messages ---------- */

.field-error { color: var(--sindoor); font-size: 13px; display: block; margin-top: 4px; }
.summary-error {
  background: #F7E7E4; border-left: 4px solid var(--sindoor);
  padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px;
}
.summary-error ul { margin: 6px 0 0; padding-left: 20px; }
.hint { font-size: 13px; color: var(--ink-60); margin: 6px 0 0; }

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