/* ==========================================================================
   ИС МЭИТ — дизайн-система ведомственного интерфейса
   Палитра: глубокий синий #1E3A8A, грифельный #0F172A, фон #F8FAFC,
            акценты — янтарный #B45309 и голубой #0EA5E9
   ========================================================================== */

:root {
  --blue-900: #172554;
  --blue-800: #1E3A8A;
  --blue-700: #1D4ED8;
  --blue-600: #2563EB;
  --blue-100: #DBEAFE;
  --blue-50:  #EFF6FF;

  --slate-900: #0F172A;
  --slate-800: #1E293B;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748B;
  --slate-400: #94A3B8;
  --slate-300: #CBD5E1;
  --slate-200: #E2E8F0;
  --slate-100: #F1F5F9;
  --slate-50:  #F8FAFC;

  --amber-700: #B45309;
  --amber-600: #D97706;
  --amber-500: #F59E0B;
  --amber-50:  #FFFBEB;

  --sky-600: #0284C7;
  --sky-500: #0EA5E9;
  --sky-50:  #F0F9FF;

  --green-700: #047857;
  --green-600: #059669;
  --green-50:  #ECFDF5;

  --red-700: #B91C1C;
  --red-600: #DC2626;
  --red-50:  #FEF2F2;

  --bg: var(--slate-50);
  --surface: #FFFFFF;
  --border: var(--slate-200);
  --text: var(--slate-900);
  --text-muted: var(--slate-500);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, .10);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, .22);

  --header-h: 62px;
  --font: "Inter", "Golos Text", "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

/* Атрибут hidden должен скрывать что угодно: у элементов с display:flex или
   grid браузерное правило `display:none` иначе проигрывает по весу, и
   скрытый по коду пункт остаётся на экране. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 0;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.011em; }
p { margin: 0; }
a { color: var(--blue-700); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: var(--blue-100); }

/* --------------------------------------------------------------------------
   Экран авторизации
   -------------------------------------------------------------------------- */

.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
}

.auth__brand {
  position: relative;
  overflow: hidden;
  padding: 56px 60px;
  color: #fff;
  background:
    radial-gradient(1100px 520px at 8% 6%, rgba(37, 99, 235, .45), transparent 62%),
    radial-gradient(760px 420px at 92% 96%, rgba(14, 165, 233, .30), transparent 60%),
    linear-gradient(155deg, var(--blue-900) 0%, #0B1531 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.auth__brand::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .045) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(720px 480px at 24% 32%, #000, transparent 72%);
  pointer-events: none;
}

.auth__brand > * { position: relative; z-index: 1; }

.brand-mark {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark__emblem {
  width: 56px;
  height: 56px;
  flex: none;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(15, 23, 42, .45));
}

.brand-mark__name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .02em;
}

.brand-mark__sub {
  font-size: 12px;
  color: rgba(226, 232, 240, .78);
  letter-spacing: .01em;
}


/* Название системы — главный акцент витрины, поэтому набрано крупно и целиком */
.auth__headline {
  font-size: 42px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -.025em;
  max-width: 20ch;
  margin-bottom: 16px;
  text-wrap: balance;
}

.auth__tagline {
  font-size: 17px;
  font-weight: 600;
  color: rgba(191, 219, 254, .95);
  letter-spacing: .01em;
  margin-bottom: 12px;
}

.auth__lead {
  font-size: 15px;
  color: rgba(226, 232, 240, .82);
  max-width: 48ch;
}


.auth__legal {
  font-size: 12px;
  color: rgba(148, 163, 184, .82);
  line-height: 1.6;
}

.auth__panel {
  display: grid;
  place-items: center;
  padding: 40px;
  background: var(--surface);
}

.auth__form {
  width: 100%;
  max-width: 400px;
}

.auth__title { font-size: 25px; margin-bottom: 6px; }
.auth__hint { color: var(--text-muted); margin-bottom: 26px; font-size: 13.5px; }


/* --------------------------------------------------------------------------
   Формы
   -------------------------------------------------------------------------- */

.field { margin-bottom: 16px; }

.field__label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--slate-700);
  margin-bottom: 6px;
}

.field__label span { color: var(--red-600); }

.input,
.select,
.textarea {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  transition: border-color .14s, box-shadow .14s, background .14s;
  outline: none;
}

.input::placeholder { color: var(--slate-400); }

.input:hover, .select:hover, .textarea:hover { border-color: var(--slate-400); }

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--blue-600);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .16);
}

.input[aria-invalid="true"] {
  border-color: var(--red-600);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, .13);
}

.input:disabled, .select:disabled, .textarea:disabled {
  background: var(--slate-100);
  color: var(--slate-500);
  cursor: not-allowed;
}

.textarea { min-height: 78px; resize: vertical; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' stroke='%2364748B' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 32px;
}

.field__error {
  display: none;
  margin-top: 5px;
  font-size: 12px;
  color: var(--red-600);
}

.field__error.is-visible { display: block; }

.field__help { margin-top: 5px; font-size: 12px; color: var(--text-muted); }

/* Поле со справочником: выбор из списка либо набор с клавиатуры.
   Список раскрывается внутри окна, поверх соседних полей. */

.combo { position: relative; }

.combo__input { padding-right: 32px; }

.combo__toggle {
  position: absolute;
  top: 1px;
  right: 1px;
  bottom: 1px;
  width: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: none;
  color: var(--slate-500);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  cursor: pointer;
  transition: color .14s, transform .14s;
}

.combo__toggle:hover { color: var(--slate-700); }

.combo.is-open .combo__toggle { transform: rotate(180deg); }

.combo__list {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 264px;
  overflow-y: auto;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}

.combo__item {
  padding: 7px 9px;
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--text);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.combo__item.is-active { background: var(--blue-50); }

.combo__empty {
  padding: 8px 9px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-muted);
}


.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 13px;
  color: var(--slate-700);
  cursor: pointer;
  user-select: none;
}

.checkbox input { margin: 2px 0 0; width: 15px; height: 15px; accent-color: var(--blue-700); }

/* --------------------------------------------------------------------------
   Кнопки
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 550;
  line-height: 1.2;
  color: var(--slate-700);
  background: var(--surface);
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background .14s, border-color .14s, color .14s, box-shadow .14s, transform .06s;
}

.btn:hover { background: var(--slate-100); border-color: var(--slate-400); }
.btn:active { transform: translateY(.5px); }
.btn:focus-visible { outline: 2px solid var(--blue-600); outline-offset: 2px; }

.btn--primary {
  color: #fff;
  background: var(--blue-800);
  border-color: var(--blue-800);
  box-shadow: var(--shadow-xs);
}
.btn--primary:hover { background: var(--blue-700); border-color: var(--blue-700); }

.btn--danger { color: #fff; background: var(--red-600); border-color: var(--red-600); }
.btn--danger:hover { background: var(--red-700); border-color: var(--red-700); }

.btn--ghost { background: transparent; border-color: transparent; color: var(--slate-600); }
.btn--ghost:hover { background: var(--slate-100); border-color: transparent; }

.btn--block { width: 100%; }
.btn--lg { padding: 11px 18px; font-size: 14.5px; }
.btn--sm { padding: 6px 10px; font-size: 12.5px; }

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: .55;
  cursor: not-allowed;
  pointer-events: auto;
}
.btn:disabled:hover { background: var(--surface); border-color: var(--slate-300); }
.btn--primary:disabled:hover { background: var(--blue-800); }

.btn.is-loading { color: transparent !important; position: relative; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 15px; height: 15px;
  border: 2px solid rgba(255, 255, 255, .45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
.btn--secondary.is-loading::after,
.btn:not(.btn--primary):not(.btn--danger).is-loading::after {
  border-color: rgba(15, 23, 42, .2);
  border-top-color: var(--slate-700);
}

@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------
   Каркас рабочего пространства
   -------------------------------------------------------------------------- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 24px;
  color: #fff;
  background: linear-gradient(180deg, var(--blue-900), #142352);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.app-header__brand { display: flex; align-items: center; gap: 11px; flex: none; }

.app-header__emblem {
  width: 34px; height: 34px;
  flex: none;
  object-fit: contain;
  filter: drop-shadow(0 1px 4px rgba(15, 23, 42, .4));
}

.app-header__name { font-size: 15.5px; font-weight: 700; letter-spacing: .02em; line-height: 1.1; }
.app-header__sub { font-size: 10.5px; color: rgba(203, 213, 225, .72); letter-spacing: .01em; }

.app-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.app-nav::-webkit-scrollbar { display: none; }

.app-nav__item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: rgba(226, 232, 240, .82);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background .14s, color .14s;
}

.app-nav__item:hover { background: rgba(255, 255, 255, .09); color: #fff; text-decoration: none; }

.app-nav__item.is-active {
  background: rgba(255, 255, 255, .15);
  border-color: rgba(255, 255, 255, .18);
  color: #fff;
  font-weight: 600;
}

.app-nav__item--admin { color: var(--amber-500); }
.app-nav__item--admin.is-active { color: #FCD34D; }

.user-chip {
  position: relative;
  flex: none;
}

.user-chip__btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 9px 5px 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .09);
  border: 1px solid rgba(255, 255, 255, .14);
  color: #fff;
  cursor: pointer;
  font: inherit;
}
.user-chip__btn:hover { background: rgba(255, 255, 255, .16); }

.user-chip__avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(150deg, var(--sky-500), var(--blue-600));
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .02em;
}

.user-chip__meta { text-align: left; line-height: 1.25; }
.user-chip__name { font-size: 12.5px; font-weight: 600; }
.user-chip__role { font-size: 10.5px; color: rgba(203, 213, 225, .8); }

.dropdown {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  min-width: 268px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 6px;
  display: none;
  z-index: 60;
}
.dropdown.is-open { display: block; animation: pop .13s ease-out; }

@keyframes pop { from { opacity: 0; transform: translateY(-4px); } }

.dropdown__head {
  padding: 10px 11px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.dropdown__name { font-size: 13.5px; font-weight: 650; color: var(--text); }
.dropdown__mail { font-size: 12px; color: var(--text-muted); word-break: break-all; }

.dropdown__item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 11px;
  font: inherit;
  font-size: 13px;
  color: var(--slate-700);
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
}
.dropdown__item:hover { background: var(--slate-100); }
.dropdown__item--danger { color: var(--red-600); }
.dropdown__item--danger:hover { background: var(--red-50); }

.app-main {
  max-width: 1560px;
  margin: 0 auto;
  padding: 26px 24px 56px;
}

/* --------------------------------------------------------------------------
   Общие блоки
   -------------------------------------------------------------------------- */

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.page-head__title { font-size: 24px; letter-spacing: -.02em; }
.page-head__sub { color: var(--text-muted); font-size: 13.5px; margin-top: 4px; }
.page-head__actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.card__title { font-size: 14.5px; font-weight: 650; }
.card__body { padding: 18px; }

.greeting {
  position: relative;
  overflow: hidden;
  padding: 26px 28px;
  border-radius: var(--radius-lg);
  color: #fff;
  background:
    radial-gradient(760px 340px at 90% -30%, rgba(14, 165, 233, .40), transparent 65%),
    linear-gradient(120deg, var(--blue-900), #1B3272 62%, #17255A);
  margin-bottom: 22px;
}

.greeting__row { display: flex; justify-content: space-between; gap: 26px; flex-wrap: wrap; }
.greeting__eyebrow {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: rgba(147, 197, 253, .92);
  font-weight: 600;
  margin-bottom: 7px;
}
.greeting__name { font-size: 25px; font-weight: 700; letter-spacing: -.02em; }
.greeting__meta { margin-top: 7px; font-size: 13.5px; color: rgba(226, 232, 240, .84); }

.greeting__facts { display: flex; gap: 26px; align-items: flex-end; flex-wrap: wrap; }
.greeting__fact-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: rgba(148, 163, 184, .9);
}
.greeting__fact-value { font-size: 15px; font-weight: 600; margin-top: 3px; }

.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .02em;
  background: rgba(245, 158, 11, .18);
  border: 1px solid rgba(245, 158, 11, .38);
  color: #FCD34D;
}
.role-badge--operator { background: rgba(14, 165, 233, .18); border-color: rgba(14, 165, 233, .4); color: #7DD3FC; }
.role-badge--viewer { background: rgba(148, 163, 184, .18); border-color: rgba(148, 163, 184, .38); color: #E2E8F0; }

/* Карточки направлений */

.sector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.sector-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  overflow: hidden;
  transition: box-shadow .18s, transform .18s, border-color .18s;
}

.sector-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--accent, var(--blue-800));
}

.sector-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--slate-300);
}

.sector-card__head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }

.sector-card__icon {
  width: 40px; height: 40px;
  flex: none;
  border-radius: 9px;
  display: grid; place-items: center;
  color: var(--accent, var(--blue-800));
  background: color-mix(in srgb, var(--accent, #1E3A8A) 10%, #fff);
  border: 1px solid color-mix(in srgb, var(--accent, #1E3A8A) 22%, #fff);
}

.sector-card__name { font-size: 15.5px; font-weight: 650; letter-spacing: -.01em; }
.sector-card__desc { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; line-height: 1.45; }

.sector-card__metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 14px;
}

.metric { padding: 10px 12px; background: var(--surface); }
.metric__label { font-size: 11px; color: var(--text-muted); line-height: 1.35; min-height: 30px; }
.metric__value { font-size: 19px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.metric__unit { font-size: 11.5px; font-weight: 500; color: var(--text-muted); margin-left: 3px; }
.metric__value--ok { color: var(--green-700); }
.metric__value--warn { color: var(--amber-700); }
.metric__value--bad { color: var(--red-600); }
.metric__value--info { color: var(--slate-900); }

.sector-card__foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

.sector-card__enter { display: inline-flex; align-items: center; gap: 5px; color: var(--blue-700); font-weight: 600; }

/* Плитки статистики */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat {
  padding: 15px 17px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}
.stat__label { font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat__value { font-size: 26px; font-weight: 700; letter-spacing: -.025em; margin-top: 7px; font-variant-numeric: tabular-nums; }
.stat__value--ok { color: var(--green-700); }
.stat__value--warn { color: var(--amber-700); }
.stat__value--bad { color: var(--red-600); }
.stat__unit { font-size: 13px; color: var(--text-muted); font-weight: 500; margin-left: 4px; }

/* --------------------------------------------------------------------------
   Панель инструментов и таблицы
   -------------------------------------------------------------------------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--slate-50);
  border-radius: var(--radius) var(--radius) 0 0;
}

.toolbar__search { position: relative; flex: 1 1 280px; min-width: 220px; max-width: 420px; }
.toolbar__search .input { padding-left: 34px; }
.toolbar__search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--slate-400); pointer-events: none; }
.toolbar__spacer { flex: 1; }
.toolbar .select { width: auto; min-width: 152px; flex: 0 1 auto; }

.tabs { display: flex; gap: 3px; padding: 4px; background: var(--slate-100); border-radius: 8px; }

.tab {
  padding: 7px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  color: var(--slate-600);
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  transition: background .14s, color .14s;
}
.tab:hover { color: var(--slate-900); }
.tab.is-active { background: var(--surface); color: var(--blue-800); box-shadow: var(--shadow-xs); }

/* Обёртка таблицы без прокрутки: тогда шапка прилипает к шапке приложения.
   Класс `is-scrollable` навешивается скриптом только тем таблицам, которые
   не помещаются по ширине, — у них появляется собственная область прокрутки. */
.table-wrap { overflow: visible; }

.table-wrap.is-scrollable {
  overflow: auto;
  max-height: calc(100vh - var(--header-h) - 140px);
}
.table-wrap.is-scrollable .table thead th { top: 0; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }

/* Шапка фиксируется под шапкой приложения и уходит вместе со своей таблицей,
   уступая место шапке следующей. */
.table thead th {
  position: sticky;
  top: var(--header-h);
  z-index: 3;
  padding: 10px 14px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .045em;
  color: var(--slate-600);
  background: var(--slate-100);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}

.table thead th.is-sortable { cursor: pointer; }
.table thead th.is-sortable:hover { color: var(--blue-800); background: var(--blue-50); }
.table thead th .sort-arrow { margin-left: 5px; opacity: .45; font-size: 10px; }
.table thead th.is-sorted .sort-arrow { opacity: 1; color: var(--blue-700); }

.table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--slate-100);
  vertical-align: middle;
  color: var(--slate-700);
}

.table tbody tr:hover td { background: var(--blue-50); }
.table tbody tr:last-child td { border-bottom: 0; }

.table td.is-primary { font-weight: 600; color: var(--text); }
.table td.is-number { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td.is-wide { min-width: 320px; max-width: 480px; white-space: normal; }
.table td.is-actions { text-align: right; white-space: nowrap; }

/* --------------------- Журнал регистрации приказов ------------------------
   Одиннадцать граф книги не помещаются по ширине, поэтому таблица получает
   свою прокрутку (её включает UI.stickyTables), шрифт на полпункта мельче, а
   длинные графы — наименование и нарушения — переносятся по словам. */

/* У журнала своя область прокрутки при любой ширине окна: строк в книге
   сотни, и шапка граф должна оставаться на экране вместе с панелью отбора. */
.table-wrap--journal {
  overflow: auto;
  max-height: calc(100vh - var(--header-h) - 96px);
}

/* Журнал регистрации занимает экран целиком: прокручивается таблица, а
   страница стоит. Иначе прокрутка уводила наверх саму область таблицы, и
   липкая шапка граф уезжала вместе с ней. */
body.is-journal { overflow: hidden; }

body.is-journal .app-main {
  height: calc(100vh - var(--header-h));
  padding-bottom: 14px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
body.is-journal .page-head { margin-bottom: 12px; }
body.is-journal #section-body,
body.is-journal #section-body > .card {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
body.is-journal .table-wrap--journal {
  flex: 1;
  min-height: 0;
  max-height: none;
}
body.is-journal .app-footer { display: none; }

/* Показатели журнала: строка «подпись — число» вместо плиток */
.metric-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  padding: 10px 16px;
  margin-bottom: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}
.metric-strip__item { display: flex; align-items: baseline; gap: 7px; }
.metric-strip__label { font-size: 12px; color: var(--slate-600); }
.metric-strip__value {
  font-size: 15px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.metric-strip__value--ok { color: var(--green-600, var(--text)); }
.metric-strip__value--warn { color: var(--amber-600); }
.metric-strip__value--bad { color: var(--red-600); }
.table-wrap--journal .table thead th { top: 0; }

.table--journal { font-size: 12.5px; min-width: 1180px; }
.table--journal thead th {
  /* Заголовки граф в книге — длинные предложения: капслок и разрядка делают
     их нечитаемыми и растягивают шапку на десяток строк. */
  white-space: normal;
  vertical-align: bottom;
  text-transform: none;
  letter-spacing: 0;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  padding: 8px 10px;
  min-width: 96px;
}
.table--journal thead th:first-child { min-width: 40px; padding-left: 8px; }
/* Графы с длинными заголовками — шире, иначе шапка уходит вниз на треть экрана */
.table--journal thead th:nth-child(6) { min-width: 150px; }
.table--journal thead th:nth-child(7),
.table--journal thead th:nth-child(8) { min-width: 112px; }
.table--journal thead th:nth-child(9) { min-width: 140px; }
.table--journal thead th:nth-child(10),
.table--journal thead th:nth-child(11) { min-width: 150px; }
.table--journal tbody td { vertical-align: top; padding-top: 9px; padding-bottom: 9px; }
.table--journal td.journal__title {
  min-width: 300px;
  max-width: 440px;
  white-space: normal;
  color: var(--text);
}
.table--journal td.journal__note {
  min-width: 130px;
  max-width: 240px;
  white-space: normal;
}
.table--journal td.is-number { width: 44px; text-align: center; color: var(--slate-500); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--ok   { color: var(--green-700); background: var(--green-50); border-color: rgba(16, 185, 129, .45); }
.badge--info { color: var(--blue-700); background: var(--blue-50); border-color: var(--blue-100); }
.badge--warn { color: var(--amber-700); background: var(--amber-50); border-color: rgba(245, 158, 11, .45); }
.badge--bad  { color: var(--red-700); background: var(--red-50); border-color: rgba(239, 68, 68, .45); }
.badge--neutral { color: var(--slate-600); background: var(--slate-100); border-color: var(--slate-200); }
.badge--plain::before { display: none; }

.bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 108px;
}
.bar__track { flex: 1; height: 6px; border-radius: 999px; background: var(--slate-200); overflow: hidden; }
.bar__fill { height: 100%; border-radius: 999px; background: var(--blue-600); }
.bar__fill--ok { background: var(--green-600); }
.bar__fill--warn { background: var(--amber-500); }
.bar__fill--bad { background: var(--red-600); }
.bar__value { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--slate-600); width: 34px; text-align: right; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.pagination__pages { display: flex; align-items: center; gap: 6px; }

.empty { padding: 52px 20px; text-align: center; color: var(--text-muted); }
.empty__icon { color: var(--slate-300); margin-bottom: 12px; }
.empty__title { font-size: 15px; font-weight: 600; color: var(--slate-700); margin-bottom: 5px; }

.skeleton {
  height: 13px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--slate-100) 25%, var(--slate-200) 37%, var(--slate-100) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* --------------------------------------------------------------------------
   Аналитика
   -------------------------------------------------------------------------- */

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 16px;
  /* Высоту задаёт содержимое карточки, а не самый высокий сосед: иначе под
     коротким блоком (три полосы) остаётся пустое поле в половину экрана. */
  align-items: start;
}

.chart__row {
  display: grid;
  grid-template-columns: minmax(120px, 34%) 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
}
.chart__label { font-size: 12.5px; color: var(--slate-600); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart__track { height: 9px; border-radius: 999px; background: var(--slate-100); overflow: hidden; }
.chart__fill { height: 100%; border-radius: 999px; background: var(--blue-700); transition: width .5s cubic-bezier(.22,.61,.36,1); }
.chart__fill--ok { background: var(--green-600); }
.chart__fill--warn { background: var(--amber-500); }
.chart__fill--bad { background: var(--red-600); }
.chart__fill--info { background: var(--blue-700); }
.chart__value { font-size: 12.5px; font-weight: 650; font-variant-numeric: tabular-nums; color: var(--slate-800); min-width: 62px; text-align: right; }

/* --------------------------------------------------------------------------
   Файлы
   -------------------------------------------------------------------------- */

.file-row { display: flex; align-items: center; gap: 12px; }
.file-icon {
  width: 34px; height: 34px;
  flex: none;
  border-radius: 7px;
  display: grid; place-items: center;
  background: var(--blue-50);
  color: var(--blue-700);
  border: 1px solid var(--blue-100);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.dropzone {
  /* Зона перетаскивания бывает и <label>, поэтому блочность задаётся явно:
     у инлайнового элемента рамка и выравнивание разъезжаются. */
  display: block;
  padding: 22px;
  border: 1.5px dashed var(--slate-300);
  border-radius: var(--radius);
  text-align: center;
  color: var(--text-muted);
  background: var(--slate-50);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--blue-600); background: var(--blue-50); color: var(--blue-800); }
.dropzone__name { margin-top: 8px; font-size: 13px; font-weight: 600; color: var(--slate-800); }

/* --------------------------------------------------------------------------
   Модальные окна
   -------------------------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(15, 23, 42, .52);
  backdrop-filter: blur(2px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 44px 18px;
  overflow-y: auto;
}
.modal-backdrop.is-open { display: flex; animation: fade .15s ease-out; }

@keyframes fade { from { opacity: 0; } }

.modal {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: rise .18s cubic-bezier(.22,.61,.36,1);
  margin: auto 0;
}
.modal--wide { max-width: 720px; }

@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.985); } }

.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 19px 22px 15px;
  border-bottom: 1px solid var(--border);
}
.modal__title { font-size: 17px; letter-spacing: -.015em; }
.modal__sub { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }

.modal__close {
  flex: none;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--slate-500);
  cursor: pointer;
}
.modal__close:hover { background: var(--slate-100); color: var(--slate-800); }

.modal__body { padding: 20px 22px; }
.modal__body--scroll { max-height: 62vh; overflow-y: auto; }

.modal__foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  padding: 15px 22px;
  border-top: 1px solid var(--border);
  background: var(--slate-50);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  flex-wrap: wrap;
}
.modal__foot--split { justify-content: space-between; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }

/* Пара полей в строке сетки выравнивается по строке ввода, а не по верху:
   подпись слева умещается в строку, справа — переносится на две, и поля
   ввода разъезжались. На ноутбуке этого не видно, на широком мониторе —
   видно, потому что переносится другая пара подписей. Поле растягивается
   на всю высоту строки, а сам ввод прижимается к её низу. */
.form-grid .field { display: flex; flex-direction: column; }

.form-grid .field > .input,
.form-grid .field > .select,
.form-grid .field > .textarea,
.form-grid .field > .combo { margin-top: auto; }

/* Поле даты Chrome рисует на 2px выше обычного — в паре с ним строка ввода
   всё равно вставала чуть выше соседней. Возвращаем общую высоту. */
.input[type="date"] { padding-top: 9px; padding-bottom: 9px; }

.form-grid .field--full { grid-column: 1 / -1; }

/* --------------------------------------------------------------------------
   Уведомления
   -------------------------------------------------------------------------- */

.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 15px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--blue-700);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  animation: slide-in .2s cubic-bezier(.22,.61,.36,1);
}
.toast--ok { border-left-color: var(--green-600); }
.toast--error { border-left-color: var(--red-600); }
.toast--warn { border-left-color: var(--amber-500); }
.toast.is-hiding { animation: slide-out .2s forwards; }

.toast__icon { flex: none; margin-top: 1px; }
.toast--ok .toast__icon { color: var(--green-600); }
.toast--error .toast__icon { color: var(--red-600); }
.toast--warn .toast__icon { color: var(--amber-600); }
.toast--info .toast__icon { color: var(--blue-700); }

.toast__title { font-size: 13.5px; font-weight: 650; }
.toast__text { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; line-height: 1.45; }

@keyframes slide-in { from { opacity: 0; transform: translateX(22px); } }
@keyframes slide-out { to { opacity: 0; transform: translateX(22px); } }

.alert {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 16px;
  border: 1px solid;
}
.alert--error { background: var(--red-50); border-color: rgba(239, 68, 68, .45); color: var(--red-700); }
.alert--warn { background: var(--amber-50); border-color: rgba(245, 158, 11, .45); color: var(--amber-700); }
.alert--info { background: var(--blue-50); border-color: var(--blue-100); color: var(--blue-800); }
.alert--ok { background: var(--green-50); border-color: rgba(16, 185, 129, .45); color: var(--green-700); }
.alert svg { flex: none; margin-top: 1px; }
.alert.is-hidden { display: none; }

/* --------------------------------------------------------------------------
   Реестр приказов: текст документа в карточке
   -------------------------------------------------------------------------- */

.order-text {
  max-height: 340px;
  overflow-y: auto;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 13.5px;
  line-height: 1.65;
}
.order-text p { margin: 0 0 9px; text-indent: 18px; }
.order-text p:last-child { margin-bottom: 0; }
.order-text .table-wrap { margin: 10px 0; }
.order-text .table { font-size: 12.5px; }

/* --------------------------------------------------------------------------
   Служебное
   -------------------------------------------------------------------------- */

.mono { font-family: "JetBrains Mono", Consolas, "Courier New", monospace; font-size: 12px; }
.muted { color: var(--text-muted); }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.is-hidden { display: none !important; }
.stack-8 { display: flex; flex-direction: column; gap: 8px; }
.row-8 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.perm-list { display: flex; flex-wrap: wrap; gap: 6px; }
.perm {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 5px;
  background: var(--slate-100);
  color: var(--slate-600);
  border: 1px solid var(--slate-200);
  font-weight: 550;
}
.perm--on { background: var(--green-50); color: var(--green-700); border-color: rgba(16, 185, 129, .45); }

.app-footer {
  padding: 20px 24px 30px;
  text-align: center;
  font-size: 12px;
  color: var(--slate-400);
  line-height: 1.6;
}

/* --------------------------------------------------------------------------
   Адаптивность
   -------------------------------------------------------------------------- */

@media (max-width: 1180px) {
  .app-header { gap: 14px; padding: 0 16px; }
  .app-header__sub { display: none; }
  .user-chip__meta { display: none; }
}

@media (max-width: 980px) {
  .auth { grid-template-columns: 1fr; }
  .auth__brand { padding: 32px 26px; }
  .auth__headline { font-size: 30px; max-width: none; }
  .auth__panel { padding: 30px 22px 54px; }
  .greeting__row { flex-direction: column; }
}

@media (max-width: 720px) {
  .app-main { padding: 18px 14px 42px; }
  .sector-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: stretch; }
  .toolbar { padding: 11px 12px; }
  .toolbar .select, .toolbar__search { flex: 1 1 100%; max-width: none; }
  .greeting { padding: 20px; }
  .greeting__name { font-size: 21px; }
  .chart-grid { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 16px 10px; }
}

/* ==========================================================================
   Ночная тема

   Шкала slate перевёрнута: slate-50 становится самым тёмным, slate-900 — самым
   светлым. Благодаря этому все обращения к шкале в дизайн-системе продолжают
   означать то же самое («самый бледный фон», «самый контрастный текст») и не
   требуют правок. Отдельно переопределены только подложки-заливки, тени и те
   места, где белый текст лежит на цветной плашке.
   ========================================================================== */

:root[data-theme="dark"] {
  color-scheme: dark;

  --slate-900: #F1F5F9;
  --slate-800: #E2E8F0;
  --slate-700: #CBD5E1;
  --slate-600: #A3B2C7;
  --slate-500: #8494AB;
  --slate-400: #6B7C93;
  --slate-300: #4A5A72;
  --slate-200: #2A3950;
  --slate-100: #1A2740;
  --slate-50:  #131F35;

  --bg: #0B1220;
  --surface: #111C2E;
  --border: #26364F;
  --text: #F1F5F9;
  --text-muted: #9AABC2;

  /* Бледные заливки-акценты становятся тёмными подсветками */
  --blue-50:  #16263F;
  --blue-100: #1E3357;
  --amber-50: #2A2010;
  --sky-50:   #0E2334;
  --green-50: #0E2A21;
  --red-50:   #2D1519;

  /* Акценты подсвечены, чтобы держать контраст на тёмном фоне */
  --blue-800: #5B8DEF;
  --blue-700: #6EA0FF;
  --blue-600: #4B82F0;
  --amber-700: #FBBF24;
  --amber-600: #F59E0B;
  --sky-600:  #38BDF8;
  --green-700: #34D399;
  --green-600: #10B981;
  --red-700:  #F87171;
  --red-600:  #EF4444;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .40);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .45), 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, .50);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .65);
}

/* Белый текст на синей плашке требует более густого синего, чем текстовый акцент */
:root[data-theme="dark"] .btn--primary,
:root[data-theme="dark"] .btn--primary:disabled:hover,
:root[data-theme="dark"] .sheet-nav button.is-active,
:root[data-theme="dark"] .segmented button.is-active {
  background: #2C5FD0;
  border-color: #2C5FD0;
  color: #fff;
}

/* Полосы прокрутки и подсветка строк под тёмный фон */
:root[data-theme="dark"] .table tbody tr:hover td { background: var(--slate-100); }
:root[data-theme="dark"] ::-webkit-scrollbar { width: 11px; height: 11px; }
:root[data-theme="dark"] ::-webkit-scrollbar-track { background: var(--bg); }
:root[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: var(--slate-300);
  border: 3px solid var(--bg);
  border-radius: 999px;
}

/* Логотипы брендов рассчитаны на светлую подложку */
:root[data-theme="dark"] .brand-logo,
:root[data-theme="dark"] img[src*="/brands/"] {
  background: #fff;
  border-radius: 4px;
  padding: 1px;
}

/* ------------------------------ Переключатель темы ----------------------- */

.header-tools { display: inline-flex; align-items: center; gap: 10px; }

.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .10);
  border: 1px solid rgba(255, 255, 255, .14);
}

.theme-switch button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, .72);
  cursor: pointer;
  transition: background .15s, color .15s;
}

.theme-switch button:hover { color: #fff; background: rgba(255, 255, 255, .12); }

.theme-switch button.is-active {
  background: var(--amber-500);
  color: #1F1400;
}

@media (max-width: 720px) { .theme-switch { display: none; } }

/* --------------------------------------------------------------------------
   Настройка доступа пользователя: разделы, вкладки и операции
   -------------------------------------------------------------------------- */

.access-tree.is-locked { opacity: .45; pointer-events: none; }

.access-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  gap: 10px;
}

.access-section {
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 11px 12px;
}

.access-section__head {
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px dashed var(--slate-200);
  font-size: 13.5px;
}

.access-tabs { display: flex; flex-direction: column; gap: 7px; }
.access-tabs .checkbox { font-size: 12.5px; }

.access-flags {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(212px, 1fr));
  gap: 9px;
  padding: 11px 12px;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.access-flags .checkbox input:disabled { accent-color: var(--slate-400); }
