/* ==========================================================================
   GST Bill Generator — Global Stylesheet
   Design system: "Classic Enterprise Fintech" (calm, trustworthy, airy)
   One global CSS file. No frameworks.
   ========================================================================== */

/* ---------- Design tokens ---------- */
:root {
  --bg: #ffffff;
  --text: #1a1a1a;
  --text-soft: #4a4a4a;
  --muted: #6b6b6b;
  --border: #e5e5e5;
  --section: #f7f7f7;
  --accent: #1f3a5f;
  --accent-hover: #16293f;
  --success: #1e7f4f;
  --error: #b3261e;
  --radius: 8px;
  --shadow-hover: 0 2px 10px rgba(26, 26, 26, 0.08);
  --maxw-text: 760px;
  --maxw-tool: 960px;
  --maxw-wide: 1180px;
  --space: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", sans-serif;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
@media (min-width: 768px) { body { font-size: 17px; } }

img { max-width: 100%; height: auto; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid rgba(31, 58, 95, 0.35);
  outline-offset: 2px;
}

h1, h2, h3, h4 { line-height: 1.25; font-weight: 700; color: var(--text); }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); margin: 0 0 .5em; }
h2 { font-size: clamp(1.3rem, 3vw, 1.6rem); margin: 1.6em 0 .5em; }
h3 { font-size: 1.15rem; margin: 1.4em 0 .4em; }
p { margin: 0 0 1em; }
ul, ol { margin: 0 0 1em; padding-left: 1.3em; }
li { margin-bottom: .35em; }
small { color: var(--muted); }
code { background: var(--section); padding: 1px 5px; border-radius: 4px; font-size: .9em; }

/* ---------- Layout helpers ---------- */
.container { width: 100%; max-width: var(--maxw-wide); margin: 0 auto; padding: 0 20px; }
.wrap-text { max-width: var(--maxw-text); margin: 0 auto; }
.wrap-tool { max-width: var(--maxw-tool); margin: 0 auto; }
main { display: block; padding: 24px 0 48px; }
.section { padding: 32px 0; }
.section--alt { background: var(--section); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: -999px; top: 0; background: var(--accent); color: #fff;
  padding: 10px 16px; z-index: 200; border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.site-header .container {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 60px; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 1.05rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand svg { flex: none; }
.main-nav { display: flex; align-items: center; gap: 4px; }
.main-nav a, .nav-toggle-tools {
  display: inline-block; padding: 8px 12px; border-radius: 6px;
  color: var(--text-soft); font-size: .97rem; background: none; border: 0;
  font-family: inherit; cursor: pointer;
}
.main-nav a:hover, .nav-toggle-tools:hover { background: var(--section); text-decoration: none; color: var(--text); }
.lang-link { font-weight: 600; color: var(--accent) !important; }

/* Tools mega dropdown */
.tools-menu { position: relative; }
.tools-panel {
  position: absolute; top: calc(100% + 6px); left: 0;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-hover); padding: 16px; width: min(680px, 92vw);
  display: none; grid-template-columns: repeat(3, 1fr); gap: 14px 22px;
}
.tools-panel.open { display: grid; }
.tools-panel h4 { margin: 0 0 6px; font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.tools-panel a { display: block; padding: 4px 0; font-size: .92rem; color: var(--text-soft); }

/* Mobile nav */
.nav-burger { display: none; background: none; border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; cursor: pointer; }
.nav-burger svg { display: block; }
@media (max-width: 860px) {
  .nav-burger { display: inline-flex; }
  .main-nav {
    position: absolute; top: 60px; left: 0; right: 0; flex-direction: column;
    align-items: stretch; background: var(--bg); border-bottom: 1px solid var(--border);
    padding: 8px 20px 16px; gap: 2px; display: none;
  }
  .main-nav.open { display: flex; }
  .tools-panel { position: static; display: grid; box-shadow: none; border: 0; width: auto; padding: 8px 0 8px 8px; grid-template-columns: 1fr; gap: 4px; }
  .tools-panel.collapsed { display: none; }
  .nav-toggle-tools { text-align: left; }
}

/* ---------- Breadcrumb ---------- */
.breadcrumb { font-size: .85rem; color: var(--muted); padding: 14px 0 0; }
.breadcrumb ol { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.breadcrumb li::after { content: "›"; margin-left: 6px; color: var(--border); }
.breadcrumb li:last-child::after { content: ""; }

/* ---------- Cards & grids ---------- */
.card {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px;
}
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 860px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.tool-card {
  display: block; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; color: var(--text);
  transition: box-shadow .18s ease, transform .18s ease, border-color .18s ease;
}
.tool-card:hover { text-decoration: none; box-shadow: var(--shadow-hover); transform: translateY(-2px); border-color: #d5d5d5; }
.tool-card h3 { margin: 0 0 6px; font-size: 1.02rem; }
.tool-card p { margin: 0; font-size: .9rem; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 20px; border-radius: 6px; font-size: 1rem;
  font-family: inherit; font-weight: 600; cursor: pointer; border: 1px solid transparent;
  transition: background .15s ease, border-color .15s ease;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-secondary { background: var(--bg); color: var(--accent); border-color: var(--border); }
.btn-secondary:hover { background: var(--section); }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label, .form-label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 6px; }
.field .hint { font-size: .82rem; color: var(--muted); margin-top: 4px; }
input, select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; font-size: 1rem; font-family: inherit;
  color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input.valid { border-color: var(--success); }
input.invalid { border-color: var(--error); }
.field-msg { font-size: .82rem; margin-top: 5px; min-height: 1.1em; }
.field-msg.ok { color: var(--success); }
.field-msg.err { color: var(--error); }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 16px; }
legend { font-weight: 600; padding: 0 6px; font-size: .95rem; }

/* Rate / choice buttons */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 40px; padding: 8px 16px; border: 1px solid var(--border); background: var(--bg);
  border-radius: 999px; font-size: .95rem; font-family: inherit; cursor: pointer; color: var(--text-soft);
}
.chip:hover { border-color: var(--accent); }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- Result panel ---------- */
.result {
  background: var(--section); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-top: 18px;
}
.result-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.result-row:last-child { border-bottom: 0; }
.result-row .label { color: var(--text-soft); }
.result-row .value { font-weight: 600; font-variant-numeric: tabular-nums; }
.result-row.total { font-size: 1.15rem; border-top: 2px solid var(--accent); border-bottom: 0; padding-top: 12px; margin-top: 6px; }
.result-row.total .value { color: var(--accent); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.data th, table.data td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.data th { background: var(--section); font-weight: 600; }
@media (min-width: 768px) { table.data tbody tr:nth-child(even) { background: #fafafa; } }
table.data tbody tr:nth-child(even) { background: #fafafa; }

/* ---------- FAQ ---------- */
.faq details { border: 1px solid var(--border); border-radius: var(--radius); padding: 0; margin-bottom: 10px; overflow: hidden; }
.faq summary { cursor: pointer; padding: 14px 16px; font-weight: 600; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; float: right; color: var(--accent); font-weight: 700; }
.faq details[open] summary::after { content: "–"; }
.faq details > p, .faq details > div { padding: 0 16px 14px; margin: 0; color: var(--text-soft); }

/* ---------- Disclaimer & meta ---------- */
.disclaimer { background: #fbfbf7; border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 6px; padding: 12px 16px; font-size: .88rem; color: var(--text-soft); margin: 20px 0; }
.updated { font-size: .82rem; color: var(--muted); margin: 8px 0 0; }
.intro { font-size: 1.05rem; color: var(--text-soft); }

/* Steps list */
.steps { counter-reset: step; list-style: none; padding: 0; }
.steps li { counter-increment: step; position: relative; padding-left: 40px; margin-bottom: 12px; }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: 0; width: 28px; height: 28px;
  background: var(--accent); color: #fff; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: .85rem; font-weight: 700;
}

/* ---------- Hero ---------- */
.hero { padding: 40px 0 28px; text-align: center; }
.hero p.lead { font-size: 1.12rem; color: var(--text-soft); max-width: 640px; margin: 0 auto 22px; }
.hero .btn-row { justify-content: center; }
.badge-row { display: flex; flex-wrap: wrap; gap: 10px 20px; justify-content: center; margin-top: 22px; font-size: .88rem; color: var(--muted); }
.badge-row span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Footer ---------- */
.site-footer { background: var(--section); border-top: 1px solid var(--border); padding: 40px 0 24px; margin-top: 40px; font-size: .9rem; }
.footer-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; }
@media (max-width: 860px) { .footer-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .footer-grid { grid-template-columns: 1fr; } }
.site-footer h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 10px; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: 6px; }
.site-footer a { color: var(--text-soft); }
.footer-bottom { border-top: 1px solid var(--border); margin-top: 28px; padding-top: 16px; color: var(--muted); font-size: .82rem; }

/* ---------- Feedback floating button + modal ---------- */
.feedback-fab {
  position: fixed; right: 18px; bottom: 18px; z-index: 120;
  background: var(--accent); color: #fff; border: 0; border-radius: 999px;
  min-height: 44px; padding: 0 18px; font-family: inherit; font-size: .95rem; font-weight: 600;
  cursor: pointer; box-shadow: 0 3px 12px rgba(0,0,0,.18); display: inline-flex; align-items: center; gap: 7px;
}
.feedback-fab:hover { background: var(--accent-hover); }
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,25,35,.5); z-index: 200;
  display: none; align-items: center; justify-content: center; padding: 18px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg); border-radius: var(--radius); border: 1px solid var(--border);
  max-width: 440px; width: 100%; padding: 22px; box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
.modal h3 { margin-top: 0; }
.stars { display: flex; gap: 6px; font-size: 1.8rem; margin-bottom: 6px; }
.stars button { background: none; border: 0; cursor: pointer; color: var(--border); line-height: 1; padding: 0; font-size: inherit; }
.stars button.on, .stars button:hover { color: #e3a712; }
.modal-close { float: right; background: none; border: 0; font-size: 1.4rem; cursor: pointer; color: var(--muted); line-height: 1; }

/* ---------- PWA install / iOS sheet ---------- */
.install-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 150;
  background: var(--bg); border-top: 1px solid var(--border); box-shadow: 0 -4px 20px rgba(0,0,0,.12);
  padding: 18px 20px calc(18px + env(safe-area-inset-bottom)); transform: translateY(110%);
  transition: transform .2s ease;
}
.install-sheet.show { transform: translateY(0); }
.install-sheet .is-inner { max-width: 640px; margin: 0 auto; }
.install-sheet p { margin: 0 0 12px; }
.install-sheet .btn-row { justify-content: flex-end; }

/* generator pages: lift FAB above sticky totals bar on mobile */
body.has-sticky-bar .feedback-fab { bottom: 84px; }

/* ---------- Generator: layout, sticky totals, HSN suggest ---------- */
.gen-grid { display: grid; grid-template-columns: 1fr; gap: 24px; }
@media (min-width: 1024px) { .gen-grid { grid-template-columns: 1.05fr 0.95fr; align-items: start; } }
.gen-preview-col { position: sticky; top: 76px; }
@media (max-width: 1023px) { .gen-preview-col { position: static; } }

.summary-panel { position: sticky; top: 76px; }
.hsn-suggest {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 40; background: var(--bg);
  border: 1px solid var(--border); border-top: 0; border-radius: 0 0 6px 6px; box-shadow: var(--shadow-hover);
  max-height: 240px; overflow-y: auto; display: none;
}
.hsn-suggest.open { display: block; }
.hsn-opt { padding: 8px 10px; font-size: .85rem; cursor: pointer; border-bottom: 1px solid var(--border); }
.hsn-opt:last-child { border-bottom: 0; }
.hsn-opt.active, .hsn-opt:hover { background: var(--section); }

#billFlash { transition: opacity .3s ease; opacity: 0; color: var(--success); font-size: .9rem; min-height: 1.2em; font-weight: 600; }

/* ---------- Invoice preview (screen + print/PDF) ---------- */
.inv-sheet {
  background: #fff; color: #1a1a1a; border: 1px solid var(--border); border-radius: 6px;
  padding: 22px; font-size: 12.5px; line-height: 1.45; max-width: 794px; margin: 0 auto;
}
.inv-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.inv-biz { font-size: 17px; font-weight: 700; }
.inv-biz2 { font-weight: 700; }
.inv-lines { color: #333; font-size: 12px; }
.inv-doctitle { font-size: 20px; font-weight: 700; text-align: right; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); }
.inv-meta { margin-left: auto; margin-top: 8px; border-collapse: collapse; font-size: 12px; }
.inv-meta td { padding: 1px 0 1px 10px; text-align: right; }
.inv-meta td:first-child { color: #666; }
.inv-parties { display: flex; justify-content: space-between; gap: 20px; margin: 16px 0; padding: 12px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.inv-lbl { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: #777; margin-bottom: 3px; }
table.inv-items { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 12px; }
table.inv-items th { background: #f2f2f2; text-align: left; padding: 6px 8px; border-bottom: 1px solid #ccc; }
table.inv-items td { padding: 6px 8px; border-bottom: 1px solid #eee; vertical-align: top; }
table.inv-items .r, .inv-totals .r { text-align: right; }
.inv-bottom { display: flex; justify-content: space-between; gap: 20px; margin-top: 14px; align-items: flex-start; }
.inv-qr { text-align: center; font-size: 10.5px; color: #555; }
.inv-qr svg { border: 1px solid #eee; }
table.inv-totals { margin-left: auto; border-collapse: collapse; min-width: 240px; font-size: 12.5px; }
table.inv-totals td { padding: 3px 8px; }
table.inv-totals tr.grand td { border-top: 2px solid var(--accent); font-weight: 700; font-size: 14px; color: var(--accent); padding-top: 6px; }
.inv-words { margin-top: 12px; padding: 8px 0; border-top: 1px dashed var(--border); font-size: 12px; }
.inv-foot { margin-top: 12px; font-size: 11.5px; }
.inv-legal { color: #777; font-size: 10.5px; margin-top: 8px; }
.inv-sign { margin-top: 24px; text-align: right; }
.inv-sign span { border-top: 1px solid #999; padding-top: 3px; }

/* print: show only the invoice */
@media print {
  body * { visibility: hidden; }
  #invoicePreview, #invoicePreview * { visibility: visible; }
  #invoicePreview { position: absolute; left: 0; top: 0; width: 100%; }
  .inv-sheet { border: 0; padding: 8mm; max-width: none; }
  .site-header, .site-footer, .feedback-fab, .install-sheet, .no-print { display: none !important; }
  @page { size: A4; margin: 8mm; }
}

/* utility */
.text-center { text-align: center; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.hidden { display: none !important; }
.tag { display: inline-block; font-size: .72rem; background: var(--section); border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px; color: var(--muted); }
