/* ------------------------------------------------------------------
   Benard Document Sign — design system
------------------------------------------------------------------- */

:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f8;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --brand: #0b2545;
  --brand-2: #123f6b;
  --brand-3: #1d5c96;
  --gold: #c9a227;
  --gold-soft: #f5e6b8;
  --accent: #0f6fbf;
  --accent-soft: #e3f0fb;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --success: #067647;
  --success-soft: #e7f6ee;
  --warning: #b54708;
  --warning-soft: #fef4e6;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.16);
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar-w: 248px;
}

html.dark {
  --bg: #0b1220;
  --surface: #111a2c;
  --surface-2: #0e1626;
  --surface-3: #16223a;
  --ink: #e8eef8;
  --ink-2: #c6d2e4;
  --muted: #8fa0b8;
  --faint: #6b7c95;
  --line: #1e2b44;
  --line-strong: #2b3c5c;
  --accent: #60a5fa;
  --accent-soft: #16283f;
  --danger: #f97066;
  --danger-soft: #2a1614;
  --success: #4ade80;
  --success-soft: #10261a;
  --warning: #fdb022;
  --warning-soft: #2a2110;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.5);
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.02em; font-weight: 650; }

svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.hash { word-break: break-all; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.hidden { display: none !important; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: linear-gradient(180deg, #0b2545 0%, #081a31 100%);
  color: #dbe6f4;
  display: flex;
  flex-direction: column;
  padding: 22px 16px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

.brand { display: flex; align-items: center; gap: 12px; color: #fff; padding: 0 6px 22px; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 11px;
  background: linear-gradient(135deg, var(--gold), #a8841d);
  color: #10233d; font-weight: 800; font-size: 15px; letter-spacing: -0.3px;
  display: grid; place-items: center;
  box-shadow: 0 6px 16px rgba(201, 162, 39, 0.35);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 16px; letter-spacing: 0.2px; }
.brand-text small { font-size: 11.5px; color: #93a9c4; letter-spacing: 0.3px; }

.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1.3px;
  color: #6f89a8; padding: 16px 10px 7px;
}
.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: 9px;
  color: #b9c9dc; font-size: 13.5px; font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.nav-link svg { width: 17px; height: 17px; color: #7d96b4; }
.nav-link:hover { background: rgba(255, 255, 255, 0.07); color: #fff; text-decoration: none; }
.nav-link:hover svg { color: #fff; }
.nav-link.is-active { background: rgba(201, 162, 39, 0.16); color: #fff; box-shadow: inset 2px 0 0 var(--gold); }
.nav-link.is-active svg { color: var(--gold); }

.sidebar-foot { border-top: 1px solid rgba(255, 255, 255, 0.09); padding-top: 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.owner { display: flex; align-items: center; gap: 10px; min-width: 0; }
.owner .avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, #2f6fa8, #1d4d78); color: #fff; font-weight: 700; display: grid; place-items: center; font-size: 13px; flex: 0 0 auto; }
.owner span:last-child { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.owner strong { font-size: 12.5px; color: #eaf1fa; font-weight: 600; }
.owner small { font-size: 10.5px; color: #7f97b3; }
.logout-btn { background: transparent; border: 1px solid rgba(255, 255, 255, 0.12); color: #9fb3cb; width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; cursor: pointer; }
.logout-btn:hover { color: #fff; border-color: rgba(255, 255, 255, 0.3); }
.logout-btn svg { width: 15px; height: 15px; }

.shell { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 66px; display: flex; align-items: center; gap: 12px;
  padding: 0 30px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.topbar-heading h1 { font-size: 18px; font-weight: 650; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.topbar-user { font-size: 12.5px; color: var(--muted); }
.mobile-menu { display: none !important; }

.icon-btn {
  width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); display: grid; place-items: center;
  cursor: pointer; transition: all 0.15s;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); background: var(--surface-2); }
.icon-btn svg { width: 17px; height: 17px; }
html.dark .icon-sun { display: none; }
html:not(.dark) .icon-moon { display: none; }

.content { padding: 28px 30px 48px; max-width: 1360px; width: 100%; margin: 0 auto; }

/* ---------- Page heading ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h2 { font-size: 23px; margin-bottom: 4px; }
.page-head p { margin: 0; color: var(--muted); font-size: 13.5px; }
.page-actions { display: flex; gap: 9px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 9px;
  padding: 9px 15px; font-size: 13.5px; font-weight: 600;
  cursor: pointer; font-family: inherit; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--brand-2); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--brand-3); }
.btn-gold { background: linear-gradient(135deg, #d4ad34, #b8911f); color: #1b2a41; box-shadow: 0 4px 14px rgba(201, 162, 39, 0.3); }
.btn-gold:hover { filter: brightness(1.04); }
.btn-ghost { background: var(--surface); color: var(--ink-2); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-soft { background: var(--accent-soft); color: var(--accent); }
.btn-soft:hover { filter: brightness(0.97); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-lg { padding: 11px 20px; font-size: 14.5px; }
.btn-block { width: 100%; }

/* ---------- Cards & stats ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-title { font-size: 14.5px; font-weight: 650; }
.card-body { padding: 20px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow-sm);
}
.stat-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex: 0 0 auto; }
.stat-icon svg { width: 19px; height: 19px; }
.stat-icon.blue { background: var(--accent-soft); color: var(--accent); }
.stat-icon.green { background: var(--success-soft); color: var(--success); }
.stat-icon.amber { background: var(--warning-soft); color: var(--warning); }
.stat-icon.gold { background: #fdf6e3; color: #a8841d; }
html.dark .stat-icon.gold { background: #2a2412; color: var(--gold); }
.stat-value { font-size: 21px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.2; }
.stat-label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.7px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.9px;
  color: var(--muted); font-weight: 650; padding: 11px 20px; background: var(--surface-2);
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 13px 20px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 13.5px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.12s; }
tbody tr:hover { background: var(--surface-2); }
.doc-cell { display: flex; align-items: center; gap: 12px; min-width: 240px; }
.file-icon { width: 36px; height: 36px; border-radius: 9px; background: var(--danger-soft); color: var(--danger); display: grid; place-items: center; flex: 0 0 auto; font-size: 9px; font-weight: 800; letter-spacing: 0.3px; }
.file-icon.signed { background: var(--success-soft); color: var(--success); }
.doc-cell strong { display: block; font-weight: 600; font-size: 13.5px; color: var(--ink); }
.doc-cell small { color: var(--muted); font-size: 11.5px; }
td .row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 650; padding: 3px 9px; border-radius: 999px;
  text-transform: capitalize; white-space: nowrap;
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge-draft { background: var(--warning-soft); color: var(--warning); }
.badge-signed { background: var(--success-soft); color: var(--success); }
.badge-ok { background: var(--success-soft); color: var(--success); }
.badge-bad { background: var(--danger-soft); color: var(--danger); }
.badge-neutral { background: var(--surface-3); color: var(--muted); }
.badge-gold { background: #fdf6e3; color: #8a6c11; }
html.dark .badge-gold { background: #2a2412; color: var(--gold); }

/* ---------- Forms ---------- */
.form-grid { display: grid; gap: 16px; }
.field label, .label { display: block; font-size: 12.5px; font-weight: 650; margin-bottom: 6px; color: var(--ink-2); }
.input, textarea.input, select.input {
  width: 100%; padding: 10px 13px; border-radius: 9px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-size: 14px; font-family: inherit; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, textarea.input:focus, select.input:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15, 111, 191, 0.13);
}
textarea.input { resize: vertical; min-height: 82px; }
.hint { font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.error-text { color: var(--danger); font-size: 12.5px; margin-top: 7px; }

.alert { padding: 11px 14px; border-radius: 9px; font-size: 13px; margin-bottom: 16px; border: 1px solid transparent; }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: rgba(180, 35, 24, 0.18); }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-info { background: var(--accent-soft); color: var(--accent); }
.alert-warn { background: var(--warning-soft); color: var(--warning); }

/* ---------- Upload ---------- */
.dropzone {
  border: 2px dashed var(--line-strong); border-radius: var(--radius);
  padding: 42px 24px; text-align: center; background: var(--surface-2);
  cursor: pointer; transition: all 0.15s; position: relative;
}
.dropzone:hover, .dropzone.is-dragging { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone .dz-icon { width: 54px; height: 54px; border-radius: 15px; background: var(--surface); border: 1px solid var(--line); display: grid; place-items: center; margin: 0 auto 14px; color: var(--accent); box-shadow: var(--shadow-sm); }
.dropzone .dz-icon svg { width: 24px; height: 24px; }
.dropzone h3 { font-size: 15.5px; margin-bottom: 4px; }
.dropzone p { margin: 0; color: var(--muted); font-size: 12.5px; }
.dz-file { display: none; align-items: center; gap: 10px; justify-content: center; margin-top: 14px; font-size: 13px; font-weight: 600; color: var(--accent); }
.dz-file.is-visible { display: flex; }

.two-col { display: grid; grid-template-columns: 1.6fr 1fr; gap: 22px; align-items: start; }

/* ---------- Auth ---------- */
.is-bare { min-height: 100vh; background: var(--surface); }
.auth-shell { min-height: 100vh; }

/* ---------- Split sign-in layout ---------- */
.auth-split { display: grid; grid-template-columns: minmax(380px, 46%) 1fr; min-height: 100vh; background: var(--surface); }

.auth-brand-panel {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
  padding: 48px 52px; color: #dbe6f4;
  background: linear-gradient(155deg, #0b2545 0%, #0a1f3a 55%, #061426 100%);
}
.auth-brand-panel::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(620px 360px at 18% 0%, rgba(201, 162, 39, 0.2), transparent 65%);
  pointer-events: none;
}
.auth-brand-panel::after {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 46px 46px;
  -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent 72%);
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent 72%);
  pointer-events: none;
}
.auth-brand-panel > * { position: relative; z-index: 1; }

.auth-brand-top { display: flex; align-items: center; gap: 14px; }
.auth-brand-top .brand-mark {
  width: 54px; height: 54px; border-radius: 15px;
  font-size: 19px; letter-spacing: -0.5px;
}
.auth-brand-name { display: flex; flex-direction: column; line-height: 1.25; }
.auth-brand-name strong { font-size: 17px; color: #fff; font-weight: 650; }
.auth-brand-name small { font-size: 10.5px; color: #8fa7c2; text-transform: uppercase; letter-spacing: 1.4px; margin-top: 3px; }

.auth-brand-copy { max-width: 430px; }
.auth-eyebrow {
  display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: 1.9px;
  text-transform: uppercase; color: #d9b84a; margin-bottom: 14px;
}
.auth-brand-copy h1 {
  font-size: 33px; line-height: 1.18; color: #fff; margin-bottom: 14px; letter-spacing: -0.03em;
}
.auth-brand-copy > p { color: #9fb3cb; font-size: 13.5px; line-height: 1.7; margin: 0 0 28px; max-width: 380px; }

.auth-points { list-style: none; display: flex; flex-direction: column; gap: 17px; margin: 0; padding: 0; }
.auth-points li { display: flex; gap: 13px; align-items: flex-start; }
.auth-points .check {
  width: 28px; height: 28px; border-radius: 50%; flex: 0 0 auto;
  background: rgba(201, 162, 39, 0.13); border: 1px solid rgba(201, 162, 39, 0.32);
  color: #e2c25c; display: grid; place-items: center;
}
.auth-points .check svg { width: 14px; height: 14px; }
.auth-points strong { display: block; font-size: 12.5px; font-weight: 600; color: #eaf1fa; margin-bottom: 2px; }
.auth-points small { display: block; font-size: 11.5px; color: #8fa7c2; line-height: 1.5; }

.auth-brand-foot {
  display: flex; justify-content: space-between; gap: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.09); padding-top: 18px;
  font-size: 10.5px; color: #6f89a8; letter-spacing: 0.2px;
}

.auth-form-panel { display: grid; place-items: center; padding: 48px 28px; background: var(--surface); }
.auth-form-inner { width: 100%; max-width: 372px; }
.auth-mobile-brand { display: none; align-items: center; gap: 12px; margin-bottom: 34px; }
.auth-mobile-brand .brand-mark { width: 42px; height: 42px; font-size: 14px; border-radius: 11px; }
.auth-mobile-brand strong { display: block; font-size: 15px; }
.auth-mobile-brand small { display: block; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-top: 2px; }

.auth-form-inner .auth-eyebrow { color: var(--accent); margin-bottom: 10px; }
.auth-form-inner .auth-title { text-align: left; font-size: 28px; margin-bottom: 8px; }
.auth-form-inner .auth-sub { text-align: left; margin: 0 0 26px; font-size: 13.5px; }

.auth-submit { margin-top: 20px; height: 46px; }
.auth-security {
  display: flex; gap: 9px; align-items: flex-start;
  margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 11.5px; line-height: 1.6;
}
.auth-security svg { width: 15px; height: 15px; color: var(--accent); flex: 0 0 auto; margin-top: 1px; }
.auth-inline-link { text-align: center; font-size: 12px; color: var(--muted); margin-top: 18px; }

.auth-single {
  min-height: 100vh; display: grid; place-items: center; padding: 28px;
  background: radial-gradient(1200px 600px at 15% 0%, #123f6b 0%, #0b2545 45%, #061426 100%);
}

.auth-card {
  width: 100%; max-width: 410px; background: var(--surface);
  border-radius: 20px; box-shadow: var(--shadow-lg); padding: 38px 34px 30px;
  position: relative; overflow: hidden;
}
.auth-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: linear-gradient(90deg, var(--gold), #e8cf7e, var(--gold)); }
.auth-brand { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 26px; }
.auth-brand .brand-mark { width: 46px; height: 46px; font-size: 24px; }
.auth-brand .brand-text strong { color: var(--ink); font-size: 17px; }
.auth-brand .brand-text small { color: var(--muted); }
.auth-lock { width: 54px; height: 54px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin: 0 auto 16px; }
.auth-lock svg { width: 24px; height: 24px; }
.auth-title { text-align: center; font-size: 21px; margin-bottom: 6px; }
.auth-sub { text-align: center; color: var(--muted); font-size: 13px; margin: 0 0 24px; }
.auth-note { text-align: center; font-size: 11.5px; color: var(--faint); margin-top: 22px; line-height: 1.6; }
.auth-note strong { color: var(--muted); }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 44px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: none; background: transparent; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 6px; display: grid; place-items: center; }
.pw-toggle:hover { color: var(--ink); }
.pw-toggle svg { width: 17px; height: 17px; }

/* ---------- Document workspace ---------- */
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 336px; gap: 18px; align-items: start; }
.viewer-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.viewer-toolbar {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  border-bottom: 1px solid var(--line); background: var(--surface); flex-wrap: wrap;
}
.tool-group { display: flex; align-items: center; gap: 4px; padding: 3px; background: var(--surface-2); border-radius: 9px; border: 1px solid var(--line); }
.tool {
  display: inline-flex; align-items: center; gap: 6px; border: none; background: transparent;
  color: var(--muted); font-size: 12.5px; font-weight: 600; font-family: inherit;
  padding: 6px 9px; border-radius: 7px; cursor: pointer; white-space: nowrap;
}
.tool svg { width: 15px; height: 15px; }
.tool:hover { color: var(--ink); background: var(--surface-3); }
.tool.is-active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }
.toolbar-spacer { flex: 1; }
.zoom-group { display: flex; align-items: center; gap: 2px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.zoom-group button { border: none; background: var(--surface); color: var(--muted); width: 30px; height: 30px; cursor: pointer; font-size: 15px; }
.zoom-group button:hover { background: var(--surface-2); color: var(--ink); }
.zoom-value { font-size: 12px; color: var(--muted); min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; }

.pdf-scroll {
  background: #e7ebf2; padding: 22px; overflow: auto;
  max-height: calc(100vh - 250px); min-height: 420px; position: relative;
}
html.dark .pdf-scroll { background: #070d18; }
.pdf-page-wrap { margin: 0 auto 18px; position: relative; box-shadow: 0 6px 22px rgba(15, 23, 42, 0.18); background: #fff; }
.pdf-page-wrap:last-child { margin-bottom: 0; }
.pdf-page-wrap canvas { display: block; width: 100%; height: auto; }
.pdf-overlay { position: absolute; inset: 0; }
.pdf-status { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(231, 235, 242, 0.9); color: var(--ink-2); font-size: 13px; z-index: 5; }
html.dark .pdf-status { background: rgba(7, 13, 24, 0.9); color: var(--ink-2); }
.pdf-status svg { width: 22px; height: 22px; margin-right: 8px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.pdf-field {
  position: absolute; border: 1.5px dashed rgba(15, 111, 191, 0.65);
  background: rgba(15, 111, 191, 0.07); border-radius: 3px;
  cursor: move; user-select: none; touch-action: none;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.pdf-field img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.pdf-field .f-tag {
  font-size: 10px; font-weight: 700; color: var(--accent); text-transform: uppercase;
  letter-spacing: 0.5px; pointer-events: none; white-space: nowrap;
}
.pdf-field.kind-date, .pdf-field.kind-text { background: rgba(201, 162, 39, 0.08); border-color: rgba(201, 162, 39, 0.75); }
.pdf-field.kind-date .f-tag, .pdf-field.kind-text .f-tag { color: #8a6c11; }
.pdf-field.selected { border-style: solid; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(15, 111, 191, 0.22); }
.pdf-field .handle {
  position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px;
  background: var(--accent); border: 1.5px solid #fff; border-radius: 3px 0 2px 0;
  cursor: nwse-resize; display: none;
}
.pdf-field.selected .handle { display: block; }
.pdf-field.readonly { cursor: default; border-color: transparent; background: transparent; }

/* Side panel */
.side-panel { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 82px; }
.panel-block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.panel-head { padding: 13px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel-head h3 { font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); font-weight: 700; }
.panel-body { padding: 14px 16px; }
.meta-list { display: flex; flex-direction: column; gap: 10px; }
.meta-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; font-size: 12.5px; }
.meta-row .k { color: var(--muted); flex: 0 0 auto; }
.meta-row .v { text-align: right; font-weight: 550; word-break: break-word; }
.tag-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }

.selected-panel .empty-selection { color: var(--muted); font-size: 12.5px; text-align: center; padding: 6px 0 2px; }
.sig-mini-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; }
.sig-mini {
  border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2);
  padding: 5px; cursor: pointer; height: 46px; display: grid; place-items: center;
  transition: all 0.12s; overflow: hidden;
}
.sig-mini img { max-width: 100%; max-height: 100%; object-fit: contain; }
.sig-mini:hover { border-color: var(--line-strong); }
.sig-mini.is-active { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.range-row { display: flex; align-items: center; gap: 10px; }
input[type="range"] { flex: 1; accent-color: var(--accent); }

.audit-list { display: flex; flex-direction: column; max-height: 300px; overflow: auto; }
.audit-item { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 12px; }
.audit-item:last-child { border-bottom: none; }
.audit-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-top: 6px; flex: 0 0 auto; }
.audit-item.danger .audit-dot { background: var(--danger); }
.audit-item.success .audit-dot { background: var(--success); }
.audit-item b { display: block; font-weight: 600; text-transform: capitalize; font-size: 12px; }
.audit-item span { color: var(--muted); font-size: 11px; }
.audit-item p { margin: 2px 0 0; color: var(--muted); font-size: 11.5px; line-height: 1.45; word-break: break-word; }

.signed-banner {
  background: linear-gradient(135deg, var(--success-soft), var(--surface));
  border: 1px solid rgba(6, 118, 71, 0.25); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 18px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.signed-banner .sb-icon { width: 44px; height: 44px; border-radius: 50%; background: var(--success); color: #fff; display: grid; place-items: center; flex: 0 0 auto; }
.signed-banner h3 { font-size: 15px; margin-bottom: 2px; }
.signed-banner p { margin: 0; color: var(--muted); font-size: 12.5px; }
.signed-banner .sb-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(8, 18, 34, 0.55); backdrop-filter: blur(2px); display: none; place-items: center; z-index: 100; padding: 20px; }
.modal-backdrop.is-open { display: grid; }
.modal-card { background: var(--surface); border-radius: 16px; width: 100%; max-width: 460px; box-shadow: var(--shadow-lg); overflow: hidden; animation: pop 0.16s ease-out; }
@keyframes pop { from { transform: scale(0.97); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-head { padding: 18px 22px 14px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.modal-head h3 { font-size: 16.5px; }
.modal-head p { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.modal-body { padding: 4px 22px 20px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 9px; background: var(--surface-2); }
.modal-close { border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: 22px; line-height: 1; padding: 2px 6px; border-radius: 6px; }
.modal-close:hover { background: var(--surface-3); color: var(--ink); }

.summary-list { display: flex; flex-direction: column; gap: 8px; font-size: 13px; margin: 12px 0 16px; }
.summary-list div { display: flex; justify-content: space-between; gap: 12px; }
.summary-list .k { color: var(--muted); }

/* ---------- Signature studio ---------- */
.sig-tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 18px; }
.sig-tab { flex: 1; border: none; background: transparent; color: var(--muted); font-family: inherit; font-size: 13px; font-weight: 600; padding: 8px 10px; border-radius: 7px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 7px; }
.sig-tab svg { width: 15px; height: 15px; }
.sig-tab.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

.pad-wrap { position: relative; border: 1px solid var(--line-strong); border-radius: 11px; background:
  linear-gradient(var(--surface-2), var(--surface-2)) padding-box,
  repeating-linear-gradient(90deg, transparent 0 27px, rgba(148, 163, 184, 0.16) 27px 28px) border-box;
  overflow: hidden; }
.pad-wrap::after { content: ""; position: absolute; left: 5%; right: 5%; bottom: 26%; border-bottom: 1px dashed var(--line-strong); pointer-events: none; }
.sig-canvas { display: block; width: 100%; height: 190px; touch-action: none; cursor: crosshair; position: relative; z-index: 1; }
.pad-tools { display: flex; align-items: center; justify-content: space-between; margin-top: 9px; gap: 10px; flex-wrap: wrap; }
.pad-tools .hint { margin: 0; }

.color-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line-strong); cursor: pointer; padding: 0; transition: transform 0.12s; }
.swatch:hover { transform: scale(1.1); }
.swatch.is-active { box-shadow: 0 0 0 2px var(--accent); transform: scale(1.08); }
.color-input { width: 38px; height: 32px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); padding: 2px; cursor: pointer; }

.type-preview { border: 1px solid var(--line-strong); border-radius: 11px; background: var(--surface-2); height: 170px; display: grid; place-items: center; overflow: hidden; padding: 10px; }
.type-preview img { max-width: 100%; max-height: 100%; }

.upload-preview { border: 1px dashed var(--line-strong); border-radius: 11px; height: 170px; display: grid; place-items: center; background: var(--surface-2); overflow: hidden; padding: 10px; }
.upload-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.upload-preview span { color: var(--muted); font-size: 12.5px; }

.signature-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.signature-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 10px; }
.signature-preview { height: 160px; background: var(--surface-2); border-radius: 9px; display: grid; place-items: center; padding: 12px; overflow: hidden; cursor: zoom-in; position: relative; }
.signature-preview img { width: 100%; height: 100%; object-fit: contain; }
.signature-preview::after {
  content: "Click to enlarge"; position: absolute; right: 8px; bottom: 6px;
  font-size: 10px; color: var(--faint); opacity: 0; transition: opacity .15s;
}
.signature-preview:hover::after { opacity: 1; }

.lightbox { position: fixed; inset: 0; background: rgba(8, 18, 34, 0.82); display: none; place-items: center; z-index: 200; padding: 24px; cursor: zoom-out; backdrop-filter: blur(3px); }
.lightbox.is-open { display: grid; }
.lightbox img { max-width: 92vw; max-height: 82vh; background: #fff; border-radius: 12px; padding: 20px; box-shadow: var(--shadow-lg); }
body.lightbox-open { overflow: hidden; }
.signature-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.signature-meta strong { font-size: 13px; font-weight: 600; }
.signature-meta small { display: block; color: var(--muted); font-size: 11px; text-transform: capitalize; }
.sig-actions { display: flex; justify-content: flex-end; }
.color-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; box-shadow: 0 0 0 1px rgba(0,0,0,0.12); }

/* ---------- Audit page ---------- */
.integrity-banner { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: var(--radius); border: 1px solid; margin-bottom: 20px; }
.integrity-banner.ok { background: var(--success-soft); border-color: rgba(6, 118, 71, 0.22); color: var(--success); }
.integrity-banner.bad { background: var(--danger-soft); border-color: rgba(180, 35, 24, 0.22); color: var(--danger); }
.integrity-banner svg { width: 22px; height: 22px; flex: 0 0 auto; }
.integrity-banner h3 { font-size: 14px; margin-bottom: 1px; }
.integrity-banner p { margin: 0; font-size: 12.5px; opacity: 0.85; }
.action-chip { display: inline-block; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; padding: 2px 8px; border-radius: 5px; background: var(--surface-3); color: var(--ink-2); }
.action-chip.signed, .action-chip.uploaded { background: var(--accent-soft); color: var(--accent); }
.action-chip.deleted { background: var(--danger-soft); color: var(--danger); }
.action-chip.login, .action-chip.logout { background: var(--surface-3); color: var(--muted); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; right: 22px; bottom: 22px; z-index: 200;
  background: var(--surface); border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 10px; box-shadow: var(--shadow-lg);
  padding: 12px 14px; display: flex; align-items: center; gap: 12px;
  font-size: 13px; max-width: 380px; animation: slideIn 0.2s ease-out;
}
.toast button { border: none; background: transparent; color: var(--muted); font-size: 18px; cursor: pointer; line-height: 1; }
@keyframes slideIn { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 54px 24px; }
.empty .empty-icon { width: 62px; height: 62px; border-radius: 16px; background: var(--surface-3); color: var(--muted); display: grid; place-items: center; margin: 0 auto 16px; }
.empty .empty-icon svg { width: 28px; height: 28px; }
.empty h3 { font-size: 16px; margin-bottom: 5px; }
.empty p { margin: 0 auto 18px; color: var(--muted); font-size: 13px; max-width: 420px; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .doc-layout { grid-template-columns: 1fr; }
  .side-panel { position: static; display: grid; grid-template-columns: 1fr 1fr; }
}
@media (max-width: 980px) {
  .auth-split { grid-template-columns: 1fr; }
  .auth-brand-panel { display: none; }
  .auth-form-panel { min-height: 100vh; padding: 36px 22px; }
  .auth-mobile-brand { display: flex; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform 0.22s ease; box-shadow: var(--shadow-lg); }
  .sidebar.is-open { transform: none; }
  .mobile-menu { display: grid !important; }
  .topbar { padding: 0 18px; }
  .content { padding: 20px 18px 40px; }
  .sidebar-scrim { position: fixed; inset: 0; background: rgba(8, 18, 34, 0.45); z-index: 35; display: none; }
  .sidebar-scrim.is-open { display: block; }
}
@media (max-width: 640px) {
  .stats-grid { grid-template-columns: 1fr; }
  .side-panel { grid-template-columns: 1fr; }
  .page-head { align-items: flex-start; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .pdf-scroll { padding: 12px; max-height: none; }
  .sig-tabs { flex-wrap: wrap; }
  .tool span { display: none; }
  .tool { padding: 7px; }
  .auth-card { padding: 30px 22px 24px; }
  .topbar-user { display: none; }
}
