:root {
  --navy-950: #0a0e1f;
  --navy-900: #111834;
  --navy-800: #1a2348;
  --navy-700: #26305c;
  --gold-500: #d9a441;
  --gold-400: #e8bd66;
  --green-600: #1b8a5a;
  --green-100: #e5f6ee;
  --amber-600: #b5790a;
  --amber-100: #fdf1dc;
  --gray-50: #f7f8fb;
  --gray-100: #eef0f6;
  --gray-300: #d7dbe6;
  --gray-500: #7c839a;
  --gray-700: #3c4257;
  --text: #1c2136;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(10,14,31,0.08), 0 1px 2px rgba(10,14,31,0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--gray-50);
  color: var(--text);
}

.topbar {
  background: var(--navy-950);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 60px;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.2px;
}

.topbar .brand .mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--gold-400), var(--gold-500));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--navy-950);
  font-weight: 800;
  font-size: 14px;
}

.topbar nav a {
  color: rgba(255,255,255,0.78);
  text-decoration: none;
  font-size: 14px;
  margin-left: 24px;
  font-weight: 500;
}
.topbar nav a:hover { color: white; }

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

h1 { font-size: 24px; margin: 0 0 4px; }
.subtitle { color: var(--gray-500); font-size: 14px; margin: 0 0 28px; }

.stat-row {
  display: flex;
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: white;
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  padding: 16px 20px;
  flex: 1;
  box-shadow: var(--shadow);
}
.stat-card .num { font-size: 26px; font-weight: 700; }
.stat-card .label { font-size: 13px; color: var(--gray-500); margin-top: 2px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--navy-950);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--navy-800); }
.btn.gold { background: var(--gold-500); color: var(--navy-950); }
.btn.gold:hover { background: var(--gold-400); }
.btn.ghost { background: transparent; color: var(--navy-950); border: 1px solid var(--gray-300); }
.btn.ghost:hover { background: var(--gray-100); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.card {
  background: white;
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

table.doclist { width: 100%; border-collapse: collapse; }
table.doclist th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-500);
  padding: 14px 20px;
  border-bottom: 1px solid var(--gray-100);
}
table.doclist td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 14px;
  vertical-align: middle;
}
table.doclist tr:last-child td { border-bottom: none; }
table.doclist tr:hover { background: var(--gray-50); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
}
.badge.signed { background: var(--green-100); color: var(--green-600); }
.badge.pending { background: var(--amber-100); color: var(--amber-600); }

.ref { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; color: var(--gray-700); }

.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--gray-500);
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy-950);
}
.login-card {
  background: white;
  border-radius: 14px;
  padding: 40px 36px;
  width: 340px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.login-card .mark {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, var(--gold-400), var(--gold-500));
  display: flex; align-items: center; justify-content: center;
  color: var(--navy-950); font-weight: 800; margin-bottom: 18px;
}
.login-card h2 { margin: 0 0 4px; font-size: 20px; }
.login-card p.sub { color: var(--gray-500); font-size: 13px; margin: 0 0 24px; }
.login-card input[type=password] {
  width: 100%; padding: 11px 14px; border-radius: 8px;
  border: 1px solid var(--gray-300); font-size: 14px; margin-bottom: 14px;
}
.login-card .error { color: #c0392b; font-size: 13px; margin-bottom: 12px; }
.login-card .btn { width: 100%; justify-content: center; }

.upload-drop {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 56px 24px;
  text-align: center;
  color: var(--gray-500);
  background: white;
}
.upload-drop input[type=file] { margin-top: 16px; }

.flash {
  background: var(--amber-100); color: var(--amber-600);
  padding: 10px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 16px;
}

/* Signing view */
.sign-layout { display: flex; gap: 24px; align-items: flex-start; }
.sign-pages { flex: 1; }
.sign-sidebar {
  width: 240px;
  position: sticky;
  top: 24px;
}
.page-block { margin-bottom: 20px; background: white; border: 1px solid var(--gray-100); border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow); }
.page-block .page-label { font-size: 12px; color: var(--gray-500); margin-bottom: 8px; padding-left: 4px; }
.page-canvas-wrap { position: relative; display: inline-block; }
.page-canvas-wrap img { display: block; max-width: 100%; height: auto; border: 1px solid var(--gray-100); }

.sig-tray {
  background: white; border: 1px solid var(--gray-100); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.sig-tray .tray-label { font-size: 12px; color: var(--gray-500); margin-bottom: 10px; }
.sig-tray-item {
  border: 1px dashed var(--gray-300); border-radius: 8px; padding: 10px;
  cursor: grab; text-align: center; background: var(--gray-50);
}
.sig-tray-item img { max-width: 140px; }

.placed-sig {
  position: absolute;
  cursor: move;
  border: 1px solid rgba(217,164,65,0.9);
  background: rgba(255,255,255,0.001);
}
.placed-sig img { width: 100%; height: 100%; display: block; pointer-events: none; }
.placed-sig .handle {
  position: absolute; width: 12px; height: 12px; right: -6px; bottom: -6px;
  background: var(--gold-500); border-radius: 50%; cursor: nwse-resize;
  border: 2px solid white;
}
.placed-sig .remove-x {
  position: absolute; top: -10px; right: -10px; width: 18px; height: 18px;
  background: #c0392b; color: white; border-radius: 50%; font-size: 12px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  line-height: 1;
}

.finish-bar {
  position: sticky; top: 24px;
}
