:root {
  --bg: #f4f8f5;
  --surface: #ffffff;
  --surface-soft: #f3f7f4;
  --text: #10261a;
  --text-soft: #5f7268;
  --line: #dfe8e2;
  --line-strong: #cbd8d0;
  --primary: #1f8a45;
  --primary-hover: #176d36;
  --primary-soft: #e4f5e9;
  --primary-dark: #15562d;
  --on-primary: #ffffff;
  --header-bg: rgba(255, 255, 255, 0.95);
  --header-line: #cae8d8;
  --header-shadow: 0 4px 14px rgba(31, 138, 69, 0.08);
  --accent-line: #76d19f;
  --toggle-hover-bg: #ffffff;
  --shadow: 0 10px 28px rgba(17, 24, 39, 0.06);
  --radius: 18px;
  --radius-sm: 12px;
  --container: 1200px;
}

html[data-theme="dark"] {
  --bg: #0d1712;
  --surface: #132018;
  --surface-soft: #1a2b21;
  --text: #e2efe7;
  --text-soft: #9fb6a8;
  --line: #2f4639;
  --line-strong: #3e5b4a;
  --primary: #2fb766;
  --primary-hover: #23904f;
  --primary-soft: #1b4a31;
  --primary-dark: #9ce6bc;
  --on-primary: #ffffff;
  --header-bg: rgba(19, 32, 24, 0.9);
  --header-line: #274133;
  --header-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  --accent-line: #2b8c55;
  --toggle-hover-bg: #1a2b21;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overflow-x: clip;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  transition: background-color 0.24s ease, color 0.24s ease, opacity 0.28s ease;
  overflow-x: clip;
}

@media (prefers-reduced-motion: no-preference) {
  body {
    animation: page-fade-in 0.34s ease both;
  }

  body.is-leaving {
    animation: none;
    opacity: 0;
  }

  .reveal-on-scroll {
    opacity: 0;
    transform: translateY(16px) scale(0.99);
    transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: opacity, transform;
  }

  .reveal-on-scroll.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 820px) and (prefers-reduced-motion: no-preference) {
  body {
    animation: none;
  }

  .reveal-on-scroll {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .collab-pulse {
    animation: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reveal-on-scroll {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}

@keyframes page-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.22s ease;
}

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

button {
  cursor: pointer;
  transition: background-color 0.22s ease, color 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
}

.collab-watch {
  position: relative;
}

@media (prefers-reduced-motion: no-preference) {
  .collab-pulse {
    animation: collab-pulse 1.05s ease;
  }
}

@keyframes collab-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(31, 138, 69, 0.42);
  }
  70% {
    box-shadow: 0 0 0 14px rgba(31, 138, 69, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(31, 138, 69, 0);
  }
}

html[data-theme="dark"] .collab-pulse {
  animation-name: collab-pulse-dark;
}

@keyframes collab-pulse-dark {
  0% {
    box-shadow: 0 0 0 0 rgba(47, 183, 102, 0.45);
  }
  70% {
    box-shadow: 0 0 0 14px rgba(47, 183, 102, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(47, 183, 102, 0);
  }
}

.site-header,
.form-block,
.form-actions,
.preview-header,
.invoice-preview,
.feature-card,
.step-card,
.seo-section .narrow,
.faq-item,
.site-footer,
.ad-placeholder,
.nav-dropdown-menu {
  transition: background-color 0.26s ease, border-color 0.26s ease, color 0.26s ease, box-shadow 0.26s ease;
}

.container {
  width: min(var(--container), calc(100% - 32px));
  margin: 0 auto;
}

.narrow {
  width: min(860px, 100%);
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  backdrop-filter: none;
  border-bottom: 1px solid var(--header-line);
  box-shadow: var(--header-shadow);
}

.site-header::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: #1f8a45;
}

.header-inner {
  min-height: 72px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 18px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0;
  color: var(--text);
  white-space: nowrap;
}

.site-logo {
  width: 250px;
  height: 100px;
  max-width: min(100%, 250px);
  display: block;
}

.site-logo-dark {
  display: none;
}

html[data-theme="dark"] .site-logo-light {
  display: none;
}

html[data-theme="dark"] .site-logo-dark {
  display: block;
}

.logo-mark {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #ecfdf3;
  border: 2px solid #16a34a;
  box-shadow: 0 2px 10px rgba(22, 163, 74, 0.14);
}

.logo-mark::before {
  content: "CI";
  position: absolute;
  top: 7px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #166534;
  line-height: 1;
}

.logo-mark::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  height: 3px;
  border-radius: 999px;
  background: #16a34a;
  box-shadow: 0 -7px 0 #86efac, 0 -14px 0 #bbf7d0;
}

.logo-text {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.018em;
  color: #0f172a;
  line-height: 1;
}

.logo-text span {
  color: #475569;
  font-size: 0.56em;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.main-nav {
  display: flex;
  flex: 1;
  justify-content: center;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
}

.main-nav a {
  font-size: 0.94rem;
  font-weight: 700;
  color: #6b7280;
  transition: color 0.2s ease;
}

.main-nav a:hover {
  color: #4b5563;
}

.nav-dropdown {
  position: relative;
}

.nav-dropdown-toggle {
  border: none;
  background: transparent;
  padding: 0;
  font-size: 0.94rem;
  font-weight: 700;
  color: #6b7280;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-dropdown-toggle:hover {
  color: #4b5563;
}

.nav-dropdown-toggle::after {
  content: "▾";
  font-size: 0.74rem;
  line-height: 1;
  opacity: 0.9;
  transform: translateY(1px);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 220px;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 14px 28px rgba(2, 6, 23, 0.14);
  display: none;
  z-index: 80;
}

.nav-dropdown-menu a {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
}

.nav-dropdown-menu a:hover {
  background: var(--surface-soft);
  color: var(--primary-dark);
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
  display: block;
}

.nav-dropdown:hover .nav-dropdown-toggle::after,
.nav-dropdown:focus-within .nav-dropdown-toggle::after {
  transform: rotate(180deg) translateY(-1px);
  opacity: 1;
}

.nav-dropdown.is-open .nav-dropdown-menu {
  display: block;
}

.nav-dropdown.is-open .nav-dropdown-toggle::after {
  transform: rotate(180deg) translateY(-1px);
  opacity: 1;
}

.header-tools {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.mobile-nav-toggle {
  display: none;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  font-size: 1.06rem;
  font-weight: 700;
  line-height: 1;
  padding: 0;
}

.mobile-nav-toggle:hover {
  border-color: var(--accent-line);
  background: var(--surface-soft);
}

.theme-toggle {
  position: relative;
  overflow: hidden;
  width: 56px;
  min-width: 56px;
  height: 32px;
  min-height: 32px;
  padding: 2px;
  border-radius: 999px;
  border: 1px solid #dbe3ec;
  background: #eef3f8;
  color: #5f6f80;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
  box-shadow: none;
  transition:
    box-shadow 0.3s ease,
    transform 0.28s ease,
    color 0.22s ease,
    background-color 0.22s ease,
    border-color 0.22s ease;
}

.theme-toggle:hover {
  border-color: #c4d0de;
  transform: translateY(-1px);
  box-shadow: none;
}

.theme-toggle:active {
  transform: translateY(0);
  box-shadow: none;
}

.theme-toggle::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.58), rgba(255, 255, 255, 0) 55%);
  opacity: 0.9;
}

.theme-toggle-track {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: inherit;
}

.theme-glyph {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.74rem;
  line-height: 1;
  transition: opacity 0.26s ease, color 0.26s ease;
}

.theme-glyph-sun {
  left: 8px;
  color: #e5a30a;
  opacity: 1;
}

.theme-glyph-moon {
  right: 8px;
  color: #6b7280;
  opacity: 0.42;
}

.theme-toggle-thumb {
  position: absolute;
  top: 1px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fdfefe;
  border: 1px solid #d7e2ec;
  box-shadow: none;
  transition: left 0.34s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.24s ease, background-color 0.24s ease, border-color 0.24s ease;
}

html[data-theme="dark"] .theme-glyph-sun {
  opacity: 0.36;
  color: #9fb6a8;
}

html[data-theme="dark"] .theme-glyph-moon {
  opacity: 1;
  color: #d6f4e2;
}

html[data-theme="dark"] .theme-toggle-thumb {
  left: calc(100% - 26px);
  background: #e5efe9;
  border-color: #3f5e4d;
  box-shadow: none;
}

@media (prefers-reduced-motion: no-preference) {
  .theme-toggle {
    animation: theme-neu-breathe 3.2s ease-in-out infinite;
  }
}

@keyframes theme-neu-breathe {
  0%,
  100% {
    border-color: #dbe3ec;
    background: #eef3f8;
  }
  50% {
    border-color: #c9d6e4;
    background: #f2f6fa;
  }
}

.theme-icon {
  width: 56px;
  min-width: 56px;
  height: 32px;
  padding: 0;
  line-height: 0;
}

html[data-theme="dark"] .site-header::before {
  background: #23904f;
}

html[data-theme="dark"] .logo-text {
  color: #e5e7eb;
}

html[data-theme="dark"] .logo-text span {
  color: #cbd5e1;
}

html[data-theme="dark"] .logo-mark {
  background: #0f1f16;
  border-color: #22c55e;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.32);
}

html[data-theme="dark"] .logo-mark::before {
  color: #bbf7d0;
}

html[data-theme="dark"] .logo-mark::after {
  background: #22c55e;
  box-shadow: 0 -7px 0 #15803d, 0 -14px 0 #166534;
}

html[data-theme="dark"] .main-nav a {
  color: var(--text-soft);
}

html[data-theme="dark"] .main-nav a:hover {
  color: var(--text);
}

html[data-theme="dark"] .nav-dropdown-toggle {
  color: var(--text-soft);
}

html[data-theme="dark"] .nav-dropdown-toggle:hover {
  color: var(--text);
}

html[data-theme="dark"] .nav-dropdown-menu {
  border-color: var(--line);
  background: var(--surface);
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.32);
}

html[data-theme="dark"] .nav-dropdown-menu a {
  color: var(--text);
}

html[data-theme="dark"] .nav-dropdown-menu a:hover {
  background: var(--surface-soft);
  color: var(--primary-dark);
}

html[data-theme="dark"] .theme-toggle {
  border-color: #304738;
  background: #18281f;
  color: #cae6d8;
  box-shadow: none;
}

html[data-theme="dark"] .theme-toggle:hover {
  border-color: #3e5b4a;
  background: #1d3025;
  color: #e6f8ee;
  box-shadow: none;
}

html[data-theme="dark"] .theme-toggle:active {
  box-shadow: none;
}

html[data-theme="dark"] .theme-toggle::before {
  background: linear-gradient(135deg, rgba(63, 97, 77, 0.48), rgba(25, 40, 31, 0) 58%);
}

@media (prefers-reduced-motion: no-preference) {
  html[data-theme="dark"] .theme-toggle {
    animation-name: theme-neu-breathe-dark;
  }
}

@keyframes theme-neu-breathe-dark {
  0%,
  100% {
    border-color: #304738;
    background: #18281f;
  }
  50% {
    border-color: #3c5948;
    background: #1b2d23;
  }
}

html[data-theme="dark"] .mobile-nav-toggle {
  background: var(--surface-soft);
  color: var(--text);
  border-color: var(--line-strong);
}

html[data-theme="dark"] .mobile-nav-toggle:hover {
  background: #223628;
  border-color: var(--accent-line);
}

/* Hero */
.hero {
  padding: 56px 0 28px;
}

.hero-inner {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
  align-items: center;
}

.hero-content {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.hero-content {
  padding: 48px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hero h1 {
  margin: 0 0 14px;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.hero-text {
  margin: 0;
  max-width: 620px;
  color: var(--text-soft);
  font-size: 1.05rem;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 28px;
}

.hero-points {
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.hero-points li {
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--header-line);
  color: var(--primary-dark);
  font-size: 0.92rem;
}


/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 700;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line-strong);
}

.btn-secondary:hover {
  background: var(--primary-soft);
  border-color: var(--accent-line);
}

.btn-light {
  background: var(--surface-soft);
  color: var(--text);
  border-color: var(--line);
}

.btn-light:hover {
  background: var(--line);
}

.btn-small {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line-strong);
  font-weight: 700;
}

.btn-small:hover {
  background: var(--primary-soft);
  border-color: var(--accent-line);
}

/* Sections */
section {
  padding: 28px 0;
}

.section-heading {
  margin-bottom: 22px;
}

.section-heading h2 {
  margin: 0 0 8px;
  font-size: clamp(1.5rem, 2.5vw, 2.2rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.section-heading p {
  margin: 0;
  color: var(--text-soft);
}

/* Generator */
.generator-section {
  padding-top: 12px;
}

.generator-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.9fr);
  gap: 24px;
  align-items: start;
}

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

.invoice-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.block-header {
  margin-bottom: 18px;
}

.block-header h3 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.3;
}

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

.form-grid {
  display: grid;
  gap: 16px;
}

.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--text);
}

.form-note {
  margin: 2px 0 0;
  font-size: 0.84rem;
  color: var(--text-soft);
  line-height: 1.45;
}

.brand-color-group {
  margin-top: 14px;
}

.form-group input[type="color"] {
  width: 70px;
  height: 44px;
  padding: 4px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
}

.shipping-row {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.shipping-row > label {
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--text-soft);
}

.shipping-add-btn {
  margin-top: 10px;
}

.shipping-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.shipping-prefix {
  min-height: 44px;
  min-width: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-soft);
  font-weight: 700;
}

.shipping-control input {
  width: 92px;
  min-height: 44px;
  text-align: right;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  padding: 0 12px;
  outline: none;
}

.shipping-control input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.12);
}

.shipping-remove {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: #ef4444;
  font-size: 1.8rem;
  line-height: 1;
  padding: 0;
}

.shipping-remove:hover {
  color: #dc2626;
}

.shipping-remove:focus-visible {
  outline: 2px solid #dc2626;
  outline-offset: 2px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  padding: 14px 14px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group textarea {
  resize: vertical;
  min-height: 110px;
}

.phone-field {
  display: flex;
  gap: 10px;
}

.phone-code {
  max-width: 135px;
  flex: 0 0 135px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.12);
}

/* Items */
.items-table {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.items-head,
.item-row {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) 0.8fr 1fr 1fr 52px;
  gap: 10px;
  align-items: center;
}

.items-head {
  padding: 0 4px;
  color: var(--text-soft);
  font-size: 0.88rem;
  font-weight: 700;
}

.items-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.item-row input {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  padding: 14px 12px;
}

.remove-item {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: #b91c1c;
  font-size: 1.2rem;
  line-height: 1;
}

.remove-item:hover {
  background: #fef2f2;
}

/* Form actions */
.form-actions {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* Preview */
.preview-sticky {
  position: sticky;
  top: 96px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.preview-header {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: 18px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.preview-header h3 {
  margin: 0 0 4px;
  font-size: 1.1rem;
}

.preview-header p {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.95rem;
}

.invoice-preview {
  --preview-accent: var(--primary-dark);
  background: #ffffff;
  color: #111827;
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.preview-top {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.preview-top h2 {
  margin: 0 0 12px;
  font-size: 2rem;
  letter-spacing: 0.06em;
  color: var(--preview-accent);
}

.preview-top p,
.preview-brand p,
.preview-billto p,
.preview-notes p,
.preview-terms p {
  margin: 4px 0;
  color: #6b7280;
}

.preview-brand {
  text-align: right;
}

.preview-logo {
  width: 84px;
  height: 84px;
  object-fit: contain;
  margin-left: auto;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  padding: 6px;
}

.preview-brand h3 {
  margin: 0 0 8px;
  font-size: 1.15rem;
}

.preview-billto,
.preview-items,
.preview-summary,
.preview-notes,
.preview-terms {
  margin-top: 24px;
}

.preview-billto h4,
.preview-notes h4,
.preview-terms h4 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.preview-items table {
  width: 100%;
  border-collapse: collapse;
}

.preview-items th,
.preview-items td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 0.95rem;
}

.preview-items th {
  color: #4b5563;
  font-weight: 700;
}

.preview-summary {
  margin-left: auto;
  width: min(320px, 100%);
}

.preview-summary p {
  margin: 0;
  padding: 10px 0;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.preview-summary span {
  color: var(--text-soft);
}

.preview-summary strong {
  color: var(--text);
}

.preview-summary .grand-total {
  padding-top: 16px;
  font-size: 1.08rem;
  border-bottom: 2px solid var(--preview-accent);
}

.preview-summary .grand-total span,
.preview-summary .grand-total strong {
  color: var(--preview-accent);
}

html[data-theme="dark"] .invoice-preview {
  background: #102017;
  color: var(--text);
  border-color: var(--line-strong);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.38), 0 0 0 1px rgba(63, 95, 77, 0.28);
}

html[data-theme="dark"] .preview-top {
  border-bottom-color: var(--line);
}

html[data-theme="dark"] .preview-top h2,
html[data-theme="dark"] .preview-brand h3,
html[data-theme="dark"] .preview-billto h4,
html[data-theme="dark"] .preview-notes h4,
html[data-theme="dark"] .preview-terms h4 {
  color: var(--text);
}

html[data-theme="dark"] .preview-top p,
html[data-theme="dark"] .preview-brand p,
html[data-theme="dark"] .preview-billto p,
html[data-theme="dark"] .preview-notes p,
html[data-theme="dark"] .preview-terms p {
  color: var(--text-soft);
}

html[data-theme="dark"] .preview-items th {
  color: #c9ddcf;
}

html[data-theme="dark"] .preview-items th,
html[data-theme="dark"] .preview-items td {
  border-bottom-color: var(--line);
}

html[data-theme="dark"] .preview-items td {
  color: var(--text);
}

html[data-theme="dark"] .preview-summary p {
  border-bottom-color: var(--line);
}

html[data-theme="dark"] .preview-summary span {
  color: var(--text-soft);
}

html[data-theme="dark"] .preview-summary strong {
  color: var(--text);
}

html[data-theme="dark"] .preview-summary .grand-total {
  border-bottom-color: var(--preview-accent);
}

html[data-theme="dark"] .preview-summary .grand-total span,
html[data-theme="dark"] .preview-summary .grand-total strong {
  color: var(--preview-accent);
}

html[data-theme="dark"] .preview-logo {
  background: #0f1f16;
  border-color: var(--line-strong);
}

/* Cards */
.feature-grid,
.steps-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.feature-card,
.step-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.feature-card h3,
.step-card h3 {
  margin: 0 0 8px;
  font-size: 1.08rem;
}

.feature-card p,
.step-card p {
  margin: 0;
  color: var(--text-soft);
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  margin-bottom: 14px;
  border-radius: 999px;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 700;
}

/* Ad */
.ad-placeholder {
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: 20px;
  min-height: 120px;
  display: grid;
  place-items: center;
  color: var(--text-soft);
  text-align: center;
  box-shadow: var(--shadow);
}

/* SEO section */
.seo-section .narrow {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.seo-section h2 {
  margin: 0 0 12px;
  font-size: 1.6rem;
}

.seo-section p {
  margin: 0 0 12px;
  color: var(--text-soft);
}

.seo-section p:last-child {
  margin-bottom: 0;
}

.page-section {
  padding-top: 56px;
}

.blog-feature-grid {
  grid-template-columns: 1fr;
}

.blog-posts-grid {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.blog-post-card {
  display: block;
}

.blog-post-card h4 {
  margin: 0 0 10px;
  font-size: 1.2rem;
  color: var(--text);
}

.blog-post-card p {
  margin: 0 0 10px;
  color: var(--text-soft);
}

.blog-post-card .blog-post-cta {
  margin-bottom: 0;
  color: var(--primary-dark);
  font-weight: 700;
}

.article-actions {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.blog-article {
  margin-top: 16px;
  padding: 24px;
}

.blog-article-image {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  margin-bottom: 10px;
}

.blog-article-credit {
  margin: 0 0 18px;
  font-size: 0.9rem;
  color: var(--text-soft);
}

.blog-article h3 {
  margin: 18px 0 8px;
  font-size: 1.15rem;
  color: var(--text);
}

.blog-article p {
  margin: 0 0 10px;
  color: var(--text-soft);
}

.blog-article ul {
  margin: 0;
  padding-left: 20px;
  color: var(--text-soft);
}

.blog-article li {
  margin: 0 0 6px;
}

/* FAQ */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.faq-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0 18px;
  box-shadow: var(--shadow);
}

.faq-item summary {
  list-style: none;
  cursor: pointer;
  padding: 18px 0;
  font-weight: 700;
  position: relative;
  padding-right: 28px;
}

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

.faq-item summary::after {
  content: "+";
  position: absolute;
  right: 0;
  top: 17px;
  font-size: 1.2rem;
  color: var(--text-soft);
}

.faq-item[open] summary::after {
  content: "–";
}

.faq-item p {
  margin: 0;
  padding: 0 0 18px;
  color: var(--text-soft);
}

/* Currency Converter */
.converter-wrap {
  display: grid;
  gap: 16px;
}

.converter-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.converter-form {
  display: grid;
  gap: 14px;
}

.converter-row {
  display: grid;
  gap: 14px;
}

.converter-row.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.converter-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.converter-actions .btn {
  min-width: 120px;
}

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

.conversion-result-value {
  margin: 0 0 6px;
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--text);
}

.conversion-result-rate,
.conversion-updated,
.conversion-status {
  margin: 0 0 4px;
  color: var(--text-soft);
  font-size: 0.95rem;
}

.conversion-status.is-error {
  color: #b91c1c;
}

html[data-theme="dark"] .conversion-status.is-error {
  color: #fca5a5;
}

/* Excel Formula Generator */
.formula-wrap {
  display: grid;
  gap: 16px;
}

.formula-card,
.formula-howto-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.formula-form {
  display: grid;
  gap: 14px;
}

.formula-row {
  display: grid;
  gap: 14px;
}

.formula-row.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.formula-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

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

.formula-output-label {
  margin: 0 0 6px;
  color: var(--text-soft);
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.formula-code {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  padding: 12px;
  color: var(--text);
  font-size: 1rem;
  font-family: Consolas, Monaco, "Courier New", monospace;
  overflow-x: auto;
}

.formula-status {
  margin: 10px 0 0;
  color: var(--text-soft);
  font-size: 0.95rem;
}

.formula-status.is-error {
  color: #b91c1c;
}

html[data-theme="dark"] .formula-status.is-error {
  color: #fca5a5;
}

.formula-howto-card h3 {
  margin: 0 0 10px;
}

.formula-howto-steps {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 6px;
  color: var(--text-soft);
}

.formula-example {
  margin: 12px 0 0;
  color: var(--text);
  font-weight: 600;
}

/* PDF to Excel Converter */
.pdfexcel-wrap {
  display: grid;
  gap: 16px;
}

.pdfexcel-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.pdfexcel-form {
  display: grid;
  gap: 14px;
}

.pdfexcel-form input[type="file"] {
  width: 100%;
}

.pdfexcel-row {
  display: grid;
  gap: 14px;
}

.pdfexcel-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

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

.pdfexcel-status {
  margin: 0 0 10px;
  color: var(--text-soft);
}

.pdfexcel-status.is-error {
  color: #b91c1c;
}

html[data-theme="dark"] .pdfexcel-status.is-error {
  color: #fca5a5;
}

.pdfexcel-preview-wrap {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: auto;
  background: var(--surface-soft);
  max-height: 380px;
}

.pdfexcel-preview-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
}

.pdfexcel-preview-table th,
.pdfexcel-preview-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  font-size: 0.92rem;
  color: var(--text);
  white-space: nowrap;
}

.pdfexcel-preview-table th {
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

/* Footer */
.site-footer {
  margin-top: 36px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.footer-inner {
  padding: 36px 0 24px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 28px;
}

.footer-brand p {
  margin: 10px 0 0;
  color: var(--text-soft);
  max-width: 380px;
}

.footer-links {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 28px;
}

.footer-links h4 {
  margin: 0 0 10px;
  font-size: 0.95rem;
}

.footer-links a {
  display: block;
  margin-bottom: 8px;
  color: var(--text-soft);
  font-size: 0.95rem;
}

.footer-links a:hover {
  color: var(--text);
}

.footer-bottom {
  border-top: 1px solid var(--line);
  padding: 16px;
  text-align: center;
  color: var(--text-soft);
  font-size: 0.92rem;
}

/* Utility */
.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 1080px) {
  .hero-inner,
  .generator-layout {
    grid-template-columns: 1fr;
  }

  .preview-sticky {
    position: static;
  }

  .site-logo {
    width: 220px;
    height: auto;
  }

}

@media (max-width: 820px) {
  .header-inner {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    padding: 14px 0;
    min-height: auto;
    gap: 12px;
  }

  .main-nav {
    display: none;
    flex: 0 0 100%;
    max-width: 100%;
    width: 100%;
    order: 4;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 10px;
    margin-top: 4px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.08);
  }

  .main-nav.is-open {
    display: flex;
  }

  .main-nav > a {
    width: 100%;
  }

  .header-tools {
    margin-left: 0;
    order: 3;
  }

  .mobile-nav-toggle {
    display: inline-flex;
    margin-left: auto;
    order: 2;
  }

  .site-logo {
    width: 180px;
    height: auto;
  }

  .nav-dropdown {
    width: 100%;
  }

  .nav-dropdown-toggle {
    width: 100%;
    text-align: left;
  }

  .nav-dropdown-menu {
    position: static;
    transform: none;
    margin-top: 8px;
    min-width: 0;
    width: 100%;
  }

  .nav-dropdown:hover .nav-dropdown-menu,
  .nav-dropdown:focus-within .nav-dropdown-menu {
    display: none;
  }

  .nav-dropdown.is-open .nav-dropdown-menu {
    display: block;
  }

  .hero-content,
  .form-block,
  .invoice-preview,
  .preview-header,
  .feature-card,
  .step-card,
  .seo-section .narrow {
    padding: 20px;
  }

  .two-col,
  .three-col,
  .converter-row.two-col,
  .formula-row.two-col,
  .feature-grid,
  .steps-grid {
    grid-template-columns: 1fr;
  }

  .items-head {
    display: none;
  }

  .item-row {
    grid-template-columns: 1fr;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface-soft);
  }

  .remove-item {
    width: 100%;
  }

  .preview-top {
    flex-direction: column;
  }

  .preview-brand {
    text-align: left;
  }

  .preview-logo {
    margin-left: 0;
  }

  .preview-summary {
    width: 100%;
  }

  .footer-inner,
  .footer-links {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .page-section {
    padding-top: 28px;
  }

  .seo-section .narrow.pdfexcel-wrap {
    padding: 18px 14px;
    border-radius: 18px;
  }

  .container {
    width: min(100% - 20px, var(--container));
  }

  .site-logo {
    width: 142px;
    height: auto;
  }

  .logo {
    min-width: 0;
    margin-right: auto;
  }

  .mobile-nav-toggle,
  .header-tools {
    flex: 0 0 auto;
  }

  .mobile-nav-toggle {
    margin-left: 8px;
  }

  .header-tools {
    margin-left: 8px;
  }

  .main-nav {
    width: 100%;
    gap: 10px;
  }

  .main-nav.is-open {
    display: grid;
    grid-template-columns: 1fr;
  }

  .main-nav > a {
    width: 100%;
  }

  .hero {
    padding-top: 28px;
  }

  .hero-content {
    padding: 22px 18px;
  }

  .hero h1 {
    font-size: 1.9rem;
  }

  .hero-text {
    font-size: 1rem;
  }

  .hero-actions,
  .form-actions {
    flex-direction: column;
  }

  .blog-article {
    padding: 18px;
  }

  .btn,
  .btn-small {
    width: 100%;
  }

  .converter-actions .btn {
    min-width: 0;
  }

  .formula-actions .btn {
    width: 100%;
  }

  .pdfexcel-actions .btn {
    width: 100%;
  }

  .pdfexcel-card {
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  .pdfexcel-output {
    margin-top: 14px;
    padding-top: 14px;
  }

  .pdfexcel-preview-wrap {
    max-height: 320px;
  }

  .pdfexcel-preview-table th,
  .pdfexcel-preview-table td {
    padding: 9px 10px;
    font-size: 0.86rem;
    white-space: normal;
    word-break: break-word;
  }

  .pdfexcel-preview-table {
    min-width: 0;
  }

  .pdfexcel-preview-table thead {
    display: none;
  }

  .pdfexcel-preview-table tbody {
    display: grid;
    gap: 10px;
    padding: 10px;
  }

  .pdfexcel-preview-table tbody tr {
    display: grid;
    gap: 6px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    padding: 8px;
  }

  .pdfexcel-preview-table tbody td {
    display: grid;
    grid-template-columns: minmax(86px, 110px) 1fr;
    align-items: start;
    gap: 8px;
    border-bottom: 1px dashed var(--line);
    padding: 6px 4px;
    line-height: 1.35;
  }

  .pdfexcel-preview-table tbody td:last-child {
    border-bottom: 0;
  }

  .pdfexcel-preview-table tbody td::before {
    content: attr(data-col);
    color: var(--text-soft);
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
  }

  .pdfexcel-preview-table tbody tr.pdfexcel-empty-row {
    border: 0;
    background: transparent;
    padding: 2px 0;
  }

  .pdfexcel-preview-table tbody tr.pdfexcel-empty-row td {
    display: block;
    border: 0;
    padding: 4px 0;
  }

  .pdfexcel-preview-table tbody tr.pdfexcel-empty-row td::before {
    content: none;
  }

  .phone-field {
    flex-direction: column;
  }

  .shipping-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .shipping-control {
    width: 100%;
  }

  .shipping-control input {
    flex: 1;
    width: 100%;
  }

  .phone-code {
    max-width: none;
    flex: 1 1 auto;
  }

  .shipping-add-btn {
    width: 100%;
  }

  .invoice-preview {
    padding: 18px;
  }

  .preview-items th,
  .preview-items td {
    padding: 10px 6px;
    font-size: 0.88rem;
  }
}

@media (max-width: 380px) {
  .container {
    width: min(100% - 16px, var(--container));
  }

  .header-inner {
    gap: 8px;
    padding: 10px 0;
  }

  .site-logo {
    width: 124px;
  }

  .mobile-nav-toggle {
    width: 32px;
    height: 32px;
    font-size: 0.92rem;
  }

  .theme-icon {
    width: 42px;
    min-width: 42px;
    height: 28px;
  }

  .main-nav {
    padding: 10px;
    gap: 8px;
  }

  .main-nav a,
  .nav-dropdown-toggle {
    font-size: 0.9rem;
  }

  .hero h1 {
    font-size: 1.6rem;
  }

  .hero-content,
  .form-block,
  .invoice-preview,
  .preview-header,
  .feature-card,
  .step-card,
  .seo-section .narrow {
    padding: 16px;
  }

  .preview-items th,
  .preview-items td {
    padding: 8px 4px;
    font-size: 0.8rem;
  }

  .pdfexcel-card {
    padding: 0;
  }

  .pdfexcel-preview-wrap {
    max-height: 280px;
  }

  .pdfexcel-preview-table {
    min-width: 0;
  }

  .pdfexcel-preview-table th,
  .pdfexcel-preview-table td {
    padding: 8px;
    font-size: 0.8rem;
  }

  .pdfexcel-preview-table tbody {
    padding: 8px;
    gap: 8px;
  }

  .pdfexcel-preview-table tbody td {
    grid-template-columns: minmax(72px, 90px) 1fr;
    gap: 6px;
    padding: 5px 2px;
  }
}
