/* ============================================================
   InvoiceGeneratorUSA — shared stylesheet
   Plain CSS, no frameworks, no external assets.
   Palette: professional blue + slate grey. Mobile-first.
   ============================================================ */

:root {
  --blue: #1d4ed8;
  --blue-dark: #1e40af;
  --blue-light: #dbeafe;
  --blue-soft: #eff6ff;
  --ink: #1e293b;
  --ink-soft: #475569;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f8fafc;
  --card: #ffffff;
  --green: #15803d;
  --green-soft: #dcfce7;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --red: #b91c1c;
  --red-soft: #fee2e2;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .05);
  --max: 1080px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
}
h1, h2, h3, h4 { line-height: 1.25; color: var(--ink); margin: 0 0 .5em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.45rem; margin-top: 1.6em; }
h3 { font-size: 1.15rem; margin-top: 1.3em; }
p { margin: 0 0 1em; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
small { color: var(--muted); }
code { background: #f1f5f9; padding: .1em .35em; border-radius: 4px; font-size: .9em; }

/* ---------- layout ---------- */
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 16px; }
.site-header { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; box-shadow: 0 1px 4px rgba(15, 23, 42, .06); }
.site-header .wrap { display: flex; align-items: center; gap: 16px; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 1.15rem; color: var(--ink); white-space: nowrap; }
.brand span { color: var(--blue); }
.brand img { height: 40px; width: auto; display: block; }

.brand:hover { text-decoration: none; }
.main-nav { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.main-nav a { display: inline-block; color: var(--ink-soft); font-size: .9rem; font-weight: 600; padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); white-space: nowrap; }
.main-nav a:hover { background: var(--blue-soft); border-color: var(--blue); color: var(--blue-dark); text-decoration: none; }
.main-nav a.active { color: var(--blue-dark); font-weight: 700; background: var(--blue-soft); border-color: var(--blue); }
.main-nav a.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.main-nav a.primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); color: #fff; }

.hero { background: linear-gradient(180deg, var(--blue-soft), var(--bg)); padding: 40px 0 28px; }
.hero h1 { font-size: 2.1rem; margin-bottom: .35em; }
.hero .lede { font-size: 1.12rem; color: var(--ink-soft); max-width: 720px; }
.tool-hero { padding: 28px 0 8px; }
.tool-hero h1 { margin-bottom: .3em; }
.answer { background: var(--card); border-left: 4px solid var(--blue); border-radius: 0 var(--radius) var(--radius) 0; box-shadow: var(--shadow); padding: 14px 18px; margin: 18px 0; }
.answer p { margin: 0; }

main { padding-bottom: 48px; }
.site-footer { border-top: 1px solid var(--line); background: var(--card); padding: 28px 0; color: var(--muted); font-size: .92rem; }
.site-footer .cols { display: flex; gap: 32px; flex-wrap: wrap; }
.site-footer .cols > div { min-width: 160px; }
.site-footer h4 { font-size: .95rem; margin-bottom: .5em; color: var(--ink-soft); }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.site-footer li { margin-bottom: 0; }
.site-footer li a { display: inline-block; padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); color: var(--ink-soft); font-size: .88rem; white-space: nowrap; }
.site-footer li a:hover { background: var(--blue-soft); border-color: var(--blue); color: var(--blue-dark); text-decoration: none; }
.footer-logo { height: 36px; width: auto; display: block; margin-bottom: 10px; }

/* ---------- cards / grids ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.tool-card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; color: var(--ink); }
.tool-card:hover { border-color: var(--blue); text-decoration: none; box-shadow: 0 4px 14px rgba(29, 78, 216, .12); }
.tool-card h3 { margin: 0 0 .35em; color: var(--blue-dark); }
.tool-card p { margin: 0; color: var(--ink-soft); font-size: .95rem; }
.tool-card .tag { display: inline-block; font-size: .78rem; font-weight: 700; color: var(--blue-dark); background: var(--blue-light); border-radius: 999px; padding: 2px 10px; margin-bottom: 8px; }

/* ---------- forms ---------- */
label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 4px; }
input[type="text"], input[type="number"], input[type="date"], input[type="email"], input[type="tel"], input[type="url"], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #cbd5e1; border-radius: 8px;
  font: inherit; font-size: .97rem; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 0; border-color: var(--blue); }
textarea { min-height: 110px; resize: vertical; }
.field { margin-bottom: 14px; }
.field .hint { font-size: .85rem; color: var(--muted); font-weight: 400; margin-top: 2px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 18px; }
legend { font-weight: 700; padding: 0 6px; }
.radio-group, .check-group { display: flex; gap: 14px; flex-wrap: wrap; }
.radio-group label, .check-group label { font-weight: 400; display: flex; align-items: center; gap: 6px; margin: 0; }
input[type="radio"], input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--blue); }

/* ---------- buttons ---------- */
.btn { display: inline-block; border: 0; border-radius: 8px; padding: 10px 18px; font: inherit; font-weight: 700; font-size: .97rem; cursor: pointer; background: var(--blue); color: #fff; text-align: center; }
.btn:hover { background: var(--blue-dark); text-decoration: none; }
.btn.secondary { background: #e2e8f0; color: var(--ink); }
.btn.secondary:hover { background: #cbd5e1; }
.btn.ghost { background: transparent; color: var(--blue); border: 1px solid var(--blue); }
.btn.ghost:hover { background: var(--blue-soft); }
.btn.small { padding: 6px 12px; font-size: .88rem; }
.btn.danger { background: var(--red); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- results ---------- */
.result { background: var(--blue-soft); border: 1px solid #bfdbfe; border-radius: var(--radius); padding: 18px 20px; margin: 18px 0; }
.result .big { font-size: 2rem; font-weight: 800; color: var(--blue-dark); line-height: 1.2; }
.result .row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed #bfdbfe; }
.result .row:last-child { border-bottom: 0; }
.result .row .k { color: var(--ink-soft); }
.result .row .v { font-weight: 700; text-align: right; }
.result .row.total .v { font-size: 1.25rem; color: var(--blue-dark); }
.callout { border-radius: var(--radius); padding: 14px 18px; margin: 18px 0; font-size: .95rem; }
.callout.info { background: var(--blue-soft); border: 1px solid #bfdbfe; }
.callout.warn { background: var(--amber-soft); border: 1px solid #fcd34d; }
.callout.good { background: var(--green-soft); border: 1px solid #86efac; }
.callout p:last-child { margin-bottom: 0; }
.note { font-size: .88rem; color: var(--muted); }
.disclaimer { font-size: .86rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; margin-top: 28px; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: .94rem; margin: 12px 0; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f1f5f9; font-weight: 700; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }

/* ---------- invoice preview ---------- */
.invoice-preview { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; margin-top: 8px; }
.invoice-preview .inv-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-bottom: 2px solid var(--ink); padding-bottom: 14px; margin-bottom: 16px; }
.invoice-preview .inv-head h2 { margin: 0; font-size: 1.7rem; letter-spacing: .04em; }
.invoice-preview .inv-logo { max-height: 64px; max-width: 200px; object-fit: contain; }
.invoice-preview .inv-meta { text-align: right; font-size: .92rem; }
.invoice-preview .inv-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.invoice-preview .inv-parties h4 { margin: 0 0 4px; font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.invoice-preview .inv-parties p { margin: 0; white-space: pre-line; }
.invoice-preview table { margin: 0 0 12px; }
.invoice-preview .inv-totals { width: 280px; max-width: 100%; margin-left: auto; }
.invoice-preview .inv-totals .row { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--line); }
.invoice-preview .inv-totals .row.grand { font-weight: 800; font-size: 1.1rem; border-bottom: 2px solid var(--ink); }
.invoice-preview .inv-notes { font-size: .92rem; color: var(--ink-soft); white-space: pre-line; margin-top: 16px; }
.invoice-preview .inv-foot { margin-top: 20px; padding-top: 10px; border-top: 1px solid var(--line); font-size: .85rem; color: var(--muted); text-align: center; }
.status-pill { display: inline-block; font-size: .8rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; }
.status-pill.unpaid { background: var(--amber-soft); color: var(--amber); }
.status-pill.paid { background: var(--green-soft); color: var(--green); }
.status-pill.overdue { background: var(--red-soft); color: var(--red); }
.status-pill.sent { background: var(--blue-light); color: var(--blue-dark); }

/* ---------- FAQ ---------- */
.faq details { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 10px; }
.faq summary { font-weight: 700; cursor: pointer; }
.faq summary:hover { color: var(--blue-dark); }
.faq p { margin: .6em 0 0; }

/* ---------- next step / related ---------- */
.next-step { background: var(--blue-dark); color: #fff; border-radius: var(--radius); padding: 20px; margin: 28px 0; }
.next-step h3 { color: #fff; margin-top: 0; }
.next-step p { color: #dbeafe; }
.next-step a { color: #fff; font-weight: 700; text-decoration: underline; }
.steps { counter-reset: step; list-style: none; padding: 0; }
.steps li { counter-increment: step; padding-left: 40px; position: relative; margin-bottom: 14px; }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--blue); color: #fff; font-weight: 700; text-align: center; line-height: 28px; font-size: .9rem; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: .92rem; box-shadow: 0 4px 16px rgba(0,0,0,.25); opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 99; max-width: 92vw; text-align: center; }
.toast.show { opacity: 1; }

/* ---------- letter output ---------- */
.letter-box { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; white-space: pre-wrap; font-size: .97rem; line-height: 1.7; box-shadow: var(--shadow); }

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  h1 { font-size: 1.6rem; }
  .hero h1 { font-size: 1.7rem; }
  .main-nav { margin-left: 0; }
  .invoice-preview { padding: 16px; }
  .invoice-preview .inv-parties { grid-template-columns: 1fr; }
  .result .big { font-size: 1.6rem; }
}

/* ---------- print: only the printable area ---------- */
@media print {
  body { background: #fff; }
  .site-header, .site-footer, .no-print, .btn-row, .toast { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  main { padding: 0; }
  .card, .invoice-preview, .letter-box { border: 0; box-shadow: none; margin: 0; padding: 0; }
  .print-area { display: block !important; }
}
