/* Quotation Generator — self-contained tool */

:root {
  color-scheme: light;
  --bg: #f0f2f7;
  --surface: #ffffff;
  --text: #121826;
  --muted: #5c6478;
  --border: #d8dde8;
  --shadow: 0 10px 36px rgba(18, 24, 38, 0.08);
  --radius: 14px;
  --radius-sm: 10px;
  --accent: #1a56a8;
  --accent-soft: #e8f0fb;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --focus: #2563eb;
  --ok: #0d6b4d;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", Arial, sans-serif;
  --max: 1180px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.skip-link:focus {
  left: 16px;
  top: 16px;
  width: auto;
  height: auto;
  padding: 10px 14px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  z-index: 1000;
  outline: 2px solid var(--focus);
}

.wrap {
  width: min(100% - 24px, var(--max));
  margin-inline: auto;
}

.site-header {
  padding: 28px 0 12px;
}

.site-header h1 {
  margin: 0 0 12px;
  font-size: clamp(1.55rem, 4vw, 2rem);
  letter-spacing: -0.02em;
}

.lead {
  margin: 0;
  max-width: 70ch;
  color: var(--muted);
  font-size: 1.05rem;
}

.layout {
  display: grid;
  gap: 20px;
  padding-bottom: 24px;
}

@media (min-width: 960px) {
  .layout {
    grid-template-columns: 1fr 300px;
    align-items: start;
  }
}

.layout-primary {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.layout-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.card-title {
  margin: 0 0 14px;
  font-size: 1.1rem;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.card-head .card-title {
  margin: 0;
}

.hint {
  margin: 0 0 12px;
  font-size: 0.9rem;
  color: var(--muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
}

.field-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
}

@media (min-width: 560px) {
  .field-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .field-span-2 {
    grid-column: span 2;
  }
}

.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  color: var(--text);
  background: #fff;
  min-height: 44px;
}

.input:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

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

.input-select {
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: none;
  min-height: 44px;
  text-decoration: none;
}

.btn:focus {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-secondary {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(26, 86, 168, 0.25);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(180, 35, 24, 0.25);
}

.btn-compact {
  padding: 8px 14px;
  min-height: 40px;
  font-size: 0.9rem;
}

.btn-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-stack .btn {
  width: 100%;
}

.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff;
  color: var(--danger);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.btn-icon:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.action-status {
  margin: 12px 0 0;
  font-size: 0.9rem;
  color: var(--ok);
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.lines-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.lines-table th,
.lines-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.lines-table th {
  background: #f6f8fc;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.lines-table tr:last-child td {
  border-bottom: none;
}

.col-narrow {
  width: 88px;
}

.col-mid {
  width: 120px;
}

.col-action {
  width: 52px;
  text-align: center;
}

.line-desc {
  min-width: 160px;
}

.totals-inputs {
  max-width: 520px;
}

.card-totals .totals-dl {
  margin: 0;
}

.totals-dl > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.totals-dl > div:last-child {
  border-bottom: none;
}

.totals-dl dt {
  margin: 0;
  font-weight: 600;
  color: var(--muted);
}

.totals-dl dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.totals-grand dt,
.totals-grand dd {
  font-size: 1.1rem;
  color: var(--text);
}

.preview-wrap {
  padding-bottom: 32px;
}

.section-heading {
  margin: 0 0 12px;
  font-size: 1.05rem;
}

.quotation-doc {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 24px 20px;
  max-width: 900px;
  margin-inline: auto;
}

@media (min-width: 640px) {
  .quotation-doc {
    padding: 32px 36px;
  }
}

.q-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 2px solid var(--text);
  padding-bottom: 18px;
  margin-bottom: 20px;
}

.q-brand-name {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.q-meta-block {
  text-align: right;
  font-size: 0.95rem;
}

.q-meta-block p {
  margin: 0.2em 0;
}

.q-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.q-columns {
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr;
  margin-bottom: 22px;
}

@media (min-width: 560px) {
  .q-columns {
    grid-template-columns: 1fr 1fr;
  }
}

.q-block h3 {
  margin: 0 0 8px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.q-block p {
  margin: 0;
  white-space: pre-wrap;
  font-size: 0.95rem;
}

.q-items {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  margin-bottom: 20px;
}

.q-items th,
.q-items td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.q-items th {
  background: #f4f6fa;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

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

.q-totals-box {
  max-width: 320px;
  margin-left: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.q-totals-box table {
  width: 100%;
  border-collapse: collapse;
}

.q-totals-box td {
  padding: 8px 12px;
  font-variant-numeric: tabular-nums;
}

.q-totals-box td:first-child {
  color: var(--muted);
  font-weight: 600;
}

.q-totals-box td:last-child {
  text-align: right;
  font-weight: 600;
}

.q-totals-box tr.grand td {
  background: #f4f6fa;
  font-size: 1.05rem;
  padding-top: 12px;
  padding-bottom: 12px;
}

.q-notes {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.q-notes h3 {
  margin: 0 0 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.q-notes p {
  margin: 0;
  white-space: pre-wrap;
  font-size: 0.9rem;
  color: var(--text);
}

.prose {
  padding-bottom: 48px;
}

.prose .card {
  margin-bottom: 18px;
}

.prose h2 {
  margin: 0 0 12px;
  font-size: 1.15rem;
}

.prose ol {
  margin: 0;
  padding-left: 1.25rem;
}

.prose li {
  margin-bottom: 8px;
}

.faq-dl dt {
  font-weight: 700;
  margin-top: 12px;
}

.faq-dl dt:first-child {
  margin-top: 0;
}

.faq-dl dd {
  margin: 4px 0 0;
  color: var(--muted);
}

.site-footer {
  padding: 20px 0 40px;
}

.footer-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}

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

.export-fallback {
  position: fixed;
  inset: 0;
  background: rgba(18, 24, 38, 0.45);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.export-fallback[hidden] {
  display: none !important;
}

.export-fallback-panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 560px;
  width: 100%;
  box-shadow: var(--shadow);
}

.export-fallback-title {
  margin: 0 0 8px;
  font-size: 1.15rem;
}

.export-fallback-hint {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.92rem;
}

.export-fallback-textarea {
  width: 100%;
  font-family: ui-monospace, monospace;
  font-size: 0.82rem;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

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

  .no-print,
  .skip-link {
    display: none !important;
  }

  .preview-wrap {
    padding: 0;
  }

  .section-heading {
    display: none;
  }

  .quotation-doc {
    box-shadow: none;
    border: none;
    max-width: none;
    margin: 0;
    padding: 12mm 15mm;
  }

  .wrap {
    width: 100%;
    max-width: none;
    margin: 0;
  }
}
