:root {
    --bg: #eef3f8;
    --card: #ffffff;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --blue: #1d4ed8;
    --blue-dark: #1e40af;
    --blue-soft: #eff6ff;
    --ok: #15803d;
    --ok-soft: #ecfdf3;
    --danger: #b91c1c;
    --danger-soft: #fef2f2;
    --warn: #b45309;
    --shadow: 0 12px 40px rgba(15, 23, 42, 0.06);
    --radius: 18px;
    color-scheme: light;
    font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); min-height: 100vh; }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }

.skip {
    position: absolute; left: 12px; top: -40px; background: #fff; padding: 8px 12px;
}
.skip:focus { top: 12px; }

.shell { width: min(440px, 100%); margin: 0 auto; padding: 18px 16px 32px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 650; }
.brand i, .doc-icon {
    width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
    background: var(--blue-soft); color: var(--blue);
}
.steps { display: flex; gap: 6px; margin: 14px 0; }
.steps span { height: 6px; flex: 1; border-radius: 99px; background: #dbe3ee; }
.steps span.on { background: var(--blue); }
h1 { font-size: 28px; line-height: 1.15; margin: 8px 0; }
.lead { color: var(--muted); margin: 0 0 16px; }
.card, .viewer, .panel, .success-card {
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
}
.panel { padding: 14px; display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.viewer { padding: 10px; margin-bottom: 14px; }
.viewer-frame {
    position: relative; background: #f8fafc; border: 1px solid #d6dbe3; border-radius: 12px;
    min-height: 280px; display: grid; place-items: center; overflow: hidden;
}
.viewer-frame canvas, .viewer-frame img { max-width: 100%; height: auto; }
.pager {
    position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%);
    background: #fff; border-radius: 999px; display: flex; gap: 8px; align-items: center;
    padding: 4px 8px; box-shadow: var(--shadow);
}
.pager button, .icon-button, .text-button {
    border: 0; background: transparent; color: var(--blue); min-height: 40px; cursor: pointer;
}
.actions { display: flex; gap: 10px; }
.btn, .btn-line {
    display: inline-flex; justify-content: center; align-items: center; gap: 8px;
    min-height: 48px; border-radius: 12px; padding: 0 16px; text-decoration: none; cursor: pointer;
    border: 1px solid transparent; font-weight: 650;
}
.btn { background: var(--blue); color: #fff; flex: 1; }
.btn:hover { background: var(--blue-dark); }
.btn:disabled { background: #93c5fd; cursor: not-allowed; }
.btn-line { background: #fff; color: var(--blue); border-color: #bfdbfe; }
.btn-danger { background: var(--danger); color: #fff; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field span, label { font-size: 14px; color: #334155; }
input[type="text"], input[type="email"], input[type="password"], input[type="datetime-local"], select, textarea {
    width: 100%; min-height: 48px; border: 1px solid #cbd5e1; border-radius: 12px; padding: 10px 12px; background: #fff;
}
textarea { min-height: 96px; }
.readonly { background: #f8fafc; }
.notice { background: var(--blue-soft); border-radius: 14px; padding: 12px; display: flex; gap: 10px; margin: 8px 0 14px; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 12px 0; }
.check input { width: 20px; height: 20px; margin-top: 2px; }
.fine { color: var(--muted); font-size: 13px; }
.stage { display: none; }
.stage.on { display: block; }
.camera-wrap { display: grid; gap: 12px; justify-items: center; }
.oval-box { position: relative; width: min(100%, 320px); aspect-ratio: 1; }
.oval-box video, .oval-box canvas.shot {
    width: 100%; height: 100%; object-fit: cover; border-radius: 50%; background: #e2e8f0;
}
.ring {
    position: absolute; inset: 8px; border-radius: 50%; border: 4px solid #94a3b8; pointer-events: none;
}
.ring.green { border-color: #16a34a; }
.chip {
    display: inline-flex; gap: 6px; align-items: center; background: var(--ok-soft); color: var(--ok);
    border-radius: 999px; padding: 6px 10px; font-weight: 650;
}
.thumbs { display: flex; gap: 8px; }
.thumbs img { width: 72px; height: 72px; object-fit: cover; border-radius: 12px; }
.done { text-align: center; padding: 28px 18px; }
.seal {
    width: 84px; height: 84px; margin: 0 auto 8px; border-radius: 50%; display: grid; place-items: center;
    background: var(--ok-soft); color: var(--ok); font-size: 40px;
}
.error { background: var(--danger-soft); color: var(--danger); padding: 10px 12px; border-radius: 12px; }
.okbox { background: var(--ok-soft); color: var(--ok); padding: 10px 12px; border-radius: 12px; }

.admin-body { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: #0f172a; color: #e2e8f0; padding: 18px 12px; }
.side a { color: #e2e8f0; text-decoration: none; display: block; padding: 10px 12px; border-radius: 10px; }
.side a:hover, .side a.on { background: #1e293b; }
.main { padding: 22px; }
.table-wrap { overflow-x: auto; background: #fff; border-radius: 16px; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.badge { border-radius: 999px; padding: 4px 8px; font-size: 12px; background: #e2e8f0; }
.badge.sent, .badge.in_progress { background: #dbeafe; color: #1d4ed8; }
.badge.signed { background: #dcfce7; color: #166534; }
.badge.expired, .badge.cancelled { background: #fee2e2; color: #991b1b; }
.banner { background: #fff7ed; border: 1px solid #fed7aa; padding: 12px; border-radius: 12px; margin-bottom: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pager-row { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
@media (max-width: 800px) {
    .admin-body { grid-template-columns: 1fr; }
    .side { display: flex; gap: 6px; overflow-x: auto; }
    .side a { white-space: nowrap; }
    .grid-2 { grid-template-columns: 1fr; }
    h1 { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) {
    * { scroll-behavior: auto; transition: none !important; }
}
