/* BAPC Contracts — design tokens and components from e-sign.vis (docs/VISUAL.md, images docs/vis/image1.png and
   image2.png): deep charcoal-brown base with warm gradients, orange/copper accents, layered tinted glass, thin amber
   illuminated borders, luminous orange primary buttons. Semantic green/red/amber only for status. F27: every brand
   colour is a token, so a tenant theme can override it (no hard-coded branding in signer or guest pages). */
:root {
  --bg-0: #0d0806;
  --bg-1: #160e0a;
  --bg-2: #21150f;
  --glass: rgba(42, 27, 19, 0.62);
  --glass-strong: rgba(52, 33, 22, 0.82);
  --glass-hi: rgba(255, 196, 140, 0.06);
  --edge: rgba(232, 133, 58, 0.34);
  --edge-strong: rgba(255, 150, 70, 0.7);
  --accent: #f07a2a;
  --accent-2: #c8743f;
  --accent-3: #ffb067;
  --accent-ink: #1b0f08;
  --text: #ffffff;
  --text-2: #f1e6dc;
  --muted: #b8a596;
  --muted-2: #8e7b6d;
  --good: #3fbf7f;
  --bad: #e5484d;
  --warn: #f2b33d;
  --info: #4c9be8;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 210, 170, 0.06);
  --focus: 0 0 0 3px rgba(255, 160, 80, 0.85);
  --font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --gap: 16px;
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text-2);
  background: radial-gradient(1200px 600px at 75% -10%, rgba(240, 122, 42, 0.16), transparent 60%),
    radial-gradient(900px 500px at -10% 30%, rgba(200, 116, 63, 0.1), transparent 60%), linear-gradient(180deg, var(--bg-1), var(--bg-0) 70%);
  background-color: var(--bg-0);
  min-height: 100vh;
  line-height: 1.5;
  font-size: 15px;
}
a { color: var(--accent-3); }
a:hover { color: #ffd2a6; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 8px; z-index: 99; }
.skip:focus { left: 8px; }
h1, h2, h3 { color: var(--text); margin: 0 0 0.4em; line-height: 1.15; }
h1 { font-size: clamp(1.6rem, 2.4vw + 1rem, 2.6rem); font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; }
.em { color: var(--accent); }
.em-2 { color: var(--accent-3); }
small, .small { font-size: 0.82rem; color: var(--muted); }
.muted { color: var(--muted); }
code, .mono { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: 0.85em; word-break: break-all; }

/* ---------- header / navigation ---------- */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px; padding: 10px 22px;
  background: rgba(16, 10, 7, 0.82); backdrop-filter: blur(14px); border-bottom: 1px solid rgba(232, 133, 58, 0.18);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; min-width: 0; }
.brand svg { width: 34px; height: 34px; flex: none; }
.brand b { font-size: 1.15rem; letter-spacing: 0.04em; display: block; line-height: 1; }
.brand span { font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav a {
  display: flex; align-items: center; gap: 6px; padding: 7px 9px; border-radius: 10px; color: var(--text-2); text-decoration: none; font-size: 0.9rem; white-space: nowrap;
  border: 1px solid transparent;
}
.nav a svg { width: 16px; height: 16px; opacity: 0.85; }
.nav a:hover { background: var(--glass-hi); color: var(--text); }
.nav a[aria-current='page'] {
  color: var(--text); background: linear-gradient(180deg, rgba(240, 122, 42, 0.28), rgba(240, 122, 42, 0.1)); border-color: var(--edge-strong);
  box-shadow: 0 0 18px rgba(240, 122, 42, 0.35), inset 0 1px 0 rgba(255, 200, 150, 0.2);
}
.search-top { display: flex; align-items: center; }
.search-top input { width: 190px; }
@media (max-width: 1700px) { .brand span span { display: none; } .who .n { display: none; } }
.who { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, #5a3520, #2b1a11); border: 1px solid var(--edge); color: var(--text); font-weight: 700; font-size: 0.8rem; }
.who .n { line-height: 1.1; font-size: 0.85rem; color: var(--text); }
.who .n small { display: block; }
.menu-btn { display: none; }

main { padding: 22px; max-width: 1560px; margin: 0 auto; }
.footer { padding: 26px 22px 40px; color: var(--muted-2); font-size: 0.8rem; text-align: center; }
.footer a { color: var(--muted); }

/* ---------- glass surfaces ---------- */
.glass, .card {
  position: relative; background: linear-gradient(160deg, var(--glass-strong), var(--glass)); backdrop-filter: blur(12px);
  border: 1px solid var(--edge); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px;
}
.card::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(135deg, rgba(255, 190, 130, 0.08), transparent 35%);
}
.card > * { position: relative; }
.card h2 { display: flex; align-items: center; gap: 8px; }
.card h2 svg { width: 18px; height: 18px; color: var(--accent); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: var(--gap); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.stack > * + * { margin-top: var(--gap); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }

/* ---------- hero ---------- */
.hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 24px; align-items: center; padding: 18px 4px 26px; position: relative; overflow: hidden; }
.hero::after {
  content: ''; position: absolute; right: -10%; top: -30%; width: 70%; height: 160%; pointer-events: none; z-index: -1;
  background: radial-gradient(closest-side, rgba(240, 122, 42, 0.25), transparent), repeating-radial-gradient(circle at 80% 40%, rgba(255, 150, 70, 0.08) 0 1px, transparent 2px 22px);
}
.hero h1 { font-size: clamp(2rem, 3.4vw + 1rem, 3.5rem); }
.hero p.lead { font-size: 1.12rem; color: var(--text-2); max-width: 40rem; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--edge); background: rgba(240, 122, 42, 0.08); font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-2); }
.eyebrow::before { content: ''; width: 8px; height: 8px; border-radius: 50%; border: 2px solid var(--accent); }
.sheets { position: relative; height: 320px; perspective: 900px; }
.sheet { position: absolute; border-radius: 14px; border: 1px solid var(--edge); background: var(--glass-strong); box-shadow: var(--shadow); padding: 12px; }
.sheet.paper { background: linear-gradient(180deg, #f6efe8, #e9ded3); color: #2b1a11; }
.sheet .line { height: 7px; border-radius: 4px; background: rgba(60, 40, 25, 0.18); margin: 7px 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 11px; font: inherit; font-weight: 600; font-size: 0.92rem;
  cursor: pointer; text-decoration: none; color: var(--text); background: rgba(30, 19, 13, 0.7); border: 1px solid var(--edge);
  box-shadow: inset 0 1px 0 rgba(255, 210, 170, 0.08); transition: box-shadow 0.15s, transform 0.05s, background 0.15s; min-height: 40px;
}
.btn:hover { border-color: var(--edge-strong); box-shadow: 0 0 16px rgba(240, 122, 42, 0.28), inset 0 1px 0 rgba(255, 210, 170, 0.12); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  color: #fff; border-color: rgba(255, 170, 100, 0.9); background: linear-gradient(180deg, #ff8f3d, #e2611c);
  box-shadow: 0 6px 22px rgba(240, 110, 30, 0.45), inset 0 1px 0 rgba(255, 230, 200, 0.45), inset 0 -2px 0 rgba(120, 40, 0, 0.35);
}
.btn.primary:hover { background: linear-gradient(180deg, #ff9d55, #ea6b25); }
.btn.danger { border-color: rgba(229, 72, 77, 0.6); }
.btn.small { padding: 6px 10px; min-height: 32px; font-size: 0.82rem; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.signin { white-space: nowrap; }

/* ---------- metric tiles ---------- */
.tile { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start; }
.tile .ico { width: 44px; height: 44px; border-radius: 11px; display: grid; place-items: center; background: rgba(240, 122, 42, 0.12); border: 1px solid var(--edge); color: var(--accent); }
.tile .ico svg { width: 22px; height: 22px; }
.tile .k { font-size: 0.85rem; color: var(--text-2); }
.tile .v { font-size: 1.8rem; font-weight: 800; color: var(--text); line-height: 1.1; }
.tile .d { font-size: 0.78rem; }
.up { color: var(--good); }
.down { color: var(--bad); }
.spark { width: 100%; height: 34px; }

/* ---------- forms ---------- */
label { display: block; font-size: 0.84rem; color: var(--text-2); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: rgba(14, 9, 6, 0.72); border: 1px solid rgba(232, 133, 58, 0.3); border-radius: 10px; padding: 9px 11px; min-height: 40px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--edge-strong); box-shadow: var(--focus); }
textarea { min-height: 120px; resize: vertical; }
.field { margin-bottom: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
fieldset { border: 1px solid var(--edge); border-radius: var(--radius-sm); padding: 12px; margin: 0 0 12px; }
legend { padding: 0 6px; color: var(--text); font-weight: 600; }
.check { display: flex; gap: 8px; align-items: flex-start; }
.check input { width: 20px; min-height: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; padding: 8px 10px; border-bottom: 1px solid rgba(232, 133, 58, 0.22); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid rgba(232, 133, 58, 0.1); vertical-align: top; }
tr:hover td { background: rgba(255, 170, 100, 0.03); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- badges / alerts ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 7px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; border: 1px solid; white-space: nowrap; }
.b-good { color: #7ee2ad; border-color: rgba(63, 191, 127, 0.55); background: rgba(63, 191, 127, 0.12); }
.b-bad { color: #ff9a9d; border-color: rgba(229, 72, 77, 0.6); background: rgba(229, 72, 77, 0.12); }
.b-warn { color: #ffd27d; border-color: rgba(242, 179, 61, 0.6); background: rgba(242, 179, 61, 0.12); }
.b-info { color: #9cc8f5; border-color: rgba(76, 155, 232, 0.6); background: rgba(76, 155, 232, 0.12); }
.b-muted { color: var(--muted); border-color: rgba(184, 165, 150, 0.4); background: rgba(184, 165, 150, 0.08); }
.b-brand { color: var(--accent-3); border-color: var(--edge-strong); background: rgba(240, 122, 42, 0.12); }
.alert { border-radius: var(--radius-sm); padding: 10px 14px; border: 1px solid var(--edge); background: rgba(240, 122, 42, 0.07); margin: 10px 0; }
.alert.bad { border-color: rgba(229, 72, 77, 0.6); background: rgba(229, 72, 77, 0.08); }
.alert.good { border-color: rgba(63, 191, 127, 0.55); background: rgba(63, 191, 127, 0.08); }
.alert.warn { border-color: rgba(242, 179, 61, 0.6); background: rgba(242, 179, 61, 0.08); }
.ai-note { font-size: 0.8rem; color: var(--muted); border-left: 3px solid var(--accent); padding: 6px 10px; margin: 8px 0; background: rgba(240, 122, 42, 0.05); }
.sample { font-size: 0.72rem; color: var(--warn); }

/* ---------- charts ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .axis { stroke: rgba(232, 133, 58, 0.25); }
.chart .grid-line { stroke: rgba(232, 133, 58, 0.09); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.8rem; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.heat { display: grid; gap: 3px; }
.heat div { border-radius: 4px; min-height: 22px; display: grid; place-items: center; font-size: 0.72rem; color: #1b0f08; font-weight: 700; }

/* ---------- timeline / lists ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 14px 1fr auto; gap: 10px; padding: 8px 0; border-bottom: 1px solid rgba(232, 133, 58, 0.08); }
.timeline .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 6px 14px; font-size: 0.9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--text-2); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--edge); margin-bottom: 14px; overflow-x: auto; }
.tabs a, .tabs button { padding: 8px 14px; color: var(--text-2); text-decoration: none; border: 0; background: none; font: inherit; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs [aria-selected='true'], .tabs [aria-current='page'] { color: var(--text); border-bottom-color: var(--accent); }
.feature { display: grid; grid-template-columns: auto 1fr; gap: 14px; }
.feature .ico { width: 52px; height: 52px; border-radius: 12px; display: grid; place-items: center; border: 1px solid var(--edge); background: rgba(240, 122, 42, 0.1); color: var(--accent); }
.feature .ico svg { width: 26px; height: 26px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 8px; border: 1px solid var(--edge-strong); color: var(--accent-3); font-size: 0.75rem; }
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.steps li { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 11px; border: 1px solid var(--edge); background: rgba(30, 19, 13, 0.6); }
.empty { padding: 26px; text-align: center; color: var(--muted); border: 1px dashed var(--edge); border-radius: var(--radius-sm); }

/* ---------- editor ---------- */
.editor-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--gap); }
.doc-paper { background: #fbf7f2; color: #241810; border-radius: 10px; padding: 36px 44px; min-height: 60vh; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5); }
.doc-paper :focus-visible { box-shadow: none; }
.doc-paper .ProseMirror { outline: none; min-height: 55vh; font-family: Georgia, 'Times New Roman', serif; font-size: 1.02rem; line-height: 1.6; }
.doc-paper h1, .doc-paper h2, .doc-paper h3 { color: #1a0f08; }
.doc-paper .flag { background: rgba(229, 72, 77, 0.18); border-bottom: 2px solid #c0392b; }
.ProseMirror-yjs-cursor { position: relative; border-left: 2px solid; margin-left: -1px; }
.ProseMirror-yjs-cursor > div { position: absolute; top: -1.3em; left: -1px; font-size: 11px; color: #fff; padding: 0 4px; border-radius: 3px; white-space: nowrap; }
.sig-pad { width: 100%; height: 160px; background: #fbf7f2; border-radius: 10px; touch-action: none; cursor: crosshair; }

@media (max-width: 1100px) {
  .g6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { grid-template-columns: 1fr; }
  .sheets { display: none; }
  .search-top input { width: 160px; }
  .editor-wrap { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  main { padding: 14px; }
  .top { flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .nav { order: 3; width: 100%; flex: none; }
  .search-top { display: none; }
  .g2, .g3, .g4, .g6 { grid-template-columns: minmax(0, 1fr); }
  .span2 { grid-column: auto; }
  .kv { grid-template-columns: 1fr; }
  .who .n { display: none; }
  .doc-paper { padding: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
