/* Реестр должников — светлая «лента» в духе Дзена: белые карточки на сером фоне,
   крупная типографика, мягкие скругления, чёрные кнопки-«пилюли», минимум цвета. */
:root {
  --bg: #f2f3f5;
  --surface: #ffffff;
  --fill: #f2f3f5;          /* поля ввода, вторичные кнопки */
  --fill-hover: #e8e9ec;
  --ink: #000000;
  --ink-2: rgba(0, 0, 0, .72);
  --muted: rgba(0, 0, 0, .48);
  --line: rgba(0, 0, 0, .08);
  --primary: #000000;
  --primary-hover: #26262a;
  --link: #0a5ddb;
  --danger: #e5352b;
  --danger-bg: #fdeceb;
  --warn: #c27a00;
  --warn-bg: #fff4e0;
  --ok: #1f8a4c;
  --ok-bg: #e7f6ed;
  --info: #3b4352;
  --info-bg: #eef0f4;
  --r-card: 24px;
  --r-ctl: 12px;
  --font: "YS Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "YS Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--link); }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.02em; }
h1 { font-size: 30px; line-height: 1.15; font-weight: 800; margin: 0 0 6px; }
h2, h3 { margin: 0; }
.container { max-width: 1240px; margin: 0 auto; padding: 24px 20px 56px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pre { white-space: pre-wrap; }
.danger { color: var(--danger); }
.hide-sm { }

/* ===== шапка ===== */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.92); backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: 0 20px; min-height: 64px; display: flex; align-items: center; gap: 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 800; font-size: 18px; letter-spacing: -0.02em; flex: none; }
.brand:hover { color: var(--ink); }
.brand-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 16px; }
.topsearch { flex: 1 1 auto; max-width: 620px; display: flex; align-items: center; background: var(--fill); border-radius: var(--r-ctl);
  border: 2px solid transparent; transition: border-color .15s, background .15s; }
.topsearch:focus-within { background: #fff; border-color: var(--ink); }
.topsearch input[type=search] { border: 0; background: transparent; min-height: 40px; padding: 8px 14px; box-shadow: none; color: var(--ink); }
.topsearch input[type=search]:focus { box-shadow: none; }
.topsearch button { flex: none; border: 0; background: transparent; color: var(--ink-2); font: inherit; font-weight: 600; padding: 0 14px; cursor: pointer; }
.topsearch button:hover { color: var(--ink); }
.topbar .nav { display: flex; gap: 2px; flex: none; }
.topbar .nav a { padding: 8px 12px; border-radius: var(--r-ctl); color: var(--ink-2); font-weight: 500; }
.topbar .nav a:hover { background: var(--fill); color: var(--ink); }
.topbar .nav a.active { background: var(--fill); color: var(--ink); font-weight: 700; }
.me { display: flex; align-items: center; gap: 8px; margin-left: auto; padding: 4px 12px 4px 4px; border-radius: 999px; flex: none; color: var(--ink); }
.me:hover, .me.active { background: var(--fill); color: var(--ink); }
.me-name { font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me .btn-link { color: var(--ink-2); }

.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 8px 16px 32px; }

/* ===== раскладка ===== */
.page-head { margin: 6px 0 20px; }
.page-head.row { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.card { background: var(--surface); border-radius: var(--r-card); padding: 24px; margin-bottom: 16px; }
.card.narrow { max-width: 520px; margin-left: auto; margin-right: auto; }
.card-title { font-size: 20px; font-weight: 800; margin-bottom: 16px; display: flex; align-items: center; gap: 10px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.card-head .card-title { margin: 0; }
.center { text-align: center; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.cols > .card, .cols > div > .card { margin-bottom: 16px; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.layout-side { position: sticky; top: 80px; }
.stack > * + * { margin-top: 12px; }
.back { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 10px; color: var(--muted); font-weight: 500; }
.back:hover { color: var(--ink); }
.step { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 14px; }

/* ===== кнопки ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; line-height: 1;
  border-radius: var(--r-ctl); padding: 0 18px; min-height: 40px; border: 0; cursor: pointer; white-space: nowrap; transition: background .15s; }
.btn:hover { text-decoration: none; }
.btn-primary, .btn-accent { background: var(--primary); color: #fff; }
.btn-primary:hover, .btn-accent:hover { background: var(--primary-hover); color: #fff; }
.btn-secondary, .btn-ghost { background: var(--fill); color: var(--ink); }
.btn-secondary:hover, .btn-ghost:hover { background: var(--fill-hover); color: var(--ink); }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; padding: 0; font: inherit; color: var(--link); cursor: pointer; }
.btn-link:hover { text-decoration: underline; }
.btn-link.danger { color: var(--danger); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.link-sm { font-size: 14px; color: var(--link); font-weight: 500; }
form.inline { display: inline; }

/* ===== формы ===== */
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--fill); border: 2px solid transparent; border-radius: var(--r-ctl);
  padding: 8px 12px; width: 100%; min-height: 42px; transition: border-color .15s, background .15s;
}
textarea { resize: vertical; }
input:hover, select:hover, textarea:hover { background: var(--fill-hover); }
input:focus, select:focus, textarea:focus { outline: none; background: #fff; border-color: var(--ink); }
input::placeholder, textarea::placeholder { color: rgba(0,0,0,.38); }
input[type=file] { padding: 7px; font-size: 14px; }
input[type=file]::file-selector-button { border: 0; border-radius: 8px; background: #fff; padding: 6px 12px; margin-right: 10px; font: inherit; font-weight: 600; cursor: pointer; }
input[type=checkbox] { width: auto; min-height: 0; accent-color: #000; }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.wide { grid-column: span 3; }
.label { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.req { color: var(--danger); }
.hint { font-size: 12px; color: var(--muted); }
.check { display: flex; gap: 8px; align-items: center; }
.has-error input, .has-error textarea, .has-error select { border-color: var(--danger); background: #fff; }
.error { color: var(--danger); font-size: 12px; font-weight: 500; }
.fgroup + .fgroup { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.fgroup-title { font-size: 13px; color: var(--muted); font-weight: 700; margin-bottom: 10px; }
.files-row { display: grid; grid-template-columns: 180px 1fr; gap: 10px; }
.actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 18px; }
.sticky-actions { position: sticky; bottom: 0; z-index: 5; background: rgba(255,255,255,.95); backdrop-filter: blur(10px);
  padding: 12px 20px; border-radius: 18px; box-shadow: 0 6px 24px rgba(0,0,0,.08); justify-content: space-between; }
.search-inline { display: flex; gap: 10px; flex-wrap: wrap; }
.search-inline > input, .search-inline > select { flex: 1 1 180px; width: auto; }
.inline-filter select { width: auto; min-width: 220px; }
.person-pick { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; background: var(--fill); border-radius: 16px; }
.person-pick b { font-size: 17px; }

/* поручители */
.guarantor { background: var(--fill); border-radius: 20px; padding: 18px; margin-bottom: 14px; }
.guarantor input, .guarantor select, .guarantor textarea { background: #fff; }
.guarantor input:hover, .guarantor select:hover, .guarantor textarea:hover { background: #fff; border-color: var(--line); }
.guarantor .btn-ghost { background: #fff; }
.guarantor-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.guarantor-head h3 { font-size: 17px; font-weight: 800; }
.guarantor .fgroup + .fgroup { border-top-color: rgba(0,0,0,.06); }

/* ===== уведомления ===== */
.flash { padding: 12px 16px; border-radius: 16px; margin-bottom: 14px; font-weight: 500; }
.flash-success { background: var(--ok-bg); color: var(--ok); }
.flash-error { background: var(--danger-bg); color: #b4231b; }
.flash-info { background: var(--info-bg); color: var(--info); }

/* ===== бейджи ===== */
.badge { display: inline-flex; align-items: center; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; vertical-align: middle; }
.badge-danger { background: var(--danger); color: #fff; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-info { background: var(--info-bg); color: var(--info); }
.tag { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--fill); color: var(--ink-2); margin-right: 4px; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 8px; }

/* ===== показатели ===== */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.stat { background: var(--surface); border-radius: var(--r-card); padding: 20px 22px; }
.stat-num { font-family: var(--font-display); font-size: 28px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 14px; margin-top: 2px; }
.stat-danger .stat-num { color: var(--danger); }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.kpi { background: var(--fill); border-radius: 16px; padding: 14px 16px; }
.kpi-num { font-family: var(--font-display); font-size: 20px; font-weight: 800; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.kpi-label { color: var(--muted); font-size: 13px; }
.kpi-danger { background: var(--danger-bg); } .kpi-danger .kpi-num { color: var(--danger); }
.kpi-warn { background: var(--warn-bg); } .kpi-warn .kpi-num { color: var(--warn); }
.kpi-note { margin: 12px 0 0; }

/* ===== вкладки ===== */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab { padding: 8px 14px; border-radius: 999px; color: var(--ink-2); font-weight: 600; font-size: 14px; }
.tab:hover { background: var(--fill); color: var(--ink); }
.tab.active { background: var(--ink); color: #fff; }

/* ===== таблицы ===== */
.table-wrap { overflow-x: auto; margin: 0 -8px; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 600; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafafb; }
.table td a { font-weight: 600; }
.table tr.row-danger td { background: #fff7f6; }
.table tr.row-danger td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-compact td { padding: 8px 12px; font-size: 14px; }
.pager { display: flex; justify-content: center; align-items: center; gap: 16px; margin-top: 16px; color: var(--muted); }
.pager a { padding: 8px 14px; border-radius: 999px; background: var(--fill); color: var(--ink); font-weight: 600; }

/* ===== карточка человека ===== */
.hero { display: flex; align-items: center; gap: 24px; padding: 28px; }
.hero-photo { flex: none; width: 112px; height: 112px; border-radius: 50%; overflow: hidden; background: var(--fill); display: grid; place-items: center; }
.hero-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero-initials { font-family: var(--font-display); font-weight: 800; font-size: 40px; color: var(--muted); }
.hero-body { flex: 1; min-width: 0; }
.hero-body h1 { margin: 0; }
.hero-meta { display: flex; gap: 6px 14px; flex-wrap: wrap; color: var(--muted); margin-top: 6px; }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; flex: none; align-self: flex-start; }
.dl { display: grid; grid-template-columns: 200px 1fr; gap: 10px 16px; margin: 0; }
.dl dt { color: var(--muted); font-size: 13px; }
.dl dd { margin: 0; }
.dl-stack { grid-template-columns: 1fr; gap: 2px; }
.dl-stack dt { margin-top: 10px; }
.dl-stack dt:first-child { margin-top: 0; }
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 14px; display: block; }
.files { list-style: none; padding: 0; margin: 0 0 14px; }
.files li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.files li a { font-weight: 600; word-break: break-word; }
.plist { list-style: none; padding: 0; margin: 0; }
.plist li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.plist li a { font-weight: 600; }
.upload { padding-top: 12px; }

/* ===== аватары ===== */
.avatar { display: inline-grid; place-items: center; border-radius: 50%; object-fit: cover; flex: none; color: #fff; font-weight: 700; background: #5b6170; }
.avatar-sm { width: 30px; height: 30px; font-size: 13px; }
.avatar-lg { width: 72px; height: 72px; font-size: 28px; }
.avatar-xl { width: 120px; height: 120px; font-size: 46px; }
.avatar-c0 { background: #3d6fd8; } .avatar-c1 { background: #2f9e62; } .avatar-c2 { background: #e0663a; }
.avatar-c3 { background: #8a55d6; } .avatar-c4 { background: #d49b1f; } .avatar-c5 { background: #2a9aa3; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; vertical-align: middle; font-weight: 600; }
.profile-head { display: flex; align-items: center; gap: 18px; }
.profile-head h1 { margin: 0; }
.about { margin: 10px 0 0; color: var(--ink-2); max-width: 640px; }
.avatar-edit { display: flex; gap: 20px; align-items: flex-start; }

/* ===== поиск ===== */
.search-main { display: flex; gap: 10px; }
.search-main input { font-size: 18px; min-height: 52px; padding: 10px 18px; border-radius: 16px; }
.search-main .btn { min-height: 52px; border-radius: 16px; padding: 0 26px; }
.search-filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.search-filters select { width: auto; }

/* ===== вход ===== */
.auth-wrap { min-height: 76vh; display: grid; place-items: center; }
.auth-card { width: 100%; max-width: 420px; padding: 32px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 800; font-size: 18px; margin-bottom: 20px; }
.secret { font: 700 22px/1.4 ui-monospace, Menlo, Consolas, monospace; background: var(--fill); border-radius: 16px; padding: 16px; text-align: center; margin: 12px 0 16px; user-select: all; }
.err-code { font-family: var(--font-display); font-size: 64px; font-weight: 800; color: rgba(0,0,0,.15); }

/* ===== адаптив ===== */
@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; }
  .layout-side { position: static; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 980px) {
  .topbar-inner { flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
  .topsearch { order: 10; flex-basis: 100%; max-width: none; }
  .me { order: 3; }
  .topbar .nav { order: 9; }
  .me-name { display: none; }
  .grid { grid-template-columns: 1fr 1fr; }
  .field.wide { grid-column: span 2; }
  .cols { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .hero { flex-wrap: wrap; }
  .hero-actions { width: 100%; }
}
@media (max-width: 560px) {
  .container { padding: 16px 12px 40px; }
  .card { padding: 18px; border-radius: 20px; }
  h1 { font-size: 24px; }
  .hide-sm { display: none; }
  .btn-accent { padding: 0 14px; }
  .grid { grid-template-columns: 1fr; }
  .field.wide { grid-column: span 1; }
  .files-row { grid-template-columns: 1fr; }
  .dl { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
  .hero { padding: 20px; gap: 16px; }
  .hero-photo { width: 80px; height: 80px; }
  .avatar-edit { flex-direction: column; }
  .search-main { flex-direction: column; }
}
@media print { .topbar, .footer, .actions, form, .hero-actions { display: none; } body { background: #fff; } }
.layout-side .files-row { grid-template-columns: 1fr; }
@media (max-width: 1080px) { .layout { grid-template-columns: minmax(0, 1fr); } .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) {
  .hero { flex-direction: column; align-items: flex-start; }
  .kpi-num { font-size: 17px; }
  .kpi { padding: 12px; }
}

/* карточка: данные слева, история справа */
.layout-left { grid-template-columns: 360px minmax(0, 1fr); }
@media (max-width: 1080px) { .layout-left { grid-template-columns: minmax(0, 1fr); } }

/* список файлов с миниатюрами */
.files li { flex-wrap: nowrap; gap: 12px; }
.file-thumb { flex: none; width: 48px; height: 48px; border-radius: 12px; overflow: hidden; display: grid; place-items: center;
  background: var(--fill); color: var(--ink-2); font-size: 11px; font-weight: 800; letter-spacing: .02em; }
.file-thumb:hover { color: inherit; opacity: .85; }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-thumb-pdf { background: #fdeceb; color: #d1342b; }
.file-thumb-docx { background: #e8f0fe; color: #2b5fd1; }
.file-thumb-xlsx { background: #e7f6ed; color: #1f8a4c; }
.file-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-del { flex: none; font-size: 13px; }
