/*
 * Free tools: an app-style workspace — a side menu of every tool, a compact
 * header, and the tool itself in panels (inputs left, live result right).
 * Loaded after style.css and article.css on the tool pages and the tools hub.
 * Pages are generated by tools/site_pages/build.js; the tools run in js/tools.js.
 */

/* ── Shell ─────────────────────────────────────────────────────────── */
.tools-main { padding: 128px 0 44px; background: var(--bg-soft); border-bottom: 1px solid var(--line); }
.tools-main + .final { padding-top: 56px; }
.tools-shell { max-width: 1440px; display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: 22px; align-items: start; }

/* Side menu */
.tools-side { position: sticky; top: 90px; display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; gap: 12px; max-height: calc(100vh - 104px); overflow-y: auto; padding-bottom: 4px; scrollbar-width: thin; }
.side-group { min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px; box-shadow: var(--shadow-sm); }
.side-label { display: block; padding: 4px 8px 6px; font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.side-nav { display: grid; gap: 1px; }
.side-nav a { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 9px; color: var(--ink-2); font-size: 14px; font-weight: 600; line-height: 1.25; text-decoration: none; transition: background .15s, color .15s; }
.side-nav a:hover { background: var(--bg-soft); color: var(--ink); }
.side-nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); }
.side-nav .si { flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--bg-soft); color: var(--muted); }
.side-nav a[aria-current="page"] .si { background: var(--brand-2); color: #fff; }
.side-nav .si svg { width: 16px; height: 16px; }
.side-promo { border-radius: 14px; padding: 14px; color: #dbe5f7; background: radial-gradient(300px 140px at 0% 0%, rgba(96, 165, 250, .45), transparent 70%), linear-gradient(135deg, #10306f, #0a1433); }
.side-promo b { display: block; color: #fff; font: 800 15px/1.3 var(--head); }
.side-promo p { margin: 6px 0 10px; font-size: 13px; line-height: 1.45; }
.side-promo .btn { width: 100%; justify-content: center; }

/* ── Work area ─────────────────────────────────────────────────────── */
.tools-work { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.work-head { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.work-head .crumbs ol { margin: 0; font-size: 13px; }
.wh-row { display: flex; gap: 14px; align-items: center; }
.wh-row .ic { flex: none; width: 48px; height: 48px; border-radius: 13px; }
.wh-row h1 { margin: 0; font-size: clamp(22px, 2.4vw, 28px); font-weight: 800; letter-spacing: -.025em; line-height: 1.15; }
.wh-row p { margin: 4px 0 0; color: var(--ink-2); font-size: 15px; line-height: 1.5; max-width: 880px; }
.wh-chips { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0; }
.wh-chips li { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.wh-chips svg { width: 14px; height: 14px; color: var(--green); }

/* Panels */
.app-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.app-grid.narrow-left { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); }
.pane { background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-sm); min-width: 0; }
.pane-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; min-height: 46px; padding: 7px 10px 7px 14px; border-bottom: 1px solid var(--line); }
.pane-head h2 { margin: 0; font: 700 14.5px/1.3 'Inter', sans-serif; letter-spacing: 0; color: var(--ink); display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.pane-head h2 small { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.pane-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.pane-body { padding: 14px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.pane-foot { padding: 9px 14px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.btn-xs { padding: 6px 11px; font-size: 13px; border-radius: 9px; gap: 6px; }
.tools-work .btn svg, .side-promo .btn svg { width: 15px; height: 15px; }

/* Compact controls inside the workspace */
.tools-work .field { gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.tools-work .field input, .tools-work .field select, .tools-work .field textarea { font-size: 14px; padding: 8px 10px; border-radius: 9px; min-height: 38px; }
.tools-work .field textarea { min-height: 60px; }
.tools-work .field input:focus, .tools-work .field select:focus, .tools-work .field textarea:focus { box-shadow: 0 0 0 3px var(--brand-soft); }
.tools-work .field small { font-weight: 500; color: var(--muted); }
.tools-work .field .hint { font-weight: 500; font-size: 12px; color: var(--muted); }
.tools-work .seg { gap: 5px; }
.tools-work .seg legend { font-size: 12.5px; margin-bottom: 5px; }
.tools-work .seg span { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.tools-work .seg-wide span { padding: 7px 6px; }
.tools-work .calc-out { border-radius: 10px; padding: 2px 14px; margin: 0; }
.tools-work .calc-out div { padding: 8px 0; }
.tools-work .calc-out dt { font-size: 14px; }
.tools-work .calc-out .total dd { font-size: 20px; }
.tools-work .calc.app-grid { padding: 0; gap: 14px; }
.tools-work .callout { margin: 0; padding: 10px 12px; font-size: 13.5px; border-radius: 10px; line-height: 1.5; }
.tools-work .fine { margin: 0; font-size: 12.5px; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px 12px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--brand-2); }
.check.sm { font-size: 12.5px; font-weight: 600; gap: 6px; }
.check.sm input { width: 15px; height: 15px; }
.formula { font-size: 13px; line-height: 1.6; color: var(--muted); padding: 10px 12px; border-radius: 10px; border: 1px dashed var(--line); }
.formula b { color: var(--ink-2); }

/* Results */
.result-big { font: 800 26px/1.15 var(--head); color: var(--brand); letter-spacing: -.02em; word-break: break-word; }
.result-sub { color: var(--muted); font-size: 13.5px; margin: 4px 0 0; }
.result-words { font: 600 17px/1.55 var(--head); color: var(--ink); padding: 14px 16px; border-radius: 10px; background: var(--bg-soft); border: 1px solid var(--line); min-height: 58px; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-weight: 700; font-size: 12px; }
.status.ok { background: rgba(5, 150, 105, .12); color: var(--green); }
.status.bad { background: rgba(220, 38, 38, .12); color: #dc2626; }
.empty-note { margin: 0; color: var(--muted); font-size: 14px; }
.copy-line { display: flex; gap: 6px; align-items: stretch; }
.copy-line code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; font: 500 12.5px ui-monospace, Consolas, monospace; padding: 8px 10px; border-radius: 9px; background: var(--bg-soft); border: 1px solid var(--line); color: var(--ink-2); }

/* The "AuditBook does this" strip under a tool */
.app-tip { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 12px 10px 16px; border-radius: 12px; border: 1px solid var(--line); background: linear-gradient(90deg, var(--brand-soft), var(--card) 70%); }
.app-tip p { margin: 0; font-size: 14px; color: var(--ink-2); }
.app-tip b { color: var(--ink); }

/* GSTIN results */
.gstin-input { width: 100%; min-height: 230px; resize: vertical; font: 500 14px/1.6 ui-monospace, Consolas, monospace; letter-spacing: .04em; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.gstin-input:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px var(--brand-soft); }
.gstin-list { display: grid; gap: 8px; max-height: 560px; overflow-y: auto; }
.gstin-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--bg); }
.gstin-item .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.gstin-item code { font: 700 14.5px ui-monospace, Consolas, monospace; letter-spacing: .05em; color: var(--ink); word-break: break-all; }
.gstin-item dl { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 8px 0 0; font-size: 13px; }
.gstin-item dt { color: var(--muted); }
.gstin-item dd { margin: 0; color: var(--ink-2); font-weight: 600; }
.gstin-item .why { margin: 6px 0 0; font-size: 13px; color: #dc2626; }

/* UPI QR card */
.qr-card { display: grid; justify-items: center; gap: 8px; padding: 18px; text-align: center; border-radius: 14px; background: #fff; color: #0b1324; border: 1px solid var(--line); }
.qr-card .qr-tag { font: 800 13px var(--head); letter-spacing: .08em; text-transform: uppercase; color: #1d4ed8; }
.qr-card canvas { width: 220px; height: 220px; image-rendering: pixelated; }
.qr-card .qr-name { font: 800 18px var(--head); }
.qr-card .qr-vpa { font: 600 13px ui-monospace, Consolas, monospace; color: #334155; word-break: break-all; }
.qr-card .qr-amt { font: 800 22px var(--head); color: #1d4ed8; }
.qr-card .qr-foot { font-size: 11.5px; color: #64748b; }

/* Due dates */
.due-list { display: grid; gap: 8px; }
.due { display: grid; grid-template-columns: 50px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px 12px 8px 8px; border: 1px solid var(--line); border-radius: 11px; background: var(--bg); }
.due .d { text-align: center; border-radius: 9px; background: var(--brand-soft); color: var(--brand); padding: 5px 0; line-height: 1.05; }
.due .d b { display: block; font: 800 19px var(--head); }
.due .d span { font-size: 11px; font-weight: 700; text-transform: uppercase; }
.due h3 { font-size: 14.5px; margin: 0; }
.due h3 small { font-weight: 500; color: var(--muted); }
.due p { margin: 2px 0 0; font-size: 13px; color: var(--muted); line-height: 1.4; }
.due .when { font-size: 12px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.due.past { opacity: .55; }
.due.soon .when { color: #b45309; }

/* ── Invoice generator: editor + document preview ──────────────────── */
.inv-app { display: grid; grid-template-columns: minmax(0, .92fr) minmax(0, 1.08fr); gap: 14px; align-items: start; }
.inv-mobilebar { display: none; }
.inv-sec { padding: 12px 14px 14px; border-bottom: 1px solid var(--line); }
.inv-sec:last-child { border-bottom: 0; }
.inv-sec > h3 { margin: 0 0 10px; font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.inv-sec > h3 small { text-transform: none; letter-spacing: 0; font-weight: 500; }
.inv-lines { display: grid; gap: 8px; }
.inv-line {
  display: grid; gap: 6px; align-items: end; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-soft);
  grid-template-columns: 22px minmax(0, .9fr) minmax(0, .7fr) minmax(0, .9fr) minmax(0, 1.2fr) minmax(0, .85fr) minmax(0, 1.3fr) 28px;
}
.inv-line .ln { grid-column: 1; grid-row: 1 / span 2; align-self: start; margin-top: 21px; width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font: 700 12px 'Inter', sans-serif; }
.inv-line .f-desc { grid-column: 2 / 8; grid-row: 1; }
.inv-line .rm { grid-column: 8; grid-row: 1; width: 28px; height: 32px; border-radius: 7px; border: 1px solid var(--line); background: var(--card); color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.inv-line .rm:hover { color: #dc2626; border-color: #dc2626; }
.inv-line .rm svg { width: 13px; height: 13px; }
.inv-line .f-hsn { grid-column: 2; }
.inv-line .f-qty { grid-column: 3; }
.inv-line .f-unit { grid-column: 4; }
.inv-line .f-rate { grid-column: 5; }
.inv-line .f-gst { grid-column: 6; }
.inv-line .f-amt { grid-column: 7 / 9; }
.tools-work .inv-line .field { gap: 3px; font-size: 11px; color: var(--muted); }
.tools-work .inv-line .field input, .tools-work .inv-line .field select { min-height: 32px; padding: 5px 7px; font-size: 13.5px; border-radius: 7px; background: var(--card); }
.inv-line .amt { display: flex; align-items: center; justify-content: flex-end; min-height: 32px; padding: 0 2px; font: 700 13.5px 'Inter', sans-serif; color: var(--ink); font-variant-numeric: tabular-nums; }
.inv-lines-foot { display: flex; gap: 10px; align-items: end; justify-content: space-between; flex-wrap: wrap; margin-top: 10px; }
.inv-lines-foot .field { width: 210px; }
.inv-preview { position: sticky; top: 90px; overflow: hidden; }
.doc-canvas { background: var(--bg-soft); padding: 16px; max-height: calc(100vh - 196px); overflow: auto; }
.doc-canvas .inv-sheet { border-radius: 3px; padding: 22px; font-size: 11.5px; box-shadow: 0 8px 26px -12px rgba(15, 35, 95, .4); }
.doc-canvas .inv-sheet table { min-width: 0; }
.doc-canvas .inv-sheet th { font-size: 9.5px; letter-spacing: 0; }
.doc-canvas .inv-sheet th, .doc-canvas .inv-sheet td { padding: 4px 5px; }

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-height: 860px) and (min-width: 1181px) { .side-promo { display: none; } }
@media (max-width: 1180px) {
  .tools-shell { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .tools-side { position: static; max-height: none; overflow: visible; padding: 0; }
  .side-group.guides, .side-promo, .side-label { display: none; }
  .side-group { padding: 6px; }
  .side-nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .side-nav::-webkit-scrollbar { display: none; }
  .side-nav a { flex: none; white-space: nowrap; padding: 5px 10px 5px 5px; font-size: 13.5px; }
  .side-nav .si { width: 26px; height: 26px; }
}
@media (max-width: 960px) {
  .app-grid, .app-grid.narrow-left, .inv-app { grid-template-columns: minmax(0, 1fr); }
  .inv-preview { position: static; scroll-margin-top: 90px; }
  .doc-canvas { max-height: none; }
  /* Phones: the bill is below the form, so keep a way to it in reach. */
  .inv-mobilebar { display: flex; gap: 8px; justify-content: flex-end; position: sticky; bottom: 10px; z-index: 5; padding: 8px; border-radius: 12px; background: var(--glass); border: 1px solid var(--line); box-shadow: var(--shadow); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
  .inv-mobilebar .btn { flex: 1; justify-content: center; }
}
@media (max-width: 640px) {
  .tools-main { padding-top: 116px; }
  .wh-row .ic { display: none; }
  .wh-row p { font-size: 14px; }
  .wh-chips li { padding: 3px 8px; font-size: 11.5px; }
  .wh-chips li:nth-child(3) { display: none; }
  .pane-body { padding: 12px; }
  .inv-sec { padding: 12px; }
  .inv-line { grid-template-columns: 22px repeat(3, minmax(0, 1fr)) 28px; }
  .inv-line .ln { grid-row: 1 / span 3; }
  .inv-line .f-desc { grid-column: 2 / 5; }
  .inv-line .rm { grid-column: 5; }
  .inv-line .f-hsn, .inv-line .f-rate { grid-column: 2; }
  .inv-line .f-qty, .inv-line .f-gst { grid-column: 3; }
  .inv-line .f-unit { grid-column: 4; }
  .inv-line .f-amt { grid-column: 4 / 6; }
  .inv-lines-foot .field { width: 100%; }
  .doc-canvas { padding: 8px; }
  .doc-canvas .inv-sheet { padding: 14px; }
  .due { grid-template-columns: 46px minmax(0, 1fr); }
  .due .when { grid-column: 2; }
}

/* ── The guide text below a tool ───────────────────────────────────── */
.work-content { display: grid; grid-template-columns: minmax(0, 1fr); margin-top: 6px; }
.work-content > .page-section { padding: 26px 0 0; margin-top: 10px; border: 0; border-top: 1px solid var(--line); background: none; }
.work-content .container { max-width: none; padding: 0; margin: 0; }
.work-content .prose { max-width: 860px; margin: 0; font-size: 16px; }
.work-content .prose h2 { font-size: 24px; margin-top: 30px; }
.work-content .prose > h2:first-child { margin-top: 0; }
.work-content .section-head { text-align: left; margin: 0 0 14px; max-width: none; }
.work-content .section-head .eyebrow { margin-bottom: 6px; }
.work-content .section-head h2 { font-size: 24px; }
.work-content .section-head > p:not(.eyebrow) { font-size: 15px; margin-top: 6px; }
.work-content .faq-list { max-width: 860px; }

/* ── Printing: only the bill (invoice generator) or the QR stand (UPI) ─ */
@media print {
  @page { size: A4; margin: 12mm; }
  body.print-only > *:not(main),
  body.print-only main > *:not(.tools-main),
  body.print-only .tools-shell > *:not(.tools-work),
  body.print-only .tools-work > *:not(.print-host),
  body.print-only .print-host .no-print { display: none !important; }
  body.print-only .tools-main { padding: 0; background: #fff; border: 0; }
  body.print-only .tools-shell { display: block; max-width: none; padding: 0; }
  body.print-only .print-host { display: block !important; }
  body.print-only .pane { border: 0; box-shadow: none; background: #fff; }
  body.print-only .doc-canvas { padding: 0; background: #fff; max-height: none; overflow: visible; }
  body.print-only .inv-sheet { box-shadow: none; border: 0; padding: 0; overflow: visible; font-size: 12px; }
  body.print-only .inv-sheet table { min-width: 0; }
  body.print-only .qr-card { border: 2px solid #1d4ed8; max-width: 420px; margin: 20mm auto 0; }
  body.print-only .qr-card canvas { width: 300px; height: 300px; }
}
