/*
 * Public proposal page (W01 Propuesta · W02 Aceptar y firmar, canvas 05).
 * Colors, type and spacing are system 00 tokens (src/theme/tokens.generated.ts); the painter's accent
 * (painterAccent.1–6, or the neutral template in textPrimary) arrives from the server as --accent.
 * Sizes are in rem so the browser's text size (AX5) scales everything; nothing has a fixed height.
 */
@font-face {
  font-family: 'Source Sans 3';
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/SourceSans3-400Regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Source Sans 3';
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/SourceSans3-600SemiBold.woff2') format('woff2');
}
@font-face {
  font-family: 'Source Sans 3';
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/SourceSans3-700Bold.woff2') format('woff2');
}

:root {
  color-scheme: light dark;
  --bg: #f3f1ec;
  --surface: #ffffff;
  --raised: #ffffff;
  --tp: #161a18;
  --ts: #434b47;
  --border: #737c78;
  --divider: #dad7cf;
  --focus: #1c4fd6;
  --success: #0b6a52;
  --success-soft: #dcf0e8;
  --warning: #8a5300;
  --warning-soft: #fcefd6;
  --danger: #b0261c;
  --danger-soft: #fbe5e2;
  --info: #1d56a8;
  --info-soft: #e2ecfa;
  --disabled-fill: #e3e1db;
  --text-disabled: #5a625e;
  --on-danger: #ffffff;
  --overlay: #161a18a6;
  --paper: #ffffff;
  --ink: #161a18;
  --sh-raised: 0 1px 3px 0 #161a1824;
  --sh-overlay: 0 8px 24px 0 #161a1833;
  --card-border: transparent;
  /* Painter accent: fills «Aceptar», the header rule, the Total rule and section titles. */
  --pa: var(--accent, var(--tp));
  --pa-on: #ffffff;
  --pa-text: var(--pa);
  --pa-sec: var(--pa);
  --veil: color-mix(in srgb, var(--tp) 12%, transparent);
  --fast: 120ms cubic-bezier(0.2, 0, 0, 1);
  --base: 220ms cubic-bezier(0.2, 0, 0, 1);
  --pad: 1rem;
  --bar-h: 15rem;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101312;
    --surface: #181c1b;
    --raised: #222826;
    --tp: #f3f5f4;
    --ts: #bcc4c0;
    --border: #88928d;
    --divider: #2e3532;
    --focus: #9bb8ff;
    --success: #5fcca8;
    --success-soft: #113a2f;
    --warning: #f3bb57;
    --warning-soft: #3a2a0c;
    --danger: #ff9187;
    --danger-soft: #3e1512;
    --info: #8cb6f7;
    --info-soft: #14284a;
    --disabled-fill: #2a302e;
    --text-disabled: #9da6a1;
    --on-danger: #1a0706;
    --overlay: #000000b3;
    --sh-raised: none;
    --sh-overlay: none;
    --card-border: #2e3532;
    /* In dark the accent only fills; titles and secondary buttons go to textPrimary. */
    --pa-text: var(--tp);
    --pa-sec: var(--tp);
  }
  html.neutral {
    --pa-on: var(--bg);
  }
}
@media (min-width: 768px) {
  :root {
    --pad: 1.5rem;
  }
}
@media (min-width: 1024px) {
  :root {
    --pad: 2rem;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--tp);
  font-family: 'Source Sans 3', -apple-system, 'Segoe UI', Arial, sans-serif;
  font-size: 1.125rem;
  line-height: 1.5rem;
  -webkit-font-smoothing: antialiased;
}
p,
h1,
h2,
ul {
  margin: 0;
}
a {
  color: var(--tp);
}
button,
input,
textarea {
  font: inherit;
  color: inherit;
}
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
[hidden] {
  display: none !important;
}
.wrap {
  overflow-wrap: anywhere;
}
.pre {
  white-space: pre-line;
}
.form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin: 0;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
svg.i {
  width: 1.5rem;
  height: 1.5rem;
  flex-shrink: 0;
  fill: currentColor;
}
svg.i.sm {
  width: 1rem;
  height: 1rem;
}

/* ---------------------------------------------------------------- type */
.t-title {
  font-size: 1.625rem;
  line-height: 2rem;
  font-weight: 700;
  letter-spacing: -0.0125rem;
}
.t-heading {
  font-size: 1.25rem;
  line-height: 1.625rem;
  font-weight: 600;
}
.t-display {
  font-size: 2.125rem;
  line-height: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.025rem;
}
.t-strong {
  font-weight: 600;
}
.t-label {
  font-size: 1rem;
  line-height: 1.25rem;
  font-weight: 600;
}
.t-caption {
  font-size: 0.875rem;
  line-height: 1.125rem;
}
.t-num {
  font-size: 1.875rem;
  line-height: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.0125rem;
}
.muted {
  color: var(--ts);
}
.tab {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.accent-title {
  color: var(--pa-text);
}

/* ---------------------------------------------------------------- layout */
.page {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 2rem;
  padding: var(--pad) var(--pad) calc(var(--bar-h) + 2rem) var(--pad);
}
.page.no-bar {
  padding-bottom: 2rem;
}
.doc {
  flex: 1 1 auto;
  max-width: 45rem;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: 1rem;
  box-shadow: var(--sh-raised);
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.stack-xs {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}
.row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.25rem 1rem;
}

/* ---------------------------------------------------------------- PainterHeader (N.º 50) */
.painter {
  border-top: 4px solid var(--pa);
}
.painter .logo {
  display: block;
  max-height: 3rem;
  max-width: 12rem;
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: left center;
}
.painter .name-big {
  color: var(--pa-text);
}
.contacts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.contact {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  max-width: 100%;
  padding: 0.5rem 0.75rem;
  border: 2px solid var(--border);
  border-radius: 0.625rem;
  color: var(--tp);
  font-size: 1rem;
  line-height: 1.25rem;
  font-weight: 600;
  text-decoration: underline;
  overflow-wrap: anywhere;
}
.compact-head {
  display: flex;
  align-items: center;
  padding: 0.75rem var(--pad);
  background: var(--surface);
  border-top: 4px solid var(--pa);
  border-bottom: 1px solid var(--divider);
}

/* ---------------------------------------------------------------- ProposalNotice (N.º 51) / Banner */
.notice {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 1rem;
  border-radius: 0.625rem;
  border: 1px solid var(--tone);
  background: var(--tone-soft);
  animation: appear var(--base);
}
.notice > svg.i {
  fill: var(--tone);
}
.notice .body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1 1 auto;
  min-width: 0;
}
.notice .body.tight {
  gap: 0.25rem;
}
.tone-success {
  --tone: var(--success);
  --tone-soft: var(--success-soft);
}
.tone-info {
  --tone: var(--info);
  --tone-soft: var(--info-soft);
}
.tone-warning {
  --tone: var(--warning);
  --tone-soft: var(--warning-soft);
}
.tone-danger {
  --tone: var(--danger);
  --tone-soft: var(--danger-soft);
}
@keyframes appear {
  from {
    opacity: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .notice {
    animation: none;
  }
}
.sig-box {
  align-self: flex-start;
  max-width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--paper);
  border: 1px solid var(--divider);
  border-radius: 0.625rem;
}
.sig-box img {
  display: block;
  height: 4rem;
  width: auto;
  max-width: 100%;
}

/* ---------------------------------------------------------------- buttons */
.btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 3.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 0.625rem;
  font-size: 1.125rem;
  line-height: 1.5rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: box-shadow var(--fast);
}
.btn.primary {
  background: var(--pa);
  color: var(--pa-on);
}
.btn.secondary {
  background: var(--surface);
  color: var(--pa-sec);
  border: 2px solid var(--pa-sec);
}
.btn.danger {
  background: var(--danger);
  color: var(--on-danger);
}
.btn.neutral {
  background: var(--tp);
  color: var(--bg);
}
/* Pressed with the painter's accent: 12 % veil of textPrimary over the control (no new tokens). */
.btn:active:not(:disabled):not([aria-disabled='true']),
.contact:active,
.link-btn:active:not(:disabled) {
  box-shadow: inset 0 0 0 100rem var(--veil);
}
.btn:disabled,
.btn.is-disabled {
  background: var(--disabled-fill);
  color: var(--text-disabled);
  border-color: transparent;
  cursor: not-allowed;
}
.btn[aria-busy='true'] {
  cursor: progress;
}
.btn[aria-busy='true'] svg.i {
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.btn.retry-ring {
  outline: 2px solid var(--danger);
  outline-offset: 2px;
}
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.btn-row > .one {
  flex: 1 1 7rem;
}
.btn-row > .two {
  flex: 2 1 12rem;
}
.link-btn {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.5rem 0.25rem;
  border: none;
  background: transparent;
  color: var(--tp);
  font-size: 1.125rem;
  line-height: 1.5rem;
  font-weight: 600;
  text-decoration: underline;
  border-radius: 0.375rem;
  cursor: pointer;
}
.link-btn:disabled {
  padding: 0.5rem 0.75rem;
  border-radius: 0.625rem;
  background: var(--disabled-fill);
  color: var(--text-disabled);
  text-decoration: none;
  cursor: not-allowed;
}

/* ---------------------------------------------------------------- document */
.sections {
  padding: 0 1rem;
  gap: 0;
}
.section {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 0;
}
.section + .section {
  border-top: 1px solid var(--divider);
}
.excl {
  padding-left: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.photos {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}
@media (min-width: 768px) {
  .photos {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}
.photo {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  padding: 0;
  border: none;
  border-radius: 0.375rem;
  background: var(--divider);
  overflow: hidden;
  cursor: zoom-in;
}
.photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.photo .room {
  position: absolute;
  left: 0.375rem;
  bottom: 0.375rem;
  max-width: calc(100% - 0.75rem);
  padding: 0.125rem 0.375rem;
  border-radius: 0.375rem;
  background: var(--surface);
  color: var(--tp);
  font-size: 0.875rem;
  line-height: 1.125rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.total-row {
  margin-top: 0.25rem;
  padding-top: 0.75rem;
  border-top: 2px solid var(--pa);
}
.trial {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--divider);
}
.trial img {
  width: 1.5rem;
  height: 1.5rem;
}
.trial a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  color: var(--ts);
}
.brand-dark {
  display: none;
}
@media (prefers-color-scheme: dark) {
  .brand-light {
    display: none;
  }
  .brand-dark {
    display: block;
  }
}
.legal-note a {
  color: var(--ts);
}

/* ---------------------------------------------------------------- StickyActionBar web (N.º 2) */
.bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  background: var(--raised);
  border-top: 1px solid var(--divider);
  box-shadow: var(--sh-overlay);
  padding: 0.75rem var(--pad) calc(1rem + env(safe-area-inset-bottom)) var(--pad);
}
.bar.static {
  position: static;
  margin-top: 1.5rem;
}
.bar .inner {
  max-width: 45rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.bar .reason {
  display: flex;
  align-items: flex-start;
  gap: 0.25rem;
  color: var(--warning);
  font-weight: 600;
}
.float-accept {
  position: fixed;
  right: 1rem;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  z-index: 3;
  min-height: 3.5rem;
  padding: 0.5rem 1.25rem;
  border: 2px solid var(--pa-sec);
  border-radius: 999px;
  background: var(--raised);
  color: var(--pa-sec);
  box-shadow: var(--sh-overlay);
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
/* DecisionPanel (N.º 52): desktop column; the bar and the in-flow totals hide. */
.side {
  display: none;
}
@media (min-width: 1024px) {
  .side {
    display: flex;
    position: sticky;
    top: 2rem;
    width: 20rem;
    flex-shrink: 0;
    flex-direction: column;
    gap: 1rem;
    padding: 1.5rem;
    background: var(--raised);
    border: 1px solid var(--card-border);
    border-radius: 1rem;
    box-shadow: var(--sh-overlay);
  }
  .bar,
  .float-accept,
  .in-totals {
    display: none !important;
  }
  .page {
    padding-bottom: 2rem;
  }
}

/* ---------------------------------------------------------------- Dialog · decline (N.º 38) */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: var(--overlay);
  overflow-y: auto;
}
.dialog {
  width: 100%;
  max-width: 30rem;
  margin: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem;
  background: var(--raised);
  border: 1px solid var(--card-border);
  border-radius: 1rem;
  box-shadow: var(--sh-overlay);
}

/* ---------------------------------------------------------------- photo viewer */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  padding-bottom: calc(1rem + env(safe-area-inset-bottom));
  background: #000000;
  color: #f3f5f4;
}
.viewer .stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.viewer .stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 0.375rem;
}
.viewer .round,
.viewer .close-wide {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 2px solid #88928d;
  background: #222826;
  color: #f3f5f4;
  cursor: pointer;
}
.viewer .round {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 999px;
  padding: 0;
}
.viewer .round.small {
  width: 2.75rem;
  height: 2.75rem;
}
.viewer .close-wide {
  flex: 1 1 auto;
  gap: 0.5rem;
  min-height: 3.5rem;
  border-radius: 0.625rem;
  font-weight: 600;
}
.viewer .round:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ---------------------------------------------------------------- ScreenState web (N.º 42/43) */
.state {
  flex-grow: 1;
  max-width: 30rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1rem;
  padding: 6rem 1.5rem 3rem;
}
.state.ok {
  padding-top: 3rem;
}
.state .badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 4rem;
  height: 4rem;
  border-radius: 999px;
  background: var(--tone-soft);
}
.state .badge svg.i {
  width: 2rem;
  height: 2rem;
  fill: var(--tone);
}
.state .badge.big {
  width: 5.5rem;
  height: 5.5rem;
}
.state .badge.big svg.i {
  width: 3rem;
  height: 3rem;
}
.tone-neutral {
  --tone: var(--ts);
  --tone-soft: var(--disabled-fill);
}
.state .actions {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}
.state .card {
  align-self: stretch;
  text-align: left;
}

/* ---------------------------------------------------------------- skeleton */
.skel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1rem;
  max-width: 45rem;
  margin: 0 auto;
}
.skel .card.head {
  border-top: 4px solid var(--disabled-fill);
}
.bone {
  border-radius: 0.375rem;
  background: var(--disabled-fill);
  height: 1.125rem;
}

/* ---------------------------------------------------------------- W02 form */
.w02 {
  max-width: 45rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.5rem var(--pad) calc(var(--bar-h) + 2rem) var(--pad);
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.input {
  display: block;
  width: 100%;
  min-height: 3.5rem;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border);
  border-radius: 0.625rem;
  background: var(--surface);
  color: var(--tp);
  font-size: 1.125rem;
  line-height: 1.5rem;
  transition: border-color var(--fast);
}
.input:focus {
  border-color: var(--pa-sec);
}
textarea.input {
  min-height: 7.5rem;
  resize: vertical;
}
.input[aria-invalid='true'] {
  border: 3px solid var(--danger);
}
fieldset {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: none;
}
legend {
  padding: 0;
  margin: 0 0 0.25rem;
}
.msg {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.375rem;
  font-size: 0.875rem;
  line-height: 1.125rem;
}
.msg.error {
  color: var(--danger);
  font-weight: 600;
}
.msg:empty {
  display: none;
}
/* SignaturePad web (N.º 20): white canvas and dark ink in both themes. */
.pad {
  position: relative;
  min-height: 12.5rem;
  border: 2px solid var(--border);
  border-radius: 0.625rem;
  background: var(--paper);
  color: var(--ink);
  overflow: hidden;
  touch-action: none;
}
.pad.drawing {
  border-color: var(--pa-sec);
}
@media (prefers-color-scheme: dark) {
  .pad.drawing {
    border-color: var(--pa);
  }
  html.neutral .pad.drawing {
    border-color: var(--tp);
  }
}
.pad.invalid {
  border: 3px solid var(--danger);
}
.pad.busy {
  pointer-events: none;
}
.pad canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.pad .baseline {
  position: absolute;
  left: 1rem;
  right: 1rem;
  bottom: 2.5rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding-bottom: 0.375rem;
  border-bottom: 2px dashed #737c78;
  font-size: 0.875rem;
  line-height: 1.125rem;
  pointer-events: none;
}
.pad.has-ink .baseline {
  border-bottom-color: #dad7cf;
}
.pad.has-ink .guide {
  display: none;
}
.sig-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}
.check {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  min-height: 2.75rem;
  cursor: pointer;
}
.check input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
}
.check .box {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid var(--border);
  border-radius: 0.375rem;
  background: var(--surface);
  color: var(--pa-on);
}
.check .box svg {
  width: 1.125rem;
  height: 1.125rem;
  fill: currentColor;
  visibility: hidden;
}
.check input:checked + .box {
  background: var(--pa);
  border-color: var(--pa);
}
.check input:checked + .box svg {
  visibility: visible;
}
.check input:focus-visible + .box {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.check input[aria-invalid='true'] + .box {
  border: 3px solid var(--danger);
}
