:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --muted: #f6f8fb;
  --line: #d9e1ec;
  --text: #111827;
  --soft-text: #5b6472;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --danger: #b42318;
  --radius: 8px;
  --shadow: 0 18px 48px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.site-header {
  align-items: center;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 18px;
  justify-content: space-between;
  min-height: 64px;
  padding: 12px clamp(16px, 4vw, 48px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  align-items: center;
  color: var(--text);
  display: inline-flex;
  font-weight: 750;
  gap: 10px;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  align-items: center;
  background: var(--accent);
  border-radius: 8px;
  color: #fff;
  display: inline-flex;
  height: 34px;
  justify-content: center;
  width: 34px;
}

nav {
  display: flex;
  gap: 16px;
}

nav a {
  color: var(--soft-text);
  font-size: 0.95rem;
  font-weight: 650;
}

main {
  padding-bottom: 88px;
}

.intro {
  display: grid;
  gap: 22px;
  margin: 0 auto;
  max-width: 1180px;
  padding: 34px clamp(16px, 4vw, 48px) 18px;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0;
  margin: 0 0 8px;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1.05;
  margin-bottom: 14px;
  max-width: 820px;
}

h2 {
  font-size: clamp(1.35rem, 2.2vw, 2rem);
  line-height: 1.18;
  margin-bottom: 12px;
}

.intro-copy {
  color: var(--soft-text);
  font-size: 1.05rem;
  max-width: 700px;
}

.trust-strip {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.trust-strip span {
  background: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--soft-text);
  font-size: 0.9rem;
  font-weight: 650;
  padding: 8px 12px;
}

.generator-shell {
  align-items: start;
  display: grid;
  gap: 28px;
  grid-template-columns: minmax(0, 1fr);
  margin: 0 auto;
  max-width: 1180px;
  padding: 18px clamp(16px, 4vw, 48px) 42px;
}

.invoice-form,
.preview-column {
  min-width: 0;
}

.form-toolbar,
.preview-actions {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.form-toolbar h2 {
  margin-bottom: 0;
}

.form-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: clip;
}

.form-section summary {
  background: var(--muted);
  cursor: pointer;
  font-weight: 750;
  list-style: none;
  padding: 14px 16px;
}

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

.form-section[open] {
  padding-bottom: 14px;
}

.form-section[open] summary {
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}

label {
  color: var(--soft-text);
  display: grid;
  font-size: 0.86rem;
  font-weight: 650;
  gap: 7px;
  padding: 0 16px 12px;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  min-height: 44px;
  padding: 10px 12px;
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

textarea {
  resize: vertical;
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
}

.hint,
.privacy-note {
  color: var(--soft-text);
  font-size: 0.88rem;
  margin: 0;
  padding: 0 16px;
}

.items {
  display: grid;
  gap: 12px;
  padding-bottom: 12px;
}

.item-row {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 0;
  grid-template-columns: 1fr;
  padding-bottom: 2px;
}

.item-row:last-child {
  border-bottom: 0;
}

.icon-button {
  background: transparent;
  border: 0;
  color: var(--danger);
  font-weight: 750;
  justify-self: start;
  min-height: 40px;
  padding: 0 16px 12px;
}

.primary-button,
.secondary-button {
  align-items: center;
  border-radius: var(--radius);
  display: inline-flex;
  font-weight: 750;
  justify-content: center;
  min-height: 44px;
  padding: 10px 14px;
  white-space: nowrap;
}

.primary-button {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
}

.secondary-button {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
}

.full {
  margin: 0 16px;
  width: calc(100% - 32px);
}

.preview-column {
  position: relative;
}

.preview-actions {
  background: #fff;
  position: sticky;
  top: 76px;
  z-index: 2;
}

.invoice-preview {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: #111827;
  min-height: 760px;
  overflow: hidden;
  padding: clamp(20px, 4vw, 42px);
}

.preview-head {
  border-bottom: 3px solid var(--accent);
  display: grid;
  gap: 22px;
  grid-template-columns: 1fr;
  margin-bottom: 26px;
  padding-bottom: 24px;
}

.preview-title {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1;
  margin: 0 0 12px;
}

.logo-preview {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  max-height: 72px;
  max-width: 160px;
  object-fit: contain;
  padding: 6px;
}

.preview-meta,
.preview-parties,
.preview-totals,
.preview-footer {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}

.preview-block h3 {
  color: var(--soft-text);
  font-size: 0.78rem;
  letter-spacing: 0;
  margin: 0 0 8px;
  text-transform: uppercase;
}

.preview-block p {
  margin: 0;
  white-space: pre-line;
}

.preview-table {
  border-collapse: collapse;
  margin: 26px 0;
  width: 100%;
}

.preview-table th,
.preview-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: right;
  vertical-align: top;
}

.preview-table th:first-child,
.preview-table td:first-child {
  text-align: left;
}

.preview-table th {
  background: var(--muted);
  color: var(--soft-text);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.preview-totals {
  margin-left: auto;
  max-width: 340px;
}

.total-line {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.total-line.strong {
  border-top: 2px solid var(--text);
  font-size: 1.2rem;
  font-weight: 800;
  padding-top: 10px;
}

.preview-footer {
  border-top: 1px solid var(--line);
  margin-top: 30px;
  padding-top: 22px;
}

.template-classic .preview-head {
  border-bottom-width: 1px;
}

.template-minimal {
  box-shadow: none;
}

.template-minimal .preview-head,
.template-minimal .preview-footer {
  border-color: #111827;
}

.seo-section {
  border-top: 1px solid var(--line);
  margin: 0 auto;
  max-width: 1180px;
  padding: 38px clamp(16px, 4vw, 48px);
}

.seo-section p {
  color: var(--soft-text);
  max-width: 760px;
}

.link-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
  margin-top: 18px;
}

.link-grid a {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-weight: 700;
  padding: 14px;
}

.faq details {
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
}

.faq summary {
  cursor: pointer;
  font-weight: 750;
}

.mobile-action-bar {
  align-items: center;
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
  bottom: 0;
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr 1fr;
  left: 0;
  padding: 10px 12px;
  position: fixed;
  right: 0;
  z-index: 20;
}

@media (min-width: 720px) {
  .grid.two,
  .preview-meta,
  .preview-parties,
  .preview-footer {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .item-row {
    align-items: end;
    grid-template-columns: minmax(180px, 2fr) repeat(4, minmax(86px, 1fr)) auto;
  }

  .item-row label {
    padding-right: 8px;
  }

  .item-row .icon-button {
    padding: 0 16px 12px 8px;
  }

  .link-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .preview-head {
    grid-template-columns: 1fr auto;
  }
}

@media (min-width: 1020px) {
  main {
    padding-bottom: 0;
  }

  .generator-shell {
    grid-template-columns: minmax(0, 1fr) minmax(420px, 0.9fr);
  }

  .mobile-action-bar {
    display: none;
  }
}

@media (max-width: 620px) {
  nav {
    display: none;
  }

  .site-header {
    min-height: 58px;
  }

  .preview-actions {
    display: none;
  }

  .invoice-preview {
    border-radius: 0;
    margin-left: -16px;
    margin-right: -16px;
    min-height: 520px;
  }

  .preview-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

@media print {
  @page {
    margin: 12mm;
  }

  body {
    background: #fff;
  }

  .site-header,
  .intro,
  .invoice-form,
  .preview-actions,
  .privacy-note,
  .seo-section,
  .mobile-action-bar {
    display: none !important;
  }

  .generator-shell {
    display: block;
    max-width: none;
    padding: 0;
  }

  .invoice-preview {
    border: 0;
    box-shadow: none;
    min-height: auto;
    padding: 0;
  }
}
