:root {
  --bg:#f4f7f8; --surface:#fff; --surface-2:#f7fafa;
  --ink:#111827; --ink-2:#374151; --muted:#6b7280; --muted-2:#9ca3af;
  --line:#e5eaed; --line-2:#d6dee2;
  --teal:#0d9488; --teal-2:#0f766e; --teal-soft:#ecfdf5; --teal-soft-2:#d1fae5;
  --indigo:#6366f1; --indigo-2:#4f46e5; --slate:#64748b;
  --green:#10b981; --green-soft:#d1fae5;
  --danger:#b91c1c; --danger-soft:#fef2f2;
  --warn:#b45309; --warn-soft:#fffbeb;
  --radius:10px; --radius-sm:7px; --radius-pill:999px;
  --shadow-sm:0 1px 2px rgba(17,24,39,.04);
  --shadow:0 1px 3px rgba(17,24,39,.06), 0 1px 2px rgba(17,24,39,.04);
  --shadow-md:0 10px 30px rgba(17,24,39,.08);
  --font:"Inter","Segoe UI",Roboto,Arial,sans-serif;
  --sidebar-w:280px; --sidebar-w-collapsed:72px;
  --sidebar-pad:16px; --sidebar-pad-r:8px;
  --topbar-h:60px; --logo-size:32px; --icon-size:28px;
  --select-arrow:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  --select-arrow-hover:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%230d9488' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}
* { box-sizing:border-box; }
html, body { height:100%; }
body { margin:0; background:var(--bg); color:var(--ink); font-family:var(--font); font-size:13.5px; -webkit-font-smoothing:antialiased; }
button { font-family:inherit; }
.hidden { display:none !important; }

select {
  appearance:none; -webkit-appearance:none; -moz-appearance:none;
  background-image:var(--select-arrow); background-repeat:no-repeat;
  background-position:right 12px center; background-size:14px;
  padding-right:34px !important; cursor:pointer;
  transition:border-color .15s, box-shadow .15s, background-image .15s;
}
select:hover { background-image:var(--select-arrow-hover); }
select:focus { background-image:var(--select-arrow-hover); outline:none; border-color:var(--teal) !important; box-shadow:0 0 0 3px var(--teal-soft-2); }

/* ===== Sidebar ===== */
.sidebar {
  position:fixed; top:0; left:0;
  width:var(--sidebar-w); height:100vh;
  background:#fff; border-right:1px solid var(--line);
  display:flex; flex-direction:column; overflow:hidden;
  padding:0 var(--sidebar-pad-r) 0 var(--sidebar-pad);
  z-index:30; transition:width .25s cubic-bezier(.4,0,.2,1), box-shadow .2s ease;
}
.brand {
  flex:0 0 auto; height:var(--topbar-h);
  display:flex; align-items:center; gap:10px;
  margin:0 calc(-1 * var(--sidebar-pad-r)) 0 calc(-1 * var(--sidebar-pad));
  padding:0 var(--sidebar-pad-r) 0 var(--sidebar-pad);
  border-bottom:1px solid var(--line); background:#fff; overflow:hidden;
  transition:padding .25s cubic-bezier(.4,0,.2,1), gap .25s cubic-bezier(.4,0,.2,1);
}
.brand-mark {
  width:var(--logo-size); height:var(--logo-size);
  flex:0 0 var(--logo-size);
  border-radius:5px;
  background:linear-gradient(135deg, var(--teal) 0%, var(--teal-2) 100%);
  color:#fff;
  display:flex; align-items:center; justify-content:center;
  line-height:0;
  box-shadow:0 3px 10px rgba(13,148,136,.22);
  transition:background .15s, box-shadow .15s;
}
.brand-mark svg { width:16px; height:16px; display:block; pointer-events:none; }
.brand-text {
  flex:0 1 auto; min-width:0; overflow:hidden;
  max-width:220px; opacity:1;
  transition:max-width .3s cubic-bezier(.4,0,.2,1), opacity .2s ease;
  white-space:nowrap;
}
.brand-title { font-size:9.5px; font-weight:800; letter-spacing:.01em; line-height:1.15; color:var(--ink); white-space:nowrap; overflow:hidden; }
.brand-sub { font-size:8.5px; color:var(--muted); letter-spacing:.03em; text-transform:uppercase; margin-top:2px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

.sidebar-nav {
  flex:1 1 auto; overflow-y:auto; overflow-x:hidden;
  padding:6px 6px 6px 15px;
  scrollbar-width:thin; scrollbar-color:#d6dee2 transparent;
  transition:padding .25s cubic-bezier(.4,0,.2,1);
}
.sidebar-nav::-webkit-scrollbar { width:6px; }
.sidebar-nav::-webkit-scrollbar-track { background:transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background:#d6dee2; border-radius:3px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background:var(--teal); }

.nav-section {
  display:flex; align-items:center; gap:8px;
  padding:6px 12px 6px 6px; margin:2px 0;
  background:transparent; border-radius:6px;
  font-size:10px; font-weight:700; letter-spacing:.08em; text-transform:uppercase;
  color:var(--muted-2); cursor:pointer; user-select:none;
  transition:color .15s, background .15s;
}
.nav-section:hover { color:var(--ink-2); }
.nav-section-icon {
  width:var(--icon-size); height:var(--icon-size);
  flex:0 0 var(--icon-size); min-width:var(--icon-size); min-height:var(--icon-size);
  display:flex; align-items:center; justify-content:center;
  color:var(--teal-2); border-radius:5px; aspect-ratio:1/1;
  transition:background .15s, color .15s;
}
.nav-section-icon svg { width:14px; height:14px; }
.nav-section-label { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; opacity:1; transition:opacity .15s ease .25s; }
.nav-caret { width:12px; height:12px; flex-shrink:0; transition:transform .2s ease, opacity .15s ease .25s; transform:rotate(-90deg); opacity:1; }
.nav-section.expanded .nav-caret { transform:rotate(0deg); }

.nav-group {
  display:flex; flex-direction:column; gap:0;
  max-height:800px; overflow:hidden; opacity:1;
  transition:max-height .28s cubic-bezier(.4,0,.2,1), opacity .2s ease;
}
.nav-group[data-collapsed="true"] { max-height:0; opacity:0; }

.nav-item {
  display:flex; align-items:center; gap:8px;
  padding:5px 10px 3px 35px; border-radius:5px;
  color:var(--ink-2); font-size:12.5px; font-weight:500;
  cursor:pointer; user-select:none; margin:0;
  border:0; background:transparent; width:100%; text-align:left;
  transition:background .15s, color .15s;
}
.nav-icon {
  width:var(--icon-size); height:var(--icon-size);
  flex:0 0 var(--icon-size); min-width:var(--icon-size); min-height:var(--icon-size);
  display:flex; align-items:center; justify-content:center;
  color:var(--muted); border-radius:5px; aspect-ratio:1/1;
  transition:background .15s, color .15s;
}
.nav-icon svg { width:16px; height:16px; }
.nav-label { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; opacity:1; transition:opacity .15s ease .25s; }
.nav-badge {
  flex-shrink:0; font-size:9px; font-weight:700; letter-spacing:.05em;
  text-transform:uppercase; color:var(--muted);
  background:var(--surface-2); border:1px solid var(--line);
  padding:0 5px; line-height:14px; border-radius:var(--radius-pill); white-space:nowrap;
}
.nav-item:hover { background:rgba(13,148,136,.06); color:var(--ink); }
.nav-item:hover .nav-icon { color:var(--teal); }
.nav-item.active { background:rgba(13,148,136,.10); color:var(--teal-2); font-weight:600; }
.nav-item.active .nav-icon { color:var(--teal); }

/* ===== Collapsed sidebar ===== */
body.sidebar-collapsed .sidebar { width:var(--sidebar-w-collapsed); }
@media (min-width:901px) {
  body.sidebar-collapsed .sidebar { overflow:visible; }
  body.sidebar-collapsed .sidebar-nav { overflow:visible; }
}
body.sidebar-collapsed .sidebar .brand { padding:0; gap:0; justify-content:center; }
body.sidebar-collapsed .sidebar .brand-text { max-width:0; opacity:0; }
body.sidebar-collapsed .sidebar .brand-mark { cursor:pointer; }
body.sidebar-collapsed .sidebar .brand-mark:hover {
  background:linear-gradient(135deg, var(--teal-2) 0%, var(--teal) 100%);
  box-shadow:0 4px 14px rgba(13,148,136,.3);
}
body.sidebar-collapsed .sidebar .sidebar-nav { padding:8px 0; }
body.sidebar-collapsed .sidebar .nav-item { display:none; }
body.sidebar-collapsed .sidebar .nav-group { display:none; }

/* Разделы в компактном виде — только иконки-кнопки + тултип.
   Без двойного контура: подсветка только на иконке. */
body.sidebar-collapsed .sidebar .nav-section {
  position:relative;
  padding:4px 0; margin:4px 0;
  justify-content:center; gap:0;
  border-radius:8px; color:var(--teal-2);
  background:transparent;
}
body.sidebar-collapsed .sidebar .nav-section-label,
body.sidebar-collapsed .sidebar .nav-caret { display:none; }
body.sidebar-collapsed .sidebar .nav-section-icon {
  width:44px; height:44px;
  flex:0 0 44px; min-width:44px; min-height:44px;
  border-radius:8px;
  background:transparent;
}
body.sidebar-collapsed .sidebar .nav-section-icon svg { width:20px; height:20px; }
body.sidebar-collapsed .sidebar .nav-section:hover,
body.sidebar-collapsed .sidebar .nav-section.has-active { background:transparent; }
body.sidebar-collapsed .sidebar .nav-section:hover .nav-section-icon {
  background:var(--teal-soft); color:var(--teal);
}
body.sidebar-collapsed .sidebar .nav-section.has-active .nav-section-icon {
  background:var(--teal-soft-2); color:var(--teal);
}

/* Тултип раздела в компактном режиме */
body.sidebar-collapsed .sidebar .nav-section::after {
  content: attr(data-tooltip);
  position:absolute;
  left:calc(100% + 10px); top:50%; transform:translateY(-50%);
  background:var(--ink); color:#fff;
  padding:6px 10px; border-radius:6px;
  font-size:11.5px; font-weight:500; line-height:1.2;
  white-space:nowrap; pointer-events:none;
  opacity:0; transition:opacity .15s ease; z-index:100;
  text-transform:none; letter-spacing:0;
  box-shadow:0 4px 14px rgba(17,24,39,.18);
}
body.sidebar-collapsed .sidebar .nav-section::before {
  content:""; position:absolute;
  left:calc(100% + 4px); top:50%; transform:translateY(-50%);
  border:5px solid transparent; border-right-color:var(--ink);
  pointer-events:none; opacity:0; transition:opacity .15s ease; z-index:100;
}
body.sidebar-collapsed .sidebar .nav-section:hover::after,
body.sidebar-collapsed .sidebar .nav-section:hover::before { opacity:1; }
@media (max-width:900px) {
  body.sidebar-collapsed .sidebar .nav-section::after,
  body.sidebar-collapsed .sidebar .nav-section::before { display:none; }
}

body.sidebar-collapsed .sidebar .sidebar-actions { padding:10px 0; align-items:center; }
body.sidebar-collapsed .sidebar .sidebar-toggle,
body.sidebar-collapsed .sidebar .support-btn { width:36px; padding:8px 0; gap:0; justify-content:center; }
body.sidebar-collapsed .sidebar .toggle-label,
body.sidebar-collapsed .sidebar .support-label { display:none; }
body.sidebar-collapsed .sidebar .sidebar-foot { padding:10px 0; justify-content:center; }
body.sidebar-collapsed .sidebar .foot-full { display:none; }
body.sidebar-collapsed .sidebar .foot-short { display:inline; }

/* ===== Sidebar actions ===== */
.sidebar-actions {
  flex:0 0 auto;
  margin:0 calc(-1 * var(--sidebar-pad-r)) 0 calc(-1 * var(--sidebar-pad));
  padding:10px var(--sidebar-pad-r) 10px var(--sidebar-pad);
  border-top:1px solid var(--line); background:#fff;
  display:flex; flex-direction:column; gap:8px;
  transition:padding .25s cubic-bezier(.4,0,.2,1);
}
.actions-divider {
  height:1px; background:var(--line); border:0; align-self:stretch;
  margin:0 calc(-1 * var(--sidebar-pad-r)) 0 calc(-1 * var(--sidebar-pad));
}
.support-btn, .sidebar-toggle {
  display:flex; align-items:center; gap:8px;
  width:100%; padding:8px 10px;
  border:1px solid var(--line); border-radius:7px;
  background:#fff; color:var(--ink-2);
  font-size:12px; font-weight:500;
  cursor:pointer; white-space:nowrap; overflow:hidden;
  justify-content:flex-start;
  transition:width .25s cubic-bezier(.4,0,.2,1), padding .25s cubic-bezier(.4,0,.2,1),
             border-color .15s, color .15s, background .15s;
}
.support-btn:hover, .sidebar-toggle:hover {
  border-color:var(--teal); color:var(--teal); background:var(--teal-soft);
}
.support-btn svg, .sidebar-toggle svg { flex:0 0 16px; width:16px; height:16px; }
.support-label, .toggle-label { flex:1 1 auto; min-width:0; overflow:hidden; text-overflow:ellipsis; text-align:left; }
.sidebar-toggle .toggle-pin { display:none; }
body.sidebar-collapsed .sidebar-toggle .toggle-chevron { display:none; }
body.sidebar-collapsed .sidebar-toggle .toggle-pin { display:block; }

.sidebar-foot {
  flex:0 0 auto;
  margin:0 calc(-1 * var(--sidebar-pad-r)) 0 calc(-1 * var(--sidebar-pad));
  padding:10px var(--sidebar-pad-r) 10px var(--sidebar-pad);
  border-top:1px solid var(--line); background:#fff;
  font-size:10.5px; color:var(--muted-2); line-height:1.3;
  display:flex; align-items:center; justify-content:flex-start;
  text-align:left;
  transition:padding .25s cubic-bezier(.4,0,.2,1);
}
.sidebar-foot .foot-short { display:none; }
.sidebar-foot a { color:var(--muted); text-decoration:none; transition:color .15s; }
.sidebar-foot a:hover { color:var(--teal); text-decoration:underline; }
.sidebar-foot .dot-sep { margin:0 6px; opacity:.55; }

/* ===== Main / topbar / iframe ===== */
.main {
  margin-left:var(--sidebar-w);
  height:100vh;
  display:flex; flex-direction:column;
  transition:margin-left .3s cubic-bezier(.4,0,.2,1);
}
body.sidebar-collapsed .main { margin-left:var(--sidebar-w-collapsed); }

.topbar {
  position:relative; flex:0 0 auto; z-index:20;
  background:rgba(255,255,255,.9); backdrop-filter:blur(8px);
  border-bottom:1px solid var(--line);
  height:var(--topbar-h);
  padding:0 28px;
  display:flex; align-items:center; gap:16px; flex-wrap:nowrap;
}
.page-title { font-size:15px; font-weight:600; letter-spacing:-.01em; margin:0; color:var(--ink); white-space:nowrap; }
.ctx-group { margin-left:auto; display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.ctx-pill {
  display:inline-flex; align-items:center; gap:8px;
  padding:6px 12px; background:var(--surface-2);
  border:1px solid var(--line); border-radius:var(--radius-pill);
  font-size:12px; color:var(--ink-2); white-space:nowrap;
}
.ctx-pill .lab { font-size:10.5px; color:var(--muted); text-transform:uppercase; letter-spacing:.12em; font-weight:600; }
.ctx-pill b { color:var(--ink); font-weight:600; }
#ctxYear, #ctxSem { text-transform:uppercase; letter-spacing:.04em; }
.ctx-dot { width:8px; height:8px; border-radius:50%; flex:0 0 auto; background:#fff; border:2px solid var(--teal); }

#contentFrame {
  flex:1 1 auto;
  border:0;
  width:100%;
  min-height:0;
  background:var(--bg);
  display:block;
}

.user { position:relative; }
.user-btn { display:flex; align-items:center; gap:10px; background:transparent; border:none; padding:5px 8px 5px 14px; border-radius:8px; cursor:pointer; transition:background .15s; }
.user-btn:hover { background:var(--surface-2); }
.user-avatar-wrap { position:relative; flex:0 0 var(--logo-size); width:var(--logo-size); height:var(--logo-size); order:2; }
.user-avatar {
  width:var(--logo-size); height:var(--logo-size); border-radius:8px;
  background:linear-gradient(135deg, var(--teal) 0%, var(--teal-2) 100%);
  color:#fff; font-weight:700; font-size:12.5px;
  display:flex; align-items:center; justify-content:center;
  background-size:cover; background-position:center; overflow:hidden;
}
.user-meta { display:flex; flex-direction:column; align-items:flex-end; text-align:right; line-height:1.2; min-width:0; order:1; }
.user-name { font-size:12px; font-weight:600; color:var(--ink); white-space:nowrap; }
.user-status { font-size:10px; color:var(--teal-2); font-weight:500; }

.notif-badge {
  position:absolute; top:-5px; right:-5px;
  min-width:16px; height:16px; padding:0 4px;
  border-radius:8px; background:#dc2626; color:#fff;
  font-size:9px; font-weight:700;
  display:flex; align-items:center; justify-content:center;
  border:2px solid #fff; box-shadow:0 1px 3px rgba(0,0,0,.15); pointer-events:none;
}

.user-menu {
  position:absolute; right:0; top:calc(100% + 8px);
  min-width:240px; background:#fff;
  border:1px solid var(--line); border-radius:var(--radius);
  box-shadow:var(--shadow-md); padding:6px;
  display:none; z-index:50;
}
.user.open .user-menu { display:block; animation:pop .15s ease; }
.user-menu a { display:flex; align-items:center; gap:10px; padding:9px 10px; border-radius:var(--radius-sm); color:var(--ink-2); font-size:13px; text-decoration:none; cursor:pointer; }
.user-menu a svg { display:block; width:16px; height:16px; flex:0 0 16px; color:var(--muted); transition:color .15s; }
.user-menu a:hover { background:var(--surface-2); color:var(--ink); }
.user-menu a:hover svg { color:var(--teal); }
.user-menu a.danger:hover { background:var(--danger-soft); color:var(--danger); }
.user-menu a.danger:hover svg { color:var(--danger); }
.user-menu .divider { height:1px; background:var(--line); margin:6px 4px; }
.user-menu .menu-head { padding:10px 12px 8px; display:flex; flex-direction:column; gap:2px; }
.user-menu .menu-head .n { font-size:13px; font-weight:600; color:var(--ink); }
.user-menu .menu-head .r { font-size:11.5px; color:var(--muted); }
.user-menu .menu-badge {
  margin-left:auto; font-size:10px; font-weight:700;
  background:#dc2626; color:#fff;
  min-width:18px; height:18px; padding:0 5px;
  border-radius:9px; display:inline-flex; align-items:center; justify-content:center;
}

/* ===== Buttons ===== */
.btn {
  display:inline-flex; align-items:center; justify-content:center; gap:6px;
  border:1px solid var(--line-2); background:#fff; color:var(--ink);
  padding:7px 14px; border-radius:6px; cursor:pointer;
  font-size:12.5px; font-weight:500;
  transition:background .15s, border-color .15s, color .15s, box-shadow .15s;
  white-space:nowrap;
}
.btn:hover { border-color:var(--teal); color:var(--teal); }
.btn.primary {
  padding: 10px 14px;
  background:var(--teal); border-color:var(--teal); color:#fff;
  box-shadow:0 3px 10px rgba(13,148,136,.2);
}
.btn.primary:hover { background:var(--teal-2); border-color:var(--teal-2); color:#fff; }
.btn.danger { color:var(--danger); border-color:#fecaca; }
.btn.danger:hover { background:var(--danger-soft); border-color:#fca5a5; }
.btn.sm { padding:5px 10px; font-size:11.5px; border-radius:5px; }
.btn.full { width:100%; }

/* ===== Drawers ===== */
.drawer-bg {
  position:fixed; inset:0;
  background:rgba(17,24,39,0); z-index:1000;
  display:flex; justify-content:flex-end; pointer-events:none;
  transition:background .25s ease;
}
.drawer-bg.open { background:rgba(17,24,39,.42); pointer-events:auto; }
.drawer {
  width:440px; max-width:100%;
  background:#fff; height:100vh;
  display:flex; flex-direction:column;
  border-left:1px solid var(--line);
  transform:translateX(100%);
  transition:transform .3s cubic-bezier(.2,.8,.2,1);
  overflow:hidden;
}
.drawer-bg.open .drawer { transform:translateX(0); }
.drawer-head {
  display:flex; align-items:center; gap:10px;
  padding:16px 20px; border-bottom:1px solid var(--line);
  background:var(--surface); flex:0 0 auto;
}
.drawer-head h2 { font-weight:600; font-size:15px; margin:0; color:var(--ink); letter-spacing:-.01em; }
.drawer-head .close {
  margin-left:auto; border:0; background:transparent;
  font-size:22px; line-height:1; color:var(--muted);
  cursor:pointer; padding:4px 6px; border-radius:6px;
  transition:background .15s, color .15s;
}
.drawer-head .close:hover { background:var(--surface-2); color:var(--ink); }
.drawer-body {
  flex:1 1 auto; padding:20px;
  display:flex; flex-direction:column; gap:14px;
  overflow-y:auto; scrollbar-width:thin; scrollbar-color:#d6dee2 transparent;
  scrollbar-gutter:stable;
}
.drawer-body::-webkit-scrollbar { width:6px; }
.drawer-body::-webkit-scrollbar-track { background:transparent; }
.drawer-body::-webkit-scrollbar-thumb { background:#d6dee2; border-radius:3px; }
.drawer-foot {
  flex:0 0 auto; padding:14px 20px;
  border-top:1px solid var(--line);
  display:flex; gap:8px; justify-content:flex-end;
  background:var(--surface-2);
}
.drawer-foot .btn { min-width:0; flex:1 1 auto; }

/* ===== Fields ===== */
.dfield { display:flex; flex-direction:column; gap:6px; }
.dfield label { font-size:10.5px; color:var(--muted); font-weight:600; text-transform:uppercase; letter-spacing:.08em; }
.dfield label .req { color:var(--danger); margin-left:2px; }
.dfield input, .dfield select, .dfield textarea {
  padding:9px 12px; border:1px solid var(--line-2); border-radius:7px;
  font-size:13px; background:var(--surface); color:var(--ink);
  width:100%; min-width:0; font-family:var(--font);
  transition:border-color .15s, box-shadow .15s;
}
.dfield textarea { resize:vertical; min-height:96px; line-height:1.45; }
.dfield input::placeholder, .dfield textarea::placeholder { color:var(--muted-2); }
.dfield input:focus, .dfield select:focus, .dfield textarea:focus {
  outline:none; border-color:var(--teal); box-shadow:0 0 0 3px var(--teal-soft-2);
}
.dfield input:disabled, .dfield select:disabled, .dfield textarea:disabled {
  background:var(--surface-2); color:var(--ink-2); cursor:not-allowed; border-color:var(--line);
}
.field-error { font-size:11px; color:var(--danger); margin-top:2px; line-height:1.3; }
.field-error.hidden { display:none; }
.input-error { border-color:#fca5a5 !important; box-shadow:0 0 0 3px #fee2e2 !important; }

.file-drop {
  display:flex; align-items:center; gap:12px; padding:12px;
  border:2px dashed var(--line-2); border-radius:8px;
  background:var(--surface-2); cursor:pointer;
  transition:border-color .15s, background .15s; min-height:80px;
}
.file-drop:hover, .file-drop.dragover { border-color:var(--teal); background:var(--teal-soft); }
.file-drop-avatar {
  width:56px; height:56px; flex:0 0 56px; border-radius:8px;
  background:linear-gradient(135deg, var(--teal) 0%, var(--teal-2) 100%);
  color:#fff; font-weight:700; font-size:18px;
  display:flex; align-items:center; justify-content:center;
  border:1px solid var(--line);
  background-size:cover; background-position:center; overflow:hidden;
}
.file-drop-body { flex:1; min-width:0; display:flex; flex-direction:column; gap:3px; }
.file-drop-title { font-size:12.5px; font-weight:600; color:var(--ink); }
.file-drop-hint { font-size:11px; color:var(--muted); }

.conflict { background:var(--danger-soft); color:var(--danger); border:1px solid #fecaca; border-radius:6px; padding:8px 10px; font-size:12px; }
.conflict.hidden { display:none; }

/* ===== Notifications ===== */
.notif-item {
  padding:12px 14px;
  border:1px solid var(--line); border-left:3px solid transparent;
  border-radius:8px; background:var(--surface-2);
  display:flex; flex-direction:column; gap:4px;
  transition:background .15s, border-color .15s, box-shadow .15s;
}
.notif-item:hover { box-shadow:var(--shadow-sm); }
.notif-item.unread { background:#fff; border-left-color:var(--teal); }
.notif-item.read { background:var(--surface-2); opacity:.85; }
.notif-header { display:flex; align-items:center; gap:8px; }
.notif-title { flex:1; font-size:13px; font-weight:600; color:var(--ink); line-height:1.35; }
.notif-item.read .notif-title { font-weight:500; color:var(--ink-2); }
.notif-action {
  border:1px solid var(--teal-soft-2);
  background:var(--teal-soft); color:var(--teal-2);
  font-size:10.5px; font-weight:600; padding:3px 8px; border-radius:5px;
  cursor:pointer; white-space:nowrap;
}
.notif-action:hover { background:var(--teal-soft-2); border-color:var(--teal); }
.notif-body { font-size:12.5px; color:var(--ink-2); line-height:1.5; }
.notif-time { font-size:11px; color:var(--muted); margin-top:2px; }

/* ===== Confirm ===== */
.confirm-target { display:flex; align-items:center; gap:12px; padding:12px; background:var(--surface-2); border:1px solid var(--line); border-radius:8px; }
.confirm-target-avatar {
  width:40px; height:40px; border-radius:8px; flex:0 0 40px;
  display:flex; align-items:center; justify-content:center;
  color:#fff; font-weight:700; font-size:14px;
  background:linear-gradient(135deg, var(--teal) 0%, var(--teal-2) 100%);
  box-shadow:0 2px 8px rgba(13,148,136,.2);
  background-size:cover; background-position:center; overflow:hidden;
}
.confirm-target-avatar.role-operator { background:linear-gradient(135deg, var(--indigo) 0%, var(--indigo-2) 100%); }
.confirm-target-avatar.role-viewer { background:linear-gradient(135deg, #94a3b8 0%, var(--slate) 100%); }
.confirm-target-meta { min-width:0; flex:1; display:flex; flex-direction:column; gap:2px; }
.confirm-target-name { font-size:13.5px; font-weight:600; color:var(--ink); line-height:1.3; word-break:break-word; }
.confirm-target-extra { font-size:11.5px; color:var(--muted); overflow:hidden; text-overflow:ellipsis; }
.confirm-message { margin:0; font-size:13px; color:var(--ink-2); line-height:1.55; padding:12px 14px; background:var(--surface-2); border-radius:8px; border-left:3px solid var(--warn); }
.confirm-message.danger { border-left-color:#dc2626; color:var(--danger); background:#fef2f2; }

/* ===== Profile ===== */
.profile-avatar-block { display:flex; align-items:stretch; gap:14px; padding:14px; background:var(--surface-2); border:1px solid var(--line); border-radius:10px; }
.profile-avatar {
  width:56px; flex:0 0 56px; aspect-ratio:1/1; border-radius:10px;
  background:linear-gradient(135deg, var(--teal) 0%, var(--teal-2) 100%);
  color:#fff; font-weight:700; font-size:20px;
  display:flex; align-items:center; justify-content:center;
  background-size:cover; background-position:center; overflow:hidden;
  border:2px solid #fff; box-shadow:0 3px 10px rgba(13,148,136,.2);
}
.profile-meta { display:flex; flex-direction:column; justify-content:center; gap:4px; min-width:0; flex:1; }
.profile-name { font-size:14px; font-weight:600; color:var(--ink); line-height:1.3; word-break:break-word; }
.profile-email { font-size:12px; color:var(--muted); word-break:break-all; line-height:1.3; }

/* ===== Toast ===== */
.toast-wrap { position:fixed; bottom:20px; right:20px; display:flex; flex-direction:column; gap:8px; z-index:2000; }
.toast {
  background:var(--ink); color:#fff;
  padding:10px 14px; border-radius:var(--radius-sm);
  font-size:12.5px; box-shadow:var(--shadow-md);
  border-left:3px solid var(--teal);
  animation:pop .18s ease; min-width:180px;
}
.toast.ok { border-left-color:var(--green); }
.toast.error { border-left-color:#ef4444; }
@keyframes pop { from { opacity:0 } to { opacity:1 } }

/* ===== Page common ===== */
.page-body { margin:0; background:var(--bg); color:var(--ink); font-family:var(--font); font-size:13.5px; -webkit-font-smoothing:antialiased; min-height:100%; }
html { height:100%; }
.wrap { padding:20px 28px 60px; width:100%; }
.empty-note {
  grid-column: 1 / -1;
  display: block;
  width: 100%;
  box-sizing: border-box;
  align-self: stretch;
  color: var(--muted);
  font-size: 12.5px;
  padding: 22px 14px;
  text-align: center;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.placeholder { padding:60px 20px; text-align:center; background:#fff; border:1px dashed var(--line-2); border-radius:var(--radius); color:var(--muted); }
.placeholder-icon { width:56px; height:56px; border-radius:14px; background:var(--teal-soft); color:var(--teal); display:inline-flex; align-items:center; justify-content:center; margin-bottom:14px; }
.placeholder h2 { margin:0 0 6px; font-size:17px; font-weight:600; color:var(--ink); }
.placeholder p { margin:0; font-size:13px; }

.page-head-actions { display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin-bottom:16px; }
.page-head-actions h2 { margin:0; font-size:15px; font-weight:600; color:var(--ink); letter-spacing:-.01em; }
.search-info { font-size:11.5px; font-weight:400; color:var(--muted); margin-left:8px; }
.page-head-actions .spacer { flex:1; }

/* ===== Users page ===== */
.users-toolbar { display:flex; gap:10px; margin-bottom:12px; width:100%; }
.search-wrap { position:relative; flex:1; width:100%; }
.search-wrap .search-icon { position:absolute; left:12px; top:50%; transform:translateY(-50%); color:var(--muted); pointer-events:none; }
.search-wrap input {
  width:100%; padding:8px 12px 8px 36px;
  border:1px solid var(--line-2); border-radius:7px;
  font-size:13px; background:#fff; color:var(--ink);
  font-family:var(--font); transition:border-color .15s, box-shadow .15s;
}
.search-wrap input:focus { outline:none; border-color:var(--teal); box-shadow:0 0 0 3px var(--teal-soft-2); }

/* Аватар пользователя (используется в таблице) */
.ucard-avatar {
  width:34px; height:34px; border-radius:7px;
  display:flex; align-items:center; justify-content:center;
  color:#fff; font-weight:700; font-size:12.5px;
  flex:0 0 34px;
  background:linear-gradient(135deg, var(--teal) 0%, var(--teal-2) 100%);
  box-shadow:0 2px 6px rgba(13,148,136,.18);
  background-size:cover; background-position:center; overflow:hidden;
}
.ucard-avatar.role-operator { background:linear-gradient(135deg, var(--indigo) 0%, var(--indigo-2) 100%); }
.ucard-avatar.role-viewer   { background:linear-gradient(135deg, #94a3b8 0%, var(--slate) 100%); }

.self-chip {
  display:inline-flex; align-items:center;
  font-size:8.5px; font-weight:700;
  text-transform:uppercase; letter-spacing:.06em;
  padding:0 4px;
  background:var(--teal-soft); color:var(--teal-2);
  border:1px solid var(--teal-soft-2);
  border-radius:3px; margin-left:5px; vertical-align:middle;
}

/* Точки статуса/онлайна (используются в таблице) */
.ufv-dot { display:inline-flex; align-items:center; gap:8px; }
.dot { display:inline-block; width:6px; height:6px; border-radius:50%; flex:0 0 auto; }
.dot.green { background:#10b981; box-shadow:0 0 0 2px #d1fae5; }
.dot.red   { background:#dc2626; box-shadow:0 0 0 2px #fee2e2; }
.dot.gray  { background:#9ca3af; box-shadow:0 0 0 2px #f1f5f9; }

/* Таблица пользователей */
.users-table-wrap {
  width:100%;
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow:var(--shadow-sm);
  overflow:hidden;
}
.users-table-scroll {
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
}
.users-table {
  width:100%;
  min-width:820px;
  border-collapse:collapse;
  font-size:13px;
}
.users-table thead {
  background:linear-gradient(180deg, #ffffff 0%, var(--surface-2) 100%);
}
.users-table th {
  text-align:left;
  padding:10px 14px;
  font-size:10px;
  font-weight:700;
  letter-spacing:.08em;
  text-transform:uppercase;
  color:var(--muted-2);
  border-bottom:1px solid var(--line);
  white-space:nowrap;
}
.users-table td {
  padding:10px 14px;
  border-bottom:1px solid var(--line);
  vertical-align:middle;
  color:var(--ink);
  font-size:13px;
}
.users-table tbody tr:last-child td { border-bottom:0; }
.users-table tbody tr:hover { background:rgba(13,148,136,.03); }
.users-table tbody tr.blocked td { color:var(--muted); }
.users-table tbody tr.blocked .user-cell-name { color:var(--muted); }

.user-cell {
  display:flex; align-items:center; gap:10px; min-width:0;
}
.user-cell-titles { display:flex; flex-direction:column; gap:2px; min-width:0; }
.user-cell-name {
  font-weight:600; font-size:13px; color:var(--ink);
  line-height:1.3; overflow-wrap:anywhere;
}
.user-cell-email {
  font-size:11px; color:var(--muted);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
  max-width:320px;
}
.user-actions-cell { white-space:nowrap; text-align:right; }
.user-actions-cell .btn.sm { margin-left:4px; }
.user-actions-cell .btn.sm:first-child { margin-left:0; }

/* Прочие кнопки действий в таблице */
.btn.sm.ghost-action { border-color:var(--line); color:var(--muted); background:#fff; }
.btn.sm.ghost-action:hover { border-color:var(--teal); color:var(--teal-2); background:var(--teal-soft); }
.btn.sm.warn-action { color:#a16207; border-color:#fde68a; background:#fff; }
.btn.sm.warn-action:hover { color:#854d0e; background:var(--warn-soft); border-color:#fcd34d; }
.btn.sm.ok-action { color:#047857; border-color:#a7f3d0; background:#fff; }
.btn.sm.ok-action:hover { color:#065f46; background:var(--green-soft); border-color:#6ee7b7; }
.btn.sm.danger-action { color:#c25a5a; border-color:#f1d5d5; background:#fff; }
.btn.sm.danger-action:hover { color:var(--danger); background:var(--danger-soft); border-color:#fecaca; }

/* ===== Settings page ===== */
.years { display:grid; grid-template-columns:repeat(3, minmax(0,1fr)); gap:14px; }
@media (max-width:1280px) { .years { grid-template-columns:repeat(2, minmax(0,1fr)); } }
@media (max-width:820px)  { .years { grid-template-columns:1fr; } }
.year {
  min-width:0; display:flex; flex-direction:column;
  background:var(--surface); border:1px solid var(--line);
  border-radius:var(--radius); box-shadow:var(--shadow-sm);
  overflow:hidden; transition:box-shadow .2s;
}
.year:hover { box-shadow:var(--shadow); }
.year-head {
  display:flex; flex-direction:column; gap:8px;
  padding:12px 14px; border-bottom:1px solid var(--line);
  background:linear-gradient(180deg, #ffffff 0%, var(--surface-2) 100%);
}
.year-title-row { display:flex; align-items:center; gap:10px; flex-wrap:wrap; min-width:0; }
.year-title-row h3 { font-weight:600; font-size:15px; letter-spacing:-.01em; margin:0; color:var(--ink); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.year-dates {
  font-size:11px; color:var(--muted); background:#fff;
  border:1px solid var(--line); padding:2px 8px;
  border-radius:var(--radius-pill); font-variant-numeric:tabular-nums; white-space:nowrap;
}
.year-badge {
  display:inline-flex; align-items:center; gap:5px;
  font-size:9.5px; letter-spacing:.08em; text-transform:uppercase;
  color:var(--teal); background:var(--teal-soft);
  border:1px solid var(--teal-soft-2); padding:2px 7px;
  border-radius:var(--radius-pill); font-weight:700; flex:0 0 auto;
}
.year-badge::before { content:""; width:5px; height:5px; border-radius:50%; background:var(--teal); }
.year-actions { display:grid; grid-template-columns:repeat(2, minmax(0,1fr)); gap:6px; }
.year-actions .btn.sm { justify-content:center; padding:6px 8px; font-size:11px; min-width:0; overflow:hidden; text-overflow:ellipsis; }
.year-body { padding:10px 12px 12px; display:flex; flex-direction:column; gap:8px; flex:1; }
.sem {
  display:flex; flex-direction:column; gap:6px;
  border:1px solid var(--line); border-radius:6px;
  padding:9px 11px; background:#fff; min-width:0;
  transition:border-color .15s, background .15s, box-shadow .15s;
}
.sem:hover { border-color:var(--line-2); box-shadow:var(--shadow-sm); }
.sem.current { border-color:var(--teal-soft-2); background:var(--teal-soft); box-shadow:0 0 0 2px rgba(13,148,136,.06); }
.sem-title-row { display:flex; align-items:center; gap:6px; justify-content:space-between; flex-wrap:wrap; min-width:0; }
.sem-title { font-weight:600; font-size:12.5px; color:var(--ink); display:flex; align-items:center; gap:6px; min-width:0; }
.sem.current .sem-title::before { content:""; width:6px; height:6px; border-radius:50%; background:var(--teal); box-shadow:0 0 0 3px var(--teal-soft-2); flex:0 0 auto; }
.sem-dates { font-size:11px; color:var(--muted); background:var(--surface-2); border:1px solid var(--line); padding:1px 8px; border-radius:var(--radius-pill); font-variant-numeric:tabular-nums; white-space:nowrap; }
.sem.current .sem-dates { background:#fff; border-color:var(--teal-soft-2); color:var(--teal-2); }
.sem-actions { display:grid; grid-template-columns:repeat(3, minmax(0,1fr)); gap:5px; }
.sem-actions .btn.sm { justify-content:center; padding:5px 6px; font-size:10.5px; min-width:0; overflow:hidden; text-overflow:ellipsis; border-color:var(--line); color:var(--muted); background:#fff; }
.sem-actions .btn.sm:hover { border-color:var(--teal); color:var(--teal-2); background:var(--teal-soft); }
.sem-actions .btn.sm.primary { background:var(--teal-soft); border-color:var(--teal-soft-2); color:var(--teal-2); box-shadow:none; }
.sem-actions .btn.sm.danger { color:#c25a5a; border-color:#f1d5d5; }
.sem-actions .btn.sm.danger:hover { color:var(--danger); background:var(--danger-soft); border-color:#fecaca; }

/* ===== Responsive ===== */
@media (max-width:900px) {
  .sidebar { position:static; width:100% !important; height:auto; border-right:0; border-bottom:1px solid var(--line); overflow:visible; padding:0 var(--sidebar-pad-r) 0 var(--sidebar-pad); }
  body.sidebar-collapsed .sidebar { width:100% !important; overflow:visible; }
  .main, body.sidebar-collapsed .main { margin-left:0 !important; height:auto; }
  #contentFrame { min-height:calc(100vh - var(--topbar-h)); }
  body.sidebar-collapsed .sidebar .brand { padding:0 var(--sidebar-pad-r) 0 var(--sidebar-pad); justify-content:flex-start; gap:10px; }
  body.sidebar-collapsed .sidebar .brand-mark { cursor:default; }
  body.sidebar-collapsed .sidebar .brand-text { max-width:220px; opacity:1; display:block; }
  body.sidebar-collapsed .sidebar .sidebar-nav { padding:6px 6px 6px 15px; overflow-y:auto; }
  body.sidebar-collapsed .sidebar .nav-section { display:flex; padding:6px 12px 6px 6px; justify-content:flex-start; gap:8px; margin:2px 0; }
  body.sidebar-collapsed .sidebar .nav-section-label,
  body.sidebar-collapsed .sidebar .nav-caret { display:inline; }
  body.sidebar-collapsed .sidebar .nav-section-icon { width:var(--icon-size); height:var(--icon-size); flex:0 0 var(--icon-size); min-width:var(--icon-size); min-height:var(--icon-size); background:transparent; }
  body.sidebar-collapsed .sidebar .nav-section-icon svg { width:14px; height:14px; }
  body.sidebar-collapsed .sidebar .nav-section:hover { background:transparent; }
  body.sidebar-collapsed .sidebar .nav-section:hover .nav-section-icon,
  body.sidebar-collapsed .sidebar .nav-section.has-active .nav-section-icon { background:transparent; color:var(--teal-2); }
  body.sidebar-collapsed .sidebar .nav-item { display:flex; padding:5px 10px 3px 35px; justify-content:flex-start; gap:8px; }
  body.sidebar-collapsed .sidebar .nav-group { display:flex; }
  body.sidebar-collapsed .sidebar .nav-label,
  body.sidebar-collapsed .sidebar .nav-badge { display:inline; }
  body.sidebar-collapsed .sidebar .nav-icon { width:var(--icon-size); height:var(--icon-size); flex:0 0 var(--icon-size); min-width:var(--icon-size); min-height:var(--icon-size); }
  body.sidebar-collapsed .sidebar .sidebar-actions { padding:10px var(--sidebar-pad-r) 10px var(--sidebar-pad); align-items:stretch; }
  body.sidebar-collapsed .sidebar .sidebar-toggle { display:none; }
  body.sidebar-collapsed .sidebar .support-btn { width:100%; padding:8px 10px; justify-content:flex-start; gap:8px; }
  body.sidebar-collapsed .sidebar .support-label { display:inline; }
  body.sidebar-collapsed .sidebar .sidebar-foot { padding:10px var(--sidebar-pad-r) 10px var(--sidebar-pad); justify-content:flex-start; }
  body.sidebar-collapsed .sidebar .foot-full { display:inline; }
  body.sidebar-collapsed .sidebar .foot-short { display:none; }
  .topbar { padding:0 16px; height:auto; min-height:var(--topbar-h); padding-top:8px; padding-bottom:8px; flex-wrap:wrap; }
  .wrap { padding:16px 16px 48px; }
  .ctx-group { margin-left:0; width:100%; }
  .user { margin-left:auto; }
  .drawer { width:100%; }
}

/* ===== Login page ===== */
body.login-body {
  /* переопределяем базовое height:100%, чтобы при нехватке места страница росла, а не обрезала карточку */
  height: auto;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 15%, rgba(13,148,136,.10), transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(99,102,241,.07), transparent 45%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(17,24,39,.10), 0 4px 12px rgba(17,24,39,.05);
  padding: 32px 28px 26px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}
.login-brand-mark {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-2) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  box-shadow: 0 4px 12px rgba(13,148,136,.28);
}
.login-brand-mark svg { width: 20px; height: 20px; display: block; pointer-events: none; }
.login-brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.login-brand-title {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .02em;
  color: var(--ink);
  text-transform: uppercase;
  line-height: 1.2;
}
.login-brand-sub {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: .08em;
  text-transform: uppercase;
}

.login-title {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -.01em;
}
.login-sub {
  margin: 0 0 22px;
  font-size: 13px;
  color: var(--muted);
}

/* Поля */
.login-card .dfield { margin-bottom: 14px; }
.login-card .dfield label { font-size: 11px; }
.login-card .dfield input {
  display: block;
  width: 100%;
  padding: 11px 14px;
  font-size: 13.5px;
  line-height: 1.4;
}

/* Поле пароля: оставляем место под кнопку-глаз.
   Селектор намеренно специфичнее, чем «.login-card .dfield input»,
   и идёт в файле позже — иначе padding-right:14px перебивает 42px. */
.login-card .password-wrap { position: relative; }
.login-card .password-wrap input { padding-right: 42px; }

.login-card .pw-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .15s, background .15s;
}
.login-card .pw-toggle:hover { color: var(--ink); background: var(--surface-2); }
.login-card .pw-toggle svg { width: 18px; height: 18px; display: block; }
.login-card .pw-toggle .eye-off { display: none; }
.login-card .pw-toggle.showing .eye-on { display: none; }
.login-card .pw-toggle.showing .eye-off { display: block; }

/* Ошибка */
.login-error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #fecaca;
  border-left: 3px solid var(--danger);
  padding: 9px 12px;
  border-radius: 7px;
  font-size: 12.5px;
  margin: 0 0 14px;
  line-height: 1.45;
}
.login-error.hidden { display: none; }

/* Кнопка входа */
.login-card .btn.primary {
  width: 100%;
  padding: 12px 14px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 7px;
}

/* Демо-подсказка */
.login-hint {
  margin-top: 22px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px dashed var(--line-2);
  border-radius: 8px;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--muted);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.login-hint strong {
  display: block;
  margin-bottom: 8px;
  color: var(--ink-2);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 700;
}
.login-hint .hint-row { margin-top: 6px; }
.login-hint .hint-row:first-of-type { margin-top: 0; }
.login-hint code {
  background: #fff;
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--line);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--teal-2);
  overflow-wrap: anywhere;
  word-break: break-all;
}

@media (max-width: 480px) {
  body.login-body { padding: 16px; }
  .login-card { padding: 24px 18px 20px; border-radius: 12px; }
  .login-title { font-size: 18px; }
}