/* ============================================================
   UES · Единая платформа торговли электроэнергией
   Базовая дизайн-система (токены + общие компоненты)
   ============================================================ */

:root {
  /* Бренд */
  --brand-50:  #f0f6fd;
  --brand-100: #e3eefb;
  --brand-200: #bcd7f5;
  --brand-400: #3987e5;
  --brand-500: #2a78d6;
  --brand-600: #1c5cab;
  --brand-700: #104281;
  --brand-800: #0d366b;

  /* Тёмная гамма (сайдбар, лендинг) */
  --navy-950: #081020;
  --navy-900: #0a1628;
  --navy-800: #0e1c33;
  --navy-700: #14264a;

  /* Энергетический акцент */
  --amber-500: #eda100;
  --amber-100: #fdf3dd;

  /* Поверхности */
  --page:   #f3f5f9;
  --card:   #ffffff;
  --card-2: #f8fafd;
  --line:   #e6eaf2;
  --line-2: #eef1f7;

  /* Текст */
  --ink:    #101c2e;
  --ink-2:  #51617a;
  --ink-3:  #8794a9;

  /* Серии графиков (валидированная палитра) */
  --s1: #2a78d6;
  --s2: #1baf7a;
  --s3: #eda100;
  --s4: #008300;
  --s5: #4a3aa7;
  --s6: #e34948;

  /* Статусы (только для смысла «хорошо/плохо») */
  --st-good:     #0ca30c;
  --st-good-bg:  #e9f7e9;
  --st-warn:     #b97900;
  --st-warn-bg:  #fdf3dd;
  --st-serious:  #c95c2f;
  --st-serious-bg:#fdeee6;
  --st-crit:     #d03b3b;
  --st-crit-bg:  #fceaea;
  --st-info:     #1c5cab;
  --st-info-bg:  #e3eefb;
  --st-neutral:  #51617a;
  --st-neutral-bg:#eef1f7;

  /* Графики: хром */
  --grid-line: #e7eaf1;
  --axis-line: #cdd4e0;
  --chart-muted: #8794a9;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-1: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.05);
  --shadow-2: 0 4px 12px rgba(16,24,40,.08), 0 2px 4px rgba(16,24,40,.04);
  --shadow-3: 0 12px 32px rgba(10,22,40,.14);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { display: block; max-width: 100%; }
a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; color: var(--ink); }

::selection { background: var(--brand-200); }

h1, h2, h3, h4 { font-weight: 700; letter-spacing: -0.01em; line-height: 1.25; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600; line-height: 1.2;
  border: 1px solid transparent; white-space: nowrap;
  transition: all .16s ease; text-decoration: none !important;
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary {
  background: linear-gradient(180deg, var(--brand-500), var(--brand-600));
  color: #fff; box-shadow: 0 1px 2px rgba(16,52,105,.3), inset 0 1px 0 rgba(255,255,255,.15);
}
.btn-primary:hover { background: linear-gradient(180deg, var(--brand-400), var(--brand-500)); transform: translateY(-1px); box-shadow: 0 4px 10px rgba(16,52,105,.28); }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover { background: var(--card-2); color: var(--ink); border-color: #d5dce8; }
.btn-soft { background: var(--brand-50); color: var(--brand-600); }
.btn-soft:hover { background: var(--brand-100); }
.btn-success { background: linear-gradient(180deg,#15b115,#0b930b); color:#fff; }
.btn-success:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-danger-soft { background: var(--st-crit-bg); color: var(--st-crit); }
.btn-danger-soft:hover { background: #f9dcdc; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg { padding: 13px 24px; font-size: 15px; border-radius: 12px; }
.btn[disabled] { opacity: .55; pointer-events: none; }

/* ---------- Бейджи статусов ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1.5; white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge-good    { background: var(--st-good-bg);    color: #0a7d0a; }
.badge-warn    { background: var(--st-warn-bg);    color: var(--st-warn); }
.badge-serious { background: var(--st-serious-bg); color: var(--st-serious); }
.badge-crit    { background: var(--st-crit-bg);    color: var(--st-crit); }
.badge-info    { background: var(--st-info-bg);    color: var(--st-info); }
.badge-neutral { background: var(--st-neutral-bg); color: var(--st-neutral); }
.badge-violet  { background: #edeafa; color: #43389c; }

/* ---------- Карточки ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-1);
}
.card-pad { padding: 20px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--line-2);
}
.card-head h3 { font-size: 15px; font-weight: 700; }
.card-head .sub { font-size: 12.5px; color: var(--ink-3); font-weight: 400; margin-top: 2px; }
.card-body { padding: 18px 20px; }

/* ---------- Формы ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.input, .select, .textarea {
  width: 100%; padding: 9px 12px; border: 1px solid #d5dce8; border-radius: var(--radius-sm);
  background: #fff; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand-400); box-shadow: 0 0 0 3px rgba(42,120,214,.14);
}
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2351617a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
.textarea { min-height: 84px; resize: vertical; }

/* ---------- Таблицы ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left; font-size: 11.5px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--ink-3);
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  background: var(--card-2); white-space: nowrap;
}
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: #f7faff; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl th.num { text-align: right; }
.tbl .strong { font-weight: 600; color: var(--ink); }
.tbl .mut { color: var(--ink-3); font-size: 12.5px; }
tr.row-link { cursor: pointer; }

/* ---------- Разное ---------- */
.mut { color: var(--ink-3); }
.small { font-size: 12.5px; }
.tnum { font-variant-numeric: tabular-nums; }
.flex { display: flex; align-items: center; gap: 10px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grow { flex: 1; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--brand-400), var(--brand-700));
}
.avatar.a2 { background: linear-gradient(135deg, #1baf7a, #0e7a54); }
.avatar.a3 { background: linear-gradient(135deg, #eda100, #b97900); }
.avatar.a4 { background: linear-gradient(135deg, #9085e9, #4a3aa7); }
.avatar.a5 { background: linear-gradient(135deg, #e87ba4, #b33d68); }
.avatar-sm { width: 26px; height: 26px; font-size: 10px; }

/* Тултип графиков */
.viz-tip {
  position: fixed; z-index: 400; pointer-events: none;
  background: #101c2e; color: #fff; border-radius: 10px;
  padding: 10px 12px; font-size: 12.5px; box-shadow: var(--shadow-3);
  opacity: 0; transition: opacity .1s; max-width: 260px;
}
.viz-tip .t-title { font-size: 11.5px; color: #9fb0c9; margin-bottom: 6px; font-weight: 600; }
.viz-tip .t-row { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.viz-tip .t-key { width: 12px; height: 0; border-top: 2.5px solid; border-radius: 2px; flex: none; }
.viz-tip .t-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.viz-tip .t-name { color: #b9c6da; }

/* Легенда графиков */
.viz-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 12px 4px 0; }
.viz-legend .lg-item { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.viz-legend .lg-line { width: 16px; height: 0; border-top: 3px solid; border-radius: 3px; }
.viz-legend .lg-rect { width: 11px; height: 11px; border-radius: 3.5px; }

/* Скроллбар */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cbd4e1; border-radius: 6px; border: 2px solid var(--page); }
::-webkit-scrollbar-track { background: transparent; }
