/* ==========================================================================
   Cleaning Invoice Generator — shared styles
   Plain CSS, no dependencies. Mobile-first, print-aware.
   ========================================================================== */

:root {
  --brand: #0f766e;
  --brand-dark: #115e59;
  --brand-light: #ccfbf1;
  --ink: #0f172a;
  --ink-soft: #475569;
  --ink-mute: #94a3b8;
  --line: #e2e8f0;
  --bg: #f8fafc;
  --card: #ffffff;
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 14px rgba(15, 23, 42, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- layout ---------- */

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
}

.site-header {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo {
  font-weight: 700;
  font-size: 17px;
  color: var(--ink);
  letter-spacing: -.01em;
}

.logo span { color: var(--brand); }

.site-nav { display: flex; gap: 18px; font-size: 14px; }
.site-nav a { color: var(--ink-soft); }

/* ---------- hero ---------- */

.hero {
  padding: 40px 0 28px;
  text-align: center;
}

.hero h1 {
  margin: 0 0 14px;
  font-size: 34px;
  line-height: 1.25;
  letter-spacing: -.02em;
}

.hero p.lede {
  margin: 0 auto;
  max-width: 660px;
  font-size: 17px;
  color: var(--ink-soft);
}

.badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
}

.badge {
  display: inline-block;
  padding: 4px 11px;
  font-size: 13px;
  border-radius: 999px;
  background: var(--brand-light);
  color: var(--brand-dark);
  font-weight: 600;
}

/* ---------- generator ---------- */

.generator {
  display: grid;
  grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  margin: 8px 0 44px;
}

@media (max-width: 900px) {
  .generator { grid-template-columns: 1fr; }
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel-body { padding: 18px; }

fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 20px;
}

fieldset:last-child { margin-bottom: 0; }

legend {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-mute);
  padding: 0 0 8px;
}

.field { margin-bottom: 12px; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 5px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 9px 11px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  transition: border-color .15s, box-shadow .15s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 0;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .12);
}

.field textarea { resize: vertical; min-height: 64px; }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

@media (max-width: 480px) {
  .row-2, .row-3 { grid-template-columns: 1fr; }
}

/* ---------- line items ---------- */

.items { border-top: 1px solid var(--line); }

.item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 78px 92px 30px;
  gap: 8px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.item input {
  width: 100%;
  padding: 7px 9px;
  font: inherit;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.item input:focus {
  outline: 0;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .12);
}

.item .line-total {
  font-size: 13px;
  font-weight: 600;
  text-align: right;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.item .del {
  border: 0;
  background: none;
  color: var(--ink-mute);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 2px;
  border-radius: 5px;
}

.item .del:hover { color: var(--danger); background: #fef2f2; }

.item-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 78px 92px 30px;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-mute);
  padding-bottom: 6px;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}

.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }

.btn-ghost {
  background: #fff;
  color: var(--ink-soft);
  border-color: var(--line);
}
.btn-ghost:hover { border-color: var(--ink-mute); color: var(--ink); }

.btn-sm { padding: 7px 11px; font-size: 13px; }

.btn-row { display: flex; flex-wrap: wrap; gap: 9px; }

/* ---------- presets ---------- */

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.preset {
  padding: 5px 10px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 999px;
  border: 1px dashed var(--brand);
  background: var(--brand-light);
  color: var(--brand-dark);
  cursor: pointer;
}

.preset:hover { background: #a7f3d0; }

/* ---------- totals ---------- */

.totals {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 4px 0;
  font-size: 14px;
  color: var(--ink-soft);
}

.total-row strong { color: var(--ink); font-variant-numeric: tabular-nums; }

.total-row.grand {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 2px solid var(--ink);
  font-size: 17px;
  color: var(--ink);
  font-weight: 700;
}

.total-row.grand strong { font-size: 20px; }

/* ---------- invoice preview ---------- */

.preview-shell { position: sticky; top: 16px; }

.invoice {
  background: #fff;
  padding: 34px 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 13px;
  line-height: 1.5;
}

.inv-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 2px solid var(--brand);
}

.inv-biz { max-width: 60%; }

.inv-biz .name {
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
  word-break: break-word;
}

.inv-biz .meta { color: var(--ink-soft); white-space: pre-line; word-break: break-word; }

.inv-title { text-align: right; }

.inv-title h2 {
  margin: 0 0 6px;
  font-size: 25px;
  letter-spacing: .04em;
  color: var(--brand);
  text-transform: uppercase;
}

.inv-title .meta { color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.inv-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  padding: 20px 0;
}

@media (max-width: 560px) { .inv-parties { grid-template-columns: 1fr; } }

.inv-parties h3 {
  margin: 0 0 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-mute);
  font-weight: 700;
}

.inv-parties .val { white-space: pre-line; word-break: break-word; }

.inv-table {
  width: 100%;
  border-collapse: collapse;
  margin: 6px 0 0;
}

.inv-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #fff;
  background: var(--brand);
  padding: 8px 10px;
  font-weight: 700;
}

.inv-table th.num, .inv-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

.inv-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  word-break: break-word;
}

.inv-table tr:nth-child(even) td { background: #f8fafc; }

.inv-sum {
  margin-left: auto;
  margin-top: 14px;
  width: 260px;
  max-width: 100%;
}

.inv-sum .r {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-variant-numeric: tabular-nums;
}

.inv-sum .r.grand {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 2px solid var(--brand);
  font-weight: 700;
  font-size: 15px;
  color: var(--brand-dark);
}

.inv-notes {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.inv-notes h3 {
  margin: 0 0 5px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-mute);
  font-weight: 700;
}

.inv-notes .val { white-space: pre-line; color: var(--ink-soft); word-break: break-word; }

/* ---------- content sections ---------- */

.section { padding: 34px 0; border-top: 1px solid var(--line); }

.section h2 {
  margin: 0 0 18px;
  font-size: 25px;
  letter-spacing: -.01em;
}

.section h3 { font-size: 17px; margin: 22px 0 8px; }

.section p { color: var(--ink-soft); }

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-top: 8px;
}

@media (max-width: 780px) { .steps { grid-template-columns: 1fr; } }

.step {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

.step .n {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 10px;
}

.step h4 { margin: 0 0 6px; font-size: 15px; }
.step p { margin: 0; font-size: 14px; }

.table-scroll { overflow-x: auto; margin: 6px 0 4px; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 460px;
}

.data-table th {
  text-align: left;
  background: #f1f5f9;
  color: var(--ink);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 10px 12px;
  border-bottom: 2px solid var(--line);
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
}

.data-table td:first-child { color: var(--ink); font-weight: 600; }

.faq { margin-top: 6px; }

.faq details {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 10px;
  padding: 0 18px;
}

.faq summary {
  cursor: pointer;
  padding: 15px 0;
  font-weight: 600;
  font-size: 15.5px;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.faq summary::-webkit-details-marker { display: none; }

.faq summary::after {
  content: "+";
  font-size: 20px;
  color: var(--brand);
  font-weight: 400;
  flex-shrink: 0;
}

.faq details[open] summary::after { content: "\2212"; }

.faq details p { margin: 0 0 16px; font-size: 15px; }

.related {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
  margin-top: 6px;
}

.related a {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}

.related a:hover {
  text-decoration: none;
  border-color: var(--brand);
  box-shadow: var(--shadow);
}

.related .t { font-weight: 600; font-size: 15px; margin-bottom: 3px; }
.related .d { font-size: 13.5px; color: var(--ink-soft); }

/* ---------- footer ---------- */

.site-footer {
  margin-top: 20px;
  padding: 26px 0 34px;
  border-top: 1px solid var(--line);
  background: #fff;
  font-size: 13.5px;
  color: var(--ink-mute);
}

.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(14px);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- print ---------- */

@media print {
  body { background: #fff; }

  .site-header, .site-footer, .hero, .generator > .panel:first-child,
  .section, .badges, .no-print { display: none !important; }

  .wrap { max-width: none; padding: 0; }

  .generator { display: block; margin: 0; }

  .preview-shell { position: static; }

  .invoice {
    border: 0;
    box-shadow: none;
    border-radius: 0;
    padding: 0;
    font-size: 12px;
  }

  .inv-table tr { page-break-inside: avoid; }

  @page { margin: 14mm; }
}