/* Free tools (/tools). Loaded on top of styles.css and blog.css; colours,
   radii and shadows come from the variables in styles.css. */

.tool-hero { padding: 40px 0 6px; background: linear-gradient(180deg, var(--green-50), transparent); }
.tool-hero h1 { font-size: clamp(2rem, 5vw, 2.9rem); margin: 6px 0 12px; }
.tool-hero .lede { max-width: 66ch; margin-bottom: 12px; }
.tool-meta { color: var(--text-3); font-size: 14px; margin: 0; }

.tool-sec { padding: 22px 0 8px; }
.tool {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; align-items: start;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px;
}
.tool.one { grid-template-columns: minmax(0, 1fr); }
.tool h2 { font-family: var(--font); font-weight: 800; font-size: 1.15rem; letter-spacing: -.01em; margin: 0 0 12px; }
.tool-out { background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 18px; }

/* tabs (mode switch) */
.modes { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; padding: 0; border: 0; }
.modes legend { font-weight: 700; font-size: 14px; margin-bottom: 8px; padding: 0; width: 100%; }
.modes label {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 14px; font-weight: 600;
  border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; background: #fff; color: var(--text-2);
}
.modes input { accent-color: var(--green-700); margin: 0; }
.modes label:has(input:checked) { border-color: var(--green-700); background: var(--green-50); color: var(--green-900); }

/* form fields */
.fields { display: grid; gap: 14px; }
.fields.two { grid-template-columns: 1fr 1fr; }
.field { display: grid; gap: 5px; min-width: 0; }
.field > label, .field > .lbl { font-size: 14px; font-weight: 700; color: var(--text); }
.field .hint { font-size: 13px; color: var(--text-3); }
.tool input[type="text"], .tool input[type="number"], .tool input[type="tel"], .tool input[type="date"],
.tool select, .tool textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; font: inherit; font-size: 16px; color: var(--text);
  background: #fff; border: 1px solid #cbd8d2; border-radius: 12px;
}
.tool textarea { min-height: 120px; resize: vertical; line-height: 1.45; }
.tool input:focus, .tool select:focus, .tool textarea:focus { outline: 3px solid var(--green-100); border-color: var(--green-700); }
.tool input[aria-invalid="true"] { border-color: #c2410c; background: #fff7f2; }
.affix { display: flex; align-items: stretch; }
.affix span {
  display: inline-flex; align-items: center; padding: 0 12px; font-weight: 700; color: var(--text-2);
  background: var(--bg-soft); border: 1px solid #cbd8d2; font-size: 15px; white-space: nowrap;
}
.affix span:first-child { border-radius: 12px 0 0 12px; border-right: 0; }
.affix span:last-child { border-radius: 0 12px 12px 0; border-left: 0; }
.affix input { border-radius: 0 !important; }
.affix input:first-child { border-radius: 12px 0 0 12px !important; }
.affix input:last-child { border-radius: 0 12px 12px 0 !important; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 14.5px; color: var(--text-2); }
.check input { margin-top: 4px; accent-color: var(--green-700); width: 18px; height: 18px; }

/* results */
.results { display: grid; gap: 10px; margin: 0; }
.results div { display: flex; justify-content: space-between; gap: 12px; align-items: baseline;
  border-bottom: 1px dashed var(--line); padding-bottom: 8px; }
.results div:last-child { border-bottom: 0; padding-bottom: 0; }
.results dt { color: var(--text-2); font-size: 15px; }
.results dd { margin: 0; font-weight: 800; font-size: 1.15rem; color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }
.results .big dd { font-size: 1.6rem; color: var(--green-700); }
.results .neg dd { color: #b42318; }
.out-note { font-size: 14.5px; color: var(--text-2); margin: 14px 0 0; }
.out-note:empty { display: none; }
.err { color: #b42318; font-size: 14px; font-weight: 600; margin: 4px 0 0; }
.err:empty { display: none; }
.warn { background: var(--amber-50); border: 1px solid #f5dfb8; border-radius: 12px; padding: 10px 12px; color: #6b4300; font-size: 14px; }
.warn:empty { display: none; }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.btn-sm { min-height: 40px; padding: 8px 14px; font-size: 14px; }
.btn-wa { background: #128c4a; color: #fff; }
.btn-wa:hover { background: #0e7a40; transform: translateY(-2px); }
.btn-link { background: none; border: 0; color: var(--green-700); text-decoration: underline; cursor: pointer; padding: 6px 0; font-weight: 600; font-size: 14px; }

/* explanatory content under the tool */
.tool-doc.prose { padding-top: 34px; }
.tool-doc h2 { scroll-margin-top: 90px; }
.tool-doc p, .tool-doc li { font-size: 17px; line-height: 1.72; }
.tool-doc .faq { margin-top: 16px; }
.tool-doc .faq details p { font-size: 16px; }
.formula { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; background: var(--bg-soft);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; font-size: 15px; overflow-x: auto; }

/* tools hub */
.tgrid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); padding: 26px 0 30px; }
.tcard { display: flex; flex-direction: column; gap: 6px; padding: 22px; background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--radius-sm); text-decoration: none; color: inherit;
  box-shadow: var(--shadow); transition: transform .15s ease, border-color .15s ease; }
.tcard:hover { transform: translateY(-2px); border-color: var(--green-500); }
.tcard h2 { font-family: var(--font); font-weight: 800; font-size: 1.12rem; letter-spacing: -.01em; margin: 0; color: var(--text); }
.tcard p { margin: 0; color: var(--text-2); font-size: 15px; }
.tcard .go { margin-top: auto; padding-top: 6px; font-weight: 700; color: var(--green-700); font-size: 14.5px; }
.tool-list { columns: 2; column-gap: 28px; padding-left: 18px; }
.tool-list li { break-inside: avoid; }

/* invoice preview */
.items { display: grid; gap: 10px; }
.item-row { display: grid; grid-template-columns: minmax(0, 1fr) 76px 110px 40px; gap: 8px; align-items: end; }
.item-row .field > label { font-size: 12.5px; font-weight: 600; color: var(--text-3); }
.item-row button { min-height: 46px; border: 1px solid var(--line); background: #fff; border-radius: 12px; cursor: pointer; font-size: 20px; line-height: 1; color: var(--text-2); }
.item-row button:hover { border-color: #c2410c; color: #c2410c; }
.inv { background: #fff; color: #111; border: 1px solid var(--line); border-radius: 12px; padding: 22px; font-size: 14.5px; line-height: 1.45; }
.inv-head { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; border-bottom: 2px solid #111; padding-bottom: 12px; margin-bottom: 12px; }
.inv-shop { font-size: 1.25rem; font-weight: 800; margin: 0; }
.inv-sub { margin: 2px 0 0; color: #444; white-space: pre-line; }
.inv-title { text-align: right; }
.inv-title b { display: block; font-size: 1.1rem; letter-spacing: .08em; text-transform: uppercase; }
.inv-to { margin: 0 0 12px; }
.inv table { width: 100%; border-collapse: collapse; }
.inv th, .inv td { padding: 7px 6px; border-bottom: 1px solid #ddd; text-align: left; vertical-align: top; }
.inv th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: #444; border-bottom: 1px solid #111; }
.inv .r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.inv-tot { margin: 12px 0 0 auto; max-width: 280px; }
.inv-tot div { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.inv-tot .grand { border-top: 2px solid #111; margin-top: 4px; padding-top: 7px; font-weight: 800; font-size: 1.12rem; }
.inv-notes { margin: 16px 0 0; color: #333; white-space: pre-line; }
.inv-empty { color: #777; font-style: italic; }

/* label sheet */
.sheet-wrap { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: #eef2f0; padding: 10px; }
.sheets { display: grid; gap: 10px; justify-content: center; }
.label-sheet {
  width: 210mm; height: 297mm; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .15);
  display: grid; align-content: start; justify-content: start; overflow: hidden; color: #000;
}
.lbl {
  overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 1.2mm 2mm; gap: .4mm; outline: 1px dashed #d0d7d3; outline-offset: -1px;
  font-family: Arial, Helvetica, sans-serif; line-height: 1.1;
}
.lbl.blank { outline-color: #eef0ef; }
.lbl-shop { font-size: var(--fs-s, 2.4mm); color: #333; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.lbl-name { font-size: var(--fs-n, 3mm); font-weight: 700; max-width: 100%; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.lbl-price { font-size: var(--fs-p, 3.6mm); font-weight: 800; }
.lbl svg { width: 100%; height: var(--bh, 9mm); display: block; flex: none; }
.lbl-code { font-size: var(--fs-c, 2.4mm); letter-spacing: .3mm; font-family: "Courier New", monospace; }
.line-errors { margin: 10px 0 0; padding-left: 18px; color: #b42318; font-size: 14px; }
.line-errors:empty { display: none; }

/* udhaar message */
.msg-out { width: 100%; min-height: 190px; font-size: 16px; line-height: 1.55; }
.msg-out[dir="rtl"] { font-family: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", "Noto Naskh Arabic", serif; font-size: 18px; line-height: 2; }
.copied { font-size: 14px; color: var(--green-700); font-weight: 700; align-self: center; }

@media (max-width: 860px) {
  .tool { grid-template-columns: minmax(0, 1fr); padding: 18px; }
}
@media (max-width: 560px) {
  .tool { padding: 16px 14px; border-radius: var(--radius-sm); }
  .fields.two { grid-template-columns: 1fr; }
  .item-row { grid-template-columns: minmax(0, 1fr) 64px 92px 40px; gap: 6px; }
  .inv { padding: 14px; font-size: 13.5px; }
  .tool-list { columns: 1; }
  .tool-doc p, .tool-doc li { font-size: 16.5px; }
}
@media (prefers-reduced-motion: reduce) { .tcard { transition: none; } .tcard:hover { transform: none; } }

/* ---------------------------------------------------------------- print */
@page { margin: 12mm; }
@page labels { size: A4 portrait; margin: 0; }
@media print {
  .hdr, .ftr, .skip, .no-print, ins.adsbygoogle, .google-auto-placed, iframe { display: none !important; }
  body { background: #fff !important; }
  main, .tool-sec, .tool-sec .wrap, .tool, .tool-out { all: unset; display: block; }
  .tool > :not(.print-area) { display: none !important; }
  .inv { border: 0; padding: 0; font-size: 12pt; }
  .sheet-wrap { all: unset; display: block; }
  .sheets { display: block; zoom: 1 !important; }
  .label-sheet { page: labels; box-shadow: none; break-after: page; zoom: 1 !important; }
  .label-sheet:last-child { break-after: auto; }
  .lbl, .lbl.blank { outline: 0; }
  .sheet-wrap.show-outlines .lbl:not(.blank) { outline: .2mm solid #bbb; }
}

/* ---- unit price rows, the cash counter, the QR code */
.item-row.up-row { grid-template-columns: minmax(0, 1fr) 96px 120px; }
.cc-h { font-family: var(--font); font-weight: 800; font-size: 1rem; margin: 18px 0 8px; }
.cc-grid { display: grid; gap: 8px; }
.cc-row { display: grid; grid-template-columns: 92px 14px 96px minmax(0, 1fr); gap: 8px; align-items: center; }
.cc-row label { font-weight: 700; font-size: 15px; }
.cc-row .cc-x { color: var(--text-3); text-align: center; }
.cc-row output { text-align: right; color: var(--text-2); font-size: 14.5px; font-variant-numeric: tabular-nums; }
.qrm-box { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px; text-align: center; }
.qrm-box canvas { width: 100%; max-width: 300px; height: auto; image-rendering: pixelated; }
.qr-caption { margin: 6px 0 0; font-weight: 700; color: #000; }
.qr-caption:empty { display: none; }
@media (max-width: 560px) {
  .item-row.up-row { grid-template-columns: minmax(0, 1fr) 76px 96px; }
  .cc-row { grid-template-columns: 78px 12px 84px minmax(0, 1fr); }
}
@media print {
  /* the cash count prints as it was typed; an empty line is left out */
  form.print-area .hint, form.print-area .cc-row:has(input:placeholder-shown) { display: none; }
  form.print-area input, form.print-area select { border: 0; padding: 0; min-height: 0; background: none; }
  .qrm-box { border: 0; }
  .qrm-box canvas { max-width: 9cm; }
  .qr-caption { font-size: 16pt; }
}
/* a part of a form that is switched off stays off, whatever display its class gives it */
.tool [hidden] { display: none !important; }

/* ---- weights, khata and stock sheets, price list, payment card, business card, shop names */
.tool-ur { font-family: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", "Noto Naskh Arabic", serif; font-size: 1.15rem;
  line-height: 2; color: var(--green-900); margin: -4px 0 10px; max-width: 66ch; text-align: left; }
.ur { font-family: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", "Noto Naskh Arabic", serif; }
.print-only { display: none; }
.sub-h { font-family: var(--font); font-weight: 800; font-size: 1.05rem; margin: 22px 0 10px; }
.tool .results.compact dd { font-size: 1.05rem; }
.mixed { font-weight: 700; color: var(--green-900); margin: 12px 0 0; }
.mixed:empty { display: none; }

/* colour swatches */
.swatches { display: flex; flex-wrap: wrap; gap: 8px; border: 0; padding: 0; margin: 0; }
.swatches legend { font-size: 14px; font-weight: 700; margin-bottom: 6px; padding: 0; }
.swatches label { position: relative; width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  background: var(--sw); border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.swatches input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.swatches label:has(input:checked) { box-shadow: 0 0 0 3px var(--text); }
.swatches label:has(input:focus-visible) { outline: 3px solid var(--green-100); outline-offset: 2px; }

/* a picture drawn on a canvas */
.pic-box { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px; text-align: center; }
.pic-box canvas { width: 100%; height: auto; max-width: 340px; border-radius: 6px; box-shadow: 0 1px 4px rgba(0, 0, 0, .12); }
.pic-box.landscape canvas { max-width: 100%; }
.pay-note { background: var(--amber-50); border: 1px solid #f5dfb8; border-radius: 12px; padding: 10px 12px; color: #6b4300; font-size: 14px; margin: 12px 0 0; }

/* A4 sheets: khata, roznamcha, stock count */
@page sheet { size: A4 portrait; margin: 0; }
.a4-wrap { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: #eef2f0; padding: 10px; margin-top: 14px; }
.a4s { display: grid; gap: 10px; justify-content: center; }
.a4 { width: 210mm; height: 297mm; box-sizing: border-box; padding: 11mm 11mm 9mm; background: #fff; color: #000;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .15); display: flex; flex-direction: column; overflow: hidden;
  font-family: Arial, Helvetica, "Noto Naskh Arabic", sans-serif; }
.a4-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 8mm; border-bottom: .6mm solid #000; padding-bottom: 2.5mm; margin-bottom: 3mm; }
.a4-shop { font-size: 6.5mm; font-weight: 800; line-height: 1.15; }
.a4-title { font-size: 4mm; font-weight: 700; text-align: end; }
.a4-meta { display: flex; flex-wrap: wrap; gap: 2mm 9mm; font-size: 3.6mm; margin-bottom: 3mm; }
.a4-meta span { white-space: nowrap; }
.a4 table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 3.4mm; }
.a4 th { border: .3mm solid #000; background: #eee; padding: 1.2mm 1.5mm; text-align: start; font-weight: 700; line-height: 1.2; }
.a4 td { border: .25mm solid #555; padding: 0 1.5mm; height: var(--rh, 8mm); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.a4 td.n { text-align: end; font-variant-numeric: tabular-nums; }
.a4 td.c { text-align: center; color: #555; }
.a4 tfoot td { font-weight: 700; background: #f6f6f6; }
.a4[dir="rtl"] th, .a4[dir="rtl"] .a4-meta, .a4[dir="rtl"] .a4-title, .a4[dir="rtl"] .a4-foot { font-family: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", "Noto Naskh Arabic", serif; line-height: 1.7; }
.a4-foot { margin-top: auto; padding-top: 3mm; display: flex; justify-content: space-between; gap: 6mm; font-size: 3.2mm; color: #333; }
.th-ur { display: block; font-family: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", "Noto Naskh Arabic", serif; font-weight: 400; font-size: 3.2mm; line-height: 1.6; }

/* shop names */
.names { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.names li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; align-items: center;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.names .nm-en { font-weight: 800; color: var(--text); }
.names .nm-ur { font-family: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", "Noto Naskh Arabic", serif; font-size: 1.15rem; line-height: 2; color: var(--green-900); }
.names .nm-btns { grid-row: 1 / span 2; grid-column: 2; display: flex; flex-direction: column; gap: 4px; }
.names button { min-height: 34px; padding: 4px 10px; font-size: 13px; font-weight: 700; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-soft); cursor: pointer; color: var(--text-2); }
.names button:hover { border-color: var(--green-700); color: var(--green-900); }

/* business cards, ten to an A4 sheet */
.card-sheet { display: grid; grid-template-columns: repeat(2, 89mm); grid-auto-rows: 51mm; justify-content: center; align-content: start; padding-top: 12mm; }
.card-sheet img { width: 89mm; height: 51mm; display: block; outline: .2mm dashed #999; outline-offset: -.1mm; }

@media print {
  .print-only { display: block !important; }
  .screen-only { display: none !important; }
  .a4-wrap { all: unset; display: block; }
  .a4s { display: block; zoom: 1 !important; }
  .a4 { page: sheet; box-shadow: none; height: 296mm; break-after: page; }
  .a4:last-child { break-after: auto; }
  .a4 th, .a4 tfoot td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .card-sheet { page: sheet; }
  .pic-print img { max-width: 100%; max-height: 260mm; display: block; margin: 0 auto; }
}
