:root {
  --navy: #0f2346; --navy-2: #16305e; --navy-3: #1d3b73;
  --bg: #f3f5f9; --card: #ffffff; --line: #e5e9f0; --line-2: #d6dce6;
  --text: #16213a; --muted: #67718a; --muted-2: #8b94a8;
  --brand: #2563eb; --brand-2: #1d4ed8; --brand-soft: #e8efff;
  --ok: #15803d; --ok-soft: #dcfce7; --warn: #b45309; --warn-soft: #fef3c7;
  --bad: #b91c1c; --bad-soft: #fee2e2; --info: #1d4ed8; --info-soft: #dbeafe;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 4px 16px rgba(16,24,40,.05);
  --r: 14px; --sidebar: 248px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14.5px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; margin: 0; }
h2 { font-size: 15px; font-weight: 700; margin: 0 0 14px; color: var(--text); }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "SF Mono", Consolas, "Roboto Mono", monospace; font-size: 13.5px; letter-spacing: .01em; }
.small { font-size: 12.5px; }

/* ---------- Layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar); flex: 0 0 var(--sidebar); background: linear-gradient(180deg, var(--navy) 0%, #0b1a36 100%); color: #dbe4f5; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px 18px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand img { width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.06); padding: 2px; }
.brand b { display: block; color: #fff; font-size: 16px; letter-spacing: .02em; }
.brand span { display: block; font-size: 12px; color: #9fb0cf; margin-top: 1px; }
.nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: #c9d5ea; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(255,255,255,.12); color: #fff; }
.nav a svg { width: 18px; height: 18px; opacity: .85; }
.nav .count { margin-left: auto; background: #2f6bff; color: #fff; font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 999px; }
.sidebar .foot { margin-top: auto; padding: 14px 16px 18px; border-top: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #2f6bff; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex: 0 0 auto; }
.avatar.soft { background: var(--brand-soft); color: var(--brand-2); }
.sidebar .foot .who { flex: 1; min-width: 0; }
.sidebar .foot .who b { display: block; color: #fff; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .foot .who span { font-size: 12px; color: #9fb0cf; }
.sidebar .foot a { color: #9fb0cf; display: inline-flex; padding: 6px; border-radius: 8px; }
.sidebar .foot a:hover { background: rgba(255,255,255,.08); color: #fff; }
.main { flex: 1; min-width: 0; padding: 28px 32px 48px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.topbar .sub { color: var(--muted); margin-top: 3px; }
.topbar .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.card .body { padding: 20px 22px; }
.card + .card { margin-top: 18px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { display: block; padding: 16px 18px; border-radius: var(--r); background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--text); transition: transform .12s, border-color .12s; }
.stat:hover { text-decoration: none; transform: translateY(-1px); border-color: var(--line-2); }
.stat.active { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.stat .l { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); font-weight: 500; }
.stat .l i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.stat .v { font-size: 28px; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; }
.dot-all { background: var(--navy-3); } .dot-awaiting_video { background: #0d9488; } .dot-awaiting_signature { background: #7c3aed; } .dot-new { background: #2563eb; } .dot-in_progress { background: #d97706; } .dot-done { background: #16a34a; } .dot-rejected { background: #dc2626; }

/* ---------- Toolbar / inputs ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.search { position: relative; flex: 1; min-width: 240px; max-width: 460px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted-2); }
.search input { width: 100%; padding-left: 36px; }
input[type=text], input[type=password], select, textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: 10px; font: inherit; background: #fff; color: var(--text); transition: border-color .12s, box-shadow .12s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { min-height: 84px; resize: vertical; }
label.field { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field-row { margin-bottom: 14px; }
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line-2); background: #fff; font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; color: var(--text); white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: #f7f9fc; text-decoration: none; border-color: #c6cfdd; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn.danger { color: var(--bad); border-color: #f3c7c7; background: #fff; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--brand); }
.btn.ghost:hover { background: var(--brand-soft); }
.btn.sm { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.inline { display: inline; }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: #fafbfd; }
th:first-child, td:first-child { padding-left: 22px; }
th:last-child, td:last-child { padding-right: 22px; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: #f8faff; }
tbody tr:last-child td { border-bottom: 0; }
.person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.person .n { font-weight: 600; color: var(--text); }
.person .u { font-size: 12.5px; color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.awaiting_video { background: #ccfbf1; color: #0f766e; }
.badge.awaiting_signature { background: #ede9fe; color: #6d28d9; }
.badge.new { background: var(--info-soft); color: var(--info); }
.badge.in_progress { background: var(--warn-soft); color: var(--warn); }
.badge.done { background: var(--ok-soft); color: var(--ok); }
.badge.rejected { background: var(--bad-soft); color: var(--bad); }
.warn { color: var(--warn); } .bad { color: var(--bad); } .ok { color: var(--ok); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty svg { width: 44px; height: 44px; color: #c3cbd9; margin-bottom: 10px; }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }

/* ---------- Detail ---------- */
.grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }
.kv { display: grid; grid-template-columns: 150px 1fr; row-gap: 14px; column-gap: 16px; }
.kv dt { color: var(--muted); font-size: 13px; padding-top: 3px; }
.kv dd { margin: 0; min-width: 0; }
.copy-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.copy-row .val { font-size: 15px; font-weight: 600; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 8px; background: #f3f5f9; border: 1px solid var(--line); font-size: 13px; }
.chip.warn { background: var(--warn-soft); border-color: #fde68a; color: var(--warn); }
.chip.bad { background: var(--bad-soft); border-color: #fecaca; color: var(--bad); }
.pw { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pw code { font-size: 16px; padding: 7px 12px; background: #f3f5f9; border: 1px solid var(--line); border-radius: 8px; min-width: 150px; letter-spacing: .06em; }
.head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.head .avatar { width: 48px; height: 48px; font-size: 17px; }
.head .t b { display: block; font-size: 19px; }
.head .t span { color: var(--muted); font-size: 13px; }
.msg { padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 13.5px; }
.msg.error { background: var(--bad-soft); color: var(--bad); }
.msg.ok { background: var(--ok-soft); color: var(--ok); }
.msg.note { background: var(--warn-soft); color: var(--warn); }
.choices { display: flex; gap: 8px; flex-wrap: wrap; }
.choices label { cursor: pointer; }
.choices input { display: none; }
.choices span { display: inline-block; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line-2); font-size: 13px; font-weight: 600; color: var(--muted); }
.choices input:checked + span.awaiting_video { background: #ccfbf1; color: #0f766e; border-color: transparent; }
.choices input:checked + span.awaiting_signature { background: #ede9fe; color: #6d28d9; border-color: transparent; }
.choices input:checked + span.new { background: var(--info-soft); color: var(--info); border-color: transparent; }
.signed-img { max-width: 100%; max-height: 520px; border: 1px solid var(--line); border-radius: 10px; display: block; }
.verify-video { width: 100%; max-height: 420px; background: #000; border-radius: 10px; display: block; }
.choices input:checked + span.in_progress { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.choices input:checked + span.done { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.choices input:checked + span.rejected { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text); }
.check input { width: 16px; height: 16px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; font-size: 13.5px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.timeline li::after { content: ""; position: absolute; left: 8px; top: 17px; bottom: 0; width: 2px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline .when { color: var(--muted); font-size: 12.5px; }
.danger-zone { border-color: #f3d6d6; }
.danger-zone h2 { color: var(--bad); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.divider { height: 1px; background: var(--line); margin: 18px 0; }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1100px 600px at 10% -10%, #1d3b73 0%, transparent 60%), radial-gradient(900px 500px at 110% 110%, #1d3b73 0%, transparent 55%), var(--navy); padding: 24px; }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 18px; padding: 34px 32px 30px; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.login-card .logo { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 22px; text-align: center; }
.login-card .logo img { width: 64px; height: 64px; border-radius: 50%; background: var(--navy); padding: 6px; }
.login-card .logo b { font-size: 18px; }
.login-card .logo span { font-size: 13px; color: var(--muted); }
.login-card .btn { width: 100%; justify-content: center; padding: 11px; margin-top: 6px; }
.login-foot { text-align: center; color: #9fb0cf; font-size: 12.5px; margin-top: 16px; }

/* ---------- Mobile ---------- */
.menu-btn { display: none; }
@media (max-width: 960px) {
  .grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 120px 1fr; }
}
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .brand { padding: 12px 16px; border: 0; flex: 1; }
  .brand img { width: 34px; height: 34px; }
  .nav { flex-direction: row; padding: 0 10px 10px; width: 100%; order: 3; }
  .nav a { padding: 8px 10px; }
  .sidebar .foot { margin: 0; border: 0; padding: 8px 12px; }
  .sidebar .foot .who { display: none; }
  .main { padding: 16px; }
  th, td { padding: 10px 10px; }
  th:first-child, td:first-child { padding-left: 14px; }
  .hide-m { display: none; }
}
