/*
  Портал управления исполнителями — базовая тема (тёмный dashboard).
  Палитра chrome/статусов подобрана и проверена по методике skill "dataviz"
  (контраст, статус-цвета "good/warning/serious/critical" — из validated референсной палитры),
  акцентный бренд-цвет (красный/неон, Этап 4) — самостоятельный выбор поверх неё, проверен на
  контраст отдельно (dataviz::validate_palette.js + ручной расчёт WCAG, см. план Этапа 4).
*/

:root {
  color-scheme: dark;

  /* ---- поверхности ---- */
  --page-bg: #0d0d0d;
  --surface-1: #17181a;
  --surface-2: #1f2023;
  --surface-3: #27282c;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --gridline: #2c2c2a;

  /* ---- текст ---- */
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;

  /* ---- бренд-акцент (красный/неон, Этап 4 — было янтарь #e3a53d/#eeb457/#c68b2a) ---- */
  --brand: #ff2d55;
  --brand-hover: #f5486a;
  --brand-active: #eb1550;
  --brand-bg: rgba(255, 45, 85, 0.12);
  --brand-text-on: #1a0508;

  /* ---- второй акцент — лайм/неон (Этап 5, редизайн IvanShild): только кнопки основного
     действия (.btn-primary) и подобные "сделай это" элементы; красный (--brand выше) остаётся
     за навигацией/иконками/рамками/логотипом — это разделение роль/цвет сознательное, не менять
     точечно только в одном месте. Контраст текста на --brand2 проверен на #14210a (тёмный, не
     чёрный — чистый чёрный на лайме визуально "дребезжит"). */
  --brand2: #b6ff3c;
  --brand2-hover: #c6ff66;
  --brand2-active: #a3ef22;
  --brand2-bg: rgba(182, 255, 60, 0.14);
  --brand2-text-on: #14210a;

  /* ---- статусы (зарезервированы, не переиспользовать для другого) ---- */
  --status-good: #0ca30c;
  --status-good-bg: rgba(12, 163, 12, 0.14);
  --status-warning: #fab219;
  --status-warning-bg: rgba(250, 178, 25, 0.14);
  --status-serious: #ec835a;
  --status-serious-bg: rgba(236, 131, 90, 0.14);
  --status-critical: #d03b3b;
  --status-critical-bg: rgba(208, 59, 59, 0.16);
  --status-info: #3987e5;
  --status-info-bg: rgba(57, 135, 229, 0.14);

  /* ---- график (категориальный слот "синий", тёмная ступень — из validated палитры dataviz) ---- */
  --chart-series-1: #3987e5;
  --chart-series-1-hover: #5ba0ee;

  /* ---- геометрия ---- */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --sidebar-width: 248px;
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lift: 0 16px 40px rgba(0, 0, 0, 0.45);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

/* Дефолтный размер для инлайновых иконок ICONS.* (common.js) — у самих <svg> нет width/height
   (только viewBox), поэтому без этого правила браузер использует свой дефолт замещаемого
   элемента (300×150px). Более специфичные правила (.btn svg, .badge svg и т.п.) по-прежнему
   переопределяют это там, где нужен другой размер. */
svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--page-bg);
  background-image:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(255, 45, 85, 0.07), transparent 60%),
    radial-gradient(ellipse 700px 500px at 100% 0%, rgba(57, 135, 229, 0.05), transparent 55%);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
}

p {
  margin: 0;
}

a {
  color: var(--brand);
  text-decoration: none;
}
a:hover {
  color: var(--brand-hover);
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

table {
  border-collapse: collapse;
  width: 100%;
}

::selection {
  background: rgba(255, 45, 85, 0.35);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}

/* ---------------------------------------------------------- layout: app shell */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 22px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  flex-shrink: 0;
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  border-left: 2px solid transparent;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-link svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  opacity: 0.85;
}

.nav-link:hover {
  background: var(--surface-2);
  color: var(--text-primary);
  text-decoration: none;
}

.nav-link.active {
  background: var(--brand-bg);
  color: var(--brand);
  border-left-color: var(--brand);
}

.nav-link.active svg {
  opacity: 1;
}

.nav-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--status-warning);
  color: #241a00;
  font-size: 10.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  min-width: 0;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.logout-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}
.logout-btn:hover {
  background: var(--surface-2);
  color: var(--status-critical);
}
.logout-btn svg {
  width: 16px;
  height: 16px;
}

.main {
  flex: 1;
  min-width: 0;
  padding: 28px 36px 60px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}

.page-subtitle {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-muted);
}

.page-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

/* ---------------------------------------------------------- utility */

.container-narrow {
  max-width: 460px;
  margin: 0 auto;
}

.flex {
  display: flex;
}
.flex-col {
  display: flex;
  flex-direction: column;
}
.items-center {
  align-items: center;
}
.justify-between {
  justify-content: space-between;
}
.gap-1 { gap: 6px; }
.gap-2 { gap: 10px; }
.gap-3 { gap: 16px; }

.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-sm { font-size: 12.5px; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

.hidden { display: none !important; }

/* Некоторые страницы (Этап 5 — ручные задачи) переключают видимость через свойство/атрибут
   `hidden` элемента (el.hidden = true), а не через класс .hidden выше. Без этого правила
   более специфичные локальные правила вида `.manual-task-loading { display: flex; }`
   перекрывают встроенный [hidden] браузера (та же специфичность, но объявлены позже) —
   элемент остаётся видимым навсегда, хотя JS уже считает его скрытым. */
[hidden] { display: none !important; }

.fade-in {
  animation: fadeIn 0.25s ease both;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.spin {
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------------------------------------------------------- auth (login / первичная настройка) */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lift);
  padding: 34px 30px 30px;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 26px;
}
.auth-brand .brand-mark {
  width: 46px;
  height: 46px;
  margin-bottom: 16px;
}
.auth-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}
.auth-subtitle {
  margin-top: 7px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.auth-submit {
  width: 100%;
  margin-top: 2px;
  padding: 10px 16px;
}
