/* ============================================================
   Liberty Sign — design system
   Deep navy + antique gold, paper-warm surfaces, Inter/Playfair
   ============================================================ */

@font-face {
  font-family: "Inter";
  src: url("/static/vendor/inter.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Playfair Display";
  src: url("/static/vendor/playfair.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}
@font-face {
  font-family: "Dancing Script";
  src: url("/static/vendor/dancing-script.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: "Caveat";
  src: url("/static/vendor/caveat.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: "Homemade Apple";
  src: url("/static/vendor/homemade-apple.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  --navy-950: #0a0f1f;
  --navy-900: #0e1426;
  --navy-850: #121a30;
  --navy-800: #141b33;
  --navy-700: #1d2747;
  --navy-600: #2a3660;
  --gold-300: #e2c47f;
  --gold-400: #d4af5e;
  --gold-500: #c9a44c;
  --gold-600: #b8923e;
  --gold-700: #97752e;
  --paper: #f4f2ec;
  --ivory: #fbfaf7;
  --card: #ffffff;
  --ink: #20263b;
  --ink-soft: #3c4360;
  --muted: #6b7186;
  --faint: #9aa0b4;
  --line: #e5e2d9;
  --line-strong: #d4d0c4;

  --green-600: #1e7f4f;
  --green-bg: #e3f2e9;
  --blue-600: #2458b3;
  --blue-bg: #e5edfb;
  --indigo-600: #4f46b8;
  --indigo-bg: #e9e8fa;
  --amber-700: #92610e;
  --amber-bg: #fbf0d9;
  --red-600: #b3363c;
  --red-bg: #fae7e8;
  --gray-600: #5d6372;
  --gray-bg: #ecedf0;

  --shadow-sm: 0 1px 2px rgba(20, 27, 51, 0.06), 0 1px 3px rgba(20, 27, 51, 0.08);
  --shadow-md: 0 2px 6px rgba(20, 27, 51, 0.07), 0 8px 24px rgba(20, 27, 51, 0.09);
  --shadow-lg: 0 4px 12px rgba(20, 27, 51, 0.1), 0 20px 48px rgba(20, 27, 51, 0.16);
  --radius: 12px;
  --radius-lg: 16px;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Playfair Display", Georgia, serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.55;
  min-height: 100vh;
}
a { color: var(--gold-700); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }

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

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: linear-gradient(178deg, var(--navy-800) 0%, var(--navy-950) 100%);
  color: #cfd4e4;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 22px 20px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.brand-mark {
  width: 38px; height: 38px; flex-shrink: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--gold-400), var(--gold-700));
  display: grid; place-items: center;
  color: var(--navy-900);
  box-shadow: 0 2px 8px rgba(201, 164, 76, 0.35);
}
.brand-name {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
  color: #f5f1e6;
  letter-spacing: 0.01em;
  line-height: 1.15;
}
.brand-name small { display: block; font-family: var(--sans); font-size: 10px; font-weight: 500; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold-400); }

.nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-label { font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: #626a85; padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px;
  border-radius: 9px;
  color: #b6bcd1;
  font-weight: 500;
  font-size: 13.5px;
  transition: background 0.15s, color 0.15s;
}
.nav a:hover { background: rgba(255, 255, 255, 0.06); color: #eef0f7; text-decoration: none; }
.nav a.active { background: rgba(201, 164, 76, 0.14); color: var(--gold-300); }
.nav a.active svg { color: var(--gold-400); }
.nav a svg { width: 17px; height: 17px; color: #7c84a1; flex-shrink: 0; }
.nav a.active svg, .nav a:hover svg { color: inherit; }

.sidebar-foot { padding: 14px 16px; border-top: 1px solid rgba(255, 255, 255, 0.07); font-size: 12px; color: #626a85; }
.sidebar-foot .userline { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--navy-600); color: #dfe3f0;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600; flex-shrink: 0;
}
.userline b { color: #dfe3f0; font-weight: 600; font-size: 12.5px; display: block; line-height: 1.2; }
.userline span { font-size: 11px; }
.logout-btn { background: none; border: none; color: #7c84a1; font-size: 12px; cursor: pointer; padding: 0; }
.logout-btn:hover { color: var(--gold-300); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: color-mix(in srgb, var(--ivory) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 14px 32px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  position: sticky; top: 0; z-index: 40;
}
.page-title { font-family: var(--serif); font-size: 21px; font-weight: 600; color: var(--navy-800); }
.content { padding: 26px 32px 60px; max-width: 1240px; width: 100%; margin: 0 auto; }

/* ---------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px;
  border-radius: 9px;
  border: 1px solid transparent;
  font-size: 13.5px; font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none !important;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary {
  background: linear-gradient(180deg, var(--navy-700), var(--navy-900));
  color: #f3ecd9;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: linear-gradient(180deg, var(--navy-600), var(--navy-800)); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-gold {
  background: linear-gradient(180deg, var(--gold-400), var(--gold-600));
  color: var(--navy-900);
  box-shadow: 0 1px 3px rgba(151, 117, 46, 0.4);
}
.btn-gold:hover { filter: brightness(1.05); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(151, 117, 46, 0.35); }
.btn-outline { background: var(--card); border-color: var(--line-strong); color: var(--ink-soft); }
.btn-outline:hover { border-color: var(--gold-500); color: var(--gold-700); }
.btn-danger { background: var(--red-bg); color: var(--red-600); }
.btn-danger:hover { background: #f5d9db; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--gray-bg); color: var(--ink); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none !important; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 7px; }
.btn-lg { padding: 12px 24px; font-size: 15px; border-radius: 11px; }

/* ---------------------------------------------------- cards & stats */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 22px 24px; }
.card h3 { font-size: 15px; font-weight: 650; color: var(--navy-800); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 26px; }
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 4px;
  background: var(--accent, var(--gold-500));
  border-radius: 4px 0 0 4px;
}
.stat-label { font-size: 11.5px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.stat-value { font-family: var(--serif); font-size: 34px; font-weight: 650; color: var(--navy-800); line-height: 1.15; margin-top: 4px; }
.stat-sub { font-size: 12px; color: var(--faint); margin-top: 2px; }

/* ---------------------------------------------------- badges */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3.5px 10px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 650; letter-spacing: 0.02em;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.draft, .badge.voided { background: var(--gray-bg); color: var(--gray-600); }
.badge.sent { background: var(--blue-bg); color: var(--blue-600); }
.badge.viewed { background: var(--indigo-bg); color: var(--indigo-600); }
.badge.partially_signed { background: var(--amber-bg); color: var(--amber-700); }
.badge.completed, .badge.signed { background: var(--green-bg); color: var(--green-600); }
.badge.declined { background: var(--red-bg); color: var(--red-600); }
.badge.expired { background: var(--amber-bg); color: var(--amber-700); }
.badge.pending { background: var(--gray-bg); color: var(--gray-600); }

/* ---------------------------------------------------- tables */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); }
table.data {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  font-size: 13.5px;
}
table.data th {
  text-align: left;
  font-size: 11px; font-weight: 650; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted);
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--ivory);
}
table.data td { padding: 14px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr { cursor: pointer; transition: background 0.12s; }
table.data tbody tr:hover { background: #faf8f2; }
table.data tbody tr:last-child td { border-bottom: none; }
.doc-name { font-weight: 600; color: var(--navy-800); }
.doc-meta { font-size: 12px; color: var(--faint); margin-top: 1px; }

.progress-pill { display: flex; align-items: center; gap: 8px; min-width: 110px; }
.progress-track { flex: 1; height: 5px; border-radius: 4px; background: var(--gray-bg); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--gold-400), var(--gold-600)); transition: width 0.4s; }
.progress-fill.full { background: linear-gradient(90deg, #35a06c, var(--green-600)); }
.progress-num { font-size: 11.5px; color: var(--muted); font-weight: 600; white-space: nowrap; }

/* ---------------------------------------------------- forms */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.field .hint { font-size: 11.5px; color: var(--faint); margin-top: 4px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="url"], input[type="date"], select, textarea {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--card);
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold-500);
  box-shadow: 0 0 0 3px rgba(201, 164, 76, 0.18);
}
textarea { resize: vertical; min-height: 80px; }
.checkbox-row { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--ink-soft); }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--gold-600); }

/* ---------------------------------------------------- tabs / filters */
.tabs { display: flex; gap: 4px; background: var(--gray-bg); padding: 4px; border-radius: 11px; width: fit-content; }
.tabs button {
  border: none; background: transparent;
  padding: 7px 15px;
  border-radius: 8px;
  font-size: 13px; font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}
.tabs button:hover { color: var(--ink); }
.tabs button.active { background: var(--card); color: var(--navy-800); box-shadow: var(--shadow-sm); }

.search-box { position: relative; }
.search-box svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--faint); }
.search-box input { padding-left: 36px; width: 260px; }

/* ---------------------------------------------------- modals */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(14, 20, 38, 0.55);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  padding: 20px;
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 520px;
  max-height: calc(100vh - 60px);
  overflow: auto;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.modal-backdrop.open .modal { transform: none; }
.modal-head { padding: 20px 24px 0; display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-family: var(--serif); font-size: 19px; color: var(--navy-800); }
.modal-body { padding: 18px 24px 24px; }
.modal-foot { padding: 0 24px 22px; display: flex; justify-content: flex-end; gap: 10px; }
.modal-close { background: none; border: none; font-size: 22px; color: var(--faint); cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--ink); }

/* ---------------------------------------------------- toasts */
#toasts { position: fixed; bottom: 24px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--navy-800);
  color: #eef0f7;
  padding: 12px 18px;
  border-radius: 11px;
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  display: flex; align-items: center; gap: 10px;
  animation: toast-in 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  border-left: 3px solid var(--gold-500);
  max-width: 380px;
}
.toast.error { border-left-color: #e0666c; }
.toast.success { border-left-color: #3dbb7d; }
@keyframes toast-in { from { transform: translateY(14px); opacity: 0; } }

/* ---------------------------------------------------- misc */
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }

/* ---------------------------------------------------- rendered PDF pages (editor + signing) */
.page-wrap {
  position: relative;
  box-shadow: var(--shadow-md);
  border-radius: 4px;
  background: #fff;
  line-height: 0;
}
.page-wrap canvas { border-radius: 4px; max-width: 100%; }
.page-overlay { position: absolute; inset: 0; line-height: normal; }
.page-num-tag {
  position: absolute; bottom: -19px; left: 50%; transform: translateX(-50%);
  font-size: 11px; color: var(--faint); font-weight: 600;
}

.empty-state { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty-state svg { width: 54px; height: 54px; color: var(--line-strong); margin-bottom: 14px; }
.empty-state h3 { font-family: var(--serif); font-size: 20px; color: var(--ink-soft); margin-bottom: 6px; }

.spinner {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(201, 164, 76, 0.25);
  border-top-color: var(--gold-600);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.copy-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--ivory);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 5px 10px;
  font-family: ui-monospace, monospace;
  font-size: 11.5px;
  color: var(--ink-soft);
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
}
.copy-chip:hover { border-color: var(--gold-500); color: var(--gold-700); }
.copy-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------- login */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-hero {
  background:
    radial-gradient(1200px 700px at 15% -10%, rgba(201, 164, 76, 0.16), transparent 55%),
    radial-gradient(900px 600px at 110% 110%, rgba(42, 54, 96, 0.5), transparent 60%),
    linear-gradient(160deg, var(--navy-800), var(--navy-950));
  color: #e8e4d6;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 48px 56px;
  position: relative;
  overflow: hidden;
}
.login-hero::after {
  content: "";
  position: absolute; inset: 0;
  background-image: repeating-linear-gradient(115deg, rgba(255,255,255,0.018) 0 2px, transparent 2px 9px);
  pointer-events: none;
}
.login-hero .brand { border: none; padding: 0; }
.hero-copy h1 {
  font-family: var(--serif);
  font-size: clamp(30px, 3.6vw, 44px);
  font-weight: 650;
  line-height: 1.16;
  color: #f7f3e7;
  max-width: 480px;
}
.hero-copy h1 em { font-style: italic; color: var(--gold-300); }
.hero-copy p { margin-top: 16px; color: #a6adc4; max-width: 430px; font-size: 15px; }
.hero-points { margin-top: 28px; display: flex; flex-direction: column; gap: 12px; }
.hero-points div { display: flex; gap: 11px; align-items: center; font-size: 13.5px; color: #c6cbdc; }
.hero-points svg { width: 17px; height: 17px; color: var(--gold-400); flex-shrink: 0; }
.login-hero .foot { font-size: 12px; color: #5d6480; position: relative; }
.login-panel { display: grid; place-items: center; padding: 40px; background: var(--paper); }
.login-card { width: 100%; max-width: 390px; }
.login-card h2 { font-family: var(--serif); font-size: 26px; color: var(--navy-800); margin-bottom: 4px; }
.login-card > p { color: var(--muted); margin-bottom: 26px; font-size: 14px; }
.login-error {
  background: var(--red-bg); color: var(--red-600);
  border-radius: 9px; padding: 10px 14px;
  font-size: 13px; font-weight: 500;
  margin-bottom: 16px;
  display: none;
}
@media (max-width: 900px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-hero { display: none; }
}

/* ---------------------------------------------------- timeline */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding-bottom: 18px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot {
  position: absolute; left: -26px; top: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--card);
  border: 2px solid var(--gold-500);
  display: grid; place-items: center;
}
.tl-dot::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--gold-500); }
.tl-title { font-weight: 600; font-size: 13.5px; color: var(--navy-800); }
.tl-meta { font-size: 12px; color: var(--faint); margin-top: 1px; }

/* ---------------------------------------------------- signer cards */
.signer-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--ivory);
}
.signer-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 650; font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}
.signer-card .info { flex: 1; min-width: 0; }
.signer-card .info b { display: block; font-size: 13.5px; color: var(--navy-800); }
.signer-card .info span { font-size: 12px; color: var(--muted); }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .content { padding: 20px 16px 50px; }
  .topbar { padding: 12px 16px; }
}
