:root {
    --ink: #132c3b;
    --muted: #607582;
    --surface: #ffffff;
    --canvas: #f3f7f8;
    --line: #dce7e9;
    --brand: #086f70;
    --brand-dark: #075658;
    --brand-soft: #e4f4f2;
    --accent: #d77a36;
    --success: #247a4d;
    --success-soft: #e7f5ed;
    --warning: #976119;
    --warning-soft: #fff3dc;
    --danger: #a33f43;
    --danger-soft: #fae9ea;
    --shadow: 0 12px 34px rgba(24, 55, 68, .08);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--canvas); color: var(--ink); }
a { color: var(--brand-dark); }
button, input, select, textarea { font: inherit; }

.app-header { background: #0d3441; color: white; border-bottom: 4px solid #37a29d; }
.header-inner { max-width: 1180px; margin: 0 auto; padding: 14px 22px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: white; text-decoration: none; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: #37a29d; font-weight: 800; font-size: 20px; }
.brand strong, .brand small { display: block; }
.brand small { color: #bed7dd; font-size: 12px; margin-top: 1px; }
.header-actions { display: flex; align-items: center; gap: 18px; }
.header-actions a, .link-button { color: #eefafa; text-decoration: none; font-weight: 650; font-size: 14px; }
.header-actions form { margin: 0; }
.link-button { border: 0; background: transparent; padding: 0; cursor: pointer; }

.page-shell { max-width: 1180px; margin: 0 auto; padding: 30px 22px 60px; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 24px; }
.heading-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.page-heading h1, .card h1, .card h2, .card h3 { margin-top: 0; }
h1 { font-size: clamp(28px, 4vw, 42px); letter-spacing: -.035em; margin-bottom: 8px; }
h2 { font-size: 21px; letter-spacing: -.015em; }
h3 { font-size: 16px; }
.lead { color: var(--muted); font-size: 17px; line-height: 1.55; margin: 0; }
.eyebrow { color: var(--brand); text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 800; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 24px; }
.login-card, .narrow-card { max-width: 520px; margin: 9vh auto 0; padding: 34px; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stats-grid-4 { grid-template-columns: repeat(4, minmax(120px, 1fr)); }
.stat { background: white; border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.stat strong { display: block; font-size: 27px; line-height: 1; margin-bottom: 7px; }
.stat span { color: var(--muted); font-size: 12px; line-height: 1.25; display: block; }
.stat-emphasis { background: #0d3441; color: white; border-color: #0d3441; }
.stat-emphasis span { color: #c6dde1; }

.toolbar { display: flex; gap: 12px; align-items: end; margin-bottom: 18px; }
.toolbar .search { flex: 1; }
.field-label, .stack-form label { display: block; font-size: 13px; font-weight: 750; margin: 0 0 7px; }
input[type="text"], input[type="password"], input[type="number"], input[type="datetime-local"], input[type="date"], input[type="tel"], input[type="file"], select, textarea {
    width: 100%; border: 1px solid #bfd0d4; background: white; color: var(--ink); border-radius: 10px; padding: 11px 12px; min-height: 44px;
}
textarea { min-height: 86px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(55, 162, 157, .18); border-color: var(--brand); }
.stack-form { display: grid; gap: 12px; margin-top: 24px; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 16px; border-radius: 10px; border: 1px solid transparent; text-decoration: none; font-weight: 750; cursor: pointer; }
.button-primary { background: var(--brand); color: white; }
.button-primary:hover { background: var(--brand-dark); }
.button-secondary { background: white; border-color: #aec4c8; color: var(--ink); }
.button-danger { background: var(--danger-soft); border-color: #e9bfc1; color: var(--danger); }
.button[disabled] { opacity: .45; cursor: not-allowed; }

.patient-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
.patient-table { width: 100%; border-collapse: collapse; background: white; }
.patient-table th { background: #edf4f5; color: #49626e; text-align: left; font-size: 11px; letter-spacing: .05em; text-transform: uppercase; padding: 12px; white-space: nowrap; }
.patient-table td { padding: 13px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
.patient-table tr:hover td { background: #f8fbfb; }
.patient-id strong, .patient-id small { display: block; }
.patient-id small { color: var(--muted); margin-top: 3px; }
.phone-link { color: var(--brand-dark); font-weight: 750; text-decoration-thickness: 1px; text-underline-offset: 3px; white-space: nowrap; }
.followup-table-wrap { overflow-x: clip; }
.followup-patient-table { table-layout: fixed; }
.followup-patient-table th { padding: 10px 6px; white-space: normal; overflow-wrap: anywhere; }
.followup-patient-table td { padding: 11px 6px; font-size: 13px; overflow-wrap: anywhere; }
.followup-patient-table th:nth-child(1) { width: 15%; }
.followup-patient-table th:nth-child(2) { width: 9%; }
.followup-patient-table th:nth-child(3) { width: 8%; }
.followup-patient-table th:nth-child(4) { width: 13%; }
.followup-patient-table th:nth-child(5) { width: 6%; }
.followup-patient-table th:nth-child(6) { width: 4.5%; }
.followup-patient-table th:nth-child(7) { width: 9%; }
.followup-patient-table th:nth-child(8) { width: 10.5%; }
.followup-patient-table th:nth-child(9) { width: 10.5%; }
.followup-patient-table th:nth-child(10) { width: 7.5%; }
.followup-patient-table th:nth-child(11) { width: 6%; }
.followup-patient-table .badge { justify-content: center; max-width: 100%; padding: 5px 7px; text-align: center; white-space: normal; line-height: 1.15; }
.followup-patient-table .phone-link { white-space: normal; }
.followup-patient-table .contact-status { min-width: 0; }
.followup-patient-table .patient-row-action .button { min-height: 36px; padding: 7px 8px; font-size: 12px; }

.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 5px 9px; font-size: 12px; font-weight: 750; white-space: nowrap; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-muted { background: #edf1f2; color: #63737b; }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.contact-status { display: flex; min-width: 180px; flex-direction: column; align-items: flex-start; gap: 7px; }
.contact-status-reason { max-width: 260px; color: #405963; font-size: 12px; line-height: 1.35; overflow-wrap: anywhere; }
.contact-status-reason strong { color: var(--danger); }

.flash-stack { display: grid; gap: 8px; margin-bottom: 18px; }
.flash { padding: 13px 15px; border-radius: 10px; border: 1px solid; font-weight: 650; }
.flash-success { background: var(--success-soft); color: var(--success); border-color: #b9dfca; }
.flash-error { background: var(--danger-soft); color: var(--danger); border-color: #ebc2c4; }
.flash-info { background: var(--brand-soft); color: var(--brand-dark); border-color: #b7ded9; }

.breadcrumb { font-size: 14px; margin-bottom: 16px; }
.visit-header { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 22px; }
.visit-header h1 { margin: 0; }
.progress-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 22px; }
.progress-item { border: 1px solid var(--line); border-radius: 14px; padding: 15px; background: white; }
.progress-item strong { display: block; margin-bottom: 6px; }
.progress-item.complete { background: var(--success-soft); border-color: #b9dfca; }
.progress-item.pending { background: var(--warning-soft); border-color: #edd39f; }
.section-card { margin-bottom: 18px; }
.section-head { display: flex; justify-content: space-between; align-items: start; gap: 20px; margin-bottom: 16px; }
.section-head p { margin: 4px 0 0; }
.model-status-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.call-guide { border: 1px solid #b8d7d5; border-radius: 14px; background: #f7fbfb; margin: 0 0 22px; overflow: hidden; }
.call-guide summary { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 18px; background: var(--brand-soft); cursor: pointer; list-style: none; }
.call-guide summary::-webkit-details-marker { display: none; }
.call-guide summary strong, .call-guide summary small { display: block; }
.call-guide summary small { color: var(--muted); font-size: 12px; margin-top: 3px; }
.call-guide-toggle { color: var(--brand-dark); font-size: 12px; font-weight: 800; }
.call-guide-toggle::after { content: " ↓"; }
.call-guide[open] .call-guide-toggle { font-size: 0; }
.call-guide[open] .call-guide-toggle::before { content: "Bezárás"; font-size: 12px; }
.call-guide[open] .call-guide-toggle::after { content: " ↑"; font-size: 12px; }
.call-guide-body { padding: 18px; }
.call-guidelines { background: #fff; border-left: 4px solid var(--accent); border-radius: 8px; color: #4d5f67; font-size: 13px; line-height: 1.55; margin-bottom: 14px; padding: 11px 13px; }
.call-pool-controls { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 0 14px; }
.call-pool-controls p, .call-pool-controls strong, .call-pool-controls span { display: block; margin: 0; }
.call-pool-controls span { color: var(--muted); font-size: 12px; margin-top: 3px; }
.call-pool-controls .button { flex: 0 0 auto; min-height: 38px; padding: 7px 12px; font-size: 12px; }
.call-script-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.call-script { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 16px; }
.call-script-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; margin-bottom: 10px; }
.script-kicker { color: var(--brand); font-size: 11px; font-weight: 850; letter-spacing: .07em; text-transform: uppercase; }
.call-script h3 { margin: 0 0 8px; }
.script-text { color: #324b57; font-size: 14px; line-height: 1.58; margin: 0 0 14px; }
.copy-script { min-height: 38px; margin-top: auto; padding: 7px 11px; font-size: 12px; }
.call-privacy-note { margin: 13px 2px 0; line-height: 1.45; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.checkbox-line { display: flex; align-items: flex-start; gap: 10px; padding: 13px; border-radius: 10px; background: var(--brand-soft); }
.checkbox-line input { width: 20px; height: 20px; margin-top: 1px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

.questionnaire-shell { max-width: 860px; margin: 0 auto; }
.question-progress { position: sticky; top: 8px; z-index: 4; background: #0d3441; color: white; border-radius: 13px; padding: 12px 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.progress-track { height: 7px; background: #315762; border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress-fill { height: 100%; width: 0; background: #5bd0c7; transition: width .2s ease; }
.question-group { border: 0; padding: 0; margin: 0 0 24px; }
.question-group legend { font-weight: 750; line-height: 1.45; margin-bottom: 11px; }
.answer-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.answer-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.answer-option { position: relative; }
.answer-option input { position: absolute; opacity: 0; pointer-events: none; }
.answer-option label { min-height: 58px; height: 100%; display: grid; place-items: center; text-align: center; border: 1px solid #bfd0d4; border-radius: 10px; padding: 8px; cursor: pointer; font-size: 13px; font-weight: 700; background: white; }
.answer-option input:checked + label { background: var(--brand); color: white; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(8, 111, 112, .15); }
.answer-option input:focus-visible + label { outline: 3px solid rgba(55, 162, 157, .3); }
.question-section-title { margin: 30px 0 16px; padding-top: 8px; border-top: 2px solid var(--line); }
.questionnaire-instruction { margin-bottom: 22px; }
.bilateral-question { border-top: 1px solid var(--line); padding-top: 18px; margin-top: 20px; }
.bilateral-question h3 { margin-bottom: 12px; }
.side-label { color: var(--muted); font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; margin: 0 0 8px; }
.bilateral-question .question-group { margin-bottom: 8px; }
.file-grid { display: grid; gap: 16px; }
.model-file-table-wrap { margin-bottom: 18px; }
.model-file-table th:nth-child(2), .model-file-table td:nth-child(2) { width: 110px; white-space: nowrap; }
.model-file-table th:last-child, .model-file-table td:last-child { width: 1%; text-align: right; }
.model-file-name { overflow-wrap: anywhere; }
.model-upload-form { display: flex; align-items: end; justify-content: space-between; gap: 18px; padding-top: 2px; }
.model-upload-form > div { flex: 1; }
.model-upload-form p { margin: 7px 0 0; }
.model-edit-note { margin: 18px 0 0; }
.addon-guide-grid { align-items: start; margin-bottom: 18px; }
.instruction-list { margin: 0; padding-left: 22px; color: #324b57; line-height: 1.6; }
.instruction-list li + li { margin-top: 9px; }
.addon-security-note { margin: 20px 0 0; font-size: 13px; line-height: 1.5; }
.addon-status-card { margin-top: 18px; }
.addon-status-card p { line-height: 1.5; margin-bottom: 0; }
.empty-state { text-align: center; color: var(--muted); padding: 36px 12px; }
code { background: #eef3f4; border-radius: 5px; padding: 2px 5px; }

@media (max-width: 900px) {
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
    .progress-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1050px) {
    .followup-table-wrap { overflow: visible; border: 0; border-radius: 0; }
    .followup-patient-table, .followup-patient-table tbody { display: block; }
    .followup-patient-table thead { display: none; }
    .followup-patient-table tbody { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .followup-patient-table tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-content: start; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: white; }
    .followup-patient-table td { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 12px; text-align: right; border-top: 1px solid var(--line); }
    .followup-patient-table td::before { content: attr(data-label); flex: 0 0 42%; color: #49626e; font-size: 10px; font-weight: 800; letter-spacing: .04em; text-align: left; text-transform: uppercase; }
    .followup-patient-table .patient-id { display: block; grid-column: 1 / -1; padding: 13px 12px; text-align: left; border-top: 0; background: #edf4f5; }
    .followup-patient-table .patient-id::before, .followup-patient-table .patient-row-action::before { content: none; }
    .followup-patient-table .contact-status { align-items: flex-end; }
    .followup-patient-table .contact-status-reason { text-align: right; }
    .followup-patient-table .patient-row-action { grid-column: 1 / -1; justify-content: stretch; padding: 10px 12px; }
    .followup-patient-table .patient-row-action .button { width: 100%; }
    .followup-patient-table tr:hover td { background: inherit; }
    .followup-patient-table tr:hover .patient-id { background: #edf4f5; }
}

@media (max-width: 640px) {
    .header-inner, .page-shell { padding-left: 14px; padding-right: 14px; }
    .header-actions a { display: none; }
    .page-heading, .visit-header, .toolbar { align-items: stretch; flex-direction: column; }
    .heading-actions { justify-content: stretch; }
    .heading-actions .button { flex: 1; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .progress-grid { grid-template-columns: 1fr 1fr; }
    .answer-grid { grid-template-columns: 1fr; }
    .call-pool-controls { align-items: stretch; flex-direction: column; }
    .model-upload-form { align-items: stretch; flex-direction: column; }
    .call-script-grid { grid-template-columns: 1fr; }
    .followup-patient-table tbody { grid-template-columns: 1fr; }
    .answer-option label { min-height: 45px; justify-items: start; text-align: left; }
    .card { padding: 18px; }
}
