:root {
  --bg: #F8FAFC;
  --card: #FFFFFF;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --text: #0F172A;
  --text-2: #334155;
  --muted: #64748B;
  --accent: #2563EB;
  --accent-hover: #1D4ED8;
  --accent-soft: #EFF6FF;
  --success: #16A34A;
  --success-soft: #F0FDF4;
  --danger: #DC2626;
  --danger-soft: #FEF2F2;
  --warn: #D97706;
  --warn-soft: #FFFBEB;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .08);
  --shadow-lg: 0 4px 6px -1px rgba(15, 23, 42, .08), 0 10px 24px -6px rgba(15, 23, 42, .12);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0 0 .75rem; }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(255,255,255,.92); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}
.topbar__inner {
  max-width: 1200px; margin: 0 auto; padding: .75rem 1rem;
  display: flex; align-items: center; gap: 1rem; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; color: var(--text); text-decoration: none; }
.brand__logo {
  width: 32px; height: 32px; border-radius: 8px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 1rem; font-weight: 800;
}
.user { display: flex; align-items: center; gap: .75rem; font-size: .9rem; color: var(--text-2); }
.container { max-width: 1200px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.container--narrow { max-width: 640px; }
.stack > * + * { margin-top: 1.25rem; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.25rem;
}
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.card__head h2 { margin: 0; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; overflow-x: auto; }
.tab {
  appearance: none; background: none; border: 0; border-bottom: 2px solid transparent;
  padding: .7rem 1rem; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Forms ---------- */
.field { display: block; margin-bottom: 1rem; }
.field__label { display: block; font-size: .875rem; font-weight: 600; color: var(--text-2); margin-bottom: .35rem; }
.field__label .req { color: var(--danger); }
.field__hint { font-size: .8rem; color: var(--muted); margin-top: .3rem; }
.field__error { font-size: .8rem; color: var(--danger); margin-top: .3rem; min-height: 0; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
@media (max-width: 480px) { .row--stack-sm { grid-template-columns: 1fr; } }

.input, .select {
  width: 100%; padding: .65rem .8rem; font: inherit; font-size: 16px; color: var(--text);
  background: #fff; border: 1px solid var(--border-strong); border-radius: 8px;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: #94A3B8; }
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.18); }
.input.is-invalid, .select.is-invalid { border-color: var(--danger); }
.input.is-invalid:focus, .select.is-invalid:focus { box-shadow: 0 0 0 3px rgba(220,38,38,.15); }
.input.is-valid { border-color: var(--success); }
.select {
  appearance: none; padding-right: 2.2rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748B' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .8rem center;
}
.input--sm, .select--sm { padding: .45rem .7rem; font-size: .9rem; }

.checkbox { display: flex; gap: .65rem; align-items: flex-start; cursor: pointer; font-size: .9rem; color: var(--text-2); }
.checkbox input { width: 18px; height: 18px; margin: .15rem 0 0; accent-color: var(--accent); flex: none; cursor: pointer; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .6rem 1.1rem; font: inherit; font-weight: 600; font-size: .925rem; line-height: 1.2;
  border-radius: 8px; border: 1px solid transparent; cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s; white-space: nowrap;
}
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(37,99,235,.3); }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); color: #fff; }
.btn--secondary { background: #fff; color: var(--text-2); border-color: var(--border-strong); }
.btn--secondary:hover { background: #F1F5F9; color: var(--text); }
.btn--ghost { background: transparent; color: var(--muted); }
.btn--ghost:hover { background: #F1F5F9; color: var(--text); }
.btn--danger { background: #fff; color: var(--danger); border-color: #FECACA; }
.btn--danger:hover { background: var(--danger-soft); }
.btn--success { background: #fff; color: var(--success); border-color: #BBF7D0; }
.btn--success:hover { background: var(--success-soft); }
.btn--sm { padding: .4rem .7rem; font-size: .825rem; }
.btn--block { width: 100%; }
.btn--lg { padding: .8rem 1.2rem; font-size: 1rem; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

/* ---------- Alerts ---------- */
.alert { padding: .8rem 1rem; border-radius: 8px; font-size: .9rem; border: 1px solid; }
.alert--error { background: var(--danger-soft); border-color: #FECACA; color: #991B1B; }
.alert--success { background: var(--success-soft); border-color: #BBF7D0; color: #166534; }
.alert--info { background: var(--accent-soft); border-color: #BFDBFE; color: #1E40AF; }
.alert--warn { background: var(--warn-soft); border-color: #FDE68A; color: #92400E; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .55rem;
  font-size: .75rem; font-weight: 600; border-radius: 999px; white-space: nowrap;
}
.badge--green { background: #DCFCE7; color: #166534; }
.badge--gray { background: #F1F5F9; color: #475569; }
.badge--blue { background: #DBEAFE; color: #1E40AF; }
.badge--red { background: #FEE2E2; color: #991B1B; }
.badge--class { background: var(--accent-soft); color: var(--accent); font-size: .8rem; min-width: 2.6rem; justify-content: center; }

/* ---------- Service list ---------- */
.svc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; }
.svc {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; background: #fff;
  display: grid; gap: .6rem;
}
.svc--closed { background: #FBFCFD; }
.svc--closed .svc__title { color: var(--muted); }
.svc__top { display: flex; justify-content: space-between; gap: .75rem; align-items: flex-start; }
.svc__title { font-weight: 600; font-size: 1rem; word-break: break-word; }
.svc__meta { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .85rem; color: var(--muted); }
.svc__meta b { color: var(--text-2); font-weight: 600; }
.svc__link { display: flex; gap: .5rem; }
.svc__link .input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8rem; background: #F8FAFC; color: var(--text-2); }
.svc__actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.created-link { margin-top: 1rem; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.15rem; }
.stat__label { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat__value { font-size: 1.6rem; font-weight: 700; margin-top: .25rem; font-variant-numeric: tabular-nums; }
.stat__value--accent { color: var(--accent); }
.stat__sub { font-size: .8rem; color: var(--muted); }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.toolbar__left, .toolbar__right { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.search { position: relative; min-width: 240px; }
.search .input { padding-left: 2.2rem; }
.search svg { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: #94A3B8; pointer-events: none; }

.segmented { display: inline-flex; background: #F1F5F9; border-radius: 8px; padding: 3px; }
.segmented button {
  appearance: none; border: 0; background: transparent; font: inherit; font-size: .85rem; font-weight: 600;
  color: var(--muted); padding: .4rem .8rem; border-radius: 6px; cursor: pointer; white-space: nowrap;
}
.segmented button[aria-pressed="true"] { background: #fff; color: var(--text); box-shadow: var(--shadow); }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
table.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th {
  text-align: left; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  color: var(--muted); background: #F8FAFC; padding: .7rem .85rem; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: .7rem .85rem; border-bottom: 1px solid #F1F5F9; vertical-align: middle; }
.table tbody tr:hover td { background: #FAFCFF; }
.table tr.is-cancelled td { color: #94A3B8; }
.table tr.is-cancelled .child { text-decoration: line-through; }
.table .center { text-align: center; }
.table .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .83rem; white-space: nowrap; }
.table tr.group-row td {
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .85rem;
  border-bottom: 1px solid #DBEAFE; padding: .5rem .85rem;
}
.table tr.group-row .group-meta { color: #3B82F6; font-weight: 500; margin-left: .5rem; }
.status-select { padding: .3rem 1.8rem .3rem .55rem; font-size: .8rem; font-weight: 600; border-radius: 999px; background-position: right .55rem center; }
.status-select[data-status="attended"] { background-color: #DCFCE7; color: #166534; border-color: #BBF7D0; }
.status-select[data-status="registered"] { background-color: #DBEAFE; color: #1E40AF; border-color: #BFDBFE; }
.status-select[data-status="cancelled"] { background-color: #F1F5F9; color: #64748B; border-color: #E2E8F0; }

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty__icon { font-size: 2rem; margin-bottom: .5rem; }

/* Мобильная таблица -> карточки */
@media (max-width: 720px) {
  .table-wrap { border: 0; background: transparent; overflow: visible; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .6rem; padding: .5rem .25rem; }
  .table td { border: 0; padding: .3rem .75rem; display: flex; justify-content: space-between; gap: 1rem; text-align: right; }
  .table td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; font-weight: 600; text-align: left; }
  .table td.center { text-align: right; }
  .table tr.group-row { background: var(--accent-soft); border-color: #DBEAFE; padding: .1rem; }
  .table tr.group-row td { display: block; text-align: left; background: transparent; border: 0; }
  .table tr.group-row td::before { content: none; }
  .table tbody tr:hover td { background: transparent; }
}

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem 1rem; }
.auth__card { width: 100%; max-width: 400px; }
.auth__brand { display: flex; flex-direction: column; align-items: center; gap: .6rem; margin-bottom: 1.25rem; text-align: center; }
.auth__brand .brand__logo { width: 48px; height: 48px; font-size: 1.4rem; border-radius: 12px; }

/* ---------- Public form ---------- */
.hero { text-align: center; margin: .5rem 0 1.25rem; }
.hero__eyebrow { font-size: .8rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .06em; }
.hero__title { font-size: 1.5rem; margin: .35rem 0 .6rem; word-break: break-word; }
.hero__meta { display: inline-flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }
.price { display: inline-flex; align-items: baseline; gap: .3rem; background: var(--accent-soft); color: var(--accent); padding: .35rem .8rem; border-radius: 999px; font-weight: 700; }
.fieldset { border: 0; padding: 0; margin: 0 0 .5rem; }
.fieldset legend { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 0; margin-bottom: .75rem; }
.divider { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }

.success { text-align: center; }
.success__icon {
  width: 64px; height: 64px; margin: 0 auto 1rem; border-radius: 50%;
  background: var(--success-soft); color: var(--success); display: grid; place-items: center;
}
.summary { text-align: left; margin: 1.25rem 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.summary dl { margin: 0; }
.summary__row { display: grid; grid-template-columns: 40% 60%; padding: .65rem 1rem; border-bottom: 1px solid #F1F5F9; font-size: .9rem; }
.summary__row:last-child { border-bottom: 0; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-weight: 600; word-break: break-word; }

.state { text-align: center; padding: 2.5rem 1.25rem; }
.state__icon { width: 56px; height: 56px; margin: 0 auto 1rem; border-radius: 50%; display: grid; place-items: center; background: #F1F5F9; color: var(--muted); }

.footer { text-align: center; font-size: .8rem; color: var(--muted); padding: 1.5rem 1rem 2rem; }

.spinner { width: 28px; height: 28px; border: 3px solid #DBEAFE; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto; }
.btn .spinner { width: 16px; height: 16px; border-width: 2px; border-color: rgba(255,255,255,.4); border-top-color: #fff; margin: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Toast ---------- */
.toast-host { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: .5rem; width: max-content; max-width: calc(100vw - 2rem); }
.toast { background: #0F172A; color: #fff; padding: .7rem 1rem; border-radius: 8px; box-shadow: var(--shadow-lg); font-size: .9rem; animation: toast-in .2s ease-out; }
.toast--error { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Doc page ---------- */
.doc h1 { margin-bottom: 1rem; }
.doc h2 { margin-top: 1.5rem; }
.doc p, .doc li { color: var(--text-2); }
.doc ol, .doc ul { padding-left: 1.25rem; }

@media (max-width: 480px) {
  .container { padding: 1rem .75rem 2.5rem; }
  .card { padding: 1rem; }
  .hero__title { font-size: 1.3rem; }
  .user__name { display: none; }
  .toolbar__left, .toolbar__right { width: 100%; }
  .search { min-width: 0; flex: 1; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; padding: .4rem .3rem; }
}

@media print {
  .topbar, .tabs, .toolbar, .btn { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 0; }
}

/* ---------- Utilities ---------- */
.segmented--full { display: flex; width: 100%; }
.segmented--full button { flex: 1; }
.mt-1 { margin-top: 1rem; }
.mb-1 { margin-bottom: 1rem; }
.mt-05 { margin-top: .5rem; }
.mb-0 { margin-bottom: 0; }
.field__error:empty { display: none; }
.segmented { max-width: 100%; }
.success .svc__actions { justify-content: center; }
@media (max-width: 480px) {
  .segmented button { white-space: normal; font-size: .78rem; line-height: 1.2; }
  .stats { grid-template-columns: 1fr 1fr; }
  .success .svc__actions .btn { flex: 1 1 100%; }
}
.input--letter { text-transform: uppercase; text-align: center; font-weight: 700; max-width: 100%; }
.field__hint + .field__error:not(:empty) { margin-top: .1rem; }
.tab { text-decoration: none; display: inline-block; }

/* ---------- 152-ФЗ ---------- */
.pd-layout { max-width: 900px; }
.pd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.pd-grid .pd-wide { grid-column: 1 / -1; }
@media (max-width: 640px) { .pd-grid { grid-template-columns: 1fr; } }
.textarea { resize: vertical; min-height: 5rem; line-height: 1.45; font-size: 15px; }
.pd-actions { position: sticky; bottom: 0; z-index: 5; }
.doc dl.req-list { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0 0 1rem; font-size: .92rem; }
.doc dl.req-list dt { color: var(--muted); }
.doc dl.req-list dd { margin: 0; color: var(--text); }
.doc .pre { white-space: pre-line; }
@media (max-width: 480px) { .doc dl.req-list { grid-template-columns: 1fr; gap: 0; } .doc dl.req-list dd { margin-bottom: .4rem; } }

/* ---------- Реестр: оплата и статус ---------- */
.paid-check {
  display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; white-space: nowrap;
  padding: .25rem .6rem .25rem .45rem; border-radius: 999px; border: 1px solid var(--border);
  font-size: .8rem; font-weight: 600; color: var(--muted); background: #fff; user-select: none;
}
.paid-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--success); cursor: pointer; }
.paid-check.is-paid { background: #DCFCE7; border-color: #BBF7D0; color: #166534; }
.table tr.is-cancelled .paid-check.is-paid { background: #FEF3C7; border-color: #FDE68A; color: #92400E; }
.status-at { margin-top: .2rem; white-space: nowrap; }
.table th, .table td { padding-left: .6rem; padding-right: .6rem; }
.table td.mono { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.table td a.small { color: var(--muted); text-decoration: none; }
.table td a.small:hover { color: var(--accent); text-decoration: underline; }
.cell-stack { display: inline-flex; flex-direction: column; gap: .1rem; }
.cell-stack--center { align-items: center; }
.status-select { min-width: 9.6rem; }
@media (max-width: 720px) {
  .cell-stack { align-items: flex-end; text-align: right; }
}
.table th { white-space: normal; vertical-align: bottom; }
.status-select { min-width: 9rem; }

/* ---------- Модальные окна ---------- */
.modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 1rem; }
.modal__overlay { position: absolute; inset: 0; background: rgba(15, 23, 42, .45); }
.modal__dialog {
  position: relative; z-index: 1; width: 100%; max-width: 520px; max-height: calc(100vh - 2rem);
  overflow: auto; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 1.25rem; animation: modal-in .16s ease-out;
}
.modal__dialog--wide { max-width: 720px; }
.modal__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.modal__head h2 { margin: 0; }
.modal__close {
  appearance: none; border: 0; background: none; font: inherit; font-size: 1.4rem; line-height: 1;
  color: var(--muted); cursor: pointer; padding: .1rem .45rem; border-radius: 6px;
}
.modal__close:hover { background: #F1F5F9; color: var(--text); }
.modal__foot { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
body.modal-open { overflow: hidden; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }
@media (max-width: 480px) { .modal__foot .btn { flex: 1 1 100%; } }

/* ---------- История изменений ---------- */
.history-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; max-height: 55vh; overflow: auto; }
.history-item { border: 1px solid var(--border); border-radius: 8px; padding: .6rem .75rem; font-size: .875rem; }
.history-item__head { display: flex; justify-content: space-between; gap: .75rem; color: var(--muted); font-size: .78rem; margin-bottom: .25rem; }
.history-item__field { font-weight: 600; color: var(--text-2); }
.history-old { color: var(--danger); text-decoration: line-through; }
.history-new { color: var(--success); font-weight: 600; }

/* ---------- Результаты поиска заявок ---------- */
.result-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.result { border: 1px solid var(--border); border-radius: 8px; padding: .75rem .9rem; }
.result__top { display: flex; justify-content: space-between; gap: .6rem; align-items: flex-start; }
.result__title { font-weight: 600; }
.result__meta { font-size: .85rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: .3rem .9rem; margin-top: .35rem; }
.result__badges { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .5rem; }

