:root {
    --ink: #142a4a;
    --muted: #5b6b84;
    --paper: #f2f5fa;
    --line: #dfe6f0;
    --sky: #0f8bd0;
    --gold: #d9a441;
}
* { box-sizing: border-box; }
body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--paper);
    color: #1c1e21;
    margin: 0;
    display: flex;
    justify-content: center;
    padding: 48px 16px;
}
.card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .08);
    padding: 32px;
    max-width: 720px;
    width: 100%;
}
h1 { font-size: 22px; margin: 0 0 24px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.qr-box svg { width: 220px; height: 220px; display: block; }

/* --- Страницы входа (auth) --- */
.auth { max-width: 440px; width: 100%; padding-top: 4vh; }
.auth-brand { margin-bottom: 28px; }
.auth-brand-compact { margin-bottom: 20px; }
.auth-eyebrow {
    margin: 0 0 10px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--sky);
}
.auth-title {
    margin: 0;
    font-size: 44px;
    font-weight: 800;
    letter-spacing: -.02em;
    line-height: 1.05;
    color: var(--ink);
}
.auth-title-small { font-size: 28px; }
.auth-stroke { display: block; width: 220px; height: 26px; margin: 2px 0 10px; }
.auth-stroke path {
    stroke: var(--gold);
    stroke-width: 2.5;
    stroke-dasharray: 420;
    stroke-dashoffset: 420;
    animation: auth-stroke-draw .9s ease-out .15s forwards;
}
@keyframes auth-stroke-draw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) {
    .auth-stroke path { animation: none; stroke-dashoffset: 0; }
}
.auth-lede { margin: 10px 0 0; font-size: 15px; line-height: 1.55; color: var(--muted); }
.brand-logo { display: block; max-height: 56px; max-width: 220px; object-fit: contain; margin-bottom: 14px; }
.brand-site-name { overflow-wrap: anywhere; }
.brand-msign-note { margin: 8px 0 0; color: var(--muted); }
.logo-preview-row { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.logo-preview { max-height: 56px; max-width: 220px; object-fit: contain; background: #fff; border-radius: 8px; padding: 4px; }
.auth-methods { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }
.method {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    text-decoration: none;
    color: var(--ink);
    transition: border-color .15s, box-shadow .15s, transform .15s;
}
.method:hover {
    border-color: var(--sky);
    box-shadow: 0 6px 18px rgba(20, 42, 74, .08);
    transform: translateY(-1px);
}
.method:focus-visible { outline: 3px solid rgba(15, 139, 208, .4); outline-offset: 2px; }
.method-icon {
    flex: 0 0 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 11px;
}
.method-icon-tg { background: #e7f3fb; color: #2596d1; }
.method-icon-qr { background: #ecf0f7; color: var(--ink); }
.method-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.method-text strong { font-size: 15px; font-weight: 650; }
.method-text span { font-size: 13px; color: var(--muted); line-height: 1.4; }
.method-arrow { margin-left: auto; color: var(--muted); font-size: 18px; transition: transform .15s, color .15s; }
.method:hover .method-arrow { transform: translateX(3px); color: var(--sky); }
.auth-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 24px;
}
.qr-frame {
    position: relative;
    width: fit-content;
    margin: 0 auto;
    padding: 14px;
}
.qr-frame::before, .qr-frame::after,
.qr-frame .qr-box::before, .qr-frame .qr-box::after {
    content: "";
    position: absolute;
    width: 22px;
    height: 22px;
    border: 2.5px solid var(--gold);
}
.qr-frame::before { top: 0; left: 0; border-right: 0; border-bottom: 0; border-radius: 6px 0 0 0; }
.qr-frame::after { top: 0; right: 0; border-left: 0; border-bottom: 0; border-radius: 0 6px 0 0; }
.qr-frame .qr-box::before { bottom: 0; left: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 6px; }
.qr-frame .qr-box::after { bottom: 0; right: 0; border-left: 0; border-top: 0; border-radius: 0 0 6px 0; }
.auth-card .hint, .auth-card .status { text-align: center; }
.auth-foot { margin-top: 24px; font-size: 13px; color: var(--muted); }
.auth-foot a { color: var(--sky); text-decoration: none; }
.auth-foot a:hover { text-decoration: underline; }
@media (max-width: 480px) {
    .auth { padding-top: 0; }
    .auth-title { font-size: 36px; }
}

/* --- Админка --- */
.admin { max-width: 880px; width: 100%; }
.admin-narrow { max-width: 560px; }
.admin-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.admin-title { margin: 0; font-size: 30px; font-weight: 800; letter-spacing: -.01em; color: var(--ink); }
.admin-sub { margin: 6px 0 0; font-size: 14px; color: var(--muted); }
.admin-head-actions { padding-bottom: 4px; }
.panel {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 24px;
    margin-bottom: 16px;
}
.panel h2 { margin-top: 0; }
.panel-empty { text-align: center; padding: 40px 24px; color: var(--muted); }
.panel-empty .btn { margin-top: 8px; }
.panel-secret { border-color: var(--gold); background: #fdf9f1; }
.panel-danger { border-color: #ecd4cf; }
.admin-table { margin: 0; }
.admin-table th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
}
.admin-table td { vertical-align: top; }
.admin-table .cell-name { font-weight: 600; color: var(--ink); }
.admin-table .cell-actions { text-align: right; white-space: nowrap; }
.uri-chip {
    display: inline-block;
    background: #eef2f8;
    border-radius: 6px;
    padding: 2px 8px;
    margin: 2px 6px 2px 0;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 12px;
    word-break: break-all;
}
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 12px 0 0; }
.kv dt { color: var(--muted); font-size: 13px; padding-top: 2px; }
.kv dd { margin: 0; }
.field-hint { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.danger-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 14px 0;
    border-top: 1px solid var(--line);
}
.danger-row:first-of-type { border-top: 0; padding-top: 4px; }
.danger-row form { margin: 0; }
.danger-row strong { color: var(--ink); }
.badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #fdf3df;
    color: #8a6416;
    font-size: 12px;
    font-weight: 600;
    vertical-align: middle;
}
.radio-row { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; font-size: 14px; color: var(--ink); }
.radio-row input { margin-top: 3px; }
.radio-row .field-hint { display: block; margin-top: 2px; font-weight: 400; }
.access-list { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.access-add-row { display: flex; gap: 8px; flex-wrap: wrap; }
.access-add-row select {
    padding: 8px 10px;
    border: 1px solid #ccd0d5;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
}
.access-add-row input { flex: 1 1 220px; width: auto; }
.btn-link {
    background: none;
    border: 0;
    padding: 0;
    color: #c0392b;
    font-size: 13px;
    cursor: pointer;
    text-decoration: underline;
}
.hint { color: #606770; font-size: 13px; margin-top: 8px; }
.error { color: #c0392b; font-size: 14px; }
.status { font-size: 14px; margin-top: 12px; }
table { border-collapse: collapse; width: 100%; margin: 16px 0; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid #e4e6eb; font-size: 14px; }
th { color: #606770; font-weight: 600; }
.btn {
    display: inline-block;
    background: #2563eb;
    color: #fff;
    border: 0;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 14px;
    text-decoration: none;
    cursor: pointer;
}
.btn.secondary { background: #e4e6eb; color: #1c1e21; }
.btn.danger { background: #c0392b; }
.actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
a { color: #2563eb; }
label { display: block; font-size: 13px; color: #606770; margin: 12px 0 4px; }
input[type=text], textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccd0d5;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
}
.secret-note { background: #f4f5f7; border-radius: 8px; padding: 12px 16px; margin: 16px 0; }
.secret-box { word-break: break-all; }

/* --- Админка: пользователи и журнал входов --- */
.admin-nav { display: flex; gap: 18px; flex-wrap: wrap; margin: -6px 0 18px; font-size: 14px; }
.admin-nav a { color: var(--muted); text-decoration: none; padding-bottom: 4px; border-bottom: 2px solid transparent; }
.admin-nav a:hover { color: var(--sky); }
.admin-nav a.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--gold); }
.admin-table .cell-time { white-space: nowrap; font-variant-numeric: tabular-nums; }
.event-where { display: block; color: var(--ink); }
.filter-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-row label { margin: 0; }
.filter-row select {
    padding: 8px 10px;
    border: 1px solid #ccd0d5;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    max-width: 100%;
}
.pager { display: flex; align-items: center; gap: 16px; margin: 4px 0 16px; font-size: 14px; }
.pager .field-hint { margin: 0; }
@media (max-width: 640px) {
    .admin .panel { overflow-x: auto; }
}

/* --- Экран согласия --- */
.consent-data {
    margin-top: 20px;
    padding: 18px 20px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
}
.consent-agent { margin: 0 0 16px; font-size: 14px; line-height: 1.5; color: var(--ink); }
.consent-agent p { margin: 0 0 6px; }
.consent-warning { color: #c0392b; }
.consent-subtitle { margin: 0 0 10px; font-size: 14px; color: var(--muted); font-weight: 600; }
.consent-list { margin: 0; padding-left: 20px; font-size: 15px; line-height: 1.6; color: var(--ink); }
.consent-list li + li { margin-top: 4px; }
.consent-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 20px; }
.consent-actions form { margin: 0; }
@media (max-width: 480px) {
    .consent-actions, .consent-actions form { width: 100%; }
    .consent-actions .btn { width: 100%; }
}
