:root {
  --bg: #f3f7fb;
  --bg-2: #eaf1f7;
  --card: #ffffff;
  --ink: #112630;
  --ink-2: #29414e;
  --muted: #566d7c;
  --line: #dde8f0;
  --line-2: #edf3f8;
  --teal: #0f9f8f;
  --teal-2: #0a7468;
  --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: #062a2f; }
.btn.primary:hover { background: var(--teal-2); border-color: var(--teal-2); color: #fff; }
.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; } }

/* ------------------------------ язык / RTL ------------------------------ */
.auth-top { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.lang-switch {
  display: inline-flex; gap: 3px; background: var(--line-2); padding: 3px;
  border-radius: 10px;
}
.lang {
  border: 0; background: transparent; color: var(--muted); font-size: 11px;
  font-weight: 700; padding: 5px 8px; border-radius: 8px; line-height: 1;
}
.lang:hover { color: var(--ink); }
.lang.active { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }
.app-lang { margin-right: 6px; }

[dir="rtl"] body {
  font-family: "Noto Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
}
[dir="rtl"] .topbar-right { margin-left: 0; margin-right: auto; }
[dir="rtl"] .app-lang { margin-right: 0; margin-left: 6px; }
[dir="rtl"] .nav-item { text-align: right; }
[dir="rtl"] .role-card { text-align: right; }
[dir="rtl"] .modal-foot { justify-content: flex-start; }
[dir="rtl"] .toast-root { right: auto; left: 18px; }
[dir="rtl"] table.data th, [dir="rtl"] table.data td { text-align: right; }
[dir="rtl"] .hero-disclaimer {
  border-left: 0; border-right: 3px solid rgba(125,232,218,.6);
  padding-left: 0; padding-right: 12px;
}
[dir="rtl"] .auth-top { justify-content: flex-start; }
[dir="rtl"] .back-link { text-align: right; }
[dir="rtl"] .file-frame iframe { direction: ltr; }

/* ------------------------------ адаптив ------------------------------ */
@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; }
}

/* --- ссылка на Telegram-бота --- */
.hero-bot {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 14px;
  background: rgba(255, 255, 255, .08);
  color: inherit;
  text-decoration: none;
  transition: background .15s ease, transform .15s ease;
}
.hero-bot:hover { background: rgba(255, 255, 255, .14); transform: translateY(-1px); }
.hero-bot b, .hero-bot small, .hero-bot-link { display: block; }
.hero-bot small { opacity: .82; line-height: 1.45; margin-top: 2px; }
.hero-bot-link { margin-top: 6px; font-weight: 700; color: #9ff3e7; }
.side-bot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}
.side-bot:hover { color: var(--teal); }

/* --- стенограмма приёма --- */
.transcript-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.transcript-tools input {
  flex: 1 1 240px; min-width: 180px; border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 12px; background: var(--card); color: var(--ink);
}
.tr-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.tr-chip {
  border: 1px solid var(--line); background: var(--card); color: var(--ink-2);
  border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 600;
}
.tr-chip.active { background: var(--teal-soft); border-color: var(--teal); color: var(--teal-2); }
.transcript-list { max-height: 58vh; overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
.transcript-row {
  display: grid; grid-template-columns: 62px 130px 1fr; gap: 10px;
  padding: 9px 12px; border-bottom: 1px solid var(--line-2); font-size: 13px;
}
.transcript-row:last-child { border-bottom: 0; }
.transcript-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.transcript-speaker { color: var(--teal-2); font-weight: 700; }
.transcript-text { color: var(--ink-2); line-height: 1.45; }
@media (max-width: 760px) {
  .transcript-row { grid-template-columns: 48px 1fr; }
  .transcript-speaker { grid-column: 2; margin-bottom: 2px; }
  .transcript-text { grid-column: 2; }
}

.tr-roles {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  margin-bottom: 12px; background: #fbfdff;
}
.tr-roles-title { font-weight: 700; margin-bottom: 2px; }
.tr-roles-hint { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.tr-role-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin: 6px 0; font-size: 13px;
}
.tr-role-row select {
  border: 1px solid var(--line); border-radius: 9px; padding: 6px 9px;
  background: var(--card); color: var(--ink-2); min-width: 190px;
}
.tr-roles .btn { margin-top: 8px; }

/* --- главное за 30 секунд --- */
.quick-summary {
  margin-top: 10px; padding: 12px 14px; border-radius: 12px;
  background: linear-gradient(135deg, #f0fbf8, #eef6ff);
  border: 1px solid #d9eee9;
}
.quick-title { font-weight: 800; color: var(--teal-2); margin-bottom: 6px; }
.quick-item { font-size: 13px; line-height: 1.5; color: var(--ink-2); margin: 4px 0; }
.quick-item b { color: var(--ink); }

/* --- задачи приёма --- */
.visit-tasks {
  margin-top: 10px; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--card);
}
.visit-tasks-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.task-row {
  display: flex; align-items: center; gap: 8px; padding: 7px 0;
  border-bottom: 1px solid var(--line-2); font-size: 13px;
}
.task-row:last-of-type { border-bottom: 0; }
.task-row input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--teal); }
.task-row span { flex: 1; line-height: 1.4; }
.task-row.done span { text-decoration: line-through; color: var(--muted); }
.task-del {
  border: 0; background: transparent; color: var(--muted); font-size: 18px;
  line-height: 1; padding: 0 4px;
}
.task-del:hover { color: var(--red); }
.task-add { display: flex; gap: 6px; margin-top: 8px; }
.task-add input {
  flex: 1; border: 1px solid var(--line); border-radius: 9px;
  padding: 7px 10px; background: #fbfdff; color: var(--ink);
}

/* --- чат по приёму --- */
.chat-list {
  max-height: 52vh; overflow: auto; display: flex; flex-direction: column;
  gap: 8px; padding: 4px 2px 10px;
}
.chat-msg { max-width: 86%; border-radius: 12px; padding: 9px 12px; font-size: 13px; line-height: 1.45; }
.chat-msg.assistant { align-self: flex-start; background: var(--teal-soft); color: var(--ink-2); }
.chat-msg.user { align-self: flex-end; background: var(--blue-soft); color: var(--ink-2); }
.chat-role { font-size: 11px; font-weight: 700; color: var(--muted); margin-bottom: 3px; }
.chat-text { white-space: pre-wrap; }
.chat-input { display: flex; gap: 8px; margin-top: 6px; }
.chat-input input {
  flex: 1; border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 12px; background: #fbfdff; color: var(--ink);
}

.notif-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 0;
  border-bottom: 1px solid var(--line-2); font-size: 13px;
}
.notif-row:last-of-type { border-bottom: 0; }
.notif-row input { width: 17px; height: 17px; accent-color: var(--teal); }

.tr-ai-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0 10px; }
.tr-ai-row .hint { margin: 0; }
.tr-role-item { margin: 6px 0; }
.tr-ai-reason { color: var(--muted); font-size: 11.5px; margin: 2px 0 0 6px; min-height: 0; }

/* --- привязка Telegram --- */
.tg-code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 30px; font-weight: 800; letter-spacing: 6px;
  text-align: center; padding: 16px; margin: 10px 0;
  border: 1px dashed var(--teal); border-radius: 14px;
  background: var(--teal-soft); color: var(--teal-2);
}
.tg-actions { display: flex; gap: 8px; flex-wrap: wrap; }

button.transcript-seek {
  border: 0; background: transparent; padding: 0; text-align: left;
  color: var(--muted); cursor: pointer; font: inherit;
  text-decoration: underline dotted; text-underline-offset: 3px;
}
button.transcript-seek:hover { color: var(--teal-2); }

/* --- тёмная тема --- */
html[data-theme="dark"] {
  --bg: #0b141a;
  --bg-2: #0f1c24;
  --card: #12212b;
  --ink: #e8f1f5;
  --ink-2: #c4d6df;
  --muted: #8fa6b2;
  --line: #243a46;
  --line-2: #1d303a;
  --teal: #2dd4bf;
  --teal-2: #5eead4;
  --teal-soft: #123c38;
  --blue: #60a5fa;
  --blue-soft: #132b45;
  --navy: #081116;
  --navy-2: #0c1a22;
  --green: #34d399;
  --green-soft: #123326;
  --amber: #fbbf24;
  --amber-soft: #3a2a12;
  --red: #f87171;
  --red-soft: #3a1715;
  --shadow: 0 12px 34px rgba(0, 0, 0, .35);
  --shadow-sm: 0 3px 12px rgba(0, 0, 0, .25);
}
html[data-theme="dark"] body { background: var(--bg); color: var(--ink); }
html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
  background: #0f1c24 !important;
  color: var(--ink) !important;
  border-color: var(--line) !important;
}
html[data-theme="dark"] .lang.active,
html[data-theme="dark"] .auth-tab.active {
  background: #1b3340;
  color: var(--ink);
}
html[data-theme="dark"] .btn.primary:hover { color: #062a2f; }
html[data-theme="dark"] .auth-hero {
  background: linear-gradient(160deg, #0d3442, #081116);
}
html[data-theme="dark"] .dropzone,
html[data-theme="dark"] .card,
html[data-theme="dark"] .profile-card,
html[data-theme="dark"] .visit-card,
html[data-theme="dark"] .modal {
  background: var(--card);
  color: var(--ink);
}
html[data-theme="dark"] .quick-summary {
  background: linear-gradient(135deg, #102c2a, #102238);
  border-color: #1e4a46;
}
html[data-theme="dark"] .tr-roles { background: #0f1c24; }
html[data-theme="dark"] .transcript-list { background: var(--card); }
html[data-theme="dark"] .banner.info { background: #102a3a; }

/* --- глобальный поиск --- */
.gs-input {
  width: 100%; border: 1px solid var(--line); border-radius: 11px;
  padding: 11px 13px; background: var(--card); color: var(--ink);
}
.gs-group { margin-top: 10px; }
.gs-head { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.gs-row {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 9px 8px; border-radius: 9px; color: var(--ink-2); cursor: pointer;
}
.gs-row:hover { background: var(--teal-soft); }
.gs-row small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

/* --- mindmap --- */
.mindmap { display: flex; flex-direction: column; gap: 10px; }
.mm-root {
  align-self: center; padding: 12px 20px; border-radius: 14px;
  background: var(--navy); color: #fff; font-weight: 800; text-align: center;
}
.mm-branch {
  border-left: 3px solid var(--teal); padding: 6px 0 6px 14px;
}
.mm-label { font-weight: 800; color: var(--teal-2); margin-bottom: 4px; }
.mm-children { display: flex; flex-wrap: wrap; gap: 6px; }
.mm-item {
  padding: 5px 9px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--card); color: var(--ink-2); font-size: 12px;
}

/* --- публичный SEO-лендинг --- */
.hero-links { margin-top: 18px; display: flex; gap: 9px; flex-wrap: wrap; }
.hero-links a {
  color: #c8f3ec; text-decoration: none; font-size: 12.5px; font-weight: 700;
  border: 1px solid rgba(125, 232, 218, .38); border-radius: 999px;
  padding: 7px 13px; background: rgba(255, 255, 255, .05);
}
.hero-links a:hover { background: rgba(255, 255, 255, .12); }

.seo-content {
  grid-column: 1 / -1; background: var(--bg); color: var(--ink);
  border-top: 1px solid var(--line); padding: 48px 32px 30px;
}
.seo-inner { max-width: 1080px; margin: 0 auto; }
.seo-kicker {
  text-transform: uppercase; letter-spacing: .09em; font-size: 12px;
  font-weight: 800; color: var(--teal-2); margin: 0 0 8px;
}
.seo-head h2 {
  font-size: clamp(26px, 3vw, 38px); line-height: 1.15; margin: 0 0 12px;
  letter-spacing: -.5px;
}
.seo-head > p { max-width: 860px; color: var(--ink-2); line-height: 1.7; margin: 0; font-size: 15.5px; }
.seo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: 30px 0; }
.seo-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 22px 22px 18px; box-shadow: var(--shadow-sm);
}
.seo-card h3 { margin: 0 0 8px; font-size: 19px; }
.seo-card p { color: var(--ink-2); line-height: 1.6; margin: 0; font-size: 14px; }
.seo-card ul { margin: 12px 0 0; padding-inline-start: 20px; color: var(--ink-2); line-height: 1.65; font-size: 14px; }
.seo-card li { margin-bottom: 6px; }
.seo-steps, .seo-faq { margin: 34px 0; }
.seo-steps h3, .seo-faq h3, .seo-trust h3 { font-size: 21px; margin: 0 0 14px; }
.seo-steps ol {
  list-style: none; counter-reset: seostep; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px;
}
.seo-steps li {
  counter-increment: seostep; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 14px 14px; position: relative;
}
.seo-steps li::before {
  content: counter(seostep); display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: 50%; background: var(--teal);
  color: #062a2f; font-weight: 800; font-size: 13px; margin-bottom: 10px;
}
.seo-steps b { display: block; font-size: 14.5px; margin-bottom: 5px; }
.seo-steps span { display: block; color: var(--muted); font-size: 13px; line-height: 1.55; }
.seo-faq details { border-bottom: 1px solid var(--line); padding: 12px 0; }
.seo-faq summary { cursor: pointer; font-weight: 700; font-size: 14.5px; }
.seo-faq summary:hover { color: var(--teal-2); }
.seo-faq p { color: var(--ink-2); line-height: 1.65; font-size: 14px; margin: 10px 0 0; max-width: 900px; }
.seo-trust {
  background: var(--teal-soft); border: 1px solid rgba(45, 212, 191, .25);
  border-radius: 16px; padding: 20px 22px; margin: 30px 0 0;
}
.seo-trust p { margin: 0; color: var(--ink-2); line-height: 1.65; font-size: 14px; }
.seo-footer {
  border-top: 1px solid var(--line); margin-top: 28px; padding-top: 18px;
  display: flex; gap: 12px 22px; flex-wrap: wrap; justify-content: space-between;
  align-items: flex-start; color: var(--muted); font-size: 13px;
}
.seo-footer div { display: flex; gap: 14px; flex-wrap: wrap; }
.seo-footer a { color: var(--teal-2); text-decoration: none; }
.seo-footer a:hover { text-decoration: underline; }
.seo-footer p { margin: 0; max-width: 640px; line-height: 1.55; }
@media (max-width: 900px) {
  .seo-content { padding: 36px 22px 26px; }
  .seo-grid { grid-template-columns: 1fr; }
  .seo-steps ol { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .seo-steps ol { grid-template-columns: 1fr; }
  .seo-footer { display: block; }
  .seo-footer p { margin-top: 10px; }
}
