:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #1f2733;
  --muted: #6b7688;
  --line: #e3e8ef;
  --brand: #2b6cb0;
  --brand-d: #245a95;
  --ok: #2f855a;
  --err: #c53030;
  --wait: #b7791f;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 30, 50, .06), 0 4px 16px rgba(20, 30, 50, .05);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

.topbar { background: linear-gradient(120deg, var(--brand), var(--brand-d)); color: #fff; }
.topbar__inner { max-width: 940px; margin: 0 auto; padding: 22px 20px; }
.brand { font-size: 22px; font-weight: 700; }
.brand__sub { opacity: .9; font-size: 14px; margin-top: 3px; }

.wrap { max-width: 940px; margin: 24px auto 60px; padding: 0 20px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin-bottom: 22px;
}
.panel__head { display: flex; align-items: center; justify-content: space-between; }
.panel h2 { font-size: 17px; margin: 0 0 2px; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0 16px; }

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 16px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field--wide { grid-column: 1 / -1; }
.field__label { font-size: 13px; color: var(--muted); font-weight: 500; }
.field__label b { color: var(--err); }
.field input, .field textarea {
  font: inherit;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(43, 108, 176, .12);
}
.field textarea { resize: vertical; }

.ai-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.ai-btn { font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; border: 1px solid var(--line); background: #fff; color: var(--brand-d); border-radius: 7px; padding: 5px 10px; }
.ai-btn:hover { border-color: var(--brand); }
.ai-btn:disabled { opacity: .6; cursor: default; }
.ai-format { background: #eef4fb; border-color: #cfe0f2; }
.ai-mic.rec { background: #fdecec; border-color: #f3c0c0; color: #a12020; }
.ai-note { font-size: 11px; color: var(--muted); }

.disclaimer { background: #fff8e6; border: 1px solid #f0e0a8; color: #7a5c00; font-size: 13px; padding: 10px 14px; border-radius: 10px; margin-bottom: 20px; }
.warnbox { display: flex; gap: 8px; background: #fdecec; border: 1px solid #f3c0c0; color: #a12020; font-size: 13.5px; padding: 11px 14px; border-radius: 10px; margin-top: 14px; }

.field select { font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
.field select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(43,108,176,.12); }

.doc__name { font-weight: 600; }
.doc__legal { display: block; font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.doc--dim { opacity: .55; }
.doc--dim .doc__head::after { content: "не требуется вашему профилю"; margin-left: auto; font-size: 11px; color: var(--muted); font-weight: 400; align-self: center; }

.badge { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 20px; margin-left: 8px; vertical-align: middle; white-space: nowrap; }
.badge.m-law { background: #fde2e2; color: #b11f1f; }
.badge.m-case { background: #ffe9d1; color: #a85a10; }
.badge.m-rec { background: #fbf3cf; color: #8a6d00; }
.badge.m-opt { background: #eceff3; color: #5b6675; }
.badge.m-unc { background: #ece0fb; color: #6b3fb0; }
.badge.m-lawyer { background: #e0ecfb; color: #2b6cb0; }

.docs { display: flex; flex-direction: column; gap: 26px; }
.catgroup { display: flex; flex-direction: column; gap: 12px; }
.catgroup__head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; padding-bottom: 4px; border-bottom: 2px solid var(--line); }
.catgroup__title { font-size: 15px; font-weight: 700; color: var(--brand-d); text-transform: uppercase; letter-spacing: .3px; }
.catgroup__desc { font-size: 13px; color: var(--muted); }
.catgroup__all { margin-left: auto; }
.uploader { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; padding: 12px 14px; background: #f7f9fc; border: 1px dashed var(--line); border-radius: 10px; }
.uploader__btn { cursor: pointer; white-space: nowrap; }
.uploader__hint { font-size: 12.5px; color: var(--muted); flex: 1; min-width: 200px; }
.uploader__hint code { background: #eef2f7; padding: 1px 5px; border-radius: 4px; }
.doc { position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.doc__del { position: absolute; top: 10px; right: 10px; z-index: 2; width: 26px; height: 26px; line-height: 1;
  border: 1px solid var(--line); background: #fff; border-radius: 6px; color: var(--muted); cursor: pointer; font-size: 13px; }
.doc__del:hover { color: var(--err); border-color: var(--err); }
.doc__head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px; cursor: pointer; user-select: none;
}
.doc__head input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--brand); }
.doc__title { font-weight: 600; display: flex; flex-direction: column; }
.doc__desc { font-weight: 400; font-size: 13px; color: var(--muted); margin-top: 2px; }
.doc__shared { font-size: 12.5px; color: var(--brand-d); background: #eef4fb; border-radius: 6px; padding: 7px 10px; margin-bottom: 12px; }
.doc__body { display: none; padding: 0 16px 18px; border-top: 1px solid var(--line); }
.doc--open { border-color: var(--brand); }
.doc--open .doc__body { display: block; padding-top: 16px; }

.actionbar {
  position: sticky; bottom: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 18px;
}
.count { color: var(--muted); font-size: 14px; }
.actionbar__btns { display: flex; gap: 10px; }

/* Модалка предпросмотра */
.modal { display: none; position: fixed; inset: 0; background: rgba(20, 30, 50, .5); z-index: 50; padding: 24px; }
.modal.open { display: flex; align-items: center; justify-content: center; }
.modal__box { background: var(--panel); border-radius: 12px; width: min(820px, 100%); max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal__title { font-weight: 700; font-size: 16px; }
.modal__actions { display: flex; gap: 10px; }
.modal__body { overflow-y: auto; padding: 18px; background: #eef1f5; }
.pv-doc { margin-bottom: 22px; }
.pv-doc__title { font-size: 13px; font-weight: 700; color: var(--brand-d); text-transform: uppercase; letter-spacing: .3px; margin-bottom: 8px; }
.pv-page { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 28px 32px; font-family: "Times New Roman", Georgia, serif; font-size: 14px; line-height: 1.5; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.pv-p { white-space: pre-wrap; margin: 0 0 6px; }
.pv-p--b { font-weight: 700; }
.pv-p--c { text-align: center; }

.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; border-radius: 8px; padding: 10px 18px;
  transition: background .15s, opacity .15s;
}
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-d); }
.btn--primary:disabled { opacity: .45; cursor: not-allowed; }
.btn--ghost { background: transparent; color: var(--muted); border-color: var(--line); padding: 6px 12px; font-size: 13px; }
.btn--ghost:hover { color: var(--ink); border-color: var(--muted); }

.status { margin-top: 14px; font-size: 14px; padding: 0 2px; min-height: 1px; }
.status--ok { color: var(--ok); font-weight: 600; }
.status--err { color: var(--err); }
.status--wait { color: var(--wait); }
.status code { background: #eef2f7; padding: 1px 6px; border-radius: 5px; }

.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 24px 20px 40px; }

/* Парольный шлюз */
.gate { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(120deg, var(--brand), var(--brand-d)); padding: 20px; }
.gate__box { background: var(--panel); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.3);
  padding: 32px 30px; width: min(360px, 100%); text-align: center; }
.gate__icon { font-size: 34px; }
.gate__title { font-size: 19px; font-weight: 700; margin-top: 8px; }
.gate__sub { color: var(--muted); font-size: 14px; margin: 4px 0 18px; }
.gate__input { width: 100%; font: inherit; padding: 11px 13px; border: 1px solid var(--line);
  border-radius: 8px; text-align: center; letter-spacing: 2px; }
.gate__input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(43,108,176,.12); }
.gate__btn { width: 100%; margin-top: 12px; }
.gate__remember { display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 12.5px; color: var(--muted); margin-top: 12px; }
.gate__err { color: var(--err); font-size: 13px; min-height: 18px; margin-top: 10px; }

@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; }
  .actionbar { flex-direction: column; align-items: stretch; }
  .btn--primary { width: 100%; }
}
