:root {
  --bg: #f6f4ef; --card: #ffffff; --ink: #1d232b; --muted: #5d6673; --line: #dcd8cf;
  --accent: #e8590c; --accent-ink: #ffffff; --field: #ffffff;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181d; --card: #1d232b; --ink: #eef0f3; --muted: #a3acb8; --line: #333c47;
    --accent: #ff7a2e; --accent-ink: #14181d; --field: #14181d;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow-wrap: anywhere; }
h1, h2, p { margin: 0 0 .6em; }
small { color: var(--muted); font-weight: 400; font-size: .8em; }

.hero, main, footer { width: min(100% - 32px, 760px); margin-inline: auto; }
.hero { padding: max(28px, env(safe-area-inset-top)) 0 20px; }
.brand { font-weight: 600; letter-spacing: .02em; color: var(--muted); }
.brand b { color: var(--accent); }
h1 { font-size: clamp(1.6rem, 5.5vw, 2.4rem); line-height: 1.15; letter-spacing: -.01em; }
.lead { color: var(--muted); font-size: 1.05rem; }
.price { font-size: 1.05rem; }
.price b { font-size: 1.5rem; color: var(--accent); }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 22px; border: 0; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink); font: 600 1rem/1 inherit; text-decoration: none; cursor: pointer; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.full { width: 100%; }
.link { background: none; border: 0; color: var(--accent); font: 600 .95rem inherit; padding: 12px 0; min-height: 44px; cursor: pointer; }
.icon { flex: none; width: 44px; height: 44px; border: 0; background: none; color: var(--muted); font-size: 1.4rem; cursor: pointer; border-radius: 8px; }
@media (hover: hover) { .btn:hover { filter: brightness(1.08); } .icon:hover { color: var(--ink); background: var(--bg); } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 16px; }
h2 { font-size: 1.1rem; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.grid .wide { grid-column: 1 / -1; }
@media (max-width: 560px) { .grid { grid-template-columns: minmax(0, 1fr); } }
label { display: grid; gap: 4px; font-size: .9rem; color: var(--muted); }
input, select, textarea { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--field); color: var(--ink); font: inherit; font-size: 1rem; }
textarea { resize: vertical; }
select { appearance: none; padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
#job-form label { margin-bottom: 12px; }
.status { margin: 10px 0 0; min-height: 1.5em; color: var(--muted); }

/* The quote looks like paper in both themes, since it is what gets printed and sent. */
.quote { background: #fff; color: #1d232b; border-radius: 6px; padding: 28px 24px; margin-bottom: 16px; box-shadow: 0 2px 16px rgba(0, 0, 0, .12); }
.quote input, .quote textarea { background: transparent; color: inherit; border-color: transparent; padding: 6px; min-height: 36px; }
.quote input:focus, .quote textarea:focus { border-color: #c9c4b9; background: #faf8f4; outline: none; }
.q-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-bottom: 2px solid #e8590c; padding-bottom: 14px; margin-bottom: 16px; }
.q-co { font-weight: 700; font-size: 1.2rem; margin: 0; }
.q-small { font-size: .82rem; color: #5d6673; white-space: pre-line; margin: 0; }
.q-meta { text-align: right; }
.q-title { font-weight: 800; letter-spacing: .12em; color: #e8590c; margin: 0; }
.q-client { margin-bottom: 16px; }
.q-client p:last-child { white-space: pre-line; font-weight: 600; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: #5d6673; border-bottom: 1px solid #dcd8cf; padding: 6px; }
td { border-bottom: 1px solid #eeebe4; vertical-align: top; padding: 2px 0; }
th.n, td.n { text-align: right; }
td.n input { text-align: right; }
td.line-total { padding: 8px 6px; white-space: nowrap; }
.quote input[type=number] { appearance: textfield; -moz-appearance: textfield; }
.quote input::-webkit-inner-spin-button, .quote input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
td:nth-child(1) { min-width: 180px; }
td:nth-child(2) { width: 70px; } td:nth-child(3) { width: 80px; } td:nth-child(4) { width: 100px; }
.totals { display: grid; grid-template-columns: auto auto; justify-content: end; gap: 4px 24px; margin: 8px 0 16px; }
.totals dd { margin: 0; text-align: right; }
.totals .big { font-weight: 700; font-size: 1.1rem; }
.sign { border: 1px dashed #c9c4b9; border-radius: 6px; min-height: 110px; padding: 10px; margin-top: 14px; font-size: .82rem; color: #5d6673; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.actions { margin-bottom: 24px; }
.hint { color: var(--muted); font-size: .9rem; }
footer { color: var(--muted); font-size: .8rem; padding: 12px 0 max(24px, env(safe-area-inset-bottom)); }

/* Phones: the quote table becomes stacked rows so nothing scrolls sideways. */
@media (max-width: 560px) {
  .quote { padding: 20px 14px; }
  thead { display: none; }
  tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.3fr) 44px; border-bottom: 1px solid #dcd8cf; padding: 6px 0; }
  td { border: 0; width: auto !important; min-width: 0 !important; }
  td:nth-child(1) { grid-column: 1 / -1; }
  td:nth-child(5) { grid-column: 1 / 4; grid-row: 3; text-align: right; font-weight: 600; padding: 4px 6px; }
  td:nth-child(6) { grid-column: 4; grid-row: 2; }
}

@media print {
  @page { margin: 14mm; }
  body { background: #fff; }
  .no-print, .hero, footer { display: none !important; }
  main { width: 100%; }
  .quote { box-shadow: none; padding: 0; }
  .quote input, .quote textarea { border: 0; padding: 0; min-height: 0; resize: none; }
  td, td.line-total { padding: 6px 0; }
  thead { display: table-header-group; }
  tbody tr { display: table-row; }
}

@media (max-width: 760px), (pointer: coarse) { input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea { font-size: 16px !important; } }
