/* Contractor onboarding — one simple page, English. Also provides base styles for /admin/. */
:root {
  --brand: #F26B1D; --brand-ink: #B84A0B; --brand-tint: #FDEBDD;
  --ink: #0C1824; --ink-2: #122333;
  --paper: #F4F2ED; --paper-2: #EAE6DD; --white: #FFFFFF;
  --line: #E1DCD2; --line-strong: #C9C1B3;
  --text: #16202B; --muted: #5E6873;
  --ok: #1B8F52; --ok-tint: #E2F4E9; --warn: #9A5B00; --warn-tint: #FBF0DC;
  --err: #B42318; --err-tint: #FDECEA;
  --focus: #2F7FC1;
  --f-display: "Archivo", system-ui, sans-serif;
  --f-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--text); font: 16px/1.55 var(--f-body); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; font-family: var(--f-display); }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- Top bar ---------- */
.ob-bar { background: var(--ink); color: #fff; }
.ob-bar-inner { max-width: 1160px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 28px); height: 58px; display: flex; align-items: center; gap: 14px; }
.ob-logo { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font: 800 1.05rem var(--f-display); font-stretch: 90%; }
.ob-logo img { border-radius: 9px; }
.ob-bar-label { color: #9EABB8; font-size: .9rem; padding-left: 14px; border-left: 1px solid rgba(255,255,255,.15); }
.he-note { background: var(--brand-tint); color: var(--brand-ink); font-size: .9rem; padding: 9px 16px; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; text-align: center; }
.he-note [lang="he"] { font-family: "IBM Plex Sans Hebrew", var(--f-body); font-weight: 600; }

/* ---------- Page ---------- */
.ob { max-width: 720px; margin: 0 auto; padding: 36px clamp(16px, 4vw, 24px) 80px; }
.ob-intro h1 { font-size: clamp(1.9rem, 5vw, 2.4rem); font-weight: 800; font-stretch: 86%; letter-spacing: -.015em; line-height: 1.1; }
.ob-intro p { color: var(--muted); margin-top: 10px; font-size: 1.02rem; }
.ob-form { margin-top: 26px; background: var(--white); border: 1px solid var(--line); border-radius: 16px; padding: 0 clamp(18px, 4vw, 32px); }
.loading { color: var(--muted); padding: 30px 0; }

.sec { padding: 28px 0; border-top: 1px solid var(--line); }
.sec:first-child { border-top: 0; }
.sec h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: 18px; }
.sec-intro { color: var(--muted); font-size: .94rem; margin: -8px 0 14px; }

/* ---------- Fields ---------- */
.field { margin: 0 0 18px; padding: 0; border: 0; min-width: 0; }
.field:last-child { margin-bottom: 0; }
.field > label, fieldset.field > legend { display: block; font-weight: 600; font-size: .95rem; margin-bottom: 6px; padding: 0; }
.req { color: var(--err); }
input[type="text"], input[type="email"], input[type="tel"], input[type="password"], select {
  width: 100%; min-height: 48px; padding: 10px 13px; border: 1.5px solid var(--line-strong); border-radius: 10px; background: var(--white);
  font-size: 16px; transition: border-color .15s, box-shadow .15s; appearance: none; -webkit-appearance: none;
}
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%235E6873' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; background-size: 12px; padding-right: 36px; }
input::placeholder { color: #9A9387; }
input:focus, select:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgba(47,127,193,.18); }
[aria-invalid="true"] { border-color: var(--err) !important; }
.help { font-size: .86rem; color: var(--muted); margin-top: 6px; }
.error { font-size: .87rem; color: var(--err); font-weight: 500; margin-top: 6px; }
.error:empty { display: none; }

.addr { display: grid; grid-template-columns: 1fr 96px 110px; gap: 8px; }
.addr .addr-street { grid-column: 1 / -1; }
@media (max-width: 480px) { .addr { grid-template-columns: 1fr 1fr; } .addr #f-city { grid-column: 1 / -1; } }

/* ---------- Coverage tags ---------- */
.tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 48px; padding: 6px 8px; border: 1.5px solid var(--line-strong); border-radius: 10px; background: var(--white); cursor: text; }
.tags:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(47,127,193,.18); }
.tags.invalid { border-color: var(--err); }
.tag-list { display: contents; list-style: none; margin: 0; padding: 0; }
.tag-list li { display: inline-flex; align-items: center; gap: 2px; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 3px 3px 3px 11px; font-size: .9rem; font-weight: 500; }
.tag-list button { width: 26px; height: 26px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; }
.tag-list button:hover { background: var(--paper-2); color: var(--text); }
.tags input { flex: 1; min-width: 180px; min-height: 34px; border: 0 !important; box-shadow: none !important; padding: 4px 6px; }

/* ---------- Services ---------- */
.svc-cat { margin-top: 18px; }
.svc-cat:first-child { margin-top: 0; }
.svc-cat h3 { font: 600 .78rem var(--f-body); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding-bottom: 6px; }
.svc-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px 14px; padding: 9px 0; border: 0; border-top: 1px solid var(--line); margin: 0; min-width: 0; }
.svc-row legend { float: left; padding: 0; font-size: .96rem; line-height: 1.35; }
.svc-row legend small { display: block; color: var(--muted); font-size: .8rem; }
.seg { display: inline-grid; grid-template-columns: repeat(3, auto); gap: 4px; }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 38px; padding: 0 12px; border: 1.5px solid var(--line-strong); border-radius: 8px; font-size: .85rem; font-weight: 600; color: var(--muted); white-space: nowrap; transition: background-color .12s, color .12s, border-color .12s; }
.seg label:hover span { border-color: #9C9383; color: var(--text); }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 1px; }
.seg input[value="in_house"]:checked + span { background: var(--ok); border-color: var(--ok); color: #fff; }
.seg input[value="outsourced"]:checked + span { background: #F2C26B; border-color: #E0AC4C; color: #3F2A00; }
.seg input[value="not_offered"]:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }
.svc-row.missing legend { color: var(--err); }
.svc-row.missing .seg span { border-color: #E3A39C; }
@media (max-width: 560px) {
  .svc-row { grid-template-columns: 1fr; }
  .seg { display: grid; grid-template-columns: repeat(3, 1fr); }
  .seg span { min-height: 42px; padding: 0 6px; }
}

.assess { margin-top: 26px; }
.assess > .help { margin: 0 0 12px; }
.opts { display: grid; gap: 8px; }
.opt { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1.5px solid var(--line-strong); border-radius: 10px; cursor: pointer; font-size: .96rem; }
.opt input { width: 20px; height: 20px; margin: 0; accent-color: var(--ink); flex-shrink: 0; }
.opt:has(input:checked) { border-color: var(--ink); background: #FBFAF7; }
.price { margin-top: 14px; }
.money { position: relative; max-width: 200px; }
.money span { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; }
.money input { padding-left: 28px; }

/* ---------- Agreement + submit ---------- */
.agree { display: flex; gap: 12px; align-items: flex-start; font-size: .92rem; line-height: 1.55; color: var(--text); cursor: pointer; }
.agree input { width: 22px; height: 22px; margin: 1px 0 0; flex-shrink: 0; accent-color: var(--ink); cursor: pointer; }
.terms-link { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--brand-ink); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.terms-link:hover { color: var(--brand); }
.btn-submit { width: 100%; margin-top: 22px; min-height: 54px; font-size: 1.05rem; }

/* ---------- Buttons (shared with admin) ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 22px; border-radius: 10px; border: 1.5px solid transparent; font-weight: 600; font-size: 1rem; cursor: pointer; text-decoration: none; transition: background-color .15s, border-color .15s, opacity .15s; white-space: nowrap; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: var(--ink); }
.btn-primary:hover:not(:disabled) { background: #FF7B2E; }
.btn-secondary { background: var(--ink); color: #fff; }
.btn-secondary:hover:not(:disabled) { background: var(--ink-2); }
.btn-ghost-dark { background: transparent; border-color: var(--line-strong); color: var(--text); }
.btn-ghost-dark:hover:not(:disabled) { border-color: var(--text); }
.btn-block { width: 100%; }

.banner { border-radius: 12px; padding: 13px 16px; margin-top: 20px; font-weight: 500; background: var(--err-tint); color: var(--err); border: 1px solid rgba(180,35,24,.25); }
.banner.info { background: #EAF3FB; color: #1D4F7A; border-color: rgba(47,127,193,.3); }

/* ---------- Confirmation ---------- */
.done { margin-top: 26px; background: var(--white); border: 1px solid var(--line); border-radius: 16px; padding: clamp(22px, 5vw, 36px); }
.done-mark { margin-bottom: 14px; }
.done h2 { font-size: clamp(1.9rem, 5vw, 2.5rem); font-weight: 800; font-stretch: 84%; outline: none; }
.done-lede { color: var(--muted); margin-top: 8px; }
.receipt { margin: 22px 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.receipt > div { display: grid; grid-template-columns: 160px 1fr; gap: 12px; padding: 11px 15px; border-top: 1px solid var(--line); font-size: .93rem; }
.receipt > div:first-child { border-top: 0; background: var(--ink); color: #fff; }
.receipt > div:first-child dt { color: #9EABB8; }
.receipt dt { color: var(--muted); }
.receipt dd { margin: 0; font-weight: 500; word-break: break-word; }
.receipt .app-id { font: 500 1.15rem var(--f-mono); }
.mono { font-family: var(--f-mono); font-size: .84rem; }
@media (max-width: 520px) { .receipt > div { grid-template-columns: 1fr; gap: 2px; } }
.done-actions { display: flex; flex-wrap: wrap; gap: 10px; }
@media (max-width: 520px) { .done-actions .btn { width: 100%; } }
.status-line { font-size: .9rem; color: var(--muted); margin-top: 10px; }
.status-line:empty { display: none; }
.status-line.ok { color: var(--ok); }
.status-line.warn { color: var(--warn); }
.done-contact { margin-top: 20px; }
.done-contact a { color: var(--brand-ink); }

/* ---------- Terms popup ---------- */
.terms-dialog { width: min(760px, calc(100vw - 32px)); max-height: min(86vh, 900px); padding: 0; border: 0; border-radius: 16px; box-shadow: 0 40px 100px -20px rgba(0,0,0,.5); color: var(--text); overflow: hidden; }
.terms-dialog[open] { display: flex; flex-direction: column; }
.terms-dialog::backdrop { background: rgba(12,24,36,.55); }
@media (max-width: 640px) { .terms-dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; } }
.td-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px 14px 24px; border-bottom: 1px solid var(--line); }
.td-head h2 { font-size: 1.1rem; }
.td-close { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 1rem; flex-shrink: 0; }
.td-body { flex: 1; overflow-y: auto; padding: 20px clamp(18px, 4vw, 32px) 32px; font-size: .92rem; line-height: 1.65; overscroll-behavior: contain; }
.td-body h1 { font-size: 1.15rem; margin-bottom: 8px; }
.td-body h2 { font-size: 1rem; margin: 22px 0 6px; }
.td-body p { margin: 0 0 9px; }
.td-body ul { padding-left: 20px; margin: 0 0 9px; }
.td-body li { margin-bottom: 5px; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: .001ms !important; } }
