/* Экзамен. Стоматолог-гигиенист */
:root {
  --bg: #f2f5f2;
  --surface: #ffffff;
  --surface-2: #f8faf8;
  --text: #14211a;
  --muted: #5b6b60;
  --line: #d8e1d9;
  --line-strong: #b9c8bc;
  --green: #14532d;
  --green-700: #166534;
  --green-600: #15803d;
  --green-50: #e9f4ed;
  --red: #991b1b;
  --red-600: #b91c1c;
  --red-50: #fdecec;
  --amber: #92400e;
  --amber-50: #fef3c7;
  --blue: #1e3a5f;
  --shadow: 0 1px 2px rgba(16, 24, 20, .06), 0 8px 24px rgba(16, 24, 20, .06);
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 100% -10%, #e4efe7 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--green-700); }
h1, h2, h3 { margin: 0 0 10px; line-height: 1.2; }
h1 { font-size: 24px; letter-spacing: -.3px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
p { margin: 0 0 10px; }
small, .muted { color: var(--muted); }
.app { min-height: 100vh; }
.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 22px 18px 80px; }
.container.narrow { max-width: 1040px; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 10px 18px;
  display: flex; align-items: center; gap: 14px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { width: 34px; height: 34px; flex: 0 0 auto; }
.brand-text { min-width: 0; }
.brand-title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-spacer { flex: 1; }
.userbox { display: flex; align-items: center; gap: 10px; min-width: 0; }
.userbox .name { font-size: 13px; color: var(--muted); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; padding: 9px 15px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-weight: 600; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .answer-btn:focus-visible, .action-row:focus-visible { outline: 3px solid #93c5a6; outline-offset: 2px; }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-700); }
.btn-danger { background: #fff; border-color: #e3b4b4; color: var(--red); }
.btn-danger:hover { background: var(--red-50); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { min-height: 32px; padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 13px; }
.field label { font-size: 13px; font-weight: 600; color: #2b3a30; }
input[type="text"], input[type="password"], input[type="search"], input[type="date"],
input[type="time"], input[type="number"], select, textarea {
  width: 100%; min-height: 42px; padding: 9px 11px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: #fff; color: var(--text);
}
textarea { min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid #cfe5d7; border-color: var(--green-600); }
.hint { font-size: 12px; color: var(--muted); }

/* Login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 22px; }
.login-card {
  width: 100%; max-width: 420px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
  padding: 28px 26px;
}
.login-logo { display: flex; justify-content: center; margin-bottom: 12px; }
.login-logo img { width: 64px; height: 64px; }
.login-card h1 { text-align: center; font-size: 21px; margin-bottom: 4px; }
.login-card .muted { text-align: center; display: block; margin-bottom: 20px; }
.login-error { display: none; margin: 0 0 12px; padding: 9px 11px; border-radius: 8px; background: var(--red-50); color: var(--red); font-size: 13px; }
.login-error.visible { display: block; }

/* Cards and stats */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 1px rgba(16,24,20,.03); }
.card-pad { padding: 18px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.stat .value { font-size: 24px; font-weight: 700; letter-spacing: -.4px; }
.stat .value small { font-size: 13px; font-weight: 500; color: var(--muted); }

/* Tabs */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab { border: 0; background: transparent; padding: 11px 14px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--green); border-bottom-color: var(--green); }

/* Participant cards */
.participant-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.participant-card {
  position: relative; display: flex; gap: 12px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 15px; text-decoration: none; color: inherit;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.participant-card:hover { border-color: #9db8a4; box-shadow: var(--shadow); transform: translateY(-1px); }
.participant-card.is-test { border-style: dashed; background: #fffdf5; }
.num-badge {
  flex: 0 0 auto; min-width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center; background: var(--green-50); color: var(--green);
  font-weight: 800; font-size: 16px;
}
.participant-main { flex: 1; min-width: 0; }
.participant-name { font-weight: 700; font-size: 14px; margin-bottom: 3px; }
.participant-sub { font-size: 12px; color: var(--muted); }
.participant-status { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.dot-stations { display: flex; gap: 4px; margin-top: 7px; flex-wrap: wrap; }
.dot {
  font-size: 11px; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--muted);
}
.dot.done { background: var(--green-50); border-color: #b9dcc4; color: var(--green); }
.dot.draft { background: var(--amber-50); border-color: #efd48a; color: var(--amber); }
.dot.absent { background: #f1f1f1; border-color: #ddd; color: #666; }
.test-badge { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; background: #fff7d6; color: #7a5a00; padding: 2px 6px; border-radius: 5px; border: 1px solid #ecd98a; }

/* Status chips */
.status { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid transparent; }
.status-none { background: #f1f3f1; color: #5c6a60; border-color: #e0e5e1; }
.status-draft { background: var(--amber-50); color: var(--amber); border-color: #efd48a; }
.status-submitted { background: var(--green-50); color: var(--green); border-color: #b9dcc4; }
.status-absent { background: #f1f1f1; color: #666; border-color: #ddd; }

/* Search row */
.toolbar-row { display: flex; gap: 10px; align-items: center; margin: 0 0 14px; }
.toolbar-row .search { flex: 1; max-width: 420px; }
.toolbar-row .grow { flex: 1; }

/* Checklist */
.check-page { padding-bottom: 110px; }
.check-head { margin-bottom: 12px; }
.check-back { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); text-decoration: none; margin-bottom: 8px; }
.check-back:hover { color: var(--green); }
.check-title-row { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.check-title { flex: 1; min-width: 220px; }
.check-title h1 { font-size: 21px; margin-bottom: 3px; }
.check-title .sub { font-size: 13px; color: var(--muted); }
.check-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.progress-card {
  position: sticky; top: 57px; z-index: 20;
  background: rgba(255,255,255,.97); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 14px;
  margin-bottom: 12px; box-shadow: 0 2px 10px rgba(16,24,20,.04);
}
.progress-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.progress-label { font-size: 13px; color: var(--muted); }
.progress-label b { color: var(--text); font-size: 15px; }
.progress-track { flex: 1; min-width: 120px; height: 8px; border-radius: 999px; background: #e7ede8; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, #2f7d4a, #15803d); transition: width .2s; }
.progress-stats { display: flex; gap: 10px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.progress-stats .yes { color: var(--green-700); font-weight: 700; }
.progress-stats .no { color: var(--red); font-weight: 700; }
.save-state { font-size: 11px; color: var(--muted); margin-top: 6px; min-height: 15px; }
.save-state.saved { color: var(--green-700); }
.save-state.error { color: var(--red); }
.save-state.offline { color: var(--amber); }

.section-nav { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 10px; }
.section-nav a { font-size: 12px; padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); text-decoration: none; }
.section-nav a:hover { border-color: #9db8a4; color: var(--green); }

.checklist { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.section-row {
  padding: 9px 14px; background: #edf2ee; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  font-weight: 800; font-size: 13px; letter-spacing: .2px; color: #263a2c;
  scroll-margin-top: 150px;
}
.section-row:first-child { border-top: 0; }
.action-row {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) 150px; gap: 12px; align-items: center;
  padding: 9px 14px; border-bottom: 1px solid #e8eee9; background: #fff;
  scroll-margin-top: 160px; transition: background .12s;
}
.action-row:last-child { border-bottom: 0; }
.action-row:hover { background: #fbfdfb; }
.action-row.current { background: #f3faf5; box-shadow: inset 4px 0 0 var(--green-600); }
.action-row.answered-yes { background: #fbfefc; }
.action-row.answered-no { background: #fffafa; }
.action-row .n { font-weight: 700; color: var(--muted); font-size: 13px; text-align: center; }
.action-row .txt { font-size: 14px; min-width: 0; }
.action-row .txt .form-badge { display: inline-block; margin-left: 6px; vertical-align: 1px; font-size: 10px; text-transform: uppercase; letter-spacing: .4px; color: #4b5b50; background: #f0f4f1; border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; white-space: nowrap; }
.answer-btns { display: flex; gap: 6px; justify-content: flex-end; }
.answer-btn {
  min-width: 64px; min-height: 38px; padding: 6px 10px;
  border: 1px solid var(--line-strong); border-radius: 9px; background: #fff; color: #425247;
  font-weight: 700; font-size: 13px; transition: all .12s;
}
.answer-btn:hover { background: #f4f7f4; }
.answer-btn.yes.active { background: var(--green); border-color: var(--green); color: #fff; }
.answer-btn.no.active { background: var(--red); border-color: var(--red); color: #fff; }
.answer-btn[disabled] { opacity: .55; cursor: default; }

.submit-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  background: rgba(255,255,255,.97); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line); padding: 9px 14px calc(9px + env(safe-area-inset-bottom));
}
.submit-bar-inner { max-width: 1040px; margin: 0 auto; display: flex; gap: 10px; align-items: center; }
.submit-bar .grow { flex: 1; }
.submit-bar .summary { font-size: 13px; color: var(--muted); }
.submit-bar .summary b { color: var(--text); }

/* Banners */
.banner { display: flex; gap: 9px; align-items: flex-start; padding: 10px 13px; border-radius: 10px; margin-bottom: 12px; font-size: 13px; border: 1px solid; }
.banner-warn { background: var(--amber-50); border-color: #efd48a; color: #6b4a06; }
.banner-info { background: #eef5fb; border-color: #c8dcef; color: #1e3a5f; }
.banner-ok { background: var(--green-50); border-color: #b9dcc4; color: var(--green); }
.banner-error { background: var(--red-50); border-color: #e6bcbc; color: var(--red); }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(10, 20, 14, .45); z-index: 100; display: grid; place-items: center; padding: 18px; }
.modal {
  width: 100%; max-width: 720px; max-height: 90vh; overflow: auto;
  background: var(--surface); border-radius: 16px; box-shadow: 0 24px 60px rgba(0,0,0,.25);
  padding: 20px;
}
.modal.modal-wide { max-width: 980px; }
.modal h2 { font-size: 19px; margin-bottom: 6px; }
.modal .modal-sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.modal-actions { display: flex; gap: 9px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }
.modal-close { float: right; border: 0; background: transparent; font-size: 22px; line-height: 1; color: var(--muted); padding: 2px 6px; }
.modal-close:hover { color: var(--text); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 200; max-width: min(620px, 92vw);
  background: #14211a; color: #fff; padding: 12px 16px; border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0,0,0,.25); font-size: 14px; line-height: 1.35;
}
.toast.ok { background: #14532d; }
.toast.error { background: #7f1d1d; }
.toast.warn { background: #6b4a06; }

/* Admin tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.matrix { width: 100%; border-collapse: collapse; min-width: 860px; }
table.matrix th, table.matrix td { padding: 9px 10px; border-bottom: 1px solid #e8eee9; text-align: left; vertical-align: middle; }
table.matrix th { background: #f2f6f3; font-size: 12px; color: #425247; white-space: nowrap; position: sticky; top: 0; }
table.matrix tbody tr:hover { background: #fbfdfb; }
table.matrix tr.is-test { background: #fffdf5; }
table.matrix td.center, table.matrix th.center { text-align: center; }
table.matrix .name-cell { min-width: 230px; }
table.matrix .num-cell { width: 46px; text-align: center; font-weight: 700; color: var(--muted); }
.score-cell { display: inline-flex; flex-direction: column; gap: 2px; border: 0; background: transparent; padding: 4px 6px; border-radius: 7px; text-align: left; width: 100%; }
.score-cell:hover { background: #f0f5f1; }
.score-cell .val { font-weight: 800; font-size: 15px; }
.score-cell .sub { font-size: 10px; color: var(--muted); }
.score-cell.good .val { color: var(--green-700); }
.score-cell.mid .val { color: var(--amber); }
.score-cell.bad .val { color: var(--red); }
.score-cell.empty .val { color: #9aa69d; font-weight: 500; }
.final-cell { font-weight: 800; font-size: 16px; }
.final-cell.good { color: var(--green-700); }
.final-cell.mid { color: var(--amber); }
.final-cell.bad { color: var(--red); }

/* Misc */
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.center { text-align: center; }
.right { text-align: right; }
.mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 18px; }
.mb-1 { margin-bottom: 6px; } .mb-2 { margin-bottom: 12px; } .mb-3 { margin-bottom: 18px; }
.hidden { display: none !important; }
.spinner { width: 22px; height: 22px; border: 3px solid #d8e1d9; border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-page { min-height: 50vh; display: grid; place-items: center; color: var(--muted); }
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .container { padding: 14px 12px 90px; }
  .topbar-inner { padding: 8px 12px; }
  .userbox .name { display: none; }
  .brand-sub { display: none; }
  h1 { font-size: 20px; }
  .progress-card { top: 53px; padding: 9px 10px; }
  .progress-stats { width: 100%; justify-content: space-between; }
  .action-row { grid-template-columns: 34px minmax(0, 1fr); gap: 6px 8px; padding: 9px 10px; }
  .action-row .txt { grid-column: 2; }
  .answer-btns { grid-column: 2; justify-content: flex-start; }
  .answer-btn { flex: 1; min-height: 42px; }
  .submit-bar-inner { flex-wrap: wrap; }
  .submit-bar .summary { width: 100%; }
  .submit-bar .btn { flex: 1; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { margin-top: 4px; }
}
@media print {
  .topbar, .submit-bar, .progress-card, .btn, .toolbar-row { display: none !important; }
  body { background: #fff; }
  .container { max-width: none; padding: 0; }
}
