:root {
    --navy: #164151;
    --teal: #1a8d96;
    --teal-soft: rgba(26,141,150,0.15);
    --bg: #f4f6f7;
    --panel: #ffffff;
    --border: #dfe3e7;
    --border-strong: #cdd3d9;
    --muted: #6b747c;
    --error: #b3261e;
    --pad: 2rem;              /* page side padding */
    --table-w: 900px;         /* keeps data readable, not flung across the screen */
}

* { box-sizing: border-box; }
html { font-size: 15px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    background: var(--bg); color: var(--navy); margin: 0; line-height: 1.45;
}

h1,h2,h3 { line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 1.3rem 0 0.6rem; font-weight: 600; }
h3 { font-size: 1rem; margin: 1.15rem 0 0.5rem; font-weight: 600; }

/* login / gate card */
.centered-page { display:flex; align-items:center; justify-content:center; min-height:100vh; padding:1rem; }
.card { background:var(--panel); border:1px solid var(--border); border-radius:12px; padding:1.75rem; width:100%; max-width:400px; box-shadow:0 1px 2px rgba(22,65,81,0.04); }
.card h1 { font-size:1.25rem; margin-top:0; }

/* top bar - full width, aligned to the page padding */
.topbar { display:flex; justify-content:space-between; align-items:center; gap:1rem; flex-wrap:wrap; padding:0.6rem var(--pad); background:var(--navy); color:#fff; }
.topbar h1 { margin:0; font-size:1.05rem; font-weight:600; }
.topbar a { color:#fff; text-decoration:none; }
.topbar-nav { display:flex; align-items:center; flex-wrap:wrap; gap:0.9rem; font-size:0.92rem; }
.topbar-nav a.link { opacity:0.85; }
.topbar-nav a.link:hover { opacity:1; }
/* secondary buttons sitting on the dark bar need a visible outline treatment */
.topbar .btn-secondary { background:transparent; color:#fff; border:1px solid rgba(255,255,255,0.55); }
.topbar .btn-secondary:hover { background:rgba(255,255,255,0.12); filter:none; }
.active-nav { opacity:1 !important; font-weight:600; box-shadow:inset 0 -2px 0 var(--teal); padding-bottom:2px; }

/* buttons */
.btn, button[type="submit"] { background:var(--teal); color:#fff; border:none; padding:0.45rem 0.95rem; border-radius:8px; cursor:pointer; text-decoration:none; font-size:0.9rem; display:inline-block; line-height:1.4; }
.btn:hover, button[type="submit"]:hover { filter:brightness(0.95); }
.btn-secondary { background:var(--panel); color:var(--navy); border:1px solid var(--border-strong); }
.btn-danger { background:var(--error); color:#fff; border-color:var(--error); }
.btn-danger:hover { filter:brightness(0.92); }
.link { color:var(--navy); }
.link-btn { background:none; border:none; padding:0; cursor:pointer; color:var(--teal); text-decoration:underline; font-size:0.9rem; }

/* tabs */
.tabs { display:flex; gap:0.3rem; padding:0.7rem var(--pad) 0; }
.tab { padding:0.4rem 0.85rem; text-decoration:none; color:var(--muted); border-bottom:2px solid transparent; font-size:0.95rem; }
.tab.active { border-bottom-color:var(--teal); color:var(--navy); font-weight:600; }

/* content */
main { padding:1.25rem var(--pad) 2.5rem; }
main.narrow { max-width:560px; }

/* tables */
.doc-table { width:100%; max-width:var(--table-w); border-collapse:separate; border-spacing:0; background:var(--panel); border:1px solid var(--border); border-radius:12px; overflow:hidden; box-shadow:0 1px 2px rgba(22,65,81,0.04); }
.doc-table th, .doc-table td { text-align:left; padding:0.65rem 0.9rem; border-bottom:1px solid #eef0f2; font-size:0.92rem; vertical-align:middle; }
.doc-table th { color:var(--muted); font-weight:600; font-size:0.74rem; text-transform:uppercase; letter-spacing:0.04em; background:#fafbfc; border-bottom-color:var(--border); white-space:nowrap; }
.doc-table tbody tr:hover td { background:#f8fafb; }
.doc-table tr:last-child td { border-bottom:none; }
.doc-table td:last-child, .doc-table th:last-child { text-align:right; white-space:nowrap; }
.doc-table a { color:var(--teal); text-decoration:none; font-weight:500; }
.doc-table a:hover { text-decoration:underline; }
.doc-table input[type="checkbox"] { width:auto; margin:0; }

.empty-state { color:var(--muted); }

/* forms + inputs (soft, not boxy) */
form label { display:block; margin-bottom:0.85rem; font-size:0.9rem; }
form input, form select, form textarea {
    display:block; width:100%; padding:0.5rem 0.7rem; margin-top:0.3rem;
    border:1px solid var(--border-strong); border-radius:8px; background:var(--panel);
    font-size:0.95rem; font-family:inherit; color:var(--navy);
    transition:border-color 0.12s, box-shadow 0.12s;
}
form input:focus, form select:focus, form textarea:focus {
    outline:none; border-color:var(--teal); box-shadow:0 0 0 3px var(--teal-soft);
}
form select {
    -webkit-appearance:none; appearance:none; padding-right:2rem; cursor:pointer;
    background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b747c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
    background-repeat:no-repeat; background-position:right 0.65rem center;
}
form input[type="checkbox"] { width:auto; display:inline-block; margin:0; }

.signer-block { border:1px solid var(--border); border-radius:10px; margin-bottom:0.85rem; padding:0.9rem 1.1rem; background:var(--panel); }
.signer-block legend { font-weight:600; padding:0 0.35rem; }

/* search row */
.search-bar { display:flex; gap:0.5rem; max-width:440px; margin-bottom:1.1rem; }
.search-bar input { margin-top:0; }
.search-bar button { flex:0 0 auto; }

.error { color:var(--error); }
.notice { color:var(--teal); }
.hint { color:var(--muted); font-size:0.88rem; }

/* inbox tiles - compact */
.stat-grid { display:flex; flex-wrap:wrap; gap:0.85rem; margin-top:0.4rem; max-width:var(--table-w); }
.stat-card { flex:1 1 150px; background:var(--panel); border:1px solid var(--border); border-radius:10px; padding:0.9rem 1rem; text-decoration:none; color:var(--navy); display:block; transition:border-color 0.12s; }
.stat-card:hover { border-color:var(--teal); }
.stat-num { font-size:1.7rem; font-weight:700; line-height:1; }
.stat-card.is-zero .stat-num { color:#c3c9ce; }
.stat-label { margin-top:0.35rem; color:var(--muted); font-size:0.85rem; }
.stat-card.attention { border-color:var(--error); background:#fdecea; }
.stat-card.attention .stat-num, .stat-card.attention .stat-label { color:var(--error); }


/* ================================================================
   Shared components (used across the admin pages)
   ================================================================ */

/* Secondary buttons that are also submit buttons keep the secondary look */
button.btn-secondary[type="submit"], button.btn-secondary { background:var(--panel); color:var(--navy); border:1px solid var(--border-strong); }
button.btn-secondary[type="submit"]:hover, .btn-secondary:hover { background:#f5f6f7; filter:none; }
button.btn-danger[type="submit"] { background:var(--error); color:#fff; }
.btn-ghost-danger, button.btn-ghost-danger[type="submit"] { background:var(--panel); color:var(--error); border:1px solid rgba(179,38,30,0.45); }
.btn-ghost-danger:hover, button.btn-ghost-danger[type="submit"]:hover { background:var(--error); color:#fff; filter:none; }
.btn-sm, button.btn-sm[type="submit"] { font-size:0.8rem; padding:0.3rem 0.7rem; }
.btn svg, button svg { vertical-align:-3px; }

/* Page container + header row */
.page { max-width:1180px; margin:0 auto; }
.page.narrow { max-width:760px; }
.page-head { display:flex; justify-content:space-between; align-items:flex-end; gap:1rem; flex-wrap:wrap; margin:0.2rem 0 1.1rem; }
.page-head h2 { margin:0; font-size:1.45rem; }
.page-head p { margin:0.25rem 0 0; color:var(--muted); font-size:0.92rem; }
.back-link { display:inline-block; color:var(--muted); text-decoration:none; font-size:0.9rem; margin-bottom:0.9rem; }
.back-link:hover { color:var(--navy); }

/* Panels */
.panel { background:var(--panel); border:1px solid var(--border); border-radius:12px; padding:1.3rem 1.5rem; margin-bottom:1.25rem; box-shadow:0 1px 2px rgba(22,65,81,0.04); }
.panel > h3:first-child { margin-top:0; }
.panel-head { display:flex; justify-content:space-between; align-items:center; gap:0.75rem; flex-wrap:wrap; margin-bottom:1rem; }
.panel-head h3 { margin:0; font-size:1.05rem; }
.panel .sub, .panel-head .sub { color:var(--muted); font-size:0.85rem; }

/* Flash messages */
.flash { border-radius:10px; padding:0.75rem 1rem; margin-bottom:1rem; font-size:0.95rem; }
.flash.ok { background:var(--teal-soft); color:var(--navy); border:1px solid rgba(26,141,150,0.35); }
.flash.error { background:#fdecea; color:var(--error); border:1px solid rgba(179,38,30,0.3); }
.flash a { color:inherit; font-weight:600; }

/* Status pills */
.pill { display:inline-flex; align-items:center; gap:0.35rem; font-size:0.74rem; font-weight:600; padding:0.18rem 0.6rem; border-radius:999px; white-space:nowrap; line-height:1.4; }
.pill.dot::before { content:''; width:6px; height:6px; border-radius:50%; background:currentColor; }
.pill.grey  { background:#eef0f2; color:#5b646c; }
.pill.amber { background:#fff4de; color:#9a6300; }
.pill.green { background:#e3f5ec; color:#1d7a4c; }
.pill.blue  { background:#e4f1fb; color:#1f639c; }
.pill.red   { background:#fdecea; color:var(--error); }
.pill.new, .pill.teal { background:var(--teal); color:#fff; }

/* Small square icon buttons */
.icon-btn { display:inline-flex; align-items:center; justify-content:center; width:32px; height:32px; border-radius:8px; border:1px solid var(--border); background:var(--panel); color:var(--navy); cursor:pointer; padding:0; text-decoration:none; vertical-align:middle; }
button.icon-btn[type="submit"] { background:var(--panel); color:var(--navy); border:1px solid var(--border); padding:0; }
.icon-btn:hover, button.icon-btn[type="submit"]:hover { border-color:var(--teal); color:var(--teal); filter:none; }
.icon-btn.danger:hover, button.icon-btn.danger[type="submit"]:hover { border-color:var(--error); color:var(--error); }
.icon-btn svg { width:15px; height:15px; }
form.inline { display:inline; margin:0; }

/* List toolbar: search + filters */
.toolbar-row { display:flex; gap:0.6rem; flex-wrap:wrap; align-items:center; margin:0 0 1rem; }
.toolbar-row .search-bar { display:flex; gap:0.5rem; flex:1 1 360px; max-width:520px; margin:0; }
.toolbar-row input[type=text], .toolbar-row select { margin:0; }
.toolbar-row select { width:auto; }
.toolbar-row .spacer { flex:1 1 auto; }

/* Sortable column headers */
.th-sort { color:inherit !important; text-decoration:none !important; font-weight:inherit !important; display:inline-flex; align-items:center; gap:0.25rem; }
.th-sort:hover { color:var(--navy) !important; }
.th-sort .arrow { font-size:0.7rem; opacity:0.35; }
.th-sort.on { color:var(--navy) !important; }
.th-sort.on .arrow { opacity:1; color:var(--teal); }

/* Paging */
.pager { display:flex; align-items:center; justify-content:space-between; gap:0.75rem; flex-wrap:wrap; margin-top:0.9rem; max-width:var(--table-w); font-size:0.88rem; color:var(--muted); }
.pager .pages { display:flex; gap:0.3rem; flex-wrap:wrap; }
.pager .pages a, .pager .pages span { min-width:2rem; text-align:center; padding:0.3rem 0.55rem; border-radius:8px; border:1px solid var(--border); background:var(--panel); color:var(--navy); text-decoration:none; }
.pager .pages a:hover { border-color:var(--teal); color:var(--teal); }
.pager .pages .cur { background:var(--navy); border-color:var(--navy); color:#fff; font-weight:600; }
.pager .pages .gap { border:none; background:none; }

/* Top-menu count badges */
.nav-badge { display:inline-block; min-width:1.15rem; padding:0 0.35rem; margin-left:0.3rem; border-radius:999px; background:var(--teal); color:#fff; font-size:0.7rem; font-weight:700; line-height:1.15rem; text-align:center; vertical-align:1px; }

/* Rich text editor (emails / templates) */
.toolbar { display:flex; gap:0.35rem; flex-wrap:wrap; border:1px solid var(--border); border-radius:8px 8px 0 0; background:#f5f6f7; padding:0.4rem; }
.toolbar button { border:1px solid transparent; background:none; padding:0.35rem 0.6rem; border-radius:6px; cursor:pointer; font-size:0.9rem; color:var(--navy); }
.toolbar button:hover { background:#e8e8e8; }
.rich-editor { min-height:200px; border:1px solid var(--border); border-top:none; border-radius:0 0 8px 8px; padding:1rem; background:#fff; font-size:0.95rem; line-height:1.5; }
.rich-editor:focus { outline:2px solid var(--teal); outline-offset:-1px; }

/* Brand mark used on login screens */
.brand { display:flex; align-items:center; gap:0.65rem; margin-bottom:1.25rem; }
.brand img { width:36px; height:36px; border-radius:9px; }
.brand .b-name { font-weight:700; font-size:1.05rem; line-height:1.1; }
.brand .b-sub { color:var(--muted); font-size:0.8rem; }
.login-bg { background:radial-gradient(circle at 20% 10%, rgba(26,141,150,0.14), transparent 45%), radial-gradient(circle at 85% 90%, rgba(22,65,81,0.12), transparent 45%), var(--bg); }
.card.login { max-width:380px; padding:2rem 2rem 1.6rem; box-shadow:0 10px 30px rgba(22,65,81,0.08); border-radius:16px; }
.card.login h1 { font-size:1.3rem; margin:0 0 0.25rem; }
.card.login .lead { color:var(--muted); font-size:0.9rem; margin:0 0 1.2rem; }
.card.login button[type="submit"] { width:100%; padding:0.6rem; font-size:0.95rem; margin-top:0.3rem; }
.card.login .code-input { font-size:1.4rem; letter-spacing:0.4em; text-align:center; font-variant-numeric:tabular-nums; }

@media (max-width: 640px) {
    :root { --pad: 1rem; }
    .panel { padding:1.1rem; }
    .doc-table { display:block; overflow-x:auto; }
    .topbar-nav { gap:0.6rem; }
}
button:disabled, .btn[disabled] { opacity:0.45; cursor:not-allowed; filter:none !important; }
@media (max-width: 640px) { .topbar-nav { flex-wrap:nowrap; overflow-x:auto; width:100%; padding-bottom:2px; } .topbar-nav > * { flex:none; } }

/* ================================================================
   Client-facing pages (signing, forms, uploads, identity check)
   ================================================================ */
.cp-body { background: linear-gradient(180deg, #eef4f5 0, var(--bg) 260px); min-height: 100vh; display: flex; flex-direction: column; }
.cp-header { background: var(--panel); border-bottom: 1px solid var(--border); }
.cp-header-inner { max-width: 980px; margin: 0 auto; padding: 0.8rem 1.1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.cp-brand { display: flex; align-items: center; gap: 0.6rem; }
.cp-mark { width: 32px; height: 32px; border-radius: 8px; }
.cp-firm { font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em; }
.cp-secure { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.78rem; font-weight: 600; color: #1d7a4c; background: #e3f5ec; padding: 0.25rem 0.65rem; border-radius: 999px; }
.cp-secure svg { width: 13px; height: 13px; }

.cp-steps { display: flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 1rem 1rem 0; max-width: 620px; margin: 0 auto; width: 100%; }
.cp-step { display: flex; align-items: center; gap: 0.45rem; color: var(--muted); font-size: 0.82rem; white-space: nowrap; }
.cp-step-n { width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 700; background: #e3e7ea; color: var(--muted); }
.cp-step.on { color: var(--navy); font-weight: 600; }
.cp-step.on .cp-step-n { background: var(--teal); color: #fff; }
.cp-step.done .cp-step-n { background: #e3f5ec; color: #1d7a4c; }
.cp-step-line { flex: 1 1 20px; height: 2px; background: #dfe3e7; min-width: 12px; }

.cp-main { flex: 1 0 auto; width: 100%; max-width: 620px; margin: 0 auto; padding: 1.5rem 1rem 2.5rem; }
.cp-main.wide { max-width: 980px; }
.cp-card { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 1.8rem 1.6rem; box-shadow: 0 8px 28px rgba(22,65,81,0.07); }
.cp-card + .cp-card { margin-top: 1rem; }
.cp-card h1 { font-size: 1.35rem; margin: 0 0 0.4rem; }
.cp-card .lead { color: var(--muted); margin: 0 0 1.3rem; font-size: 0.95rem; }
.cp-doc-name { display: flex; align-items: center; gap: 0.65rem; background: #f5f8f9; border: 1px solid var(--border); border-radius: 10px; padding: 0.7rem 0.85rem; margin: 0 0 1.3rem; font-weight: 600; }
.cp-doc-name svg { width: 20px; height: 20px; color: var(--teal); flex: none; }
.cp-doc-name small { display: block; font-weight: 400; color: var(--muted); font-size: 0.8rem; }

.cp-btn, .cp-card button[type="submit"] { display: block; width: 100%; text-align: center; background: var(--teal); color: #fff; border: none; border-radius: 10px; padding: 0.8rem 1rem; font-size: 1rem; font-weight: 600; cursor: pointer; text-decoration: none; }
.cp-btn:hover, .cp-card button[type="submit"]:hover { filter: brightness(0.95); }
.cp-btn.secondary { background: var(--panel); color: var(--navy); border: 1px solid var(--border-strong); }
.cp-card form input[type="text"], .cp-card form input[type="password"], .cp-card form input[type="date"], .cp-card form textarea, .cp-card form input[type="email"] { font-size: 1rem; padding: 0.7rem 0.85rem; border-radius: 10px; }
.cp-dob { font-size: 1.5rem !important; letter-spacing: 0.35em; text-align: center; font-variant-numeric: tabular-nums; }
.cp-error { background: #fdecea; color: var(--error); border: 1px solid rgba(179,38,30,0.3); border-radius: 10px; padding: 0.7rem 0.9rem; margin: 0 0 1rem; font-size: 0.92rem; }
.cp-note { color: var(--muted); font-size: 0.85rem; }

.cp-message { text-align: center; padding: 2.3rem 1.6rem; }
.cp-message p { color: var(--muted); margin: 0.2rem 0 1.4rem; line-height: 1.55; }
.cp-icon { width: 60px; height: 60px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 1rem; }
.cp-icon svg { width: 30px; height: 30px; }
.cp-icon.done { background: #e3f5ec; color: #1d7a4c; }
.cp-icon.info { background: var(--teal-soft); color: var(--teal); }
.cp-icon.warn { background: #fff4de; color: #9a6300; }

.cp-footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 1.2rem 1rem 1.6rem; }
.cp-footer a { color: var(--teal); }
.cp-dot { margin: 0 0.35rem; }

/* Document viewer + signing */
.cp-intro { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.cp-intro h1 { font-size: 1.3rem; margin: 0; }
.cp-intro p { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.92rem; }
.cp-pages .page-wrap { position: relative; margin: 0 auto 1rem; background: #fff; box-shadow: 0 2px 12px rgba(22,65,81,0.12); border-radius: 4px; overflow: hidden; }
.cp-pages .page-wrap canvas { display: block; width: 100%; height: auto; }
.cp-loading { text-align: center; color: var(--muted); padding: 3rem 1rem; }

/* Upload */
.cp-drop { border: 2px dashed var(--teal); border-radius: 14px; background: #f7fbfb; padding: 2.2rem 1.2rem; text-align: center; cursor: pointer; transition: background .15s, border-color .15s; }
.cp-drop:hover, .cp-drop.drag-over { background: var(--teal-soft); border-color: var(--navy); }
.cp-drop svg { width: 38px; height: 38px; color: var(--teal); }

@media (max-width: 560px) {
    .cp-step-l { display: none; }
    .cp-step.on .cp-step-l { display: inline; }
    .cp-card { padding: 1.4rem 1.15rem; border-radius: 14px; }
    .cp-firm { font-size: 0.98rem; }
}

/* Live email preview */
.ep { margin-top: 1.1rem; border: 1px solid var(--border); border-radius: 12px; background: #f4f6f7; overflow: hidden; }
.ep-head { display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem 0.9rem; background: var(--panel); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.ep-head .ep-sub { color: var(--muted); font-size: 0.82rem; }
.ep-who { width: auto !important; margin: 0 0 0 auto !important; padding: 0.3rem 2rem 0.3rem 0.6rem !important; font-size: 0.85rem !important; }
.ep-meta { padding: 0.6rem 0.9rem; background: var(--panel); border-bottom: 1px solid var(--border); font-size: 0.88rem; line-height: 1.7; }
.ep-k { display: inline-block; width: 4.8rem; color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
.ep-frame { display: block; width: 100%; height: 520px; border: 0; background: #f4f6f7; }
.ep-note { margin: 0; padding: 0.45rem 0.9rem; color: var(--muted); font-size: 0.8rem; }
.ep-note:empty { display: none; }
.ep-err { color: var(--error); }
.ep-loading { color: var(--muted); }

/* Elements marked hidden stay hidden, even where a rule sets display (e.g. form labels). */
[hidden] { display: none !important; }
