:root {
  --bg: #f4f6f9; --card: #fff; --text: #1d2433; --muted: #5f6b7d; --line: #dfe4ec;
  --primary: #1f5fbf; --primary-d: #164a97; --ok: #1c8f4a; --warn: #b9770e; --bad: #c62828; --info-bg: #eaf2ff;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 17px; line-height: 1.45; }
a { color: var(--primary); }
h1 { font-size: 1.45rem; margin: 0 0 .6rem; }
h2 { font-size: 1.15rem; margin: 1.2rem 0 .5rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
.muted { color: var(--muted); } .small { font-size: .88rem; }
.container { max-width: 1100px; margin: 0 auto; padding: 16px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: #fff; border-bottom: 1px solid var(--line); padding: 10px 16px; }
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.topbar nav { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; font-size: .95rem; }
.topbar nav a { text-decoration: none; padding: 4px 6px; border-radius: 6px; }
.topbar nav a.active { background: var(--info-bg); }
.who { color: var(--muted); }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 24px 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-bottom: 18px; }
.center-card { max-width: 480px; margin: 40px auto; }
.flash { background: #e7f6ec; border: 1px solid #b7e2c5; color: #14532d; padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.alert { background: #fdecea; border: 1px solid #f5c2c0; color: #7f1d1d; padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.alert.info { background: var(--info-bg); border-color: #b9d1f5; color: #163a6b; }
label { display: block; margin: 10px 0; }
input[type=text], input[type=password], input[type=number], select, textarea, input:not([type]) {
  width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; margin-top: 4px;
}
textarea { resize: vertical; }
.btn { display: inline-block; font: inherit; font-weight: 600; padding: 10px 16px; border-radius: 9px; border: 1px solid var(--line); background: #fff; color: var(--text); cursor: pointer; text-decoration: none; }
.btn:hover { background: #f1f4f8; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-danger { color: var(--bad); border-color: #f0b4b4; }
.btn-big { width: 100%; padding: 14px; font-size: 1.1rem; }
.btn-sm { padding: 6px 10px; font-size: .88rem; }
.btn:disabled { opacity: .6; cursor: wait; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.code-input { text-align: center; font-size: 2rem; letter-spacing: .3em; text-transform: uppercase; font-family: ui-monospace, Consolas, monospace; margin-bottom: 12px; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f7f9fc; font-weight: 600; }
tr.sub td { background: #f7f9fc; font-weight: 600; }
tr.total td { background: #eef3fb; font-weight: 700; }
.table-wrap { overflow-x: auto; }
.num { text-align: right; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.stat .v { font-size: 1.8rem; font-weight: 700; } .stat .l { color: var(--muted); font-size: .85rem; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.badge.pending { background: #fff4d6; color: #7a4d00; } .badge.in_progress { background: #e1ecfb; color: #164a97; }
.badge.completed { background: #dff5e6; color: #14532d; } .badge.excluded { background: #eee; color: #555; }
.badge.ok { background: #dff5e6; color: #14532d; } .badge.miss { background: #fdecea; color: #7f1d1d; }
.bar-wrap { background: #e9edf3; border-radius: 6px; height: 10px; overflow: hidden; min-width: 80px; }
.bar-wrap .bar { height: 100%; background: var(--ok); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.link-box { font-family: ui-monospace, Consolas, monospace; word-break: break-all; background: #f7f9fc; padding: 10px; border-radius: 8px; border: 1px dashed var(--line); }
.access-code { font-family: ui-monospace, Consolas, monospace; font-size: 2.4rem; letter-spacing: .25em; font-weight: 700; text-align: center; padding: 10px; background: #fffbe6; border: 2px solid #f1d675; border-radius: 12px; }
.qr { text-align: center; } .qr img { max-width: 220px; }

/* ---- çalışma seçimi ---- */
.study-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-top: 16px; }
.study-card { display: flex; flex-direction: column; gap: 4px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 20px; text-decoration: none; color: var(--text); transition: border-color .15s, box-shadow .15s; }
.study-card:hover { border-color: var(--primary); box-shadow: 0 2px 10px rgba(31,95,191,.12); }
.study-card.soon { background: #fafbfc; }
.study-card.soon h2 { color: var(--muted); }
.study-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.study-head h2 { margin: 0; font-size: 1.2rem; }
.study-card p { margin: 6px 0 0; }
.study-stats { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: .92rem; }
.study-go { margin-top: 14px; font-weight: 600; color: var(--primary); }

/* ---- grafikler ---- */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.chart-box { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; }
.chart-box h3 { margin: 0 0 2px; font-size: .98rem; }
.chart-box .muted { font-size: .8rem; }
.chart { width: 100%; height: auto; display: block; }
.ch-grid { stroke: #e6eaf0; stroke-width: 1; }
.ch-ref { stroke: #c62828; stroke-width: 1; stroke-dasharray: 4 4; opacity: .6; }
.ch-ax { fill: #5f6b7d; font-size: 11px; font-family: system-ui, sans-serif; }
.ch-val { fill: #1d2433; font-size: 11px; font-weight: 600; font-family: system-ui, sans-serif; }
.ch-line { fill: none; stroke: #1f5fbf; stroke-width: 2.5; stroke-linejoin: round; }
.ch-dot { fill: #fff; stroke: #1f5fbf; stroke-width: 2.5; }

/* ---- anket ---- */
.survey-wrap { max-width: 760px; margin: 0 auto; padding-bottom: 24px; }
.survey-top { position: sticky; top: 0; background: var(--bg); padding: 10px 0 6px; z-index: 5; }
.progress { height: 8px; background: #e2e7ef; border-radius: 6px; overflow: hidden; }
.progress .bar { height: 100%; background: var(--primary); transition: width .3s; }
.progress-text { display: flex; justify-content: space-between; font-size: .85rem; color: var(--muted); margin-top: 4px; }
.pcode { font-family: ui-monospace, Consolas, monospace; }
.page h1 { font-size: 1.35rem; }
.infobox { background: var(--info-bg); border: 1px solid #c7dbf7; border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; }
.infobox h2 { margin-top: 0; font-size: 1.05rem; } .infobox p { margin: .4rem 0; font-size: .97rem; white-space: pre-line; }
.q { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin: 12px 0; }
.q.bad { border-color: var(--bad); box-shadow: 0 0 0 2px #fbd5d5; }
.qtext { font-weight: 600; margin-bottom: 8px; white-space: pre-line; }
.opt { display: flex; align-items: flex-start; gap: 12px; padding: 11px 10px; margin: 4px 0; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.opt:has(input:checked) { background: var(--info-bg); border-color: var(--primary); }
.opt input { width: 22px; height: 22px; flex: 0 0 22px; margin-top: 2px; accent-color: var(--primary); }
.opt.consent { background: #fff; font-weight: 600; margin-top: 12px; }
.other { margin-top: 6px; }
.qerr { color: var(--bad); font-size: .9rem; margin-top: 6px; }
.num { max-width: 160px; display: inline-block; } .unit { color: var(--muted); }
.scale { display: grid; grid-template-columns: repeat(11, 1fr); gap: 5px; }
.scale-btn { font: inherit; font-weight: 600; padding: 12px 0; border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; }
.scale-btn.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.scale-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: .82rem; margin-top: 6px; }
.mrow { border-top: 1px solid var(--line); padding: 10px 0; }
.mtext { margin-bottom: 6px; font-weight: 600; }
.opt span, .mopt span { font-weight: 500; }
.mopts { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 5px; }
.mopt { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 8px 4px; border: 1px solid var(--line); border-radius: 8px; font-size: .9rem; cursor: pointer; }
.mopt:has(input:checked) { background: var(--info-bg); border-color: var(--primary); }
.mopt input { width: 20px; height: 20px; accent-color: var(--primary); }
/* Düğme çubuğu sayfanın sonunda durur ve kaydırırken ekranın altına yapışır (sticky). Eski "fixed" çubuk bazı Android
   tabletlerde sistem gezinme çubuğunun altında kalıyordu; safe-area payı, çentikli/hareketli gezinmeli ekranlar içindir. */
.survey-nav { position: sticky; bottom: 0; z-index: 6; background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -4px 12px rgba(0, 0, 0, .06);
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom, 0px)); margin-top: 16px; display: flex; gap: 12px; justify-content: space-between; }
.survey-nav .btn-big { width: auto; flex: 1; max-width: 420px; }

/* ---- hasta (tablet) ekranı: yaşlı hastalar için büyük yazı ve büyük işaret kutuları ---- */
.survey-wrap[data-mode="patient"] { font-size: 1.3rem; }
.survey-wrap[data-mode="patient"] .page h1 { font-size: 1.45em; }
.survey-wrap[data-mode="patient"] .qtext,
.survey-wrap[data-mode="patient"] .mtext { font-size: 1.05em; font-weight: 700; }
.survey-wrap[data-mode="patient"] .opt span,
.survey-wrap[data-mode="patient"] .mopt span { font-weight: 600; }
.survey-wrap[data-mode="patient"] .infobox p { font-weight: 500; }
.survey-wrap[data-mode="patient"] .infobox p { font-size: 1em; }
.survey-wrap[data-mode="patient"] .opt { padding: 14px 12px; gap: 14px; }
.survey-wrap[data-mode="patient"] .opt input { width: 32px; height: 32px; flex: 0 0 32px; margin-top: 0; }
.survey-wrap[data-mode="patient"] .mopt { font-size: .95em; padding: 12px 4px; line-height: 1.25; overflow-wrap: anywhere; hyphens: auto; }
.survey-wrap[data-mode="patient"] .mopt input { width: 30px; height: 30px; }
.survey-wrap[data-mode="patient"] .scale-btn { padding: 16px 0; font-size: 1.1em; }
.survey-wrap[data-mode="patient"] .scale-labels,
.survey-wrap[data-mode="patient"] .progress-text { font-size: .8em; }
.survey-wrap[data-mode="patient"] .btn { font-size: 1.15em; padding: 14px 18px; }
.survey-wrap[data-mode="patient"] .btn-big { font-size: 1.25em; padding: 16px; }

/* ---- soruya eklenen şekil (ör. SMMT kesişen beşgenler): dokununca tam ekran ---- */
.qfig { margin: 4px 0 12px; text-align: center; cursor: zoom-in; }
.qfig .fig { display: inline-block; width: 100%; max-width: 380px; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.qfig svg { width: 100%; height: auto; display: block; }
.qfig .fig-text { font-size: 2rem; font-weight: 800; letter-spacing: .04em; padding: 18px 6px; color: #000; }
.qfig .fig-hint { display: block; color: var(--muted); font-size: .85rem; margin-top: 4px; }
.qfig.big { position: fixed; inset: 0; z-index: 50; background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 0; cursor: zoom-out; }
.qfig.big .fig { max-width: 92vw; width: 92vw; border: none; }
.qfig.big svg { max-height: 80vh; }
.qfig.big .fig-text { font-size: min(11vw, 7rem); }
.done { text-align: center; padding-top: 40px; }
.bigcheck { width: 90px; height: 90px; border-radius: 50%; background: var(--ok); color: #fff; font-size: 3rem; line-height: 90px; margin: 0 auto 16px; }

/* ---- klinisyen formu ---- */
.hform .q { padding: 10px 14px; }
.hform .opt { padding: 7px 10px; font-size: .95rem; }
.hform .opts-inline { display: flex; flex-wrap: wrap; gap: 6px; }
.hform .opts-inline .opt { margin: 0; }

/* ---- yazdırma ---- */
.print-form .q { break-inside: avoid; }
.print-form .opt { padding: 4px 8px; font-size: .92rem; border: none; }
.print-form .opt input { display: none; }
.print-form .opt::before { content: "○ "; }
.print-form .opt.multi::before { content: "☐ "; }
.print-form .mopts { display: block; }
.print-form .mopt { display: inline-block; margin-right: 8px; border: none; padding: 2px; }
@media print { .topbar, .foot, .no-print { display: none; } body { background: #fff; font-size: 12px; } .card, .q { border: none; padding: 4px 0; } }

@media (max-width: 900px) {
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  body { font-size: 16px; }
  .container { padding: 10px; }
  .scale { grid-template-columns: repeat(6, 1fr); }
  .mopts { gap: 3px; }
  .mopt { font-size: .8rem; padding: 6px 2px; line-height: 1.15; hyphens: auto; }
  .mopt input { width: 18px; height: 18px; }
  .kv { grid-template-columns: 1fr; }
}
