@font-face { font-family: "Montserrat"; src: url(fonts/Montserrat-Regular.ttf) format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Montserrat"; src: url(fonts/Montserrat-Bold.ttf) format("truetype"); font-weight: 700; font-display: swap; }

:root {
  --bg: #f4f5fa; --card: #fff; --ink: #161827; --muted: #6b7083; --line: #e3e5ee;
  --brand: #3716ff; --brand2: #1f7bde; --brand3: #9e2d95;
  --ok: #157f3b; --ok-bg: #e8f6ed; --warn: #8a5a00; --warn-bg: #fff5dc; --err: #b42318; --err-bg: #fdecea;
  --grad: linear-gradient(90deg, #1f7bde 0%, #3716ff 52%, #9e2d95 100%);
  --r: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 4px 0 14px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 16px 0 8px; }
code { font-size: 12px; background: #eef0f7; padding: 1px 5px; border-radius: 5px; }
.muted, .sub { color: var(--muted); }
.sub { font-size: 12px; margin-top: 2px; }
.strong { font-weight: 700; }

/* шапка */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 24px; padding: 0 20px; height: 56px;
  background: #fff; border-bottom: 1px solid var(--line); }
.top::after { content: ""; position: absolute; left: 0; right: 0; bottom: -3px; height: 3px; background: var(--grad); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.brand img { width: 30px; height: 30px; }
.brand:hover { text-decoration: none; }
.top nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.top nav a, .subnav a { padding: 8px 12px; border-radius: 8px; color: var(--ink); white-space: nowrap; }
.top nav a.on, .subnav a.on { background: #eceaff; color: var(--brand); font-weight: 700; }
.top nav a:hover, .subnav a:hover { text-decoration: none; background: #f1f2f8; }
.me { display: flex; align-items: center; gap: 12px; font-size: 13px; white-space: nowrap; }
.me form { margin: 0; }
.subnav { display: flex; gap: 4px; padding: 10px 20px 0; max-width: 1320px; margin: 0 auto; overflow-x: auto; }
.wrap { max-width: 1320px; margin: 0 auto; padding: 18px 20px 60px; }

/* элементы */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin-bottom: 16px; }
.card.narrow { max-width: 460px; margin: 40px auto; }
.ok-card { border-color: #b7e2c4; } .warn-card { border-color: #f1d48a; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { border-color: #c9cce0; text-decoration: none; }
.btn.primary { background: var(--grad); color: #fff; border: 0; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.big { padding: 13px 22px; font-size: 15px; width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
button.link { background: none; border: 0; color: var(--brand); font: inherit; cursor: pointer; padding: 0; }
input, select, textarea { font: inherit; color: inherit; border: 1px solid #d5d8e4; border-radius: 8px; padding: 8px 10px; background: #fff; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid #c8c0ff; border-color: var(--brand); }
textarea { width: 100%; resize: vertical; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 700; }
label > input, label > select, label > textarea { font-weight: 400; font-size: 14px; color: var(--ink); }
label.inline { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; color: var(--ink); font-size: 13px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.compact { gap: 9px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid.map { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kv { font-size: 14px; } .kv span { display: block; font-size: 12px; color: var(--muted); font-weight: 700; }
.kvtable { border-collapse: collapse; width: 100%; } .kvtable th, .kvtable td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.kvtable th { color: var(--muted); font-weight: 400; } .num { text-align: right; font-weight: 700; font-size: 16px; }

.flash { background: #eceaff; border: 1px solid #d3cdff; border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-weight: 700; }
.alert { border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; border: 1px solid; }
.alert.err { background: var(--err-bg); border-color: #f5c2bd; color: var(--err); }
.alert.warn { background: var(--warn-bg); border-color: #f1d48a; color: var(--warn); }
.alert.ok { background: var(--ok-bg); border-color: #b7e2c4; color: var(--ok); }
.big-ok { font-size: 15px; }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 20px; background: #eef0f7; color: var(--muted); font-weight: 700; }
.tag.red { background: var(--err-bg); color: var(--err); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: #c0c4d4; }
.dot.d-verified { background: #22a356; } .dot.d-needs_check { background: #e5484d; } .dot.d-unverified { background: #f0a020; }

/* статусы */
.status { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; background: #eef0f7; color: #3b3f52; white-space: nowrap; }
.status.big { font-size: 13px; padding: 6px 14px; }
.st-NO_ANSWER { background: #fff1d6; color: #8a5a00; }
.st-CONTACTED { background: #e3f0ff; color: #1659b8; }
.st-LETTER_READY { background: #ece8ff; color: #4b2bd6; }
.st-LETTER_SENT { background: #e1dcff; color: #3716ff; }
.st-TO_DIRECTOR, .st-REVIEW { background: #f6e3f4; color: #8e2585; }
.st-AGREED, .st-SCHEDULED { background: #dff5e7; color: #157f3b; }
.st-DONE { background: #157f3b; color: #fff; }
.st-REFUSED, .st-DO_NOT_CONTACT { background: #fdecea; color: #b42318; }
.st-NOT_TARGET, .st-BAD_DATA { background: #ececec; color: #666; }

.head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.head-row .actions { display: flex; gap: 10px; align-items: center; }
.school-title { margin-bottom: 4px; max-width: 860px; }
.crumbs { font-size: 13px; margin-bottom: 6px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filters .grow { flex: 1 1 260px; }
.filters.tight { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip { padding: 5px 11px; border-radius: 20px; background: #fff; border: 1px solid var(--line); color: var(--ink); font-size: 12px; }
.chip b { margin-left: 4px; } .chip.on { outline: 2px solid var(--brand); }
.chip:hover { text-decoration: none; filter: brightness(.97); }

.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 14px; }
table.list { width: 100%; border-collapse: collapse; }
.list th, .list td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.list thead th { font-size: 12px; color: var(--muted); background: #fafbfe; position: sticky; top: 0; }
.list tr:last-child td { border-bottom: 0; }
.list tr.due td { background: #fffaf0; }
.list tr.off td { opacity: .55; }
.list .cb { width: 32px; }
.list.small td, .list.small th { padding: 6px 8px; font-size: 12px; }
.list.numeric td { text-align: right; } .list.numeric tbody th, .list.numeric tr > th:first-child { text-align: left; }
.list td.details { font-size: 12px; max-width: 520px; word-break: break-word; }
.empty { text-align: center; color: var(--muted); padding: 30px !important; }
.imp-error td { background: var(--err-bg); } .imp-dup td, .imp-dup_file td { background: #f6f6f6; color: #777; }
.pager { display: flex; gap: 10px; justify-content: center; margin: 10px 0 20px; }
.bulk { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.bulk .sep { width: 1px; height: 26px; background: var(--line); }

.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.grid-letter { display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); gap: 16px; align-items: start; }
.director .big-name { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.director { margin-bottom: 14px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.tabs button, .tabs a { background: none; border: 0; padding: 8px 12px; font: inherit; font-weight: 700; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs .on { color: var(--brand); border-bottom-color: var(--brand); }
.tabs.static { margin-bottom: 14px; }
.letter-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.history { list-style: none; padding: 0; margin: 0; }
.history li { padding: 9px 0 9px 14px; border-left: 2px solid var(--line); position: relative; }
.history li::before { content: ""; position: absolute; left: -5px; top: 14px; width: 8px; height: 8px; border-radius: 50%; background: #c0c4d4; }
.history li.ev-sent::before, .history li.ev-reply::before { background: var(--brand); }
.history li.ev-letter::before { background: var(--brand3); }
.history .when { font-size: 12px; color: var(--muted); }
.seg { display: flex; gap: 6px; }
.seg label { flex-direction: row; align-items: center; gap: 6px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); font-size: 14px; cursor: pointer; }
.seg label:has(input:checked) { border-color: var(--brand); background: #f1efff; }
.preview { position: sticky; top: 76px; }
.preview iframe { width: 100%; height: calc(100vh - 120px); min-height: 640px; border: 1px solid var(--line); border-radius: var(--r); background: #fff; }
iframe.mini { width: 100%; height: 640px; border: 1px solid var(--line); border-radius: 8px; }
.preview-empty { height: 400px; display: grid; place-items: center; color: var(--muted); border: 2px dashed var(--line); border-radius: var(--r); }
.pw { font-size: 16px; padding: 3px 8px; }
.logo-prev { max-width: 220px; display: block; margin-bottom: 10px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.kpi span { display: block; font-size: 12px; color: var(--muted); font-weight: 700; }
.kpi b { display: block; font-size: 28px; line-height: 1.2; margin: 4px 0; }
.kpi i { font-style: normal; font-size: 12px; color: var(--muted); }
.kpi.main { border-top: 3px solid var(--brand); } .kpi.bad b { color: var(--err); }
.funnel .fstep { display: grid; grid-template-columns: 170px 1fr 48px 52px; gap: 10px; align-items: center; padding: 5px 0; font-size: 13px; }
.fbar { height: 12px; background: #f0f1f7; border-radius: 6px; overflow: hidden; }
.fbar i { display: block; height: 100%; background: var(--grad); border-radius: 6px; }
.fstep b { text-align: right; } .fconv { color: var(--muted); font-size: 12px; text-align: right; }

.login { max-width: 380px; margin: 9vh auto; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 30px; }
.login-logo { width: 190px; display: block; margin-bottom: 18px; }
.login h1 { font-size: 20px; margin-bottom: 2px; }

@media (max-width: 960px) {
  .grid2, .grid-letter { grid-template-columns: 1fr; }
  .preview { position: static; }
  .preview iframe { height: 75vh; min-height: 0; }
  .form-grid.map { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .top { height: auto; flex-wrap: wrap; gap: 6px 12px; padding: 8px 16px; }
  .top nav { order: 3; flex-basis: 100%; }
  .me span { display: none; }
  .wrap { padding: 14px 16px 50px; }
  .form-grid, .form-grid.map { grid-template-columns: 1fr; }
  .funnel .fstep { grid-template-columns: 110px 1fr 40px 44px; font-size: 12px; }
  h1 { font-size: 19px; }
}
