:root {
  color-scheme: light;
  --bg: #f3eee4;
  --panel: #fffaf0;
  --ink: #211d1f;
  --muted: #70665b;
  --line: #dfd2bd;
  --red: #9f3326;
  --green: #2f604d;
  --blue: #2a506f;
  --gold: #d7a72d;
  --bronze: #a97b43;
  --shadow: 0 18px 55px rgba(33, 29, 31, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

.app-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: end;
  padding: 28px clamp(16px, 4vw, 46px);
  color: #fff;
  background: linear-gradient(115deg, #171314 0%, #211d1f 54%, #7c572e 100%);
  border-bottom: 4px solid var(--gold);
}

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

.brand-logo {
  width: clamp(76px, 10vw, 116px);
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 999px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.26);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  max-width: 720px;
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 4.4rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.2rem;
}

.header-actions,
.form-actions,
.signature-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 850;
}

.primary {
  color: #211d1f;
  background: var(--gold);
}

.secondary {
  color: #fff;
  background: var(--bronze);
}

.ghost {
  color: var(--ink);
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(420px, 1.2fr) minmax(360px, 0.8fr);
  gap: 18px;
  padding: 18px clamp(16px, 4vw, 46px);
}

body.quote-view .app-shell {
  grid-template-columns: minmax(0, 980px);
  justify-content: center;
}

body.quote-view .form-panel,
body.quote-view .archive-panel {
  display: none;
}

body.quote-view .quote-panel {
  position: static;
}

body.quote-view #signaturePad,
body.quote-view .signature-actions {
  display: none;
}

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

.panel-heading {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-heading span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.repair-form {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.field-grid,
.cost-grid,
.photo-grid {
  display: grid;
  gap: 12px;
}

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

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

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 850;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  color: var(--ink);
  background: #fff;
}

.consent-check {
  grid-template-columns: auto 1fr;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff7e4;
}

.consent-check input {
  width: 18px;
  min-height: 18px;
  margin-top: 2px;
}

.consent-check span {
  line-height: 1.45;
}

textarea {
  resize: vertical;
}

.upload-card {
  position: relative;
  min-height: 220px;
  overflow: hidden;
  border: 1px dashed #bdb3a5;
  border-radius: 8px;
  padding: 12px;
  background: #faf7f0;
}

.upload-card input {
  min-height: auto;
  padding: 0;
  border: 0;
}

.upload-card span {
  color: var(--muted);
  font-size: 0.82rem;
}

.upload-preview-grid,
.quote-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.upload-preview-grid figure,
.quote-photo-grid figure {
  margin: 0;
}

.upload-preview-grid img,
.quote-photo-grid img {
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: #eee7dc;
}

.upload-preview-grid figcaption,
.quote-photo-grid figcaption {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 850;
}

.clear-photo-btn {
  width: fit-content;
  margin-top: 8px;
}

.quote-panel {
  position: sticky;
  top: 12px;
  align-self: start;
}

.quote-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 18px 0;
}

.quote-card {
  margin: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.quote-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  color: #fff;
  background: linear-gradient(115deg, #171314, #211d1f 70%, #7c572e);
}

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

.quote-brand img {
  width: 56px;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 999px;
  background: #211d1f;
}

.quote-head p {
  margin: 3px 0 0;
  color: #d7d2c8;
}

.quote-head span {
  color: var(--gold);
  font-weight: 900;
}

.quote-data {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  background: var(--line);
}

.quote-data div {
  padding: 12px;
  background: #fff;
}

dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

dd {
  margin: 5px 0 0;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.quote-description,
.signature-block,
.terms {
  padding: 16px 18px;
}

.quote-description p,
.terms {
  color: var(--muted);
  line-height: 1.5;
}

.storage-note {
  margin-top: 10px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  color: #5f4430;
  font-weight: 850;
}

.quote-photos {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 0 18px 18px;
}

figure {
  margin: 0;
}

figure img {
  width: 100%;
  height: 130px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: #eee7dc;
}

.quote-photo-grid figure img {
  height: auto;
}

.empty-photo {
  display: grid;
  min-height: 80px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

figcaption {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

canvas {
  width: 100%;
  height: 150px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  touch-action: none;
}

.saved-signature {
  width: 100%;
  height: 150px;
  margin-top: 10px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

canvas.has-saved-signature {
  display: none;
}

.signature-missing {
  margin: 10px 0 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
  font-weight: 850;
}

.signature-actions {
  margin-top: 10px;
}

.archive-panel {
  margin: 0 clamp(16px, 4vw, 46px) 36px;
}

.archive-tools {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

#searchInput,
#archiveFilter {
  max-width: 420px;
}

.repair-list {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.repair-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.status-panel {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.status-panel[hidden] {
  display: none;
}

.repair-item strong,
.repair-item span {
  display: block;
}

.repair-item span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.repair-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  font-weight: 850;
}

.mini-button.danger {
  border-color: #d8a3a3;
  color: #9f1d1d;
  background: #fff8f8;
}

.customer-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #171314, #211d1f 58%, #7c572e);
}

.quote-page {
  min-height: 100vh;
  background: var(--bg);
}

.quote-view-shell {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.quote-view-panel .quote-card {
  margin-top: 0;
}

.customer-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: clamp(16px, 4vw, 44px);
}

.customer-panel {
  width: min(860px, 100%);
  overflow: hidden;
}

.customer-message {
  padding: 26px;
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 850;
}

.customer-quote {
  display: grid;
  gap: 16px;
  padding-bottom: 18px;
}

.customer-quote label {
  padding: 0 18px;
}

@media (max-width: 980px) {
  .app-header,
  .app-shell,
  .field-grid,
  .cost-grid,
  .photo-grid,
  .archive-tools,
  .repair-item {
    grid-template-columns: 1fr;
  }

  .archive-tools {
    justify-content: stretch;
  }

  .quote-panel {
    position: static;
  }
}

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

  .app-header,
  .form-panel,
  .archive-panel,
  .panel-heading,
  .no-print,
  .signature-actions {
    display: none !important;
  }

  .app-shell {
    display: block;
    padding: 0;
  }

  .quote-panel,
  .quote-card {
    border: 0;
    box-shadow: none;
  }

  .quote-card {
    margin: 0;
  }
}
