:root {
  --bg: #f3f7fb;
  --bg-2: #eaf1f7;
  --card: #ffffff;
  --ink: #112630;
  --ink-2: #29414e;
  --muted: #6b8292;
  --line: #dde8f0;
  --line-2: #edf3f8;
  --teal: #0f9f8f;
  --teal-2: #0b8275;
  --teal-soft: #e7f7f4;
  --blue: #2563eb;
  --blue-soft: #eaf1ff;
  --navy: #0a2833;
  --navy-2: #0d3442;
  --green: #067647;
  --green-soft: #e8f7ef;
  --amber: #a15c07;
  --amber-soft: #fff5e5;
  --red: #b42318;
  --red-soft: #fdeceb;
  --shadow: 0 12px 34px rgba(16, 48, 68, .08);
  --shadow-sm: 0 3px 12px rgba(16, 48, 68, .06);
  --radius: 18px;
  --radius-sm: 12px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Noto Sans", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--teal-2); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

/* ------------------------------ общее ------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 12px; padding: 10px 16px; font-size: 14px; font-weight: 600;
  transition: .15s ease; white-space: nowrap;
}
.btn:hover { border-color: #c7d8e4; background: #f8fbfd; }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-2); border-color: var(--teal-2); }
.btn.blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.danger { background: #fff; color: var(--red); border-color: #f3c6c2; }
.btn.danger:hover { background: var(--red-soft); }
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn.w-full { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn {
  border: 0; background: transparent; font-size: 20px; color: var(--ink-2);
  width: 38px; height: 38px; border-radius: 10px;
}
.icon-btn:hover { background: var(--line-2); }
.hint { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin: 0; }
.muted { color: var(--muted); }
.warn { color: var(--amber); }
.error { color: var(--red); }
.nowrap { white-space: nowrap; }
.w-full { width: 100%; }

/* ------------------------------ бренд ------------------------------ */
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid; place-items: center; width: 42px; height: 42px;
  border-radius: 14px; background: linear-gradient(135deg, var(--teal), #1fc4b0);
  color: #fff; font-weight: 800; font-size: 14px; letter-spacing: .5px;
  box-shadow: 0 6px 16px rgba(15,159,143,.35);
}
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: -.2px; }
.brand-sub { font-size: 11.5px; color: var(--muted); }
.brand-lg .brand-mark { width: 54px; height: 54px; font-size: 17px; }
.brand-lg .brand-name { font-size: 24px; color: #fff; }
.brand-lg .brand-sub { color: rgba(255,255,255,.72); font-size: 12px; }

/* ------------------------------ вход ------------------------------ */
.auth-screen {
  min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(420px, .85fr);
}
.auth-hero {
  position: relative; overflow: hidden; color: #fff;
  background:
    radial-gradient(900px 500px at 8% 8%, rgba(31,196,176,.30), transparent 60%),
    radial-gradient(700px 500px at 90% 90%, rgba(37,99,235,.28), transparent 60%),
    linear-gradient(150deg, #082530 0%, #0b3340 52%, #0a2b38 100%);
  display: flex; align-items: center; padding: 56px 64px;
}
.auth-hero::after {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,.055) 1px, transparent 1px);
  background-size: 22px 22px; pointer-events: none;
}
.auth-hero-inner { position: relative; z-index: 1; max-width: 640px; }
.auth-hero h1 {
  font-size: clamp(30px, 3.6vw, 48px); line-height: 1.08; margin: 34px 0 18px;
  letter-spacing: -1px; font-weight: 800;
}
.auth-hero h1 span { color: #7de8da; }
.hero-lead { color: rgba(255,255,255,.78); font-size: 16px; line-height: 1.65; max-width: 560px; margin: 0 0 26px; }
.hero-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.hero-points li { display: flex; gap: 12px; align-items: flex-start; }
.hp-icon {
  flex: 0 0 38px; height: 38px; display: grid; place-items: center;
  background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.14);
  border-radius: 12px; font-size: 18px;
}
.hero-points b { display: block; font-size: 14.5px; margin-bottom: 2px; }
.hero-points small { color: rgba(255,255,255,.66); font-size: 12.5px; line-height: 1.45; }
.hero-disclaimer {
  margin-top: 30px; font-size: 11.5px; color: rgba(255,255,255,.55);
  border-left: 3px solid rgba(125,232,218,.6); padding-left: 12px; max-width: 560px;
}
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 36px 28px; background: var(--bg); }
.auth-card {
  width: 100%; max-width: 460px; background: var(--card); border: 1px solid var(--line);
  border-radius: 24px; box-shadow: var(--shadow); padding: 28px;
}
.auth-tabs { display: flex; gap: 6px; background: var(--line-2); padding: 5px; border-radius: 13px; margin-bottom: 22px; }
.auth-tab {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  padding: 10px; border-radius: 10px; font-weight: 700; font-size: 14px;
}
.auth-tab.active { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }
.auth-form { display: grid; gap: 14px; }
.auth-form label { display: grid; gap: 7px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.auth-form input, .auth-form select, .auth-form textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font-size: 14.5px; background: #fbfdff; outline: none;
  transition: .15s;
}
.auth-form input:focus, .auth-form select:focus, .auth-form textarea:focus {
  border-color: var(--teal); box-shadow: 0 0 0 3px rgba(15,159,143,.12); background: #fff;
}
.role-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.role-card {
  text-align: left; border: 1px solid var(--line); background: #fbfdff;
  border-radius: 14px; padding: 13px; display: grid; gap: 4px; color: var(--ink);
}
.role-card b { font-size: 13.5px; }
.role-card small { color: var(--muted); font-size: 11.5px; line-height: 1.35; }
.role-card .role-emoji { font-size: 22px; }
.role-card.active { border-color: var(--teal); background: var(--teal-soft); box-shadow: 0 0 0 3px rgba(15,159,143,.10); }
.auth-error {
  margin-top: 14px; background: var(--red-soft); color: var(--red);
  border: 1px solid #f3c6c2; padding: 10px 12px; border-radius: 10px; font-size: 13px;
}
.ai-badge {
  margin-top: 18px; padding: 10px 12px; border-radius: 11px; font-size: 12px;
  background: var(--line-2); color: var(--muted); line-height: 1.45;
}
.ai-badge.ok { background: var(--green-soft); color: var(--green); }
.ai-badge.warn { background: var(--amber-soft); color: var(--amber); }
.auth-note { margin-top: 14px; font-size: 11px; color: var(--muted); line-height: 1.45; }

/* ------------------------------ каркас ------------------------------ */
.app-screen { min-height: 100vh; display: flex; }
.sidebar {
  width: 268px; flex: 0 0 268px; background: linear-gradient(180deg, var(--navy), var(--navy-2));
  color: #fff; padding: 22px 16px; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { padding: 2px 8px 22px; }
.sidebar-brand .brand-name { color: #fff; }
.sidebar-brand .brand-sub { color: rgba(255,255,255,.55); }
.nav { display: grid; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  border: 0; background: transparent; color: rgba(255,255,255,.68);
  padding: 11px 12px; border-radius: 11px; font-size: 13.5px; font-weight: 600;
}
.nav-item .ni { width: 20px; text-align: center; font-size: 16px; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: rgba(31,196,176,.17); color: #7de8da; }
.sidebar-foot { margin-top: auto; display: grid; gap: 10px; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.09); }
.side-user { padding: 0 6px; }
.side-user b { display: block; font-size: 13.5px; color: #fff; }
.side-user small { color: rgba(255,255,255,.55); font-size: 11.5px; }
.sidebar-foot .btn { color: rgba(255,255,255,.75); border-color: rgba(255,255,255,.16); }
.sidebar-foot .btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(243,247,251,.88);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; padding: 12px 26px;
}
#menu-toggle { display: none; }
.page-title { font-size: 16px; font-weight: 800; letter-spacing: -.2px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.role-badge {
  font-size: 11px; font-weight: 700; padding: 6px 10px; border-radius: 999px;
  background: var(--blue-soft); color: var(--blue); text-transform: uppercase; letter-spacing: .4px;
}
.role-badge.doctor { background: var(--teal-soft); color: var(--teal-2); }
.role-badge.admin { background: #f2ecff; color: #6d3fd1; }
.ai-pill {
  font-size: 11.5px; color: var(--muted); background: #fff; border: 1px solid var(--line);
  padding: 6px 10px; border-radius: 999px; white-space: nowrap;
}
.ai-pill.ok { color: var(--green); border-color: #b9e6cd; background: var(--green-soft); }
.ai-pill.warn { color: var(--amber); border-color: #f0d5a8; background: var(--amber-soft); }
.content { width: 100%; max-width: 1180px; margin: 0 auto; padding: 26px; flex: 1; }

/* ------------------------------ страницы ------------------------------ */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { margin: 0 0 4px; font-size: 23px; letter-spacing: -.5px; }
.page-head p { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back-link { border: 0; background: transparent; color: var(--muted); font-size: 13px; padding: 0 0 10px; }
.back-link:hover { color: var(--ink); }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 15px 16px; box-shadow: var(--shadow-sm); }
.stat-card .sc-label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 700; }
.stat-card .sc-value { font-size: 28px; font-weight: 800; color: var(--ink); margin-top: 5px; line-height: 1; }
.stat-card .sc-sub { font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.stat-card.accent { background: linear-gradient(135deg, var(--teal), #16b7a3); border-color: transparent; }
.stat-card.accent .sc-label, .stat-card.accent .sc-sub { color: rgba(255,255,255,.75); }
.stat-card.accent .sc-value { color: #fff; }

.banner {
  display: flex; gap: 11px; align-items: flex-start; padding: 13px 15px; border-radius: 13px;
  font-size: 13px; line-height: 1.5; margin-bottom: 18px; border: 1px solid transparent;
}
.banner .b-icon { font-size: 18px; flex: 0 0 auto; }
.banner.warn { background: var(--amber-soft); color: var(--amber); border-color: #f0d5a8; }
.banner.info { background: var(--blue-soft); color: #1e40af; border-color: #cbdcff; }
.banner.ok { background: var(--green-soft); color: var(--green); border-color: #b9e6cd; }
.banner.error { background: var(--red-soft); color: var(--red); border-color: #f3c6c2; }
.banner b { font-weight: 800; }

.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 18px;
}
.problem-card { display: flex; flex-direction: column; gap: 10px; cursor: pointer; transition: .16s; }
.problem-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #c9dde9; }
.problem-head { display: flex; align-items: flex-start; gap: 10px; }
.problem-icon {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--teal-soft); font-size: 20px; flex: 0 0 40px;
}
.problem-title { font-weight: 800; font-size: 15.5px; line-height: 1.25; }
.problem-meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.problem-preview { color: var(--ink-2); font-size: 13px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.problem-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 6px; }
.mini-count { font-size: 12px; color: var(--muted); }

.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700;
  padding: 5px 9px; border-radius: 999px; white-space: nowrap;
}
.badge.gray { background: var(--line-2); color: var(--muted); }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.teal { background: var(--teal-soft); color: var(--teal-2); }

.empty-state {
  text-align: center; padding: 46px 20px; background: var(--card); border: 1px dashed #c9dbe7;
  border-radius: var(--radius); color: var(--muted);
}
.empty-state .es-icon { font-size: 44px; margin-bottom: 10px; }
.empty-state h3 { margin: 0 0 6px; color: var(--ink); font-size: 17px; }
.empty-state p { margin: 0 auto 16px; max-width: 520px; font-size: 13px; line-height: 1.55; }

/* ------------------------------ проблема ------------------------------ */
.problem-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.problem-header h2 { margin: 0 0 5px; font-size: 26px; letter-spacing: -.6px; }
.problem-header .sub { color: var(--muted); font-size: 13px; }
.problem-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.verdict-card {
  background: linear-gradient(160deg, #ffffff, #f6fcff); border: 1px solid #cfe8e4;
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 20px;
}
.verdict-card.stale { border-color: #f0d5a8; background: linear-gradient(160deg, #fffdf8, #fff8ec); }
.verdict-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.verdict-head h3 { margin: 0; font-size: 18px; letter-spacing: -.3px; }
.verdict-head .vh-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.verdict-block { border-top: 1px solid var(--line-2); padding: 13px 0 2px; }
.verdict-block:first-of-type { border-top: 0; padding-top: 4px; }
.verdict-block h4 { margin: 0 0 6px; font-size: 13px; color: var(--teal-2); letter-spacing: .1px; }
.verdict-block .pre { white-space: pre-wrap; font-size: 13.5px; line-height: 1.6; color: var(--ink-2); }
.verdict-block.flags h4 { color: var(--red); }
.verdict-block.flags .pre { color: var(--red); }
.verdict-placeholder { text-align: center; padding: 12px 8px 4px; }
.verdict-placeholder p { color: var(--muted); font-size: 13px; line-height: 1.55; max-width: 620px; margin: 0 auto 14px; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 26px 0 12px; flex-wrap: wrap; }
.section-head h3 { margin: 0; font-size: 18px; }
.section-head .sh-sub { color: var(--muted); font-size: 12.5px; }

.doc-list { display: grid; gap: 10px; }
.doc-row {
  display: flex; align-items: flex-start; gap: 12px; background: var(--card);
  border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px;
  cursor: pointer; transition: .15s;
}
.doc-row:hover { border-color: #c7dce8; box-shadow: var(--shadow-sm); }
.doc-ico {
  width: 38px; height: 38px; flex: 0 0 38px; display: grid; place-items: center;
  border-radius: 11px; background: var(--blue-soft); font-size: 19px;
}
.doc-main { flex: 1; min-width: 0; }
.doc-title { font-weight: 700; font-size: 14px; margin-bottom: 3px; }
.doc-meta { color: var(--muted); font-size: 12px; line-height: 1.45; }
.doc-preview { color: var(--ink-2); font-size: 12.5px; line-height: 1.5; margin-top: 7px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.doc-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: 0 0 auto; }

/* ------------------------------ документ ------------------------------ */
.doc-layout { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: 16px; align-items: start; }
.doc-preview-card { position: sticky; top: 78px; }
.file-frame {
  border: 1px solid var(--line); border-radius: 13px; overflow: hidden; background: #f8fbfd;
  min-height: 280px; display: grid; place-items: center;
}
.file-frame iframe { width: 100%; height: 66vh; border: 0; background: #fff; }
.file-frame img { max-width: 100%; max-height: 66vh; display: block; }
.file-frame .file-placeholder { text-align: center; padding: 40px 20px; color: var(--muted); font-size: 13px; }
.file-frame .file-placeholder .fp-icon { font-size: 52px; margin-bottom: 10px; }
.meta-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; margin: 14px 0; }
.meta-item { font-size: 12.5px; }
.meta-item .mi-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; font-weight: 700; }
.meta-item .mi-value { color: var(--ink-2); margin-top: 3px; word-break: break-word; }
.text-preview { white-space: pre-wrap; font-family: "Cascadia Code", "Consolas", monospace; font-size: 12px; line-height: 1.55; background: #f7fafc; border: 1px solid var(--line); border-radius: 11px; padding: 12px; max-height: 360px; overflow: auto; }
details.acc { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fbfdff; margin-top: 10px; }
details.acc summary { cursor: pointer; font-weight: 700; font-size: 13px; color: var(--ink-2); }
details.acc .acc-body { padding-top: 10px; }

/* ------------------------------ врач ------------------------------ */
.patient-row { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 13px 15px; cursor: pointer; }
.patient-row:hover { border-color: #c7dce8; box-shadow: var(--shadow-sm); }
.patient-avatar { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 50%; display: grid; place-items: center; background: var(--teal-soft); color: var(--teal-2); font-weight: 800; }
.patient-main { flex: 1; }
.patient-name { font-weight: 700; font-size: 14px; }
.patient-meta { color: var(--muted); font-size: 12px; }
.visit-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 10px; }
.visit-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.visit-title { font-weight: 700; font-size: 14px; }
.visit-meta { color: var(--muted); font-size: 12px; }
.visit-body { margin-top: 10px; }
.visit-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.live-box { border: 1px solid var(--line); border-radius: 14px; padding: 14px; background: #fbfdff; }
.live-timer { font-size: 26px; font-weight: 800; color: var(--red); letter-spacing: -1px; }
.live-transcript { max-height: 240px; overflow: auto; white-space: pre-wrap; font-size: 12.5px; line-height: 1.55; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 11px; margin-top: 10px; }
.question-list { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.55; }
.question-list li { margin-bottom: 6px; }

/* ------------------------------ админ ------------------------------ */
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; padding: 12px 14px; background: #f7fafc; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--line); }
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: #fbfdff; }
.td-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ------------------------------ кабинет ------------------------------ */
.profile-grid { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 16px; }
.profile-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.kv-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.kv-row:last-child { border-bottom: 0; }
.kv-row .k { color: var(--muted); }
.kv-row .v { font-weight: 700; text-align: right; word-break: break-word; }
.log-row { font-size: 12.5px; color: var(--ink-2); padding: 7px 0; border-bottom: 1px solid var(--line-2); }
.log-row:last-child { border-bottom: 0; }
.log-row .lt { color: var(--muted); margin-right: 8px; }

/* ------------------------------ модальные ------------------------------ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(6, 28, 38, .48);
  backdrop-filter: blur(3px); display: flex; align-items: flex-start; justify-content: center;
  padding: 34px 18px; overflow-y: auto; animation: fade .15s ease;
}
.modal {
  width: 100%; max-width: 620px; background: var(--card); border-radius: 20px;
  box-shadow: 0 30px 80px rgba(4, 24, 34, .30); overflow: hidden; animation: rise .18s ease;
}
.modal.wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-close { border: 0; background: transparent; font-size: 24px; line-height: 1; color: var(--muted); padding: 0 4px; }
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: #fbfdff; flex-wrap: wrap; }
.form-grid { display: grid; gap: 13px; }
.form-grid.two { grid-template-columns: 1fr 1fr; }
.form-grid label { display: grid; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.form-grid input, .form-grid select, .form-grid textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px;
  font-size: 14px; background: #fbfdff; outline: none;
}
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus {
  border-color: var(--teal); box-shadow: 0 0 0 3px rgba(15,159,143,.12); background: #fff;
}
.form-grid textarea { min-height: 84px; resize: vertical; }
.form-span { grid-column: 1 / -1; }
.dropzone {
  border: 2px dashed #c9dbe7; border-radius: 14px; padding: 26px 18px; text-align: center;
  background: #fbfdff; cursor: pointer; transition: .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--teal); background: var(--teal-soft); }
.dropzone .dz-icon { font-size: 34px; margin-bottom: 6px; }
.dropzone .dz-text { font-size: 13.5px; font-weight: 700; color: var(--ink-2); }
.dropzone .dz-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.dz-file { margin-top: 10px; font-size: 12.5px; color: var(--teal-2); font-weight: 700; word-break: break-all; }

/* ------------------------------ прочее ------------------------------ */
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; padding: 26px 0; justify-content: center; }
.spinner {
  width: 18px; height: 18px; border: 2px solid #cfe1ea; border-top-color: var(--teal);
  border-radius: 50%; animation: spin .8s linear infinite; display: inline-block;
}
.spinner.lg { width: 26px; height: 26px; border-width: 3px; }
.toast-root { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: grid; gap: 8px; max-width: 380px; }
.toast {
  background: var(--navy); color: #fff; padding: 12px 14px; border-radius: 12px;
  font-size: 13px; line-height: 1.45; box-shadow: 0 12px 30px rgba(4,24,34,.28);
  animation: rise .18s ease;
}
.toast.ok { background: #075e4f; }
.toast.error { background: #8f1d14; }
.toast.warn { background: #7a4a06; }

.skeleton { background: linear-gradient(90deg, #eef4f8 25%, #f8fbfd 50%, #eef4f8 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 10px; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ------------------------------ адаптив ------------------------------ */
@media (max-width: 1080px) {
  .auth-screen { grid-template-columns: 1fr; }
  .auth-hero { padding: 40px 30px; }
  .auth-hero h1 { font-size: 34px; }
  .auth-panel { padding: 26px 18px 42px; }
  .doc-layout { grid-template-columns: 1fr; }
  .doc-preview-card { position: static; }
  .profile-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 60;
    transform: translateX(-100%); transition: transform .2s ease; width: 280px;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 60px rgba(0,0,0,.3); }
  #menu-toggle { display: inline-grid; place-items: center; }
  .topbar { padding: 10px 14px; }
  .content { padding: 16px 14px 30px; }
  .page-head h2 { font-size: 20px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 12px; }
  .stat-card .sc-value { font-size: 23px; }
  .form-grid.two { grid-template-columns: 1fr; }
  .meta-grid { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 14px 10px; }
  .modal-body { padding: 15px; }
  .role-picker { grid-template-columns: 1fr; }
  .auth-hero { padding: 30px 20px; }
  .auth-hero h1 { font-size: 29px; }
  .hero-points li small { font-size: 12px; }
  .ai-pill { display: none; }
  .doc-row { padding: 11px; }
  .doc-side { align-items: flex-end; }
  .table-wrap { overflow-x: auto; }
  table.data { min-width: 680px; }
}
