:root {
    --brand: #4f46e5;
    --brand-dark: #4338ca;
    --brand-grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #1e293b;
    --muted: #64748b;
    --border: #e2e8f0;
    --danger: #e11d48;
    --warn: #ea580c;
    --ok: #16a34a;
    --info: #4f46e5;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    background-image: radial-gradient(circle at 15% 10%, rgba(79,70,229,.07), transparent 40%),
                      radial-gradient(circle at 85% 0%, rgba(124,58,237,.07), transparent 40%);
    color: var(--text);
    line-height: 1.55;
    min-height: 100vh;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
    max-width: 880px;
    margin: 0 auto;
    padding: 1.5rem 1rem 4rem;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    box-shadow: 0 4px 24px rgba(30,41,59,.06);
    padding: 1.75rem;
    margin-bottom: 1.25rem;
}

.hero {
    background: var(--brand-grad);
    color: #fff;
    text-align: left;
    padding: 2rem 1.75rem;
}
.hero h1 { color: #fff; margin-bottom: .6rem; }
.hero p { color: rgba(255,255,255,.85); margin: 0; }

h1 { font-size: 1.9rem; margin: 0 0 .5rem; line-height: 1.2; }
h2 { font-size: 1.2rem; margin: 0 0 1rem; }
h3 { font-size: 1.05rem; margin: 0 0 .75rem; }

p { margin: 0 0 .75rem; }
p:last-child { margin-bottom: 0; }

label { display: block; font-weight: 600; margin-bottom: .4rem; font-size: .95rem; }

input, select, textarea {
    width: 100%;
    padding: .65rem .8rem;
    border: 1.5px solid var(--border);
    border-radius: .65rem;
    background: #fff;
    font-size: 1rem;
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
    -webkit-appearance: none;
    appearance: none;
}
input:hover, select:hover { border-color: #cbd5e1; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(79,70,229,.12);
}

.btn {
    display: inline-block;
    cursor: pointer;
    border: none;
    border-radius: .65rem;
    padding: .8rem 1.5rem;
    font-size: 1rem;
    font-weight: 700;
    transition: transform .1s, box-shadow .15s, background .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
    background: var(--brand-grad);
    color: #fff;
    box-shadow: 0 6px 18px rgba(79,70,229,.35);
}
.btn-primary:hover { box-shadow: 0 8px 22px rgba(79,70,229,.45); }
.btn-block { width: 100%; }
.btn-ghost { background: #e2e8f0; color: var(--text); }
.btn-ghost:hover { background: #cbd5e1; }

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 1.25rem;
}
@media (max-width: 640px) {
    .form-grid { grid-template-columns: 1fr; }
}

.field { margin-bottom: 1rem; }
.form-grid .field { margin-bottom: 0; }

.panel {
    background: #f8fafc;
    border: 1.5px dashed #c7d2fe;
    border-radius: .75rem;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}
.panel h2 { color: var(--brand-dark); }

.divider {
    height: 1px;
    background: var(--border);
    margin: 1.5rem 0;
}

.badge {
    display: inline-block;
    padding: .2rem .7rem;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 700;
}
.badge-high { background: #ffe4e6; color: var(--danger); }
.badge-low  { background: #dcfce7; color: var(--ok); }

/* Блок результата */
.alert {
    padding: 1.5rem 1.75rem;
    border-radius: 1rem;
    border: 2px solid;
    margin-bottom: 1.25rem;
}
.alert.danger  { background: #fff1f2; border-color: #fecdd3; }
.alert.danger h2 { color: var(--danger); }
.alert.warning { background: #fff7ed; border-color: #fed7aa; }
.alert.warning h2 { color: var(--warn); }
.alert.info    { background: #eef2ff; border-color: #c7d2fe; }
.alert.info h2 { color: var(--brand-dark); }
.alert.success { background: #f0fdf4; border-color: #bbf7d0; }
.alert.success h2 { color: var(--ok); }

/* Счётчик риска */
.risk-meta {
    display: flex;
    align-items: baseline;
    gap: .5rem;
    flex-wrap: wrap;
    margin-bottom: .5rem;
}
.risk-percent {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1;
}
.risk-scale {
    height: 12px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
    margin: .75rem 0 1.25rem;
}
.risk-scale-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--brand-grad);
    width: 0;
    transition: width .8s cubic-bezier(.22,1,.36,1);
}

/* Человечки */
.figures {
    display: grid;
    grid-template-columns: repeat(20, 1fr);
    gap: 6px;
    margin: 1.25rem 0 .5rem;
}

.figure {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    opacity: 0;
    transform: scale(0) translateY(6px);
    animation: pop .45s cubic-bezier(.34,1.56,.64,1) forwards;
}
@keyframes pop {
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.fig-head {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: block;
}
.fig-body {
    width: 14px;
    height: 12px;
    border-radius: 6px 6px 3px 3px;
    display: block;
    margin-top: 2px;
}

.figure.healthy .fig-head { background: #3b82f6; }
.figure.healthy .fig-body { background: #60a5fa; }

.figure.sick .fig-head { background: #ef4444; }
.figure.sick .fig-body { background: #f87171; }

/* Пульсация красных человечков для акцента */
.figure.sick { animation: pop .45s cubic-bezier(.34,1.56,.64,1) forwards, pulse 1.6s ease-in-out 1.2s infinite; }
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.12); }
}

.figures-caption {
    color: var(--muted);
    font-size: .88rem;
    text-align: center;
    margin: .5rem 0 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    flex-wrap: wrap;
}
.dot-blue, .dot-red {
    display: inline-block;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    vertical-align: middle;
}
.dot-blue { background: #3b82f6; }
.dot-red { background: #ef4444; }

/* Список рекомендаций */
.route-list { margin: .75rem 0 0; padding-left: 1.25rem; }
.route-list li { margin-bottom: .4rem; }

/* Админка: таблица */
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: .6rem .55rem; vertical-align: top; }
thead th { border-bottom: 2px solid var(--border); font-weight: 600; }
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }

pre.json {
    background: #0f172a;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: .6rem;
    overflow-x: auto;
    font-size: .85rem;
    line-height: 1.5;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
}
