/* ============================================================
   Sunject — Offer document (.ofd-*), phase 9 layout (.offer-*),
   customer page offerta.html (.op-*).
   The document uses the app tokens when present (index.html loads
   styles.css first) and falls back to the same values on the
   customer page, which loads only this file.
   ============================================================ */

/* ── Document ─────────────────────────────────────────────── */
.ofd {
  --o-ink: var(--text-primary, #1c1b19);
  --o-muted: var(--text-muted, #76716b);
  --o-border: var(--border, #e7e6e4);
  --o-soft: var(--bg-primary, #f8f8f7);
  --o-brand: var(--brand, #d97706);
  --o-brand-ink: var(--brand-ink, #9a4a05);
  color: var(--o-ink);
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.55;
}
.ofd section { margin-top: 26px; }
.ofd h3 { font-size: 1.02rem; font-weight: 650; margin: 0 0 10px; padding-bottom: 6px; position: relative; }
.ofd h3::after { content: ''; position: absolute; left: 0; bottom: 0; width: 28px; height: 3px; border-radius: 2px; background: var(--o-brand); }
.ofd p { margin: 0 0 8px; }
.ofd-head { display: flex; gap: 20px; align-items: center; padding-bottom: 18px; border-bottom: 1px solid var(--o-border); }
.ofd-logo { height: 46px; width: auto; object-fit: contain; }
.ofd-eyebrow { display: block; font-size: 0.72rem; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--o-brand-ink); }
.ofd-title h1 { font-size: 1.55rem; font-weight: 700; margin: 2px 0; letter-spacing: -0.01em; }
.ofd-title p { color: var(--o-muted); margin: 0; font-size: 0.86rem; }
.ofd-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.ofd-parties h4, .ofd-kpi span { font-size: 0.72rem; font-weight: 650; letter-spacing: 0.05em; text-transform: uppercase; color: var(--o-muted); margin: 0 0 4px; }
.ofd-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.ofd-kpi { background: var(--o-soft); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; }
.ofd-kpi b { font-size: 1.35rem; font-weight: 700; line-height: 1.2; margin-top: 2px; font-variant-numeric: tabular-nums; }
.ofd-kpi small { color: var(--o-muted); font-size: 0.76rem; }
.ofd-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.ofd-table th { text-align: left; font-size: 0.72rem; font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; color: var(--o-muted); padding: 6px 8px; border-bottom: 1px solid var(--o-border); }
.ofd-table td { padding: 8px; border-bottom: 1px solid var(--o-border); vertical-align: top; }
.ofd-table-small { font-size: 0.8rem; }
.ofd-table-small td { padding: 5px 8px; }
.ofd-num { text-align: right !important; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ofd-spec { color: var(--o-muted); font-size: 0.78rem; }
.ofd-muted { color: var(--o-muted); font-size: 0.8rem; }
.ofd-bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; height: 120px; margin: 12px 0 10px; }
.ofd-bar { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; min-width: 0; }
.ofd-bar i { display: block; width: 100%; max-width: 30px; border-radius: 4px 4px 0 0; background: var(--o-brand); }
.ofd-bar span { font-size: 0.68rem; color: var(--o-muted); }
.ofd-list { margin: 0; padding-left: 20px; }
.ofd-list li { margin-bottom: 4px; }
.ofd-notes { white-space: pre-line; }
.ofd-terms p { font-size: 0.84rem; }
.ofd-signed img { display: block; max-width: 260px; max-height: 110px; border-bottom: 1px solid var(--o-border); margin-bottom: 8px; }
.ofd-signed .ofd-muted { word-break: break-all; }

@media (max-width: 640px) {
  .ofd-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .ofd-parties { grid-template-columns: 1fr; gap: 10px; }
  .ofd-kpis { grid-template-columns: 1fr 1fr; }
  .ofd-bars { gap: 3px; height: 96px; }
}

/* ── Phase 9 in the app ───────────────────────────────────── */
.offer-layout { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 18px; align-items: start; }
.offer-side { display: flex; flex-direction: column; gap: 14px; }
.offer-side .form-card { margin: 0; }
.offer-side textarea.form-input { resize: vertical; font-family: inherit; line-height: 1.45; }
.offer-main { min-width: 0; }
.offer-toolbar { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.offer-toolbar #offerStale { flex: 1; min-width: 200px; color: var(--warning, #9a4a05); font-weight: 500; }
.offer-toolbar #offerStale:empty { visibility: hidden; }
.offer-paper { background: var(--bg-card, #fff); border: 1px solid var(--border, #e7e6e4); border-radius: var(--radius-lg, 14px); padding: 36px 40px; box-shadow: var(--shadow-float); }
.offer-issues { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 0.84rem; }
.offer-issues li { padding: 7px 10px; border-radius: 8px; }
.offer-issues li.error { background: var(--error-bg); color: var(--error); }
.offer-issues li.warn { background: var(--warning-bg); color: var(--warning); }
.offer-ok { color: var(--success); font-weight: 500; font-size: 0.86rem; }
.offer-warn { background: var(--warning-bg); color: var(--warning); padding: 8px 10px; border-radius: 8px; font-size: 0.8rem; margin-bottom: 10px; }
.offer-warn code { font-size: 0.78rem; }
.offer-links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; font-size: 0.84rem; }
.offer-links li { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.offer-link-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.offer-chip { display: inline-block; font-size: 0.72rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--bg-soft); color: var(--text-secondary); }
.offer-chip.viewed { background: var(--info-bg); color: var(--info); }
.offer-chip.signed { background: var(--success-bg); color: var(--success); }
.offer-chip.expired, .offer-chip.superseded { background: var(--bg-soft); color: var(--text-muted); }
@media (max-width: 1100px) {
  .offer-layout { grid-template-columns: 1fr; }
  .offer-paper { padding: 22px 18px; }
}

/* ── Customer page (offerta.html) ─────────────────────────── */
.op-body { margin: 0; background: #f3f3f2; color: #1c1b19; font-family: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif; -webkit-font-smoothing: antialiased; }
.op-main { max-width: 860px; margin: 0 auto; padding: 28px 16px 60px; }
.op-paper { background: #fff; border-radius: 16px; padding: 40px 44px; box-shadow: 0 8px 28px rgba(28,27,25,0.08), 0 1px 2px rgba(28,27,25,0.05); }
.op-message { background: #fff; border-radius: 16px; padding: 48px 28px; text-align: center; }
.op-message h1 { font-size: 1.3rem; margin: 0 0 8px; }
.op-message p { color: #57534e; margin: 0; }
.op-banner { border-radius: 12px; padding: 14px 18px; margin-bottom: 16px; font-size: 0.95rem; }
.op-banner.ok { background: rgba(21,128,61,0.1); color: #15803d; }
.op-banner.warn { background: rgba(217,119,6,0.12); color: #9a4a05; }
.op-sign { background: #fff; border-radius: 16px; padding: 28px 44px 32px; margin-top: 16px; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 8px 28px rgba(28,27,25,0.08); }
.op-sign h2 { font-size: 1.2rem; margin: 0 0 6px; }
.op-sign label { font-size: 0.84rem; font-weight: 600; color: #57534e; margin-top: 6px; }
.op-sign input[type=text] { font: inherit; font-size: 1rem; padding: 11px 12px; border: 1px solid #d4d2cf; border-radius: 10px; }
.op-sign input[type=text]:focus, .op-btn:focus-visible, .op-check input:focus-visible { outline: 2px solid #d97706; outline-offset: 2px; }
.op-pad { position: relative; }
.op-pad canvas { display: block; width: 100%; height: 180px; border: 1px dashed #b9b6b2; border-radius: 12px; background: #fdfdfc; touch-action: none; cursor: crosshair; }
.op-pad .op-btn { position: absolute; right: 8px; bottom: 8px; }
.op-check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500 !important; color: #1c1b19 !important; font-size: 0.95rem !important; margin-top: 10px !important; }
.op-check input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: #1c1b19; }
.op-fine { font-size: 0.78rem; color: #76716b; margin: 4px 0; line-height: 1.5; }
.op-error { color: #c62828; font-size: 0.88rem; min-height: 1.2em; margin: 0; }
.op-btn { font: inherit; font-weight: 600; font-size: 1rem; border: 0; border-radius: 10px; padding: 13px 22px; background: #1c1b19; color: #fff; cursor: pointer; }
.op-btn:disabled { opacity: 0.55; cursor: default; }
.op-btn.ghost { background: transparent; color: #1c1b19; border: 1px solid #d4d2cf; }
.op-btn.small { font-size: 0.8rem; padding: 6px 10px; background: rgba(255,255,255,0.9); }
.op-actions { text-align: center; margin-top: 18px; }
@media (max-width: 640px) {
  .op-main { padding: 12px 10px 40px; }
  .op-paper { padding: 22px 16px; border-radius: 12px; }
  .op-sign { padding: 20px 16px 24px; }
}
@media print {
  .op-body { background: #fff; }
  .op-main { padding: 0; max-width: none; }
  .op-paper { box-shadow: none; padding: 0; }
  .op-sign, .op-actions { display: none; }
  .ofd section { break-inside: avoid; }
}
