:root {
  color-scheme: light;
  --ink: #1f2933;
  --muted: #64748b;
  --line: #d9e2ec;
  --panel: #ffffff;
  --page: #f4f7f9;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --accent: #b45309;
  --soft: #e8f3f1;
  --danger: #b91c1c;
  --shadow: 0 18px 50px rgba(31, 41, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 48px);
  background: rgba(244, 247, 249, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: var(--muted);
  font-size: 13px;
}

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

main {
  padding: clamp(18px, 4vw, 48px);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  align-items: start;
  max-width: 1240px;
  margin: 0 auto;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.form-panel {
  display: grid;
  gap: 22px;
  padding: clamp(18px, 3vw, 32px);
}

.link-panel {
  position: sticky;
  top: 92px;
  display: grid;
  gap: 18px;
  padding: 24px;
}

.section-heading p,
.items-header p,
.eyebrow {
  margin: 0 0 6px;
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.section-heading h1,
.section-heading h2 {
  margin: 0;
  line-height: 1.08;
}

.section-heading h1 {
  max-width: 680px;
  font-size: clamp(30px, 5vw, 56px);
}

.section-heading h2 {
  font-size: 22px;
}

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

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

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

label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--soft);
}

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

.items-header span,
.hint {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

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

.item-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 96px 130px 72px;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfe;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button,
.primary-link,
.secondary-link {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

.primary-button,
.primary-link {
  background: var(--primary);
  color: white;
}

.primary-button:hover,
.primary-link:hover {
  background: var(--primary-dark);
}

.secondary-button {
  background: var(--soft);
  color: var(--primary-dark);
  border-color: #b8d9d3;
}

.secondary-link {
  background: #fff7ed;
  color: var(--accent);
  border-color: #fed7aa;
}

.ghost-button {
  background: white;
  color: var(--ink);
  border-color: var(--line);
}

.icon-button {
  color: var(--danger);
  background: #fff5f5;
  border-color: #fecaca;
}

.wide {
  width: 100%;
}

.empty-state {
  display: grid;
  min-height: 132px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  padding: 20px;
}

.generated-link {
  display: grid;
  gap: 12px;
}

.quote-page {
  max-width: 1040px;
  margin: 0 auto;
}

.quote-export-bar {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-bottom: 18px;
}

.quote-sheet {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.alfa-template {
  position: relative;
  width: min(100%, 794px);
  min-height: 1123px;
  margin: 0 auto;
  padding: 52px 68px 148px;
  border-radius: 0;
  color: #4b4b4b;
  font-family: "Trebuchet MS", Inter, ui-sans-serif, system-ui, sans-serif;
}

.legacy-preview {
  display: none;
}

.corner-gradient {
  position: absolute;
  z-index: 0;
  pointer-events: none;
}

.top-left {
  top: 0;
  left: 0;
  width: 470px;
  height: 142px;
  background:
    radial-gradient(circle at 15% 20%, #ff2bb8 0, transparent 35%),
    linear-gradient(135deg, #3c82ff 0%, #6517ae 48%, #21002c 100%);
  border-bottom-right-radius: 70% 100%;
}

.top-left::after,
.bottom-right::before {
  content: "";
  position: absolute;
  background: rgba(196, 157, 235, 0.78);
}

.top-left::after {
  right: -165px;
  bottom: 0;
  width: 310px;
  height: 118px;
  border-radius: 72% 0 0 0;
  transform: skewX(-14deg);
}

.bottom-right {
  right: 0;
  bottom: 0;
  width: 470px;
  height: 146px;
  background:
    radial-gradient(circle at 70% 40%, #ff2bb8 0, transparent 35%),
    linear-gradient(135deg, #c49deb 0%, #6417a8 52%, #17001f 100%);
  border-top-left-radius: 70% 100%;
}

.bottom-right::before {
  left: -160px;
  top: 0;
  width: 310px;
  height: 118px;
  border-radius: 0 0 72% 0;
  transform: skewX(-14deg);
}

.circle-accent {
  position: absolute;
  z-index: 0;
  width: 86px;
  height: 86px;
  border: 24px solid #c49deb;
  border-radius: 50%;
  pointer-events: none;
}

.circle-accent.left {
  left: -52px;
  top: 246px;
}

.circle-accent.right {
  right: -48px;
  bottom: 235px;
}

.alfa-template > *:not(.corner-gradient):not(.circle-accent) {
  position: relative;
  z-index: 1;
}

.template-header {
  display: grid;
  grid-template-columns: 260px 1fr;
  align-items: start;
  min-height: 170px;
}

.alfa-logo {
  display: grid;
  grid-template-columns: 72px 1fr;
  align-items: center;
  column-gap: 12px;
  color: white;
  line-height: 0.86;
}

.alfa-logo strong {
  font-size: 42px;
  letter-spacing: 0;
}

.alfa-logo small {
  grid-column: 2;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0;
}

.logo-dots {
  position: relative;
  width: 72px;
  height: 60px;
  grid-row: span 2;
}

.logo-dots i {
  position: absolute;
  display: block;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: white;
}

.logo-dots i:nth-child(1) {
  left: 0;
  bottom: 7px;
}

.logo-dots i:nth-child(2) {
  left: 28px;
  top: 0;
}

.logo-dots i:nth-child(3) {
  right: 0;
  bottom: 4px;
}

.template-title {
  display: grid;
  justify-items: end;
  gap: 20px;
  padding-top: 106px;
}

.template-title h1 {
  margin: 0;
  color: #6b22bd;
  font-size: 48px;
  line-height: 1;
  font-weight: 900;
}

.date-ribbon {
  min-width: 330px;
  padding: 12px 34px;
  border-radius: 999px 0 0 999px;
  background: #c7a4ee;
  color: #2d0c4a;
  text-align: right;
  font-size: 20px;
  font-weight: 900;
}

.arrow-strip {
  display: flex;
  gap: 24px;
  margin: 8px 0 30px;
}

.arrow-strip span {
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 14px solid #003d5b;
}

.customer-block {
  max-width: 620px;
  margin-bottom: 30px;
  padding-left: 16px;
  font-size: 18px;
  line-height: 1.48;
}

.customer-block p,
.customer-block h2 {
  margin: 0 0 5px;
}

.customer-block h2 {
  color: #111;
  font-size: 21px;
}

.template-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 78px;
}

.template-table th {
  padding: 14px 12px;
  background: #55158e;
  color: white;
  font-size: 17px;
  text-align: left;
}

.template-table th:first-child {
  border-radius: 18px 0 0 18px;
  width: 72px;
}

.template-table th:nth-child(2) {
  width: 350px;
}

.template-table th:last-child {
  border-radius: 0 18px 18px 0;
}

.template-table td {
  min-height: 62px;
  padding: 20px 12px;
  border-bottom: 1px solid #565656;
  font-size: 18px;
  vertical-align: top;
}

.template-table td:not(:nth-child(2)) {
  white-space: nowrap;
}

.template-bottom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 46px;
  align-items: start;
}

.terms h3 {
  margin: 0 0 8px;
  font-size: 18px;
  color: #555;
}

.terms p {
  margin: 0 0 18px;
  white-space: pre-line;
  line-height: 1.46;
  font-size: 15px;
}

.signature-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 118px;
  border: 2px solid #55158e;
  color: #111;
  font-size: 13px;
}

.signature-box div {
  padding: 8px;
}

.signature-box div + div {
  border-left: 1px solid #555;
}

.signature-box strong {
  display: grid;
  place-items: center;
  min-height: 76px;
  color: #2563eb;
}

.template-totals {
  margin-top: 4px;
  font-size: 15px;
}

.template-totals div {
  border-bottom: 0;
  padding: 7px 0;
}

.template-totals .grand-total {
  border-top: 1px solid #555;
  color: #4b4b4b;
  font-size: 16px;
  font-weight: 900;
}

.template-footer {
  position: absolute;
  right: 30px;
  bottom: 18px;
  z-index: 2;
  width: 420px;
  color: white;
  text-align: right;
  font-size: 17px;
  line-height: 1.34;
}

.template-footer p {
  margin: 0 0 6px;
}

.quote-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 28px;
  padding: clamp(24px, 5vw, 56px);
  background: linear-gradient(135deg, #f8fafc 0%, #e8f3f1 100%);
  border-bottom: 1px solid var(--line);
}

.quote-hero h1 {
  margin: 0 0 12px;
  max-width: 700px;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1.08;
}

.quote-hero p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.quote-meta {
  display: grid;
  gap: 10px;
  align-content: start;
}

.quote-meta span {
  display: block;
  padding: 10px 12px;
  border: 1px solid #b8d9d3;
  border-radius: 8px;
  background: white;
  color: #334155;
  font-weight: 800;
}

.parties {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  padding: 28px clamp(20px, 5vw, 56px);
}

.parties div {
  display: grid;
  gap: 6px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.parties span,
.notes span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.parties strong {
  font-size: 19px;
}

.parties small {
  color: var(--muted);
}

.quote-table {
  width: calc(100% - clamp(40px, 10vw, 112px));
  margin: 0 auto;
  border-collapse: collapse;
}

.quote-table th,
.quote-table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.quote-table th {
  color: #334155;
  font-size: 13px;
  text-transform: uppercase;
}

.quote-table th:not(:first-child),
.quote-table td:not(:first-child) {
  text-align: right;
}

.totals {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 26px;
  padding: 28px clamp(20px, 5vw, 56px) 44px;
}

.notes p {
  margin: 8px 0 0;
  color: #475569;
  line-height: 1.6;
}

dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

dl div {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  font-weight: 900;
}

.grand-total {
  color: var(--primary-dark);
  font-size: 22px;
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .workspace,
  .quote-hero,
  .parties,
  .totals {
    grid-template-columns: 1fr;
  }

  .link-panel {
    position: static;
  }

  .item-row,
  .two,
  .three {
    grid-template-columns: 1fr;
  }

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

  .nav-actions {
    width: 100%;
  }

  .nav-actions button {
    flex: 1;
  }

  .quote-export-bar {
    justify-content: stretch;
  }

  .quote-export-bar > * {
    flex: 1;
  }

  .alfa-template {
    min-height: auto;
    padding: 34px 22px 150px;
  }

  .template-header,
  .template-bottom {
    grid-template-columns: 1fr;
  }

  .template-title {
    justify-items: start;
    padding-top: 72px;
  }

  .template-title h1 {
    font-size: 34px;
  }

  .date-ribbon {
    min-width: 100%;
  }

  .template-table {
    display: block;
    overflow-x: auto;
  }

  .signature-box {
    grid-template-columns: 1fr;
  }

  .signature-box div + div {
    border-left: 0;
    border-top: 1px solid #555;
  }

  .template-footer {
    left: 22px;
    right: 22px;
    width: auto;
    font-size: 14px;
  }
}

@media print {
  @page {
    size: A4;
    margin: 0;
  }

  body {
    background: white;
  }

  .topbar,
  .workspace,
  .quote-export-bar {
    display: none !important;
  }

  main {
    padding: 0;
  }

  .quote-page,
  .quote-sheet {
    max-width: none;
    margin: 0;
  }

  .quote-sheet {
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .alfa-template {
    width: 210mm;
    min-height: 297mm;
    padding: 13mm 18mm 39mm;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}
