:root {
  --page-bg: #f8faf9;
  --text-primary: #0f172a;
  --text-muted: #64748b;
  --surface: #ffffff;
  --surface-strong: #f1f5f9;
  --border: #e2e8f0;
  --accent: #00ab85;
  --header-height: 80px;
  color-scheme: light;
}

body.theme-light {
  --page-bg: #f8faf9;
  --text-primary: #0f172a;
  --text-muted: #64748b;
  --surface: #ffffff;
  --surface-strong: #f1f5f9;
  --border: #e2e8f0;
  --accent: #00ab85;
  color-scheme: light;
}

body.theme-dark {
  --page-bg: #0a1011;
  --text-primary: #f6fbf7;
  --text-muted: #b4beb7;
  --surface: #111a1c;
  --surface-strong: #1e2b2f;
  --border: #2d3b3f;
  --accent: #277940;
  color-scheme: dark;
}

#logo-dark {
  visibility: hidden;
  display: none;
  width: 170px;
}

#logo-light {
  visibility: visible;
  display: block;
  width: 170px;
}

#logo-icon-light,
#logo-icon-dark {
  display: none;
  width: 48px;
  height: 48px;
  object-fit: contain;
}

body.theme-dark #logo-dark {
  visibility: visible;
  display: block;
}

body.theme-dark #logo-light {
  visibility: hidden;
  display: none;
}

body.theme-light #logo-dark {
  visibility: hidden;
  display: none;
}

body.theme-light #logo-light {
  visibility: visible;
  display: block;
}

body.theme-light #logo-icon-light,
body.theme-light #logo-icon-dark,
body.theme-dark #logo-icon-light,
body.theme-dark #logo-icon-dark,
body.theme-auto #logo-icon-light,
body.theme-auto #logo-icon-dark {
  display: none;
}

@media (prefers-color-scheme: dark) {

  body.theme-auto,
  body:not(.theme-light):not(.theme-dark) {
    --page-bg: #0a1011;
    --text-primary: #f6fbf7;
    --text-muted: #b4beb7;
    --surface: #111a1c;
    --surface-strong: #1e2b2f;
    --border: #2d3b3f;
    --accent: #277940;
    color-scheme: dark;
  }

  body.theme-auto #logo-dark,
  body:not(.theme-light):not(.theme-dark) #logo-dark {
    visibility: visible;
    display: block;
  }

  body.theme-auto #logo-light,
  body:not(.theme-light):not(.theme-dark) #logo-light {
    visibility: hidden;
    display: none;
  }
}

* {
  box-sizing: border-box;
}


@font-face {
  font-family: 'GreenPower-Eurostile';
  src: url('fonts/EurostileExtendedBlack.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: Axiforma;
  src: url('fonts/AXIFORMA/Axiforma-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: Axiforma;
  src: url('fonts/AXIFORMA/Axiforma-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

body {
  margin: 0;
  padding: var(--header-height) 20px 20px;
  font-family: Axiforma, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  background: var(--page-bg);
  color: var(--text-primary);
  transition: background 0.4s ease, color 0.4s ease;
  font-size: calc(1rem * var(--font-scale, 1));
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

/* Debug: outline all elements for layout troubleshooting */
/* outline disabled */

#page-loader {
  position: fixed;
  inset: 0;
  background: var(--page-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

#page-loader.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.loader-card {
  display: grid;
  gap: 0.75rem;
  justify-items: center;
  padding: 1.5rem 2rem;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.15);
}

.loader-spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

body:not(.page-loaded) header,
body:not(.page-loaded) main,
body:not(.page-loaded) footer {
  opacity: 0;
}

body:not(.page-loaded) {
  overflow: hidden;
  height: 100vh;
}

body.page-loaded header,
body.page-loaded main,
body.page-loaded footer {
  opacity: 1;
  transition: opacity 0.6s ease;
}

.noscript-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 14, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  color: #fff;
  text-align: center;
  padding: 2rem;
}

.noscript-card {
  max-width: 520px;
  background: rgba(20, 26, 30, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.noscript-card h2 {
  margin-top: 0;
}

input,
select,
button,
textarea {
  font-family: Axiforma, sans-serif;
  font-size: 1em;
}

@keyframes gp-autofill-start {
  from {}

  to {}
}

@keyframes gp-autofill-cancel {
  from {}

  to {}
}

input:-webkit-autofill {
  animation-name: gp-autofill-start;
  animation-duration: 0.01s;
  animation-iteration-count: 1;
}

input:not(:-webkit-autofill) {
  animation-name: gp-autofill-cancel;
  animation-duration: 0.01s;
  animation-iteration-count: 1;
}

input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
}

#email:disabled {
  background: var(--surface-strong);
  color: var(--text-primary);
  border-color: var(--border);
  opacity: 0.7;
}

button {
  cursor: pointer;
}

::selection {
  background: rgba(0, 171, 133, 0.35);
  color: #0a1f1c;
}

::-moz-selection {
  background: rgba(0, 171, 133, 0.35);
  color: #0a1f1c;
}

body.theme-dark ::selection {
  color: #ffffff;
}

body.theme-dark ::-moz-selection {
  color: #ffffff;
}

header h1,
.form-section legend,
h2,
h3,
h4 {
  font-family: 'GreenPower-Eurostile', sans-serif;
  font-weight: normal; /* Prevent browser from trying to bold an already black font */
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  background: var(--page-bg);
  border-bottom: none;
  box-shadow: none;
  padding: 0 20px;
  margin: 0;
  height: var(--header-height);
}




body.theme-dark header {
  background: var(--page-bg);
  border-bottom: none;
  box-shadow: none;
}

@media (prefers-color-scheme: dark) {

  body.theme-auto header,
  body:not(.theme-light):not(.theme-dark) header {
    background: var(--page-bg);
    border-bottom: none;
    box-shadow: none;
  }
}

header h1 {
  font-size: 1.3rem;
  position: relative;
  display: inline-block;
  line-height: 1.2;
}

.beta-tag {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0;
  font-family: Axiforma, sans-serif;
  font-size: 0.48rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent) 0%, #00896a 100%);
  color: #fff;
  padding: 3px 9px;
  border-radius: 100px;
  letter-spacing: 0.1em;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 171, 133, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.15);
  overflow: hidden;
  text-transform: uppercase;
  white-space: nowrap;
  animation: beta-glow 3s infinite ease-in-out;
}

.beta-tag::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.4),
    transparent
  );
  animation: beta-shimmer 4s infinite linear;
}

@keyframes beta-shimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

@keyframes beta-glow {
  0% { box-shadow: 0 4px 12px rgba(0, 171, 133, 0.25); transform: scale(1); }
  50% { box-shadow: 0 4px 20px rgba(0, 171, 133, 0.5); transform: scale(1.02); }
  100% { box-shadow: 0 4px 12px rgba(0, 171, 133, 0.25); transform: scale(1); }
}



#font-controls {
  display: grid;
  gap: 0.4rem;
  align-items: start;
}

.font-size-controls {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
}

.info-button>span {
  transform: translateY(2.7px);
}

#font-controls .font-size-label {
  font-weight: 600;
  font-size: 0.9rem;
}

#font-controls button {
  padding: 0.45rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text-primary);
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

#font-size-input {
  width: 72px;
  padding: 0.4rem 0.5rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text-primary);
  font-size: 0.9rem;
  text-align: center;
}

.settings-section input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.settings-section button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  filter: grayscale(0.2);
}

.field-hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-primary);
  opacity: 0.7;
}


#font-controls .icon {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1;
}

#font-controls .label {
  font-weight: 700;
  font-size: 0.95rem;
}

body.button-display-both #settings-button.icon-only-button,
body.button-display-icon-only #settings-button.icon-only-button {
  width: 3.1rem;
  height: 3.1rem;
  padding: 0;
  justify-content: center;
}

#settings-overlay,
#company-manage-overlay,
#company-add-overlay,
#product-manage-overlay,
#product-add-overlay,
#user-manage-overlay,
#user-edit-overlay,
#preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 14, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 80;
}

.hidden {
  display: none;
}

#settings-overlay.hidden,
#export-overlay.hidden,
#company-manage-overlay.hidden,
#company-add-overlay.hidden,
#product-manage-overlay.hidden,
#product-add-overlay.hidden,
#user-manage-overlay.hidden,
#user-edit-overlay.hidden,
#preview-overlay.hidden {
  display: none;
}

#settings-overlay:not(.hidden),
#company-manage-overlay:not(.hidden),
#company-add-overlay:not(.hidden),
#product-manage-overlay:not(.hidden),
#product-add-overlay:not(.hidden),
#user-manage-overlay:not(.hidden),
#user-edit-overlay:not(.hidden),
#preview-overlay:not(.hidden) {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

body.settings-open {
  overflow: hidden;
}

body.company-open {
  overflow: hidden;
}

body.product-open {
  overflow: hidden;
}

html.modal-open,
body.modal-open {
  overflow: hidden;
  height: 100%;
  overscroll-behavior: none;
}

.settings-panel {
  width: min(720px, calc(100% - 2rem));
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 0;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
  max-height: calc(100vh - 3rem);
  overflow: auto;
}

.preview-panel {
  width: min(1100px, calc(100% - 2rem));
  display: flex;
  flex-direction: column;
  height: calc(100vh - 4rem);
  max-height: 900px;
  overflow: hidden;
}

.preview-panel .settings-header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem;
}

.preview-panel .header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.preview-panel .settings-body {
  padding: 0;
  background: var(--page-bg);
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#preview-results {
  flex: 1;
  width: 100%;
  height: 100%;
  background: #525659;
  /* Standard PDF viewer background */
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  /* Momentum scrolling for mobile */
}

#preview-results iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
  display: block;
}

.preview-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: white;
  text-align: center;
}

.loader-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.preview-error {
  color: #ff4d4d;
  background: rgba(255, 77, 77, 0.1);
  padding: 2rem;
  border-radius: 12px;
  text-align: center;
}

/* Canvas-based PDF preview for mobile */
#preview-results.pdf-canvas-scroll {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.pdf-canvas-page {
  display: flex;
  justify-content: center;
  padding: 8px 0;
}

.pdf-canvas-page:first-child {
  padding-top: 12px;
}

.pdf-canvas-page:last-child {
  padding-bottom: 12px;
}

.pdf-canvas-page canvas {
  display: block;
  max-width: 100%;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  background: white;
}

@media (max-width: 640px) {
  .preview-panel {
    height: calc(100vh - 2rem);
    max-height: none;
    width: calc(100% - 1rem);
  }

  .preview-panel #preview-download .button-label,
  .preview-panel #preview-full-screen .button-label {
    display: none;
  }

  .preview-panel #preview-download,
  .preview-panel #preview-full-screen {
    padding: 0;
    width: 40px;
    height: 40px;
    justify-content: center;
  }

  .preview-panel .settings-header {
    padding: 0.75rem 1rem;
  }

  .preview-panel .header-actions {
    gap: 0.5rem;
  }
}

.company-panel {
  width: min(860px, calc(100% - 2rem));
}

.company-panel input {
  width: 100%;
  padding: 0.6em;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text-primary);
}

.product-panel,
.user-panel {
  width: min(720px, calc(100% - 2rem));
}

.product-panel input,
.product-panel textarea {
  width: 100%;
  padding: 0.6em;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text-primary);
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: var(--surface);
  padding: 1.25rem 1.5rem;
  z-index: 2;
  box-shadow: none;
}

#company-manage-overlay .settings-header,
#company-add-overlay .settings-header {
  position: static;
  box-shadow: none;
}

#settings-close,
#preview-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text-primary);
  font-size: 0.95rem;
}

#company-manage-close,
#company-add-close,
#product-manage-close,
#product-add-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text-primary);
  font-size: 0.95rem;
}

#settings-close:hover,
#preview-close:hover,
#company-manage-close:hover,
#company-add-close:hover,
#product-manage-close:hover,
#product-add-close:hover,
#user-manage-close:hover,
#user-edit-close:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.16);
  transform: translateY(-1px);
}

#settings-close:active,
#preview-close:active,
#company-manage-close:active,
#company-add-close:active,
#product-manage-close:active,
#product-add-close:active {
  transform: translateY(0);
  box-shadow: none;
}

.settings-body {
  display: grid;
  gap: 1.5rem;
  padding: 1rem 1.5rem 1.5rem;
}

.settings-section {
  display: grid;
  gap: 0.75rem;
}

.setting-group {
  display: grid;
  gap: 0.5rem;
}

.setting-title {
  font-weight: 600;
}

.setting-group .pill-switch {
  width: fit-content;
  max-width: 100%;
  align-self: flex-start;
}

.settings-note {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-primary);
  opacity: 0.8;
}

.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch .slider {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background 0.2s ease, border-color 0.2s ease;
  flex-shrink: 0;
  cursor: pointer;
}

.switch .slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  top: 2px;
  left: 2px;
  transition: transform 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.switch input:checked+.slider {
  background: var(--accent);
  border-color: var(--accent);
}

.switch input:checked+.slider::before {
  transform: translateX(20px);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.settings-grid .action-button {
  width: 100%;
  justify-content: flex-start;
  padding: 0.75rem 1rem;
  height: auto;
}

.pill-switch {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 0.35rem;
  padding: 0.3rem;
  border-radius: 999px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: thin;
}

.pill-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.pill-switch .pill-highlight {
  position: absolute;
  top: 0.3rem;
  left: 0.3rem;
  height: calc(100% - 0.6rem);
  border-radius: 999px;
  background: var(--accent);
  transition: transform 0.22s ease, width 0.22s ease;
  z-index: 0;
}

.pill-switch label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: background 0.2s ease, color 0.2s ease;
  position: relative;
  z-index: 1;
}

.pill-switch label span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pill-switch input:checked+span {
  color: #fff;
}

.settings-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

#settings-reset {
  border: 1px solid rgba(196, 46, 46, 0.6);
  background: rgba(196, 46, 46, 0.12);
  color: #c42e2e;
}

#settings-save {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

#settings-clear-all {
  border: 1px solid rgba(196, 46, 46, 0.6);
  background: rgba(196, 46, 46, 0.12);
  color: #c42e2e;
}

.settings-grid label {
  display: grid;
  gap: 0.3rem;
}

.settings-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.settings-inline input {
  width: 90px;
  text-align: right;
}

.settings-grid input {
  width: 100%;
  padding: 0.6em;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text-primary);
}

.company-card {
  position: relative;
}

.company-manage {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

.input-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.input-label-row h3 {
  margin: 0;
}

#company-sites,
#company-contacts {
  display: grid;
  gap: 0.75rem;
  padding-top: 0.2rem;
  overflow-x: auto;
}

.manage-search {
  width: 100%;
}

.company-list {
  display: grid;
  gap: 0.6rem;
}

.company-list-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
}

.company-list-name {
  font-weight: 600;
}

.company-list-item button {
  width: auto;
  height: auto;
  padding: 0;
  border-radius: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

.product-list {
  display: grid;
  gap: 0.6rem;
}

.product-list-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
}

.product-list-name {
  font-weight: 600;
}

.product-list-meta {
  font-size: 0.85rem;
  opacity: 0.8;
}

.product-list-item button {
  width: auto;
  height: auto;
  padding: 0;
  border-radius: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

.delete-button {
  color: #c42e2e !important;
  border-color: transparent !important;
  background: transparent !important;
}

.delete-button .icon,
.delete-button i {
  color: #c42e2e !important;
}

.company-row {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(4, minmax(160px, 1fr)) auto;
  align-items: center;
  overflow: visible;
  min-width: 760px;
  padding: 0.2rem 0.15rem 0.35rem;
}

.company-row input {
  width: 100%;
  padding: 0.6em;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text-primary);
}

.company-row .remove-product {
  width: 36px;
  height: 36px;
  justify-self: end;
  align-self: center;
}

#setting-history-count {
  text-align: right;
}

@media (max-width: 640px) {
  :root {
    --header-height: 64px;
  }

  header {
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
  }

  header h1 {
    font-size: 1.1rem;
  }

  #logo-light,
  #logo-dark,
  body.theme-dark #logo-dark,
  body.theme-light #logo-light,
  body.theme-auto #logo-dark,
  body.theme-auto #logo-light,
  body:not(.theme-light):not(.theme-dark) #logo-dark,
  body:not(.theme-light):not(.theme-dark) #logo-light {
    display: none !important;
  }

  #logo-icon-light,
  #logo-icon-dark {
    display: block;
  }

  #font-controls {
    align-self: flex-end;
  }

  #font-controls button {
    padding: 0.35rem 0.55rem;
    font-size: 0.8rem;
  }

  #font-controls .icon {
    font-size: 0.85rem;
  }

  #font-controls .label {
    font-size: 0.8rem;
  }
}

@media (max-width: 640px) {
  body.theme-dark #logo-icon-light {
    display: none !important;
  }

  body.theme-dark #logo-icon-dark {
    display: block !important;
  }

  body.theme-light #logo-icon-light {
    display: block !important;
  }

  body.theme-light #logo-icon-dark {
    display: none !important;
  }
}

@media (prefers-color-scheme: dark) and (max-width: 640px) {

  body.theme-auto #logo-icon-light,
  body:not(.theme-light):not(.theme-dark) #logo-icon-light {
    display: none !important;
  }

  body.theme-auto #logo-icon-dark,
  body:not(.theme-light):not(.theme-dark) #logo-icon-dark {
    display: block !important;
  }
}

@media (prefers-color-scheme: light) and (max-width: 640px) {

  body.theme-auto #logo-icon-light,
  body:not(.theme-light):not(.theme-dark) #logo-icon-light {
    display: block !important;
  }

  body.theme-auto #logo-icon-dark,
  body:not(.theme-light):not(.theme-dark) #logo-icon-dark {
    display: none !important;
  }
}

main {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1.5rem;
  align-items: start;
  max-width: 100%;
}

@media (max-width: 640px) {
  main {
    grid-template-columns: 1fr;
  }
}

#quote-form {
  min-width: 0;
}

#quote-results {
  min-width: 0;
}

@media (min-width: 900px) {
  #quote-results {
    position: static;
    top: auto;
    max-height: none;
    overflow: visible;
    padding-bottom: 0;
  }
}

form {
  display: grid;
  gap: 1rem;
}

.form-section {
  display: grid;
  gap: 0.75rem;
  padding: 1.25rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  min-width: 0;
  position: relative;
}

.form-section legend {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.info-button {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

body.hide-info-icons .info-button,
body.hide-info-icons .info-card {
  display: none !important;
}

.info-card {
  display: none;
  position: absolute;
  top: 12px;
  right: 12px;
  max-width: 280px;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
  font-size: 0.9rem;
  line-height: 1.4;
  z-index: 5;
}

.info-card.is-open {
  display: block;
}

.info-card::before {
  content: '';
  position: absolute;
  top: 12px;
  left: -8px;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-right: 8px solid var(--surface-strong);
}

.info-card::after {
  content: '';
  position: absolute;
  top: 12px;
  left: -9px;
  width: 0;
  height: 0;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-right: 9px solid var(--border);
}

.validation-summary {
  margin: 0.6rem 0 0;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(196, 46, 46, 0.45);
  background: rgba(196, 46, 46, 0.08);
  color: var(--text-primary);
  display: grid;
  gap: 0.4rem;
  position: relative;
  cursor: pointer;
}

.validation-summary:empty {
  display: none;
}

.validation-summary ul {
  margin: 0;
  padding-left: 1.1rem;
}

.validation-summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  text-align: left;
}

.validation-summary .validation-toggle {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.validation-summary.is-collapsed ul {
  display: none;
}

.toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  line-height: 1;
  width: 1.25rem;
}

.field-error {
  margin: 0.2rem 0 0;
  font-size: 0.85rem;
  color: #c42e2e;
}

.prefix-field {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.prefix-text {
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.prefix-field input {
  flex: 1;
  min-width: 0;
}

.suffix-field {
  position: relative;
  display: flex;
  align-items: center;
}

.suffix-text {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-weight: 400;
  color: var(--text-primary);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0.7;
}

.suffix-field input {
  flex: 1;
  min-width: 0;
  padding-right: 14.5rem;
}

.unit-label {
  padding: 0 0.4rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.input-error,
.form-section input.input-error,
.form-section select.input-error,
.form-section textarea.input-error {
  border-color: rgba(196, 46, 46, 0.95);
  box-shadow: 0 0 0 2px rgba(196, 46, 46, 0.22);
}

.form-section input.input-error:focus,
.form-section select.input-error:focus,
.form-section textarea.input-error:focus {
  border-color: rgba(196, 46, 46, 0.95);
  box-shadow: 0 0 0 2px rgba(196, 46, 46, 0.28);
}

input[type='date'] {
  resize: none;
}

#valid-from {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.section-actions {
  display: inline-flex;
  gap: 0.5rem;
}

.section-title-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

body .icon-only-button .button-label,
body .icon-only-button .label {
  display: none;
}

body.button-display-text-only .icon-text-button i,
body.button-display-text-only .icon-text-button .icon {
  display: none;
}

body.button-display-icon-only .icon-text-button .button-label,
body.button-display-icon-only .icon-text-button .label {
  display: none;
}

body.button-display-icon-text .icon-only-button .button-label,
body.button-display-text-only .icon-only-button .button-label {
  display: inline;
}

body.button-display-text-only .icon-only-button i,
body.button-display-text-only .icon-only-button .icon,
body.button-display-text-only .icon-only-button .button-icon {
  display: none;
}

body.button-display-text-only .remove-product .button-icon {
  display: inline-flex;
}

body.button-display-icon-only .icon-only-button .button-label {
  display: none;
}

body.button-display-text-only .icon-text-button,
body.button-display-icon-only .icon-text-button {
  justify-content: center;
  gap: 0;
}

body.button-display-icon-text .icon-only-button {
  justify-content: center;
  gap: 0.4rem;
}

body.button-display-both .icon-only-button {
  justify-content: center;
  gap: 0;
}

#toggle-summary {
  padding: 0;
  border-radius: 0;
  border: none;
  background: transparent;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  flex-direction: row-reverse;
}


#toggle-history {
  padding: 0;
  border-radius: 0;
  border: none;
  background: transparent;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  flex-direction: row-reverse;
}

#pdf-history-content.is-collapsed {
  display: none;
}

#reload-page {
  padding: 0;
  min-height: auto;
  border-radius: 0;
  border: none;
  background: transparent;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
}

body.button-display-both #reload-page,
body.button-display-icon-only #reload-page {
  width: auto;
  height: auto;
  padding: 0;
  gap: 0.35rem;
}

.form-section legend {
  padding: 0 0.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.field-row label {
  margin-bottom: 0.3rem;
}

.field-row>div {
  display: grid;
  min-width: 0;
}



.form-section input,
.form-section select,
.form-section textarea {
  width: 100%;
  padding: 0.65em;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text-primary);
  resize: vertical;
}

.form-section input:focus,
.form-section select:focus,
.form-section textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 171, 133, 0.18);
  outline: none;
}

.form-section input::selection,
.form-section textarea::selection {
  background: rgba(0, 171, 133, 0.28);
}

.product-name-field {
  position: relative;
}

.product-suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
  max-height: 350px;
  overflow-y: auto;
  z-index: 10;
  padding: 6px;
  display: none;
}

.product-suggestions.is-open {
  display: block;
}

.product-suggestion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.product-suggestion small {
  opacity: 0.7;
}

.product-suggestion.is-active,
.product-suggestion:hover {
  background: var(--surface-strong);
}

.form-details {
  display: grid;
  gap: 0.75rem;
  min-width: 0;
}

.form-details summary {
  cursor: pointer;
  font-weight: 600;
}

.form-details summary {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  min-width: 0;
}

.form-details summary .fa-chevron-down {
  font-size: 0.85rem;
  transition: transform 0.2s ease;
}

.form-details summary .inline-switch {
  margin-left: auto;
}

@media (max-width: 640px) {
  .form-details summary {
    flex-wrap: wrap;
  }

  .form-details summary>span {
    min-width: 0;
    flex: 1 1 auto;
    overflow-wrap: anywhere;
  }

  .form-details summary .inline-switch {
    margin-left: 0;
    width: 100%;
    justify-content: space-between;
  }
}

.form-details[open] summary .fa-chevron-down {
  transform: rotate(180deg);
}

.inline-switch {
  gap: 0.5rem;
}

.inline-switch>span {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.product-line {
  display: grid;
  grid-template-columns: 2.4fr 0.6fr 0.8fr auto;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.75rem;
  animation: rowFadeIn 0.2s ease;
}

.product-line.is-blank input {
  background: rgba(223, 231, 222, 0.5);
  border-color: rgba(197, 208, 196, 0.6);
}

@keyframes rowFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.product-line select,
.product-line input[type='number'],
.product-line input[type='text'] {
  width: 100%;
  padding: 0.65em;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text-primary);
  min-height: 44px;
  height: 44px;
}

.remove-product {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid rgba(196, 46, 46, 0.35);
  background: rgba(196, 46, 46, 0.08);
  color: #c42e2e;
  font-size: 1.1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.remove-product.is-hidden {
  visibility: hidden;
  pointer-events: none;
}


body.button-display-text-only .remove-product,
body.button-display-icon-text .remove-product {
  width: auto;
  height: 44px;
  padding: 0.35rem 0.7rem;
  border-radius: 10px;
  font-size: 0.95rem;
}

.remove-product:hover {
  box-shadow: none;
  background: #c42e2e;
  color: #ffffff;
  border-color: rgba(196, 46, 46, 0.75);
  transform: none;
}

.remove-product .button-icon {
  font-size: 1.45rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1em;
  height: 1em;
  text-align: center;
  transform: translateY(2px);
}

#results {
  min-height: 150px;
  background: var(--surface-strong);
  border-radius: 12px;
  border: 1px dashed var(--border);
  padding: 1rem;
}

#results table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

#results th,
#results td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
  word-break: break-word;
  overflow-wrap: anywhere;
}

#results .price-note {
  font-size: 0.85em;
  font-weight: 500;
  opacity: 0.7;
}


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

.summary-grid.summary-grid-stack {
  grid-template-columns: 1fr;
}

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

@media (min-width: 641px) {
  .info-card {
    left: auto;
    right: 12px;
    bottom: auto;
    max-width: 280px;
    width: auto;
    transform: translateY(-45px);
  }
}

@media (max-width: 640px) {
  .info-card {
    right: auto;
    left: 12px;
    top: 12px;
    max-width: calc(100% - 24px);
  }

  .info-card::before,
  .info-card::after {
    display: none;
  }
}

#pdf-actions {
  margin-top: 1rem;
  width: 100%;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

#pdf-actions .action-button {
  height: 40px;
  font-size: 0.9rem;
  padding: 0 1rem;
}

#pdf-actions.is-floating {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  width: min(560px, calc(100% - 3rem));
  z-index: 50;
}

@media (max-width: 900px) {
  #pdf-actions.is-floating {
    left: 1rem;
    right: 1rem;
    width: auto;
  }
}

@media (max-width: 640px) {
  #pdf-actions.is-floating {
    bottom: calc(10px + env(safe-area-inset-bottom));
    left: 10px;
    right: 10px;
    width: auto;
    max-width: calc(100% - 20px);
  }
}

@media (max-width: 640px) {
  #pdf-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
  }

  #pdf-actions .action-button {
    height: 40px;
    padding: 0 1rem;
    font-size: 0.9rem;
    border-radius: 20px;
  }

  #download-pdf {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
  }

  #settings-button {
    width: fit-content;
    justify-self: end;
  }
}

@media (max-width: 900px) {
  main {
    padding-bottom: calc(7rem + env(safe-area-inset-bottom));
  }
}

.action-button {
  border-radius: 20px;
  height: 3.1rem;
  padding: 0 1.3rem;
  font-size: 1.05rem;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}

.action-button.action-secondary {
  background: var(--surface-strong);
  color: var(--text-primary);
  border-color: var(--border);
}

.action-button:disabled {
  background: #9aa3a0;
  color: #f3f3f3;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
  border-color: transparent;
}

.action-button.is-disabled,
.action-button[aria-disabled='true'] {
  background: #9aa3a0;
  color: #f3f3f3;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
  border-color: transparent;
}

.action-button.action-secondary:disabled {
  background: var(--surface-strong);
  color: var(--text-primary);
  border-color: var(--border);
  opacity: 0.55;
}

.action-button.action-secondary.is-disabled,
.action-button.action-secondary[aria-disabled='true'] {
  background: var(--surface-strong);
  color: var(--text-primary);
  border-color: var(--border);
  opacity: 0.55;
}

#email-quote {
  flex: 1 1 220px;
}

#download-pdf {
  flex: 1 1 240px;
  justify-content: flex-start;
}

#download-pdf .icon-right {
  margin-left: auto;
}

#settings-button {
  flex: 0 0 auto;
}

#pdf-actions .action-button {
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

#pdf-actions .action-button:hover:not(:disabled):not([aria-disabled='true']) {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.12);
  transform: translateY(-1px);
}

#pdf-actions .action-button:active:not(:disabled):not([aria-disabled='true']) {
  transform: translateY(0);
  box-shadow: none;
}

.action-button .icon {
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0;
  border-radius: 0;
  border: none;
  background: transparent;
  line-height: 1;
}

#download-pdf {
  flex: 1;
}

#fill-test.action-secondary {
  width: 180px;
  background: var(--surface-strong);
  color: var(--text-primary);
  border-color: var(--border);
}

#fill-test.action-secondary:hover {
  background: var(--surface);
  border-color: var(--accent);
}

#pdf-disabled-note {
  display: none;
}

.pdf-status {
  margin-top: 0.6rem;
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.pdf-status-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  min-width: 0;
  flex: 1 1 320px;
}


.pdf-status.is-hidden {
  display: none;
}

.pdf-status.is-error {
  border-color: rgba(196, 46, 46, 0.6);
  background: rgba(196, 46, 46, 0.08);
}

.pdf-status.is-success {
  border-color: rgba(29, 127, 61, 0.45);
  background: rgba(29, 127, 61, 0.08);
}

#pdf-last-generated {
  margin-left: auto;
  font-size: 0.85rem;
  opacity: 0.75;
}

.export-panel {
  margin-top: 1rem;
  padding: 1.25rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: grid;
  gap: 0.75rem;
  transition: opacity 0.25s ease;
}

.export-panel.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  user-select: none;
}

.export-panel.is-disabled * {
  pointer-events: none;
}

.export-panel .section-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.export-panel .section-actions .icon-text-button {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: inherit;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.section-header #view-preview.icon-text-button,
.section-header #clear-form.icon-text-button,
.section-header #settings-button.icon-text-button {
  background: var(--surface-strong);
  border: 1px solid var(--border);
  color: var(--text-primary);
  height: 38px;
  padding: 0 1.1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.section-header #settings-button.icon-text-button {
  width: 38px;
  padding: 0;
  flex-shrink: 0;
}

.section-header #view-preview.icon-text-button:hover:not(:disabled),
.section-header #clear-form.icon-text-button:hover:not(:disabled),
.section-header #settings-button.icon-text-button:hover:not(:disabled) {
  background: var(--surface);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

#main-generate-btn {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#main-generate-btn:hover:not(:disabled) {
  transform: translateY(-3px);
  box-shadow: 0 15px 35px rgba(0, 171, 133, 0.35) !important;
  filter: brightness(1.1);
}

#main-generate-btn:active {
  transform: translateY(-1px);
}

#main-generate-btn:disabled,
#main-generate-btn[disabled],
.action-button:disabled,
.action-button[disabled] {
  background: #2a2a2a !important; /* Force a dark grey */
  border-color: #444 !important;
  color: #888 !important;
  cursor: not-allowed !important;
  box-shadow: none !important;
  transform: none !important;
  opacity: 0.6 !important;
  filter: grayscale(1) !important;
}

#main-generate-btn:disabled *,
#main-generate-btn[disabled] * {
  cursor: not-allowed !important;
  pointer-events: none !important;
}

.icon-text-button.action-primary {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #ffffff !important;
}

.icon-text-button.action-primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 85%, #000) !important;
  border-color: color-mix(in srgb, var(--accent) 85%, #000) !important;
  color: #ffffff !important;
}

#export-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 14, 0.45);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
  animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.export-modal-panel {
  width: min(540px, 100%);
  background: var(--surface);
  border-radius: 20px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
  animation: modalSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideUp {
  from { transform: translateY(20px); }
  to { transform: translateY(0); }
}

.export-modal-panel .settings-header {
  padding: 1.5rem 1.75rem;
  background: linear-gradient(to right, rgba(0, 171, 133, 0.05), transparent);
  border-bottom: 1px solid var(--border);
}

.export-modal-panel .settings-body {
  padding: 2rem;
  display: grid;
  gap: 2rem;
}

.modal-section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
}

.modal-section-title label {
  font-family: 'GreenPower-Eurostile', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text-primary);
  text-transform: uppercase;
}

.share-input-group {
  display: flex;
  background: var(--surface-strong);
  border-radius: 12px;
  padding: 4px;
  border: 1.5px solid var(--border);
  transition: all 0.2s ease;
}

.share-input-group:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 171, 133, 0.15);
}

.share-input-group input {
  background: transparent !important;
  border: none !important;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  color: var(--text-primary);
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

.share-input-group .action-button {
  background: transparent;
  color: var(--text-primary);
  height: auto;
  min-height: 40px;
  padding: 0 0.85rem;
  border-radius: 8px;
  box-shadow: none;
  border: none;
}

.share-input-group .action-button:hover:not(:disabled) {
  background: var(--surface);
  color: var(--accent);
  transform: none;
  box-shadow: var(--shadow-sm);
}

.share-input-group .action-button .icon {
  font-size: 1.1rem;
}

.share-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.export-full textarea {
  width: 100%;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-secondary);
  resize: none;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

.export-full label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.section-header #view-preview.icon-text-button:active:not(:disabled),
.section-header #clear-form.icon-text-button:active:not(:disabled),
.section-header #settings-button.icon-text-button:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: none;
}

.export-panel .section-actions .icon-text-button:visited {
  color: inherit;
}

.export-panel .section-actions .icon-text-button .icon {
  display: inline-flex;
  align-items: center;
}

.export-panel .section-actions .icon-text-button:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.12);
  transform: translateY(-1px);
}

.export-panel .section-actions .icon-text-button:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: none;
}

.export-panel .section-actions .icon-text-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.export-panel .section-actions .icon-text-button.is-disabled,
.export-panel .section-actions .icon-text-button[aria-disabled='true'] {
  opacity: 0.55;
  cursor: not-allowed;
}

.export-panel .section-actions #download-attachments {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.export-panel .section-actions #download-attachments:hover:not(:disabled) {
  box-shadow: 0 10px 20px rgba(14, 38, 87, 0.25);
}

.export-full {
  width: 100%;
}

.export-panel textarea {
  width: 100%;
  padding: 0.65em;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text-primary);
  resize: vertical;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

.share-input-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  background: var(--surface-strong);
  padding: 0.35rem;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.share-input-group input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 0.5rem;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  width: 100%;
  outline: none;
}

.share-input-group .action-button {
  width: 36px;
  height: 36px;
  min-height: auto;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--surface);
}

.share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
  align-items: center;
}

.share-actions .divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 0.25rem;
}

.share-actions .action-button {
  flex: 1;
  min-width: 140px;
  justify-content: center;
}

.attachment-list {
  display: grid;
  gap: 0.5rem;
}

.attachment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
}

.attachment-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.attachment-meta {
  font-size: 0.8rem;
  opacity: 0.7;
}

.attachment-download {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.85rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.attachment-download .icon {
  display: inline-flex;
  align-items: center;
}

.attachment-download:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.12);
  transform: translateY(-1px);
}

.attachment-download:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: none;
}

.attachment-download:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

#pdf-history {
  margin-top: 1rem;
  margin-bottom: 2.5rem;
}

#pdf-history h4 {
  margin: 0;
}

.pdf-history-row {
  display: flex;
  align-items: stretch;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.2s ease;
}

.pdf-history-row:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
  background: var(--surface-strong);
}

.pdf-history-group {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.2s ease;
}

.pdf-history-group.has-versions {
  position: relative;
  box-shadow:
    0 1px 1px rgba(0, 0, 0, 0.05),
    0 4px 0 -2px var(--surface),
    0 4px 0 -1px var(--border),
    0 8px 0 -4px var(--surface),
    0 8px 0 -3px var(--border);
  margin-bottom: 8px;
}

.pdf-history-group.has-versions.is-expanded {
  box-shadow: none;
  margin-bottom: 0;
}

.pdf-history-group .pdf-history-row {
  border: none;
  border-radius: 0;
  background: transparent;
}

.pdf-history-group .pdf-history-row.is-latest {
  cursor: pointer;
}

.pdf-history-group.has-versions:not(.is-expanded) .pdf-history-row.is-latest:hover {
  background: var(--surface-strong);
}

.pdf-history-versions {
  display: flex;
  flex-direction: column;
  padding-left: 1rem;
  background: rgba(0, 0, 0, 0.02);
  border-top: 1px solid var(--border-subtle);
}

.pdf-history-versions .pdf-history-row {
  border-bottom: 1px solid var(--border-subtle);
}

.pdf-history-versions .pdf-history-row:last-child {
  border-bottom: none;
}

.version-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.1rem 0.5rem;
  background: var(--accent);
  color: white;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  vertical-align: middle;
}

.group-expand-icon {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--text-muted);
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pdf-history-list {
  display: grid;
  gap: 0.8rem;
}

.pdf-history-item {
  flex: 1;
  text-align: left;
  padding: 0.7rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-width: 0;
  cursor: default;
  user-select: none;
}

.has-versions > .pdf-history-row.is-latest .pdf-history-item {
  cursor: pointer;
}

.has-versions > .pdf-history-row.is-latest .pdf-history-item:hover {
  background: rgba(0, 171, 133, 0.06);
}

.pdf-history-icon {
  color: var(--text-primary);
  font-size: 0.95rem;
}

.pdf-history-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  align-items: flex-start;
  min-width: 0;
}

.pdf-history-title {
  color: var(--text-primary);
  font-weight: 600;
}

.pdf-history-date {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.pdf-history-row-actions {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  padding-right: 0.6rem;
  border-left: 1px solid var(--border-subtle);
}

.pdf-history-empty {
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  background: var(--surface);
}

.pdf-history-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem;
  color: var(--text-muted);
  background: var(--surface-strong);
  border-radius: 10px;
  border: 1px dashed var(--border);
  font-size: 0.9rem;
}

.pdf-history-loading i {
  color: var(--accent);
  font-size: 1rem;
}

.pdf-history-actions {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
}

#toggle-history {
  padding: 0;
  border-radius: 0;
  border: none;
  background: transparent;
  color: var(--text-primary);
}

#toggle-history-list {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.85rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

#toggle-history-list:hover:not(:disabled):not([aria-disabled='true']),
.archive-link-header:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.12);
  transform: translateY(-1px);
}

.archive-link-header {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.85rem;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

#toggle-history-list:active:not(:disabled):not([aria-disabled='true']),
.archive-link-header:active {
  transform: translateY(0);
  box-shadow: none;
}

#settings-clear-history {
  margin-top: 0.75rem;
  width: 100%;
  padding: 0 1.3rem;
  height: 3.1rem;
  border-radius: 20px;
  border: 1px solid rgba(196, 46, 46, 0.6);
  background: rgba(196, 46, 46, 0.12);
  color: #c42e2e;
}

.pdf-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.6rem;
}

.pdf-history-header h3 {
  margin: 0;
  font-size: 1.25rem;
}

.pdf-history-apply,
.pdf-history-export {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

body.button-display-text-only .pdf-history-apply,
body.button-display-text-only .pdf-history-export,
body.button-display-icon-text .pdf-history-apply,
body.button-display-icon-text .pdf-history-export {
  width: auto;
  height: auto;
  padding: 0.35rem 0.7rem;
  border-radius: 10px;
  gap: 0.4rem;
}

.pdf-history-apply:hover,
.pdf-history-export:hover {
  border-color: var(--accent);
  color: var(--text-primary);
  background: var(--surface-strong);
}

.product-controls {
  display: grid;
  gap: 0.6rem;
  align-items: center;
}

.product-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.product-select {
  width: 100%;
  padding: 0.65em;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text-primary);
  min-height: 44px;
  height: 44px;
}

.hidden {
  display: none;
}

#add-hire-blank,
#add-hire-from-list,
#add-sale-blank,
#add-sale-from-list {
  padding: 0.7rem 1.1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text-primary);
  font-size: 0.9rem;
  align-self: flex-start;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  flex-direction: row-reverse;
}

#add-hire-blank:hover,
#add-hire-from-list:hover,
#add-sale-blank:hover,
#add-sale-from-list:hover {
  background: var(--surface);
  border-color: var(--accent);
}

@media (max-width: 640px) {
  footer {
    padding-bottom: 5rem;
  }
}

/* Archive Page Styles */
.archive-container {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.archive-filters {
  position: sticky;
  top: 1rem;
  z-index: 100;
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  align-items: flex-end;
  background: var(--surface);
  padding: 1.5rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
  min-width: 200px;
}

.filter-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.filter-group.full-width {
  flex: 1 1 100%;
}

.search-field-toggles {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

.field-toggle {
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.field-toggle:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.field-toggle.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 171, 133, 0.25);
}

.archive-results {
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 1rem;
}

.archive-header-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.archive-header-row h1 {
  font-size: 2.25rem;
  letter-spacing: -0.02em;
  margin: 0;
}

.results-count-badge {
  background: var(--surface-strong);
  color: var(--text-muted);
  padding: 0.25rem 0.75rem;
  border-radius: 99px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--border);
}

.archive-back {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  transition: all 0.2s ease;
}

.archive-back:hover {
  transform: translateX(-4px);
  opacity: 0.8;
}

footer {
  margin-bottom: 4.5rem;
}
/* --- Floating Generate & Export Button --- */
.generate-trigger-zone {
    position: fixed;
    bottom: 2.5rem;
    right: 2.5rem;
    z-index: 100;
    pointer-events: none;
}

#main-generate-btn {
    pointer-events: auto;
    display: flex !important;
    align-items: center;
    justify-content: center;
    min-width: 280px;
    padding: 1.25rem 2.5rem !important;
    border-radius: 100px !important;
    background: var(--accent) !important;
    color: #fff !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    box-shadow: 0 15px 40px rgba(0, 171, 133, 0.4) !important;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    gap: 0.85rem !important;
    text-decoration: none !important;
    overflow: hidden;
    position: relative;
}

#main-generate-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transition: none;
}

#main-generate-btn:hover::before {
    left: 100%;
    transition: left 0.7s ease-in-out;
}

#main-generate-btn:hover {
    transform: translateY(-8px) scale(1.03) !important;
    box-shadow: 0 22px 55px rgba(0, 171, 133, 0.5) !important;
    background: color-mix(in srgb, var(--accent), #fff 10%) !important;
}

#main-generate-btn:active {
    transform: translateY(-2px) scale(0.97) !important;
    box-shadow: 0 8px 20px rgba(0, 171, 133, 0.3) !important;
}

#main-generate-btn .button-label {
    font-size: 1.1rem !important;
    font-weight: 800 !important;
    letter-spacing: -0.01em;
}

#main-generate-btn .icon {
    font-size: 1.2rem !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

#main-generate-btn .icon-right {
    margin-left: 0.25rem;
    transition: transform 0.3s ease;
}

#main-generate-btn:hover .icon-right {
    transform: translateX(6px);
}

@media (max-width: 640px) {
    .generate-trigger-zone {
        bottom: 0.75rem;
        right: 1rem;
        left: 1rem;
    }
    
    #main-generate-btn {
        width: 100% !important;
        min-width: 0;
        padding: 1.1rem !important;
    }

    .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.85rem;
        margin-bottom: 1.25rem;
    }

    .section-title-actions h2 {
        margin: 0;
        font-size: 1.5rem;
    }

    .section-actions {
        width: 100%;
        display: flex;
        gap: 0.5rem;
    }

    .section-actions .icon-text-button {
        flex: 1;
        justify-content: center;
        padding: 0.65rem 0.5rem;
        font-size: 0.88rem;
    }

    #settings-button.icon-text-button {
        flex: 0 0 44px;
        height: 44px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}
