@page {
  size: A4;
  margin: 6mm;
  @top-right {
    content: "pagina n° " counter(page) " di " counter(pages);
    font-size: 10pt;
    font-family: "Segoe UI", Arial, sans-serif;
  }
}

@page :first {
  @top-right {
    content: "PAG. " counter(page);
    font-size: 10pt;
    font-family: "Segoe UI", Arial, sans-serif;
  }
}

:root {
  --ink: #1f2328;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #0f172a;
}

* {
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: #f3f4f6;
  margin: 0;
}

.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  z-index: 20;
  display: flex;
  align-items: center;
}

.top-nav-inner {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.top-nav-logo {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.04em;
}

.top-nav-links {
  display: flex;
  gap: 16px;
}

.top-nav-link {
  text-decoration: none;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.top-nav-link:hover {
  color: #2563eb;
}

.auth-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid #1f2328;
  background: #fff;
  color: #1f2328;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 30;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
  font-size: 18px;
  text-decoration: none;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 25;
}

.auth-overlay.is-open {
  display: flex;
}

.auth-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 24px;
  width: 320px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  display: grid;
  gap: 12px;
}

.auth-title {
  font-size: 16px;
  font-weight: 700;
  text-align: center;
}

.auth-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
}

.auth-btn {
  padding: 8px 10px;
  border: 1px solid #1f2328;
  border-radius: 8px;
  background: #1f2937;
  color: #fff;
  cursor: pointer;
}

.auth-btn.secondary {
  background: #fff;
  color: #1f2328;
}

.auth-link {
  background: transparent;
  border: none;
  color: #2563eb;
  text-decoration: underline;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  justify-self: center;
}

.auth-error {
  font-size: 12px;
  color: #b91c1c;
  text-align: center;
  min-height: 16px;
}

.auth-close {
  background: #fff;
  color: #1f2328;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 26;
}

.modal-overlay.is-open {
  display: flex;
}

.modal {
  background: #fff;
  border-radius: 12px;
  width: 320px;
  padding: 20px;
  border: 1px solid #e5e7eb;
  display: grid;
  gap: 10px;
}

.modal-title {
  font-weight: 700;
  font-size: 14px;
  text-align: center;
}

.modal-actions {
  display: grid;
  gap: 8px;
}

.modal-close {
  background: #fff;
  color: #1f2328;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}

.paywall-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 55;
}

.paywall-overlay.is-open {
  display: flex;
}

.paywall-overlay.is-busy .paywall-buttons {
  opacity: 0.6;
  pointer-events: none;
}

.paywall-overlay.is-busy .paywall-actions {
  opacity: 0.8;
}

.paywall-card {
  width: min(360px, 90vw);
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid #e5e7eb;
  padding: 24px;
  display: grid;
  gap: 10px;
  text-align: center;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.2);
}

.paywall-title {
  font-weight: 800;
  font-size: 16px;
}

.paywall-subtitle {
  font-size: 13px;
  color: var(--muted);
}

.paywall-amount {
  font-size: 22px;
  font-weight: 800;
  color: #0f172a;
}

.paywall-note {
  font-size: 12px;
  color: var(--muted);
}

.paywall-buttons {
  display: grid;
  gap: 10px;
  margin-top: 6px;
}

.paywall-btn-slot {
  min-height: 36px;
}

.paywall-error {
  font-size: 11px;
  color: #b91c1c;
  min-height: 16px;
}

.paywall-actions {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.paywall-btn {
  border-radius: 10px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #1f2328;
  padding: 10px 12px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 700;
}

.paywall-btn.primary {
  background: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
}

.paywall-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.home-body {
  background: linear-gradient(180deg, #f8fafc 0%, #eef2ff 45%, #fef9f3 100%);
  padding-top: 72px;
}

.home-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 80px;
  display: grid;
  gap: 48px;
}

.home-hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
  align-items: center;
  background: radial-gradient(circle at top left, #e0f2fe 0%, rgba(224, 242, 254, 0) 55%),
    radial-gradient(circle at bottom right, #e9d5ff 0%, rgba(233, 213, 255, 0) 60%);
  border-radius: 24px;
  padding: 28px;
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.home-hero-content {
  display: grid;
  gap: 16px;
}

.home-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: #e0f2fe;
  color: #0369a1;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  width: fit-content;
}

.home-title {
  font-size: 34px;
  margin: 0;
  letter-spacing: -0.02em;
}

.home-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.home-cta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.home-btn {
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  text-decoration: none;
  font-weight: 700;
  font-size: 13px;
}

.home-btn.primary {
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  color: #fff;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.25);
}

.home-btn.secondary {
  background: rgba(255, 255, 255, 0.9);
  color: #2563eb;
  border-color: #bfdbfe;
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.12);
}

.home-hero-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 20px;
  display: grid;
  gap: 12px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.home-video-hero {
  display: grid;
  gap: 10px;
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
}

.home-video-hero-media {
  width: 100vw;
  height: auto;
  max-height: 100vh;
  min-height: 0;
  border-radius: 0;
  background: #0f172a;
  object-fit: contain;
  display: block;
  border: none;
  box-shadow: none;
}

.home-video-hero-caption {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}

.home-hero-media {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 12px;
  display: grid;
  gap: 10px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.home-hero-video {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  background: #0f172a;
  object-fit: cover;
  display: block;
}

.home-hero-media-caption {
  font-size: 12px;
  color: var(--muted);
}

.home-trust {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.trust-item {
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-radius: 12px;
  padding: 10px 14px;
  display: grid;
  gap: 4px;
  min-width: 120px;
}

.trust-item strong {
  font-size: 16px;
}

.trust-item span {
  font-size: 11px;
  color: var(--muted);
}

.home-hero-card-title {
  font-weight: 700;
  font-size: 14px;
}

.home-hero-card-body {
  color: var(--muted);
  font-size: 13px;
}

.home-hero-card-footer {
  font-size: 12px;
  color: #16a34a;
  font-weight: 700;
}

.home-seo {
  padding: 28px;
  border-radius: 24px;
  background: radial-gradient(circle at top left, rgba(37, 99, 235, 0.18), rgba(15, 23, 42, 0) 60%),
    linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.96));
  color: #e2e8f0;
  border: 1px solid rgba(148, 163, 184, 0.3);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.35);
}

.home-seo-inner {
  display: grid;
  gap: 16px;
  max-width: 900px;
}

.home-seo-card {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 16px;
  padding: 16px 18px;
  display: grid;
  gap: 8px;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.25);
}

.home-seo h2,
.home-seo h3,
.home-seo h4,
.home-seo h5 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.home-seo h2 {
  font-size: 18px;
  color: #bae6fd;
}

.home-seo h3 {
  font-size: 16px;
  color: #93c5fd;
}

.home-seo h4 {
  font-size: 15px;
  color: #a5b4fc;
}

.home-seo h5 {
  font-size: 14px;
  color: #c4b5fd;
}

.home-seo p {
  margin: 0;
  color: #cbd5f5;
  font-size: 14px;
  line-height: 1.7;
}

.readtime-btn {
  border: none;
  background: transparent;
  padding: 0;
  font-size: 12px;
  color: #16a34a;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.info-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.info-modal-overlay.is-open {
  display: flex;
}

.info-modal {
  width: min(520px, 92vw);
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 20px;
  display: grid;
  gap: 12px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
}

.info-modal-title {
  font-size: 16px;
  font-weight: 800;
  color: #0f172a;
}

.info-modal-list {
  margin: 0;
  padding-left: 18px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.6;
}

.info-modal-close {
  justify-self: end;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #1f2328;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}

.home-section {
  display: grid;
  gap: 20px;
}

.home-section.highlight {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(244, 114, 182, 0.12));
  border-radius: 20px;
  padding: 24px;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.home-section-header h2 {
  margin: 0 0 6px;
  font-size: 22px;
}

.home-section-header p {
  margin: 0;
  color: var(--muted);
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.home-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 16px;
  display: grid;
  gap: 8px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.home-card.emphasis {
  background: linear-gradient(135deg, #ffffff 0%, #f1f5ff 100%);
  border-color: rgba(99, 102, 241, 0.25);
}

.home-card h3 {
  margin: 0;
  font-size: 15px;
}

.home-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.home-card.outline {
  background: #f8fafc;
  border-style: dashed;
}

.home-grid.pricing {
  align-items: stretch;
}

.home-card.pricing {
  gap: 12px;
}

.home-card.pricing ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.home-card.pricing.featured {
  border-color: #2563eb;
  box-shadow: 0 18px 40px rgba(37, 99, 235, 0.22);
  transform: translateY(-6px);
}

.price-title {
  font-weight: 700;
  font-size: 14px;
}

.price-value {
  font-size: 22px;
  font-weight: 800;
}

.home-card.info {
  background: linear-gradient(135deg, #fefce8 0%, #fff7ed 100%);
  border-color: #fde68a;
}

.cta-final {
  background: linear-gradient(135deg, #1d4ed8 0%, #9333ea 100%);
  color: #fff;
  border-radius: 24px;
  padding: 28px;
  text-align: center;
}

.cta-final .home-section-header h2,
.cta-final .home-section-header p {
  color: #fff;
}

.cta-final .home-cta {
  justify-content: center;
}

.settings-toggle {
  position: fixed;
  top: 16px;
  left: 16px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid #2563eb;
  background: #dbeafe;
  color: #1d4ed8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 11;
}

.settings-toggle:hover {
  background: #bfdbfe;
}

.print-toggle {
  position: fixed;
  top: 16px;
  left: 136px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid #7c3aed;
  background: #ede9fe;
  color: #6d28d9;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 11;
}

.print-toggle:hover {
  background: #ddd6fe;
}

.print-toggle:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.print-toggle.is-hidden {
  display: none !important;
}

.save-toggle {
  position: fixed;
  top: 16px;
  left: 56px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid #16a34a;
  background: #dcfce7;
  color: #15803d;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 11;
}

.save-toggle:hover {
  background: #bbf7d0;
}

.logout-toggle {
  position: fixed;
  top: 16px;
  left: 96px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid #dc2626;
  background: #fee2e2;
  color: #b91c1c;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 11;
  text-decoration: none;
}

.logout-toggle:hover {
  background: #fecaca;
}

.sidebar {
  position: fixed;
  top: 72px;
  left: 16px;
  width: 220px;
  min-height: 200px;
  background: #e5e7eb;
  border: 1px solid var(--line);
  border-radius: 10px;
  display: none;
  padding: 10px;
}

.sidebar.is-open {
  display: block;
}

.sidebar-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-user {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  display: grid;
  gap: 4px;
}

.sidebar-search {
  display: grid;
}

.sidebar-search-input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 11px;
  background: #ffffff;
  outline: none;
}

.sidebar-search-input:focus {
  border-color: #94a3b8;
  box-shadow: 0 0 0 2px rgba(148, 163, 184, 0.2);
}

.sidebar-user-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}

.sidebar-user-value {
  font-size: 11px;
  color: var(--ink);
  word-break: break-all;
}

.sidebar-title {
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.sidebar-actions {
  display: grid;
  gap: 6px;
}

.sidebar-btn {
  border: 1px solid transparent;
  background: #f8fafc;
  color: var(--ink);
  padding: 5px 8px;
  font-size: 10px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sidebar-btn:hover {
  background: #e2e8f0;
}

.sidebar-btn.small {
  font-size: 9px;
  padding: 4px 6px;
}

.sidebar-btn#new-quote {
  background: #ecfeff;
  border-color: #06b6d4;
  color: #0e7490;
}

.sidebar-btn#save-copy {
  background: #dcfce7;
  border-color: #16a34a;
  color: #15803d;
}

.sidebar-btn#update-quote {
  background: #ede9fe;
  border-color: #7c3aed;
  color: #6d28d9;
}

.sidebar-btn#toggle-list {
  background: #fff7ed;
  border-color: #f59e0b;
  color: #b45309;
}

.sidebar-list {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.sidebar-list.is-hidden {
  display: none;
}

.sidebar-item {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  display: grid;
  gap: 6px;
}

.sidebar-item.is-selected {
  border-color: #94a3b8;
  box-shadow: 0 0 0 2px rgba(148, 163, 184, 0.4);
  background: rgba(148, 163, 184, 0.15);
}

.sidebar-item-title {
  font-weight: 700;
  font-size: 12px;
  color: var(--ink);
}

.sidebar-item-meta {
  font-size: 10px;
  color: var(--muted);
}

.sidebar-item-actions {
  display: flex;
  gap: 6px;
}

.sidebar-empty {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  padding: 8px 4px;
}

.preview {
  padding: 24px;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  padding-left: 260px;
}

.page {
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  background: #fff;
  padding: 18mm 14mm;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.08);
}

.header {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: 16px;
  align-items: start;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 12px;
}

.logo {
  border: 2px solid var(--ink);
  padding: 6px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  cursor: pointer;
  position: relative;
}

.logo.has-image {
  border-color: transparent;
}

.logo-image {
  max-width: 110px;
  height: auto;
  display: block;
}

.logo-placeholder {
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.08em;
}

.logo:not(.has-image) .logo-image {
  display: none;
}

.logo.has-image .logo-placeholder {
  display: none;
}

.logo-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  color: #111827;
  font-size: 12px;
  line-height: 1;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.logo.has-image .logo-remove {
  display: inline-flex;
}

.company {
  font-size: 12px;
  line-height: 1.5;
}

.company-name {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 4px;
}

.doc-meta {
  text-align: right;
  font-size: 12px;
}

.doc-title {
  font-weight: 800;
  font-size: 16px;
  margin-bottom: 6px;
}

.doc-legend {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.doc-field {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  color: var(--muted);
}

.doc-field strong {
  color: var(--ink);
  min-width: 70px;
  text-align: right;
}

.info-table {
  margin-top: 14px;
  border: 1px solid var(--ink);
}

.info-row {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  border-bottom: 1px solid var(--ink);
}

.info-row.small {
  grid-template-columns: 1fr 1fr;
}

.info-row:last-child {
  border-bottom: none;
}

.info-cell {
  padding: 8px 10px;
  border-right: 1px solid var(--ink);
  font-size: 12px;
}

.info-cell:last-child {
  border-right: none;
}

.cell-title {
  font-weight: 700;
  margin-bottom: 6px;
}

.cell-grid {
  display: grid;
  gap: 4px;
}

.cell-item {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px;
  border-bottom: 1px dotted #d1d5db;
  padding-bottom: 2px;
}

.cell-item span {
  color: var(--muted);
}

.client-cell .cell-item span {
  text-align: left;
  justify-self: start;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
  color: #111827;
}

.cell-item strong {
  justify-self: end;
  text-align: right;
  min-height: 1em;
  font-weight: 600;
  color: #111827;
}

.cell-note {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}

.items {
  margin-top: 18px;
}

.row-controls {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  justify-content: flex-end;
}

.btn {
  border: 1px solid var(--ink);
  background: #fff;
  color: var(--ink);
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 6px;
  cursor: pointer;
}

.btn:hover {
  background: #f3f4f6;
}

.table {
  border: 1px solid var(--ink);
  font-size: 11.5px;
}

.thead {
  display: grid;
  grid-template-columns: 4fr 0.6fr 1.2fr 1.2fr 0.6fr;
  background: #ffffff;
  font-weight: 700;
  border-bottom: 1px solid var(--ink);
  font-size: 11.5px;
}

.row {
  display: grid;
  grid-template-columns: 4fr 0.6fr 1.2fr 1.2fr 0.6fr;
  font-size: 11.5px;
  border-bottom: 1px solid var(--ink);
}

.col {
  padding: 8px 10px;
  border-right: 1px solid var(--ink);
}

.col:last-child {
  border-right: none;
}

.desc {
  line-height: 1.4;
  font-weight: 600;
  color: #111827;
}

.qty,
.unit,
.amount,
.vat {
  text-align: right;
  white-space: nowrap;
}

.totals {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 0;
  align-items: stretch;
  justify-content: start;
}

.totals-box {
  width: 100%;
  border: 1px solid var(--ink);
  border-radius: 10px 0 0 10px;
  border-right: none;
  padding: 10px 12px;
  font-size: 12px;
}

.accept-box {
  width: 100%;
  border: 1px solid var(--ink);
  border-radius: 0 10px 10px 0;
  border-left: none;
  padding: 10px 12px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.accept-title {
  font-weight: 700;
}

.accept-line {
  border-bottom: 1px solid var(--ink);
  height: 24px;
}

.accept-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.accept-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.accept-blank {
  display: inline-block;
  min-width: 120px;
  border-bottom: 1px solid var(--ink);
  height: 18px;
}

.total-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
}

.total-row.grand {
  font-weight: 800;
  border-top: 1px solid var(--ink);
  margin-top: 6px;
  padding-top: 8px;
}

.terms {
  margin-top: 18px;
  font-size: 12px;
  border: 1px solid var(--ink);
  padding: 10px 12px;
}

.terms-title {
  font-weight: 700;
  margin-bottom: 6px;
}

.signature {
  margin-top: 18px;
  color: var(--muted);
}

.footer {
  margin-top: 22px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.footer .thanks {
  color: var(--ink);
  font-weight: 700;
  margin-top: 6px;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  background: rgba(15, 23, 42, 0.9);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 12px;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 60;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

#pdf-render {
  position: fixed;
  top: 0;
  left: -10000px;
  opacity: 1;
  pointer-events: none;
  width: 210mm !important;
  min-height: 297mm !important;
  padding: 20mm !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  page-break-after: always;
  background: #ffffff;
  z-index: -1;
}

#pdf-render .page {
  width: 100% !important;
  max-width: 100% !important;
  min-height: calc(297mm - 40mm) !important;
  margin: 0 !important;
  padding: 0 !important;
  box-sizing: border-box !important;
  box-shadow: none !important;
}

#pdf-render .header {
  grid-template-columns: 1fr 2fr 1fr !important;
}

#pdf-render .info-row {
  grid-template-columns: 1.3fr 1fr !important;
}

#pdf-render .info-row.small {
  grid-template-columns: 1fr 1fr !important;
}

#pdf-render .totals {
  grid-template-columns: 280px 1fr !important;
}

#pdf-render .header {
  font-size: 12px !important;
}

#pdf-render .doc-title {
  font-size: 16px !important;
}

#pdf-render .company-name {
  font-size: 13px !important;
}

#pdf-render .table,
#pdf-render .thead,
#pdf-render .row {
  font-size: 11.5px !important;
}

#pdf-render .col {
  padding: 8px 10px !important;
}

#pdf-render .row-controls,
#pdf-render .logo-remove,
#pdf-render .settings-toggle,
#pdf-render .print-toggle,
#pdf-render .save-toggle,
#pdf-render .logout-toggle,
#pdf-render .sidebar {
  display: none !important;
}

#pdf-render,
#pdf-render .table,
#pdf-render .row,
#pdf-render .info-table,
#pdf-render .totals,
#pdf-render .terms,
#pdf-render .footer {
  break-inside: avoid;
  page-break-inside: avoid;
}

#pdf-render p,
#pdf-render div,
#pdf-render span {
  orphans: 3;
  widows: 3;
}

@media (max-width: 1300px) {
  .page {
    width: 100%;
    min-height: auto;
  }
}

@media (max-width: 900px) {
  .preview {
    padding: 16px;
  }

  .page {
    width: 100%;
    min-height: auto;
  }
}

@media (max-width: 768px) {
  .top-nav-inner {
    flex-direction: column;
    gap: 8px;
    padding: 12px;
  }

  .top-nav-links {
    flex-wrap: wrap;
    justify-content: center;
  }

  .home-hero {
    grid-template-columns: 1fr;
  }

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

  .home-title {
    font-size: 26px;
  }

  .home-cta {
    flex-direction: column;
  }

  .home-btn {
    width: 100%;
    text-align: center;
  }

  .preview {
    padding-left: 16px;
  }

  .sidebar {
    width: 100%;
    left: 0;
    right: 0;
    top: 60px;
  }

  .header {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .info-row {
    grid-template-columns: 1fr;
  }

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

  .totals-box {
    border-radius: 10px 10px 0 0;
    border-right: 1px solid var(--ink);
    border-bottom: none;
  }

  .accept-box {
    border-radius: 0 0 10px 10px;
    border-left: 1px solid var(--ink);
    border-top: none;
  }

  .accept-meta {
    grid-template-columns: 1fr;
  }

  .settings-toggle,
  .print-toggle,
  .save-toggle,
  .logout-toggle {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }

  .save-toggle {
    left: 46px;
  }

  .logout-toggle {
    left: 76px;
  }

  .print-toggle {
    left: 106px;
  }

  .auth-toggle {
    width: 36px;
    height: 36px;
    top: 12px;
    right: 12px;
  }

  .auth-card,
  .modal,
  .paywall-card {
    width: 95vw;
    padding: 20px;
  }

  .home-main {
    padding: 16px 12px 60px;
  }

  .home-video-hero {
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
  }

  .home-video-hero-media {
    height: 70vh;
    min-height: 360px;
  }

  .home-section {
    padding: 16px;
  }

  .home-trust {
    flex-direction: column;
  }

  .trust-item {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .top-nav {
    height: auto;
    min-height: 56px;
  }

  .top-nav-logo {
    font-size: 14px;
  }

  .top-nav-link {
    font-size: 12px;
  }

  .home-title {
    font-size: 22px;
  }

  .home-subtitle {
    font-size: 14px;
  }

  .home-badge {
    font-size: 11px;
    padding: 4px 10px;
  }

  .page {
    padding: 12mm 8mm;
  }

  .header {
    font-size: 11px;
  }

  .doc-title {
    font-size: 14px;
  }

  .company-name {
    font-size: 12px;
  }

  .table,
  .thead,
  .row {
    font-size: 10px;
  }

  .col {
    padding: 6px 8px;
  }

  .btn {
    padding: 5px 10px;
    font-size: 11px;
  }

  .row-controls {
    flex-direction: column;
    gap: 8px;
  }

  .row-controls .btn {
    width: 100%;
  }

  .settings-toggle,
  .print-toggle,
  .save-toggle,
  .logout-toggle {
    width: 26px;
    height: 26px;
    font-size: 11px;
    top: 12px;
  }

  .save-toggle {
    left: 40px;
  }

  .logout-toggle {
    left: 68px;
  }

  .print-toggle {
    left: 96px;
  }

  .sidebar {
    top: auto;
    bottom: 0;
    max-height: 70vh;
    border-radius: 10px 10px 0 0;
  }

  .paywall-card {
    padding: 16px;
  }

  .paywall-title {
    font-size: 15px;
  }

  .paywall-amount {
    font-size: 20px;
  }
}

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

  .page,
  #pdf-render,
  .pdf-wrapper {
    width: 210mm !important;
    min-height: 297mm !important;
    padding: 20mm !important;
    margin: auto !important;
    box-sizing: border-box !important;
    page-break-after: always;
    break-inside: avoid;
    page-break-inside: avoid;
    orphans: 3;
    widows: 3;
  }

  body.print-blocked .preview,
  body.print-blocked .page {
    display: none;
  }

  .preview {
    padding: 0;
  }

  .page {
    box-shadow: none;
    display: flex;
    flex-direction: column;
  }

  #doc-page {
    display: none;
  }

  .row-controls {
    display: none;
  }

  .sidebar,
  .settings-toggle {
    display: none;
  }

  .print-toggle {
    display: none;
  }

  .save-toggle {
    display: none;
  }

  .logout-toggle {
    display: none;
  }

  .logo-remove {
    display: none !important;
  }

  .header {
    grid-template-columns: 1fr 2fr 1fr;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .logo {
    justify-self: start;
  }

  .doc-meta {
    text-align: right;
    justify-self: end;
  }

  .info-row {
    grid-template-columns: 1.3fr 1fr;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .info-row.small {
    grid-template-columns: 1fr 1fr;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .items {
    flex: 1 1 auto;
  }

  .terms {
    margin-top: auto;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .table,
  .thead,
  .row,
  .totals,
  .footer {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .header p,
  .header div,
  .info-row p,
  .info-row div,
  .row p,
  .row div,
  .footer p,
  .footer div {
    orphans: 3;
    widows: 3;
  }
}

/* Hide interactive elements when preparing for PDF export */
.hide-interactive .logo-remove,
.hide-interactive #add-row,
.hide-interactive #remove-row,
.hide-interactive .row-controls,
.hide-interactive .edit-control {
  display: none !important;
}

[contenteditable="true"] {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

[contenteditable="true"]:focus {
  outline: 2px dashed #94a3b8;
  outline-offset: 2px;
  background: #f8fafc;
}

[contenteditable="true"][data-placeholder]:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
  display: block;
  text-align: right;
}

.client-cell [contenteditable="true"][data-placeholder]:empty::before {
  display: inline;
  text-align: left;
}

[data-placeholder]:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
}

/* Loader overlay styles */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.loader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(1px);
}

.loader-overlay.is-visible {
  display: flex;
}

.loader-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 4px solid #e5e7eb;
  border-top: 4px solid #2563eb;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loader-text {
  font-size: 16px;
  color: #333333;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* Cookie Consent Banner Styles */
.cookie-consent {
  position: fixed;
  bottom: -400px;
  left: 0;
  right: 0;
  background: #1f2328;
  color: #ffffff;
  padding: 20px;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
  z-index: 9998;
  transition: bottom 0.3s ease-in-out;
  font-family: "Segoe UI", Arial, sans-serif;
}

.cookie-consent.is-visible {
  bottom: 0;
}

.cookie-consent-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.cookie-consent-text {
  flex: 1 1 60%;
  min-width: 250px;
}

.cookie-consent-text strong {
  font-size: 16px;
  font-weight: 600;
  display: block;
  margin-bottom: 8px;
}

.cookie-consent-text p {
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
  color: #e5e7eb;
}

.cookie-consent-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex: 1 1 40%;
  min-width: 250px;
}

.cookie-consent-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.cookie-consent-btn.reject {
  background: transparent;
  color: #ffffff;
  border: 1px solid #6b7280;
}

.cookie-consent-btn.reject:hover {
  background: rgba(107, 114, 128, 0.1);
  border-color: #ffffff;
}

.cookie-consent-btn.accept {
  background: #2563eb;
  color: #ffffff;
}

.cookie-consent-btn.accept:hover {
  background: #1d4ed8;
}

@media (max-width: 768px) {
  .cookie-consent-content {
    flex-direction: column;
    align-items: stretch;
  }

  .cookie-consent-text {
    flex: 1 1 100%;
  }

  .cookie-consent-buttons {
    flex: 1 1 100%;
    justify-content: stretch;
  }

  .cookie-consent-btn {
    flex: 1;
  }
}
