/* MDKM HUB — Design Tokens v3.0 (брендбук МДКМ) */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800&family=Manrope:wght@400;500;600;700;800;900&family=Unbounded:wght@500;600;700;800;900&display=swap');

/* ═══════════════════════════════════════════════════════
   ОСНОВНЫЕ ЦВЕТА БРЕНДА
   ═══════════════════════════════════════════════════════ */
:root {
  /* Бренд */
  --brand:        #5D6EFE;   /* фиолетовый — главный акцент */
  --brand-hover:  #4859e8;
  --brand-soft:   #e7eaff;   /* светлый фон акцента (для блоков) */
  --brand-glow:   rgba(93,110,254,0.30);
  --brand-deep:   #101D72;   /* тёмно-синий — для гипер-акцентов */
  --brand-sky:    #BAF2FF;   /* голубой — лёгкие подсветки */
  --brand-sky-soft: #e3f9ff;

  /* Алиасы для обратной совместимости со старым CSS */
  --accent:       var(--brand);
  --accent-hover: var(--brand-hover);
  --accent-glow:  var(--brand-glow);

  /* Нейтральная шкала */
  --black:    #1C1C1C;
  --gray-100: #f6f6fa;
  --gray-200: #ececf3;
  --gray-300: #dadae5;
  --gray-400: #b4b4c5;
  --gray-500: #80809a;
  --gray-600: #545470;
  --gray-700: #3a3a52;
  --gray-800: #232336;

  /* Surfaces (только светлая тема) */
  --bg:        #f4f5fb;
  --surface:   #ffffff;
  --surface2:  #f0f1f9;
  --surface3:  #e7e9f4;
  --text:      #1C1C1C;
  --text-sub:  #545470;
  --text-mute: #80809a;
  --border:    rgba(28,28,28,0.08);
  --border-strong: rgba(28,28,28,0.14);
  --bdr-sub:   rgba(28,28,28,0.05);

  /* Тени */
  --card-shadow:    0 1px 2px rgba(28,28,28,0.04), 0 4px 12px rgba(28,28,28,0.04);
  --card-shadow-md: 0 2px 6px rgba(28,28,28,0.06), 0 12px 28px rgba(28,28,28,0.08);
  --card-shadow-lg: 0 8px 16px rgba(28,28,28,0.08), 0 24px 60px rgba(28,28,28,0.12);
  --shadow-brand-sm: 0 4px 12px var(--brand-glow);
  --shadow-brand-md: 0 8px 24px rgba(93,110,254,0.36);
  --shadow-brand-lg: 0 12px 40px rgba(93,110,254,0.45);
  --shadow-modal:    0 24px 80px rgba(28,28,28,0.18);

  /* Статусы */
  --status-green:      #16b870;
  --status-green-bg:   rgba(22,184,112,0.10);
  --status-green-bdr:  rgba(22,184,112,0.22);
  --status-yellow:     #e89a00;
  --status-yellow-bg:  rgba(232,154,0,0.10);
  --status-yellow-bdr: rgba(232,154,0,0.22);
  --status-red:        #e44848;
  --status-red-bg:     rgba(228,72,72,0.08);
  --status-red-bdr:    rgba(228,72,72,0.20);
  --status-blue:       #2f8fee;
  --status-blue-bg:    rgba(47,143,238,0.10);
  --status-gold:       #d4a017;
  --status-silver:     #98a0b3;
  --status-bronze:     #b97a3e;

  /* Цвета ролей */
  --role-res-color:  #5D6EFE;  --role-res-bg:  rgba(93,110,254,0.12);
  --role-cand-color: #e89a00;  --role-cand-bg: rgba(232,154,0,0.12);
  --role-vol-color:  #16b870;  --role-vol-bg:  rgba(22,184,112,0.10);
  --role-tr-color:   #545470;  --role-tr-bg:   rgba(84,84,112,0.10);

  /* Палитра проектов / направлений (брендбук, дополнительные цвета) */
  --proj-1: #5D6EFE; --proj-1-bg: rgba(93,110,254,0.12);
  --proj-2: #e44848; --proj-2-bg: rgba(228,72,72,0.10);
  --proj-3: #ec5fa6; --proj-3-bg: rgba(236,95,166,0.12);
  --proj-4: #2f8fee; --proj-4-bg: rgba(47,143,238,0.12);
  --proj-5: #f08538; --proj-5-bg: rgba(240,133,56,0.12);
  --proj-6: #c9a772; --proj-6-bg: rgba(201,167,114,0.14);
  --proj-7: #16b870; --proj-7-bg: rgba(22,184,112,0.12);
  --proj-8: #f0d840; --proj-8-bg: rgba(240,216,64,0.16);

  /* Шрифты: Montserrat — основной текст (брендбук v2); Grandis Extended — подключить локально в public/fonts/grandis/ через @font-face и подставить в --font-display при наличии файлов */
  --font-body:    'Montserrat', 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Unbounded', 'Montserrat', sans-serif;
  --font-mono:    'SF Mono', 'JetBrains Mono', Consolas, monospace;

  /* Радиусы */
  --r-xs: 6px; --r-sm: 10px; --r-md: 14px; --r-lg: 18px; --r-xl: 24px; --r-2xl: 32px;
  --r-pill: 999px;
  --r-avatar-sm: 8px; --r-avatar-md: 12px; --r-avatar-lg: 18px;

  /* Анимации */
  --t-fast: 150ms ease;
  --t-base: 250ms cubic-bezier(0.22, 1, 0.36, 1);
  --t-slow: 400ms cubic-bezier(0.22, 1, 0.36, 1);

  /* Layout */
  --sidebar-w: 240px;
  --header-h:  64px;
}

/* Тёмная тема — handoff; класс на <html> (ранний paint) и/или <body> */
html.theme-dark,
body.theme-dark {
  color-scheme: dark;
  --brand:        #7280ff;
  --brand-hover:  #8f9cff;
  --brand-soft:   rgba(114, 128, 255, 0.14);
  --brand-glow:   rgba(114, 128, 255, 0.28);
  --accent:       var(--brand);
  --accent-hover: var(--brand-hover);
  --accent-glow:  var(--brand-glow);
  --bg:       #0f0f14;
  --surface:  #17171f;
  --surface2: #1e1e28;
  --surface3: #26263a;
  --text:     #e8e8f2;
  --text-sub: #9898b8;
  --text-mute:#5e5e80;
  --border:    rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);
  --bdr-sub:   rgba(255, 255, 255, 0.05);
  --card-shadow:    0 1px 2px rgba(0, 0, 0, 0.35), 0 4px 16px rgba(0, 0, 0, 0.22);
  --card-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35), 0 12px 28px rgba(0, 0, 0, 0.28);
  --card-shadow-lg: 0 8px 20px rgba(0, 0, 0, 0.4), 0 24px 48px rgba(0, 0, 0, 0.35);
  --shadow-brand-sm: 0 4px 16px rgba(114, 128, 255, 0.22);
  --shadow-brand-md: 0 8px 28px rgba(114, 128, 255, 0.28);
  --shadow-brand-lg: 0 12px 36px rgba(114, 128, 255, 0.35);
  --shadow-modal:    0 24px 80px rgba(0, 0, 0, 0.55);
}

/* ═══════════════════════════════════════════════════════
   БАЗОВЫЙ СБРОС
   ═══════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

/* Меньше горизонтального «rubber-band» и системного «назад» по краю в мобильных браузерах (полный контроль — только кнопка Назад в UI). */
@media (max-width: 900px) {
  html,
  body {
    overscroll-behavior-x: none;
  }
}

body {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

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

::selection { background: var(--brand-soft); color: var(--brand-deep); }

/* Заголовки в Unbounded */
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 800; letter-spacing: -0.01em; color: var(--text); }
h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
h4 { font-size: 15px; }

/* Watermark — крупная серая цифра/глиф (как в брендбуке) */
.watermark {
  position: absolute;
  font-family: var(--font-display);
  font-weight: 900;
  color: var(--brand-soft);
  pointer-events: none;
  user-select: none;
  z-index: 0;
}

/* ═══════════════════════════════════════════════════════
   ЗАГРУЗЧИК
   ═══════════════════════════════════════════════════════ */
.loader-overlay {
  position: fixed; inset: 0; z-index: 99999;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 18px;
  transition: opacity 0.7s ease, visibility 0.7s;
}
.loader-overlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loader-spinner {
  width: 44px; height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: mdkm-spin 0.9s linear infinite;
}
.loader-logo {
  font-family: var(--font-display);
  color: var(--brand); font-weight: 800;
  font-size: 14px; letter-spacing: 0.12em;
}
@keyframes mdkm-spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════════════
   КАРТОЧКИ
   ═══════════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  box-shadow: var(--card-shadow);
  padding: 16px;
  transition: var(--t-base);
}
.card-sm  { border-radius: var(--r-sm); padding: 10px 12px; }
.card-md  { border-radius: var(--r-md); }
.card-xl  { border-radius: var(--r-xl); padding: 24px; }
.card-hover:hover { transform: translateY(-2px); box-shadow: var(--card-shadow-md); }

/* ═══════════════════════════════════════════════════════
   КНОПКИ
   ═══════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border: none; border-radius: var(--r-md);
  font-family: var(--font-body); font-weight: 700; font-size: 14px;
  cursor: pointer; text-decoration: none;
  transition: var(--t-base);
  white-space: nowrap;
  user-select: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-accent {
  background: var(--brand); color: #fff;
  box-shadow: var(--shadow-brand-sm);
}
.btn-accent:hover { background: var(--brand-hover); box-shadow: var(--shadow-brand-md); }

.btn-ghost {
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface3); border-color: var(--border-strong); }

.btn-outline {
  background: transparent; color: var(--brand);
  border: 1px solid var(--brand);
}
.btn-outline:hover { background: var(--brand-soft); }

.btn-danger { background: var(--status-red-bg); color: var(--status-red); border: 1px solid var(--status-red-bdr); }
.btn-danger:hover { background: var(--status-red); color: #fff; }

.btn-full  { width: 100%; }
.btn-sm    { padding: 8px 14px; font-size: 12px; border-radius: var(--r-sm); }
.btn-lg    { padding: 16px 24px; font-size: 15px; border-radius: var(--r-lg); }
.btn-icon  { padding: 10px; aspect-ratio: 1; }

/* ═══════════════════════════════════════════════════════
   БЕЙДЖИ
   ═══════════════════════════════════════════════════════ */
.badge {
  display: inline-block;
  font-size: 10px; font-weight: 700;
  padding: 3px 8px; border-radius: var(--r-pill);
  text-transform: uppercase; letter-spacing: 0.4px;
  line-height: 1.4;
  white-space: nowrap;
}
.badge-res    { color: var(--role-res-color);  background: var(--role-res-bg); }
.badge-cand   { color: var(--role-cand-color); background: var(--role-cand-bg); }
.badge-vol    { color: var(--role-vol-color);  background: var(--role-vol-bg); }
.badge-tr     { color: var(--role-tr-color);   background: var(--role-tr-bg); }
.badge-green  { color: var(--status-green);    background: var(--status-green-bg); }
.badge-yellow { color: var(--status-yellow);   background: var(--status-yellow-bg); }
.badge-red    { color: var(--status-red);      background: var(--status-red-bg); }
.badge-blue   { color: var(--status-blue);     background: var(--status-blue-bg); }
.badge-accent { color: var(--brand);           background: var(--brand-soft); }

/* ═══════════════════════════════════════════════════════
   ИНПУТЫ
   ═══════════════════════════════════════════════════════ */
input, select, textarea {
  font-family: var(--font-body);
  font-size: 13px; font-weight: 500;
  color: var(--text); background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 12px 14px; width: 100%;
  transition: var(--t-fast);
  -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--brand-glow);
}
input::placeholder, textarea::placeholder { color: var(--text-mute); }

label {
  display: block;
  font-size: 11px; font-weight: 700;
  color: var(--text-sub);
  text-transform: uppercase; letter-spacing: 0.4px;
  margin-bottom: 5px;
}

/* ═══════════════════════════════════════════════════════
   АВАТАРЫ И ЛОГО
   ═══════════════════════════════════════════════════════ */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-soft); color: var(--brand);
  font-family: var(--font-display); font-weight: 800;
  border-radius: var(--r-avatar-md);
  overflow: hidden;
  flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 32px; height: 32px; font-size: 12px; border-radius: var(--r-avatar-sm); }
.avatar-md { width: 48px; height: 48px; font-size: 16px; }
.avatar-lg { width: 72px; height: 72px; font-size: 22px; border-radius: var(--r-avatar-lg); }

.logo-mark {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand); color: #fff;
  font-family: var(--font-display); font-weight: 900;
  border-radius: var(--r-md);
  flex-shrink: 0;
  letter-spacing: -0.04em;
}

/* ═══════════════════════════════════════════════════════
   КАЛЕНДАРЬ
   ═══════════════════════════════════════════════════════ */
.cal-day {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  min-height: 80px;
  padding: 6px;
  background: var(--surface);
  display: flex; flex-direction: column;
  overflow: hidden;
  transition: var(--t-fast);
}
.cal-day.today { border-color: var(--brand); background: var(--brand-soft); }
.cal-day.other-month { opacity: 0.4; }
.cal-day.holiday .cal-date { color: var(--status-red); }
.cal-date {
  font-weight: 800; font-size: 13px;
  width: 24px; height: 24px; line-height: 24px;
  text-align: center; border-radius: 50%;
  margin-bottom: 4px;
}

/* ═══════════════════════════════════════════════════════
   ЗОНЫ АКТИВНОСТИ
   ═══════════════════════════════════════════════════════ */
.zone-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}
.zone-green  { background: var(--status-green); }
.zone-yellow { background: var(--status-yellow); }
.zone-red    { background: var(--status-red); }

/* ═══════════════════════════════════════════════════════
   BOTTOM-NAV (мобильный профиль)
   ═══════════════════════════════════════════════════════ */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: 72px; z-index: 1000;
  display: flex; align-items: stretch;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  padding: 8px 4px env(safe-area-inset-bottom);
}
.bottom-nav-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  color: var(--text-mute);
  font-size: 10px; font-weight: 700;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: var(--t-fast);
  text-decoration: none;
}
.bottom-nav-item svg { width: 22px; height: 22px; stroke-width: 2; }
.bottom-nav-item.active { color: var(--brand); background: var(--brand-soft); }
.bottom-nav-item:hover { color: var(--text); }

html.theme-dark .bottom-nav {
  background: rgba(23, 23, 31, 0.96);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

/* ═══════════════════════════════════════════════════════
   УТИЛИТЫ
   ═══════════════════════════════════════════════════════ */
.flex      { display: flex; }
.flex-col  { display: flex; flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.text-sub  { color: var(--text-sub); }
.text-mute { color: var(--text-mute); }
.text-brand { color: var(--brand); }
.font-display { font-family: var(--font-display); font-weight: 800; }
.text-xs   { font-size: 11px; }
.text-sm   { font-size: 12px; }
.text-md   { font-size: 14px; }
.text-lg   { font-size: 16px; }
.text-xl   { font-size: 18px; font-weight: 700; }
.text-2xl  { font-size: 24px; font-weight: 800; }
.fw-7      { font-weight: 700; }
.fw-8      { font-weight: 800; }
.opacity-50 { opacity: 0.5; }
.scrollbar-thin::-webkit-scrollbar { width: 6px; height: 6px; }
.scrollbar-thin::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.scrollbar-thin::-webkit-scrollbar-track { background: transparent; }

/* ── SVG Icons (sprite) ────────────────────────────────── */
.icon {
  display: inline-block;
  width: 1.15em;
  height: 1.15em;
  vertical-align: -0.18em;
  color: currentColor;
  flex-shrink: 0;
}
.icon-sm { width: 14px; height: 14px; vertical-align: -0.15em; }
.icon-md { width: 18px; height: 18px; vertical-align: -0.16em; }
.icon-lg { width: 24px; height: 24px; vertical-align: -0.2em; }
.icon-xl { width: 32px; height: 32px; vertical-align: -0.25em; }

/* ═══════════════════════════════════════════════════════
   Статусы задач (список / карточки; классы из handoff v2)
   ═══════════════════════════════════════════════════════ */
.badge.task-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-transform: none;
  letter-spacing: 0.02em;
  font-weight: 700;
  font-size: 11px;
  line-height: 1.3;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  margin-left: 0;
}
.task-status--pending {
  color: var(--status-yellow);
  background: var(--status-yellow-bg);
  border-color: var(--status-yellow-bdr);
}
.task-status--inwork {
  color: var(--brand);
  background: var(--brand-soft);
  border-color: rgba(93, 110, 254, 0.22);
}
.task-status--review {
  color: var(--status-blue);
  background: var(--status-blue-bg);
  border-color: rgba(47, 143, 238, 0.22);
}
.task-status--done {
  color: var(--status-green);
  background: var(--status-green-bg);
  border-color: var(--status-green-bdr);
}
.task-status--negative {
  color: var(--status-red);
  background: var(--status-red-bg);
  border-color: var(--status-red-bdr);
}

/* Общие поверхности для таблиц и блоков панели */
.mdkm-panel-surface {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--card-shadow);
}
