* { box-sizing: border-box; }

:root {
    --bg: #f6f8fb;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --border: #e5e7eb;
    --error: #b91c1c;
    --error-bg: #fee2e2;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
}

body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.card {
    width: 100%;
    max-width: 480px;
    background: var(--card);
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.06);
    padding: 2rem;
}

h1 {
    font-size: 1.4rem;
    margin: 0 0 0.5rem 0;
}

.lead {
    color: var(--muted);
    margin: 0 0 1.5rem 0;
    font-size: 0.95rem;
}

label {
    display: block;
    margin-bottom: 1rem;
}

/* HTML-атрибут hidden должен иметь приоритет над display: block/flex/inline-flex */
label[hidden],
fieldset[hidden],
.conditional[hidden] {
    display: none !important;
}

label.checkbox {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    padding: 0.8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

label.checkbox:hover {
    border-color: var(--accent);
    background: #f8fafc;
}

label.checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    flex-shrink: 0;
    cursor: pointer;
}

label.checkbox > span {
    margin: 0;
    font-weight: 500;
}

label.checkbox small {
    display: block;
    margin-top: 2px;
    font-size: 0.825rem;
    color: var(--muted);
    font-weight: 400;
}

fieldset.search-mode {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.6rem 0.9rem 0.4rem 0.9rem;
    margin: 0 0 1rem 0;
}

fieldset.search-mode legend {
    padding: 0 0.4rem;
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 500;
}

label.radio {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0.25rem 0.9rem 0.4rem 0;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 400;
}

label.radio input[type="radio"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

label.radio > span {
    margin: 0;
    font-weight: 400;
}

.conditional {
    margin-top: 0.5rem;
    animation: slide-down 0.18s ease;
    overflow: hidden;
}

@keyframes slide-down {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

label > span {
    display: block;
    font-size: 0.875rem;
    margin-bottom: 0.35rem;
    color: var(--text);
    font-weight: 500;
}

.optional {
    color: var(--muted);
    font-weight: 400;
}

input, textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font-family: inherit;
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

textarea {
    resize: vertical;
    min-height: 70px;
}

button, .primary {
    display: block;
    width: 100%;
    padding: 0.7rem 1rem;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: background 0.15s ease;
    margin-top: 0.5rem;
}

button:hover:not(:disabled), .primary:hover {
    background: var(--accent-hover);
}

button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.error {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 8px;
    background: var(--error-bg);
    color: var(--error);
    font-size: 0.9rem;
}

.legal {
    margin-top: 1.5rem;
    font-size: 0.8rem;
    color: var(--muted);
    line-height: 1.4;
}

.spinner {
    width: 48px;
    height: 48px;
    margin: 1.5rem auto;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.progress-wrap {
    margin: 1.75rem 0 1.25rem 0;
}

.progress-bar {
    height: 10px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #60a5fa);
    border-radius: 999px;
    transition: width 0.4s ease;
    width: 0%;
}

.progress-fill.indeterminate {
    width: 30% !important;
    animation: indeterminate 1.4s ease-in-out infinite;
}

@keyframes indeterminate {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(400%); }
}

.progress-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 0.6rem;
    font-size: 0.875rem;
    color: var(--muted);
}

.progress-meta #progress-percent {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--text);
}


/* ===== Модалка подтверждения пациента ===== */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 1000;
    animation: fade-in 0.18s ease;
}

/* HTML-атрибут hidden должен иметь приоритет над display:flex */
.modal-backdrop[hidden] {
    display: none !important;
}

@keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal {
    background: var(--card);
    border-radius: 12px;
    padding: 1.5rem 1.6rem;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 12px 36px rgba(0,0,0,0.18);
    animation: slide-down 0.18s ease;
}

.modal h2 {
    margin: 0 0 0.4rem 0;
    font-size: 1.2rem;
}

.modal .lead {
    margin: 0 0 1rem 0;
}

.confirm-data {
    margin: 0 0 1.25rem 0;
    display: grid;
    grid-template-columns: minmax(110px, auto) 1fr;
    gap: 0.4rem 0.9rem;
    font-size: 0.95rem;
}

.confirm-data dt {
    color: var(--muted);
    font-size: 0.85rem;
    align-self: center;
}

.confirm-data dd {
    margin: 0;
    font-weight: 500;
    word-break: break-word;
}

.modal-actions {
    display: flex;
    gap: 0.6rem;
    margin-top: 0.5rem;
}

.modal-actions button {
    flex: 1;
    margin: 0;
}

.modal-actions button.secondary {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
}

.modal-actions button.secondary:hover:not(:disabled) {
    background: #f9fafb;
}


.back-link {
    margin: 1rem 0 0 0;
    text-align: center;
    font-size: 0.9rem;
}

.back-link a {
    color: var(--accent);
    text-decoration: none;
}

.back-link a:hover {
    text-decoration: underline;
}
