/* Fix Plan Builder, plus the sign-in gate shared by every technician page. Uses the tokens from brand.css. */

/* Before GET /api/session answers: a neutral panel instead of the sign-in form or the tool, so
   neither flashes. The spinner only fades in after 0.4s, so a quick check shows just the navy page. */
.session-check { display: grid; place-items: center; align-content: center; gap: 12px; min-height: 40vh; padding: 48px 16px; animation: session-check-in 0.2s ease 0.4s both; }
.session-check-note { margin: 0; color: var(--muted); }
@keyframes session-check-in { from { opacity: 0; } to { opacity: 1; } }

/* Sign-in gate: a centred card on the navy page */
.gate { display: grid; place-items: center; padding: clamp(32px, 8vh, 88px) 0; }
.gate-card {
  width: 100%; max-width: 420px; padding: 32px 28px; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.gate-logo { display: block; margin: 0 auto 16px; color: var(--accent); }
.gate h1 { font-size: 1.625rem; margin: 0 0 6px; letter-spacing: -0.01em; }
.gate-for { color: var(--muted); margin: 0 auto 24px; max-width: 32ch; }
.gate-form { display: grid; gap: 8px; text-align: left; }
.gate-form label { font-weight: 600; font-size: 0.9375rem; }
.gate-form input { width: 100%; min-height: 48px; padding: 10px 14px; }
.gate-form button { margin-top: 6px; min-height: 48px; width: 100%; }
.gate .form-error { text-align: left; }
.builder { padding: 32px 0 64px; }
.loading-line { display: flex; align-items: center; gap: 10px; color: var(--muted); margin-top: 16px; }
.spinner.small { width: 18px; height: 18px; border-width: 2px; }

.tabs { display: flex; gap: 6px; align-items: center; margin: 28px 0 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tab {
  background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; margin-bottom: -1px;
  color: var(--muted); font-weight: 650;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-actions { margin-left: auto; padding-bottom: 6px; }

.doc {
  background: var(--surface); border: 1px solid var(--border); border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius); padding: 32px; box-shadow: var(--shadow);
}
.doc h2 { font-size: 26px; margin: 0 0 4px; letter-spacing: -0.01em; }
.doc h3 { font-size: 18px; margin: 32px 0 10px; }
.doc p { margin: 6px 0; }
.doc .muted { color: var(--muted); }
.doc-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-bottom: 1px solid var(--border); padding-bottom: 18px; margin-bottom: 8px; }
.doc-brand { font-weight: 800; font-size: 15px; letter-spacing: 0.02em; color: var(--accent); }
.doc-meta { text-align: right; color: var(--muted); font-size: 14px; }

.grade-shift { display: flex; align-items: center; gap: 14px; margin: 20px 0 6px; flex-wrap: wrap; }
.grade-chip { width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; font-size: 28px; font-weight: 800; color: var(--grade-ink); background: var(--grade-none); }
.grade-chip[data-grade="A"] { background: var(--grade-a); }
.grade-chip[data-grade="B"] { background: var(--grade-b); }
.grade-chip[data-grade="C"] { background: var(--grade-c); }
.grade-chip[data-grade="D"] { background: var(--grade-d); }
.grade-chip[data-grade="F"] { background: var(--grade-f); }
.arrow { font-size: 24px; color: var(--muted); }
.grade-caption { color: var(--muted); font-size: 14px; }
.grade-limits-title { margin: 4px 0 0; font-weight: 600; }
.grade-limits { margin: 4px 0 8px; padding-left: 22px; }
.grade-limits li { margin: 3px 0; }

.fix-item { border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; margin: 10px 0; break-inside: avoid; }
.fix-item-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.fix-item h4 { margin: 0; font-size: 16px; }
.price { font-weight: 700; white-space: nowrap; }
.fix-item .why { margin-top: 6px; }
.fix-item .change { color: var(--muted); font-size: 15px; }
.phase-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); margin: 22px 0 2px; }

table.price-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.price-table td, .price-table th { padding: 8px 4px; border-bottom: 1px solid var(--border); text-align: left; }
.price-table td:last-child, .price-table th:last-child { text-align: right; white-space: nowrap; }
.price-table tr.total td { font-weight: 800; border-bottom: 0; font-size: 17px; }
.price-table tr.strike td:last-child { text-decoration: line-through; color: var(--muted); font-weight: 400; }
.callout { background: var(--surface-2); border-radius: 12px; padding: 14px 16px; margin-top: 12px; }
/* Fix packages, ongoing options and the founding offer (client plan) */
.packages, .recurring { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-top: 8px; }
.package { border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; break-inside: avoid; }
.package[data-recommended="true"] { border: 2px solid var(--accent); }
.package-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.package-head h4 { margin: 0; font-size: 17px; }
.package-head .price { margin-left: auto; font-size: 20px; }
.package-tag { font-size: 12px; font-weight: 700; color: var(--accent); }
.package-scope { margin: 6px 0 4px; font-weight: 600; }
.recurring-option { margin-top: 0; break-inside: avoid; }
.founding-offer { border: 2px dashed var(--accent); margin-top: 16px; }
.founding-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); }
.founding-toggle { margin: 18px 0 0; }
.next-step { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 28px; background: var(--surface-2); border-radius: 12px; padding: 18px 20px; }

/* Technician view */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin: 16px 0; }
.fact { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.fact .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }
.fact .v { font-weight: 600; word-break: break-word; }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; padding: 5px 0; }
.checklist input { margin-top: 4px; width: 18px; height: 18px; flex: none; }
.checklist li.done span { text-decoration: line-through; color: var(--muted); }
.task { border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; margin: 12px 0; break-inside: avoid; }
.task h4 { margin: 0 0 8px; font-size: 16px; }
.task .est { color: var(--muted); font-weight: 500; font-size: 14px; }
.record { border: 1px solid var(--border); border-radius: 10px; margin: 10px 0; overflow: hidden; }
.record-head { display: flex; gap: 12px; align-items: center; justify-content: space-between; background: var(--surface-2); padding: 8px 12px; font-size: 14px; flex-wrap: wrap; }
.record-head b { font-family: var(--mono); }
.record-note { color: var(--warn); font-weight: 600; }
.record-value { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; }
.record-value code { flex: 1; font: 13px/1.5 var(--mono); word-break: break-all; white-space: pre-wrap; }
.copy-btn { flex: none; font-size: 13px; padding: 4px 10px; }
.task .sub { margin: 14px 0 4px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.found { margin: 0; padding-left: 20px; }
.found li { padding: 2px 0; word-break: break-word; }
table.change-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.change-table th, .change-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.change-table th { font-size: 12px; color: var(--muted); }
.change-table td.now { color: var(--fail); }
.change-table td.to { color: var(--pass); font-weight: 600; }
.record .action { display: inline-block; font-weight: 800; font-size: 12px; text-transform: uppercase; padding: 1px 8px; border-radius: 999px; margin-right: 6px; background: var(--pass-bg); color: var(--pass); }
.record[data-action="Replace"] .action { background: var(--warn-bg); color: var(--warn); }
.record[data-action="Delete"] .action { background: var(--fail-bg); color: var(--fail); }
.record[data-action="Delete"] .record-value code { text-decoration: line-through; color: var(--muted); }
.record-value .lbl { flex: none; width: 34px; font-size: 12px; font-weight: 700; color: var(--muted); padding-top: 2px; }
.record-value.current code { color: var(--muted); }
.record-value.current { border-bottom: 1px dashed var(--border); }
.record-value.generated em { color: var(--muted); }
.record[data-blocked="true"] { border-color: var(--fail); }
.record[data-blocked="true"] .record-note { color: var(--fail); }
.record-check { padding: 0 12px 10px; font-size: 13px; color: var(--pass); font-weight: 600; }
.record[data-blocked="true"] .record-check { color: var(--fail); }
.rollback { margin-top: 4px; font-size: 15px; }
.rollback b { color: var(--warn); }
.safety { border-radius: 10px; padding: 10px 14px; margin: 12px 0; font-size: 15px; }
.safety.ok { background: var(--pass-bg); color: var(--pass); font-weight: 600; }
.safety.bad { background: var(--fail-bg); color: var(--fail); }
.safety ul { margin: 6px 0 0; }
.verify { margin-top: 8px; font-size: 15px; }
.verify b { color: var(--pass); }

@media (max-width: 640px) {
  .doc { padding: 20px 16px; }
  .doc-meta { text-align: left; }
  .tab-actions { margin-left: 0; width: 100%; padding: 8px 0; }
}

@media print {
  .site-header, .no-print, .tabs { display: none !important; }
  .doc { border: 0; box-shadow: none; padding: 0; }
  .doc[hidden] { display: none !important; }
  .copy-btn { display: none; }
}

/* Zone upload */
.zone-upload { margin: 10px 0 0; }
.zone-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.file-btn { cursor: pointer; display: inline-block; }
.zone-chip { background: var(--pass-bg); color: var(--pass); font-weight: 600; font-size: 14px; padding: 4px 10px; border-radius: 999px; }
.zone-help { font-size: 13px; color: var(--muted); margin: 6px 0 0; max-width: 760px; }
#zone-paste textarea { width: 100%; font: 13px/1.4 var(--mono); margin: 8px 0; padding: 8px; border-radius: 8px; background: var(--surface); }
.zone-panel { border: 1px solid var(--border); border-radius: 12px; padding: 4px 18px 12px; margin: 0 0 18px; }
.zone-panel h3 { margin-top: 12px; }
code.wrap { word-break: break-all; white-space: pre-wrap; font-size: 13px; }
.small { font-size: 13px; }

/* Dry run */
.tab-badge { font-size: 12px; font-weight: 800; margin-left: 4px; }
.tab-badge[data-verdict="safe"] { color: var(--pass); }
.tab-badge[data-verdict="blocked"] { color: var(--fail); }
.verdict { border-radius: 12px; padding: 14px 16px; margin: 16px 0; }
.verdict.ok { background: var(--pass-bg); color: var(--pass); }
.verdict.bad { background: var(--fail-bg); color: var(--fail); }
.verdict.check { background: var(--warn-bg); color: var(--warn); }
.tab-badge[data-verdict="check"] { color: var(--warn); }
.verdict-title { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.verdict ul { margin: 8px 0 0; }
.grade-move { display: flex; gap: 18px; align-items: center; margin: 8px 0; }
.grade-move .k { font-size: 12px; color: var(--muted); text-transform: uppercase; font-weight: 700; }
.grade-move .v { font-size: 34px; font-weight: 800; line-height: 1.1; }
.grade-move .s { color: var(--muted); }
.grade-move .arrow { font-size: 26px; color: var(--muted); }
.changes tr[data-status="later"] td, .changes tr[data-status="not-simulated"] td { color: var(--muted); }
.changes tr[data-status="blocked"] td, .changes tr[data-status="conflict"] td { color: var(--fail); }
.changes .from code { color: var(--muted); text-decoration: line-through; }
.sim-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.live-done { color: var(--pass); font-weight: 700; }
.live-pending { color: var(--warn); font-weight: 700; }
.live-error { color: var(--fail); font-weight: 700; }

/* Change review: before | after */
.review-panel { border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin: 18px 0 24px; }
.review-panel h3 { margin-top: 0; }
.diff-entry { border-top: 1px solid var(--border); padding: 14px 0; }
.diff-entry[data-blocked="true"] .diff-head, .diff-blocked { color: var(--fail); }
.diff-entry[data-blocked="unverified"] .diff-blocked { color: var(--warn); }
.diff-head { margin-bottom: 8px; }
.diff-head .action { text-transform: uppercase; font-size: 12px; font-weight: 700; letter-spacing: 0.05em; }
.diff-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.diff-col { min-width: 0; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.diff-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.diff-value { margin: 4px 0; overflow-wrap: anywhere; }
.diff-value code { white-space: pre-wrap; word-break: break-word; }
.diff-empty { color: var(--muted); font-style: italic; }
.term.added, .diff-value.added code { background: var(--pass-bg); color: var(--pass); border-radius: 3px; padding: 0 2px; }
.term.removed, .diff-value.removed code { background: var(--fail-bg); color: var(--fail); text-decoration: line-through; border-radius: 3px; padding: 0 2px; }
.diff-changes { margin: 8px 0 0; font-size: 14px; color: var(--muted); }
.diff-changes .op-remove { color: var(--fail); }
.diff-changes .op-add { color: var(--pass); }
.review-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.check-row { display: flex; gap: 8px; align-items: center; }
.confirm-dialog { max-width: 640px; width: calc(100% - 32px); background: var(--surface); color: var(--text); border: 1px solid var(--control-border); border-radius: var(--radius); padding: 22px; }
.confirm-dialog::backdrop { background: rgba(3, 7, 18, 0.7); }
.confirm-dialog input[type="text"] { display: block; width: 100%; margin-top: 6px; padding: 8px 10px; min-height: 44px; }
.copy-btn:disabled { opacity: 0.5; cursor: not-allowed; }
@media (max-width: 640px) { .diff-cols { grid-template-columns: 1fr; } }
@media print { .diff-col { background: none; } }
