/* C4X Sign: C4X website style, app/admin-tool chrome. Tokens and components follow the c4x-website-style skill. */
:root {
  --c4x-hero: #004675; --c4x-hero-deep: #00304f; --c4x-body-bg: #071b2c; --c4x-panel-bg: #0f2c42;
  --c4x-body-text: #eaf1f7; --c4x-muted: #9fb4c7; --c4x-accent: #00a4bf; --c4x-accent-dark: #00c0ce; --c4x-gold: #e8b84b;
  --c4x-border: rgba(255,255,255,0.12); --c4x-white: #ffffff; --c4x-field-text: #0e283a;
  --c4x-glow-cyan: #67e8f9; --c4x-glow-teal: #0891b2;
  --font-heading: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font-body); background-color: var(--c4x-body-bg);
  background-image:
    radial-gradient(900px circle at 12% 0%, color-mix(in srgb, var(--c4x-glow-cyan) 22%, transparent), transparent 60%),
    radial-gradient(700px circle at 92% 18%, color-mix(in srgb, var(--c4x-glow-teal) 20%, transparent), transparent 55%),
    radial-gradient(800px circle at 50% 100%, color-mix(in srgb, var(--c4x-hero) 30%, transparent), transparent 60%);
  background-repeat: no-repeat; background-attachment: fixed; color: var(--c4x-body-text);
  -webkit-font-smoothing: antialiased; line-height: 1.6;
}
h1, h2, h3, h4, .brand, .btn { font-family: var(--font-heading); line-height: 1.15; }
h1 { font-size: clamp(1.7rem, 3.4vw, 2.3rem); font-weight: 800; margin: 0 0 1rem; }
h2 { font-size: clamp(1.25rem, 2.2vw, 1.55rem); font-weight: 700; margin: 0 0 1rem; }
h3 { font-size: 1.05rem; font-weight: 700; margin: 0 0 0.5rem; }
p { margin: 0 0 1rem; }
a { color: var(--c4x-accent); }
.muted { color: var(--c4x-muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; overflow-wrap: anywhere; }
.hidden { display: none !important; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
main { max-width: 1280px; margin: 0 auto; padding: 24px 20px 64px; }

/* top nav */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 24px; background: linear-gradient(160deg, var(--c4x-hero-deep) 0%, var(--c4x-hero) 100%); color: #fff; }
.topbar .brand { display: inline-flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 700; color: #fff; text-decoration: none; white-space: nowrap; }
.topbar .brand::before { content: ''; width: 14px; height: 14px; border-radius: 50%; background: var(--c4x-accent-dark); box-shadow: 0 0 0 4px rgba(0,192,206,.25); }
.topbar nav { display: flex; gap: 20px; align-items: center; overflow-x: auto; scrollbar-width: none; }
.topbar nav a { color: #c7d0e0; text-decoration: none; font-size: 14px; font-weight: 500; white-space: nowrap; padding: 6px 0; }
.topbar nav a:hover, .topbar nav a.active { color: #fff; }
.topbar .who { font-size: 13px; color: #c7d0e0; text-align: right; }
@media (max-width: 760px) { .topbar { flex-wrap: wrap; padding: 10px 14px; } .topbar nav { order: 3; width: 100%; } .topbar .who { max-width: 45%; overflow: hidden; text-overflow: ellipsis; } }

/* buttons: 4 tiers */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 14px; font-weight: 600; padding: 10px 18px; border-radius: 6px; border: 1px solid transparent; cursor: pointer; text-decoration: none; transition: filter .12s ease, background .12s ease; min-height: 40px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-gold { background: var(--c4x-gold); color: #1d1500; }
.btn-gold:hover:not(:disabled) { background: #cf9a2f; }
.btn-accent { background: var(--c4x-accent); color: #fff; }
.btn-accent:hover:not(:disabled) { background: var(--c4x-accent-dark); }
.btn-outline { background: transparent; border-color: var(--c4x-border); color: var(--c4x-body-text); }
.btn-outline:hover:not(:disabled) { border-color: var(--c4x-accent); color: var(--c4x-accent); }
.btn-ghost { background: transparent; color: var(--c4x-muted); border: none; padding: 6px 10px; }
.btn-ghost:hover:not(:disabled) { color: var(--c4x-body-text); }
.btn-danger { background: transparent; color: #ff9c92; border: 1px solid #ff9c92; }
.btn-sm { padding: 6px 12px; font-size: 13px; min-height: 34px; }

/* forms */
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
input[type="text"], input[type="email"], input[type="number"], input[type="search"], input[type="password"], select, textarea {
  width: 100%; font-family: var(--font-body); font-size: 16px; color: var(--c4x-field-text); background: #fff;
  border: 1px solid var(--c4x-border); border-radius: 6px; padding: 9px 11px;
}
input[type="text"], input[type="email"], input[type="number"], input[type="search"], input[type="password"] { height: 40px; }
select { height: 40px; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--c4x-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c4x-accent) 18%, transparent); }
.field { margin-bottom: 14px; }
.field-row { display: flex; gap: 12px; }
.field-row > .field { flex: 1; min-width: 0; }
.checkbox-field { display: flex; align-items: flex-start; gap: 10px; }
.checkbox-field input { margin-top: 4px; width: 20px; height: 20px; flex: none; accent-color: var(--c4x-accent); }
.checkbox-field label { margin: 0; font-weight: 500; }
@media (max-width: 640px) { .field-row { flex-direction: column; gap: 0; } }

/* panels, banners, badges, stats, tables */
.panel { background: var(--c4x-panel-bg); border: 1px solid var(--c4x-border); border-radius: 10px; box-shadow: 0 10px 28px rgba(0,8,16,.35); }
.section-panel { padding: 24px; margin-bottom: 24px; }
@media (max-width: 640px) { .section-panel { padding: 16px; } }
.status-banner { padding: 12px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 14px; }
.status-banner-info { background: rgba(255,255,255,.05); color: var(--c4x-muted); border: 1px solid var(--c4x-border); }
.status-banner-warn { background: color-mix(in srgb, var(--c4x-gold) 12%, transparent); color: var(--c4x-gold); border: 1px solid color-mix(in srgb, var(--c4x-gold) 40%, transparent); }
.status-banner-error { background: rgba(226,87,76,.12); color: #ff9c92; border: 1px solid rgba(226,87,76,.4); }
.status-banner-ok { background: rgba(0,164,191,.12); color: var(--c4x-accent-dark); border: 1px solid rgba(0,164,191,.4); }
.badge { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--c4x-border); color: var(--c4x-muted); background: var(--c4x-body-bg); white-space: nowrap; }
.badge-positive { color: #04222b; background: var(--c4x-accent); border-color: var(--c4x-accent); }
.badge-warn { color: var(--c4x-gold); border-color: color-mix(in srgb, var(--c4x-gold) 50%, transparent); }
.badge-bad { color: #ff9c92; border-color: #ff9c92; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin: 16px 0 24px; }
.stat-card { padding: 16px 18px; }
.stat-card .label { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--c4x-muted); font-weight: 700; }
.stat-card .value { font-family: var(--font-heading); font-size: 26px; font-weight: 800; margin-top: 4px; overflow-wrap: anywhere; }
.table-wrap { overflow-x: auto; }
/* Cells may break anywhere, so without a floor a phone crushes the columns to a character wide instead of scrolling. */
.table-wrap table { min-width: 640px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--c4x-border); font-size: 14px; overflow-wrap: anywhere; vertical-align: top; }
th { white-space: nowrap; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--c4x-muted); font-weight: 700; }
tbody tr:hover { background: rgba(255,255,255,.04); }
tr.clickable { cursor: pointer; }

/* three-column shell (envelope editor) */
.app-shell { --rail-w: 260px; --summary-w: 320px; display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr) var(--summary-w); min-height: calc(100vh - 64px); position: relative; }
.app-shell.rail-collapsed { --rail-w: 0px; } .app-shell.summary-collapsed { --summary-w: 0px; }
.app-rail { border-right: 1px solid var(--c4x-border); padding: 18px 14px; background: var(--c4x-panel-bg); overflow: hidden auto; }
.app-shell.rail-collapsed .app-rail { padding-left: 0; padding-right: 0; border-right-color: transparent; }
.app-shell.summary-collapsed .app-summary { padding-left: 0; padding-right: 0; border-left-color: transparent; }
.app-canvas { background-color: var(--c4x-body-bg); padding: 24px clamp(14px, 3vw, 48px) 96px; width: 100%; min-width: 0; }
.app-summary { border-left: 1px solid var(--c4x-border); background: var(--c4x-panel-bg); padding: 18px; overflow: hidden auto; }
.rail-toggle-tab { position: fixed; top: 50%; width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--c4x-border); background: var(--c4x-panel-bg); color: var(--c4x-muted); display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 12px; padding: 0; z-index: 20; }
.rail-toggle-tab:hover { color: var(--c4x-accent); border-color: var(--c4x-accent); }
#rail-toggle-tab { left: var(--rail-w); transform: translate(-50%, -50%); }
#summary-toggle-tab { right: var(--summary-w); transform: translate(50%, -50%); }
.app-shell.rail-collapsed #rail-toggle-tab { left: 6px; transform: translateY(-50%); }
.app-shell.summary-collapsed #summary-toggle-tab { right: 6px; transform: translateY(-50%); }
@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .app-rail, .app-summary { border: none; border-bottom: 1px solid var(--c4x-border); }
  .app-shell.rail-collapsed .app-rail, .app-shell.summary-collapsed .app-summary { display: none; }
  .rail-toggle-tab { display: none; }
}

/* signer cards in the rail */
.signer-card { border: 1px solid var(--c4x-border); border-left: 4px solid var(--sc, var(--c4x-accent)); border-radius: 8px; padding: 10px; margin-bottom: 10px; background: rgba(255,255,255,.03); }
.signer-card.active { background: rgba(255,255,255,.08); border-color: var(--sc); }
.signer-card .field { margin-bottom: 8px; }
.palette { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0 16px; }
.palette .btn.on { border-color: var(--c4x-accent); color: var(--c4x-accent); background: rgba(0,164,191,.1); }

/* protected content zone: the document is client-facing output and stays on a neutral light theme */
.protected-content {
  --c4x-body-text: #101c2b; --c4x-body-bg: #eef1ee; --c4x-panel-bg: #ffffff; --c4x-border: #c7cfc9; --c4x-muted: #5c6a63;
  color: var(--c4x-body-text); background-color: var(--c4x-body-bg); border-radius: 10px; padding: 14px; max-width: 920px; margin: 0 auto;
}
.pdf-page { position: relative; margin: 0 auto 14px; background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.2); touch-action: manipulation; }
.pdf-page canvas { display: block; width: 100%; height: auto; }
.pdf-page .overlay { position: absolute; inset: 0; }
.pdf-page .page-no { position: absolute; right: 8px; bottom: 6px; font-size: 11px; color: #667; background: rgba(255,255,255,.8); padding: 0 6px; border-radius: 4px; }
.field-box { position: absolute; border: 2px solid var(--fc, #00a4bf); background: color-mix(in srgb, var(--fc, #00a4bf) 14%, transparent); border-radius: 4px; font-size: 11px; color: #0e283a; display: flex; align-items: center; justify-content: center; overflow: hidden; font-weight: 600; user-select: none; white-space: nowrap; text-overflow: ellipsis; padding: 0 3px; }
.field-box.selected { outline: 2px dashed #0e283a; outline-offset: 2px; }
.field-box.editable { cursor: move; touch-action: none; }
.field-box.other { opacity: .55; border-style: dashed; }
.field-box.todo { animation: pulse 1.6s ease-in-out infinite; }
.field-box .value { font-family: 'Times New Roman', Times, serif; font-style: italic; font-weight: 400; font-size: clamp(11px, 2.4vw, 22px); color: #0b1f5c; white-space: nowrap; }
.field-box input { width: 100%; height: 100%; border: none; background: rgba(255,255,255,.85); font-size: 14px; padding: 0 4px; min-height: 0; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(0,164,191,.5); } 50% { box-shadow: 0 0 0 6px rgba(0,164,191,0); } }
@media (prefers-reduced-motion: reduce) { .field-box.todo { animation: none; } }

/* login */
.center-wrap { min-height: calc(100vh - 64px); display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 440px; padding: 28px; }
.emergency { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--c4x-border); }
.emergency summary { cursor: pointer; font-size: 13px; color: var(--c4x-muted); min-height: 32px; display: flex; align-items: center; }
.emergency[open] summary { color: var(--c4x-text, inherit); margin-bottom: 8px; }
.secret-box { font-family: ui-monospace, Consolas, monospace; font-size: 18px; letter-spacing: .04em; padding: 12px 14px; border: 1px dashed var(--c4x-border); border-radius: 8px; margin: 8px 0; user-select: all; overflow-wrap: anywhere; }

/* signing page */
.sign-bar { position: sticky; bottom: 0; z-index: 10; background: var(--c4x-panel-bg); border-top: 1px solid var(--c4x-border); padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -10px 28px rgba(0,8,16,.4); }
.sign-bar .inner { max-width: 920px; margin: 0 auto; }
@media (max-width: 600px) {
  /* Leave most of a phone screen for the document; the consent text scrolls inside the bar. */
  .sign-bar { max-height: 38vh; overflow-y: auto; padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); overscroll-behavior: contain; }
  .sign-bar .field { margin-bottom: 6px; }
  .sign-bar .sign-preview { font-size: 20px; margin: 2px 0 4px; }
  .sign-bar .checkbox-field label { font-size: 12px; line-height: 1.35; }
}
.consent-box { font-size: 13px; color: var(--c4x-muted); margin: 10px 0; }
.sign-preview { font-family: 'Times New Roman', Times, serif; font-style: italic; font-size: 26px; color: #fff; min-height: 38px; border-bottom: 1px solid var(--c4x-border); margin-bottom: 12px; overflow-wrap: anywhere; }
.progress-note { position: sticky; top: 0; z-index: 9; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 14px; }
.kv dt { color: var(--c4x-muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }

/* Kebab (three-dot) menu: a row or header with more actions than fit. The menu itself is drawn in <body>, positioned with fixed coordinates. */
.kebab-btn { display: inline-grid; place-items: center; width: 36px; height: 34px; padding: 0; border-radius: 6px; border: 1px solid var(--c4x-border); background: transparent; color: var(--c4x-body-text); cursor: pointer; transition: border-color .12s ease, background .12s ease; }
.kebab-btn:hover, .kebab-btn[aria-expanded="true"] { border-color: var(--c4x-accent); color: var(--c4x-accent); background: color-mix(in srgb, var(--c4x-accent) 12%, transparent); }
.kebab-btn:focus-visible { outline: 2px solid var(--c4x-accent); outline-offset: 2px; }
.kebab-menu { position: fixed; z-index: 1000; min-width: 210px; max-width: calc(100vw - 16px); overflow-y: auto; padding: 6px; background: var(--c4x-panel-bg); border: 1px solid var(--c4x-border); border-radius: 8px; box-shadow: 0 14px 36px rgba(0, 8, 16, .5); }
.kebab-item { display: block; width: 100%; box-sizing: border-box; min-height: 38px; padding: 9px 12px; border: 0; border-radius: 6px; background: transparent; color: var(--c4x-body-text); font: inherit; font-size: 14px; text-align: left; text-decoration: none; cursor: pointer; white-space: nowrap; }
.kebab-item:hover, .kebab-item:focus { background: color-mix(in srgb, var(--c4x-accent) 16%, transparent); outline: none; }
.kebab-item:focus-visible { outline: 2px solid var(--c4x-accent); outline-offset: -2px; }
.kebab-item.danger { color: #ff9c92; }
.kebab-item.danger:hover, .kebab-item.danger:focus { background: color-mix(in srgb, #ff9c92 16%, transparent); }
.kebab-item:disabled { opacity: .45; cursor: not-allowed; }
.kebab-sep { height: 1px; margin: 6px 4px; background: var(--c4x-border); }
.kebab-head { padding: 8px 12px 3px; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--c4x-muted); }
.cell-actions { text-align: right; width: 1%; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
