:root {
  --ink: #17211d;
  --muted: #617068;
  --surface: #ffffff;
  --background: #f4f7f5;
  --primary: #176b50;
  --primary-dark: #0e4f3a;
  --border: #d7e0db;
  --error: #a12626;
  --focus: #78bda7;
  --radius: 14px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--background);
  line-height: 1.5;
}

body {
  margin: 0;
  min-width: 320px;
}

a {
  color: var(--primary-dark);
  font-weight: 650;
}

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

.shell {
  width: min(100% - 32px, 720px);
  margin-inline: auto;
}

.site-header {
  min-height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  color: var(--ink);
  font-size: 1.1rem;
  text-decoration: none;
  letter-spacing: -0.02em;
}

nav {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.9rem;
}

nav a,
.link-button {
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
}

.inline-form {
  display: inline;
}

.link-button {
  padding: 8px 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.page {
  padding-block: 28px 48px;
}

.auth-card,
.form-card,
.home-hero,
.recent-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgb(24 57 44 / 6%);
}

.auth-card {
  max-width: 480px;
  margin: 5vh auto 0;
  padding: 28px 22px;
}

.form-card,
.home-hero,
.recent-section {
  padding: 24px 20px;
}

.recent-section {
  margin-top: 20px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(1.7rem, 7vw, 2.25rem);
  line-height: 1.15;
  letter-spacing: -0.035em;
}

h2 {
  margin-bottom: 16px;
  font-size: 1.15rem;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--primary);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.lede {
  margin-bottom: 26px;
  color: var(--muted);
}

.field {
  margin-bottom: 20px;
}

.field label {
  display: block;
  margin-bottom: 7px;
  font-size: 0.92rem;
  font-weight: 700;
}

.optional {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.form-control {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #aebdb5;
  border-radius: 9px;
  outline: none;
}

textarea.form-control {
  min-height: 88px;
  resize: vertical;
}

input[type="file"].form-control {
  padding: 9px;
  background: #f9fbfa;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgb(120 189 167 / 35%);
}

.help-text,
.help-text ul {
  margin: 7px 0 0;
  padding-left: 0;
  color: var(--muted);
  font-size: 0.8rem;
  list-style: none;
}

.field-error,
.errorlist {
  margin: 6px 0 0;
  padding: 0;
  color: var(--error);
  font-size: 0.85rem;
  list-style: none;
}

.form-alert {
  margin-bottom: 18px;
  padding: 12px;
  color: var(--error);
  background: #fff2f2;
  border: 1px solid #eccaca;
  border-radius: 9px;
}

.button {
  min-height: 48px;
  padding: 11px 20px;
  border: 0;
  border-radius: 10px;
  font-weight: 750;
  cursor: pointer;
}

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

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

.button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.button-full {
  width: 100%;
}

.button-large {
  width: 100%;
  min-height: 56px;
  font-size: 1.05rem;
}

.auth-switch {
  margin: 22px 0 0;
  color: var(--muted);
  text-align: center;
}

.logo-preview {
  display: block;
  width: 96px;
  height: 96px;
  margin-bottom: 12px;
  object-fit: contain;
  background: #f7f9f8;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.is-hidden {
  display: none;
}

.form-actions {
  position: sticky;
  bottom: 0;
  margin: 8px -4px -4px;
  padding: 12px 4px 4px;
  background: linear-gradient(to bottom, transparent, var(--surface) 24%);
}

.business-heading {
  display: flex;
  align-items: center;
  gap: 14px;
}

.business-heading h1 {
  margin-bottom: 0;
}

.business-logo {
  width: 62px;
  height: 62px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 11px;
}

.coming-soon {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  text-align: center;
}

.empty-state {
  padding: 24px 16px;
  color: var(--muted);
  background: var(--background);
  border-radius: 10px;
  text-align: center;
}

.empty-state p {
  margin: 0;
}

@media (min-width: 620px) {
  .page {
    padding-top: 48px;
  }

  .auth-card,
  .form-card,
  .home-hero,
  .recent-section {
    padding: 34px;
  }

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

  .button-large {
    width: auto;
    min-width: 210px;
  }

  .coming-soon {
    text-align: left;
  }
}

@media (max-width: 480px) {
  .shell {
    width: min(100% - 24px, 720px);
  }

  nav {
    gap: 10px;
    font-size: 0.78rem;
  }

  .site-header,
  .header-inner {
    min-height: 58px;
  }

  .page {
    padding-top: 18px;
  }
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  text-decoration: none;
}

.button-secondary {
  color: var(--primary-dark);
  background: #e7f2ed;
  border: 1px solid #bfd8cd;
}

.secondary-link {
  color: var(--muted);
  white-space: nowrap;
}


.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-bottom: 12px;
  color: var(--primary-dark);
  font-weight: 700;
  text-decoration: none;
}
.quote-builder,
.quote-detail {
  max-width: 720px;
  margin-inline: auto;
}

.builder-heading,
.detail-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.builder-section {
  min-width: 0;
  margin: 0 0 18px;
  padding: 20px 16px 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.builder-section legend {
  padding: 0 6px;
  font-size: 1.05rem;
  font-weight: 800;
}

.section-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 18px;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.section-divider::before,
.section-divider::after {
  height: 1px;
  flex: 1;
  background: var(--border);
  content: "";
}

.muted-fields {
  display: none;
}

.line-item {
  margin-bottom: 14px;
  padding: 15px;
  background: #f8faf9;
  border: 1px solid var(--border);
  border-radius: 11px;
}

.line-item.is-removed {
  display: none;
}

.delete-field {
  display: none;
}

.item-numbers {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 10px;
}

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

.line-total {
  font-weight: 750;
}

.remove-item {
  min-height: 42px;
  padding: 7px 10px;
  color: var(--error);
  background: transparent;
  border: 0;
  font-weight: 700;
  cursor: pointer;
}

.quote-totals,
.detail-totals {
  margin: 18px 0;
  padding: 18px;
  background: #edf5f1;
  border: 1px solid #c9ddd4;
  border-radius: var(--radius);
}

.quote-totals > div,
.detail-totals > div {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 5px 0;
}

.quote-totals .grand-total,
.detail-totals .grand-total {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid #b5d0c5;
  font-size: 1.15rem;
  text-transform: uppercase;
}

.save-bar {
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding: 10px 0 max(10px, env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent, var(--background) 24%);
}

.quote-detail {
  padding: 24px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.detail-customer {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.quote-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin: 0 0 28px;
}

.quote-meta div {
  padding: 10px;
  background: var(--background);
  border-radius: 8px;
}

.quote-meta dt {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.quote-meta dd {
  margin: 2px 0 0;
  font-weight: 700;
}

.detail-item,
.quote-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.detail-item > div,
.quote-list-item > div {
  min-width: 0;
}

.detail-item span,
.quote-list-item span {
  display: block;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.84rem;
}

.quote-notes {
  overflow-wrap: anywhere;
}
.phase-note {
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  text-align: center;
}

.quote-list-item {
  color: var(--ink);
  text-decoration: none;
}

.quote-list-item:first-child {
  padding-top: 0;
}

.quote-list-item:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.quote-list-amount {
  flex: 0 0 auto;
  text-align: right;
}

.detail-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.detail-actions .button {
  width: 100%;
}

@media (min-width: 620px) {
  .builder-section,
  .quote-detail {
    padding-inline: 28px;
  }

  .save-bar .button {
    margin-left: auto;
    width: auto;
    min-width: 220px;
  }

  .detail-actions {
    display: flex;
    justify-content: flex-end;
  }

  .detail-actions .button {
    width: auto;
    min-width: 170px;
  }
}

@media (max-width: 480px) {
  .detail-heading {
    display: block;
  }

  .detail-item {
    align-items: flex-start;
  }
}
