  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  html { scroll-padding-top: 240px; }

  :root {
    --bg: #0f1117;
    --surface: #1a1d26;
    --surface2: #22263a;
    --border: #2e3250;
    --accent: #4f6ef7;
    --accent2: #6c7fff;
    --text: #e8eaf6;
    --text2: #8b90b8;
    --green: #43e97b;
    --red: #ff5f6d;
    --yellow: #ffd740;
    --show-bg: #1e2235;
    --radius: 10px;
    --shadow: 0 4px 24px rgba(0,0,0,0.4);
  }

  body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

  /* ── ШАПКА ── */
  .header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    position: sticky; top: 0; z-index: 100;
  }
  .header-logo { font-size: 18px; font-weight: 700; letter-spacing: 0.5px; }
  .header-logo span { color: var(--accent2); }
  .header-nav { display: flex; gap: 8px; align-items: center; }
  .btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 16px; border-radius: 8px; border: none; cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.15s; }
  .btn-ghost { background: transparent; color: var(--text2); }
  .btn-ghost:hover { background: var(--surface2); color: var(--text); }
  .btn-primary { background: var(--accent); color: #fff; }
  .btn-primary:hover { background: var(--accent2); }
  .btn-danger { background: var(--red); color: #fff; }
  .btn-danger:hover { opacity: 0.85; }
  .btn-sm { padding: 4px 10px; font-size: 13px; }
  .btn-icon { width: 34px; height: 34px; padding: 0; justify-content: center; border-radius: 8px; }

  /* ── ОСНОВНОЙ КОНТЕНТ ── */
  .main { max-width: 1400px; margin: 0 auto; padding: 24px 16px; }

  /* ── НАВИГАЦИЯ ПО НЕДЕЛЯМ ── */
  .week-nav {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px; gap: 12px; flex-wrap: wrap;
  }
  .week-title { font-size: 20px; font-weight: 700; }
  .week-note { font-size: 13px; color: var(--yellow); margin-top: 2px; }
  .week-controls { display: flex; gap: 8px; align-items: center; }

  /* ── ФИЛЬТР ПО ВЕДУЩЕМУ ── */
  .host-filter { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
  .host-chip {
    padding: 6px 14px; border-radius: 20px; border: 1.5px solid var(--border);
    cursor: pointer; font-size: 13px; font-weight: 500; transition: all 0.15s;
    color: var(--text2);
  }
  .host-chip:hover { border-color: var(--accent); color: var(--text); }
  .host-chip.active { color: #fff; border-color: transparent; }

  /* ── СЕТКА РАСПИСАНИЯ ── */
  .schedule-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
  }
  @media (max-width: 900px)  { .schedule-grid { grid-template-columns: repeat(4, 1fr); } }
  @media (max-width: 700px)  { .schedule-grid { grid-template-columns: repeat(2, 1fr); } }
  @media (max-width: 480px)  {
    .schedule-grid { grid-template-columns: 1fr 1fr; }
    .week-nav { flex-direction: column; align-items: flex-start; gap: 8px; }
    .host-filter { gap: 6px; }
    .host-chip { padding: 5px 10px; font-size: 12px; }
  }
  .mobile-day-nav { display: none; }
  @media (max-width: 700px) {
    .mobile-day-nav {
      display: flex; gap: 6px; align-items: center;
      margin-bottom: 12px; flex-wrap: wrap;
    }
    .mobile-toggle { display: flex; gap: 4px; margin-left: auto; }
    .mobile-toggle button {
      padding: 5px 12px; border-radius: 7px;
      border: 1px solid var(--border); background: transparent;
      color: var(--text2); font-size: 13px; cursor: pointer;
    }
    .mobile-toggle button.active { background: var(--accent); color: #fff; border-color: transparent; }
  }

  .day-col {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
  }
  .day-col.is-friday  { border-color: rgba(100,120,255,0.35); background: rgba(79,110,247,0.04); }
  .day-col.is-weekend { border-color: rgba(155,89,182,0.35);  background: rgba(155,89,182,0.05); }
  .day-col.is-today-col { border-color: rgba(67,233,123,0.4) !important; }
  .day-header {
    padding: 10px 12px 8px;
    border-bottom: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 1px;
  }
  .day-name { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text2); }
  .day-date { font-size: 17px; font-weight: 700; }
  .day-date.weekend { color: var(--accent2); }
  .day-date.today { color: var(--green); }

  .slots { display: flex; flex-direction: column; gap: 4px; padding: 8px; }

  .slot {
    border-radius: 7px; padding: 8px 10px;
    transition: all 0.15s;
  }
  .slot-show {
    background: var(--show-bg);
    border: 1px dashed var(--border);
  }
  .slot-host {
    border: 1px solid var(--border);
    background: var(--surface2);
    cursor: default;
  }
  .slot-host.dimmed { opacity: 0.25; }
  .slot-host.highlighted { border-color: currentColor; box-shadow: 0 0 0 1px currentColor; }
  .slot-time { font-size: 11px; color: var(--text2); font-variant-numeric: tabular-nums; }
  .slot-name { font-size: 14px; font-weight: 600; margin-top: 2px; }
  .slot-label { font-size: 11px; color: var(--text2); margin-top: 1px; }
  .slot-penalty { font-size: 11px; color: var(--red); margin-top: 2px; }
  .slot-empty { font-size: 13px; color: var(--text2); font-style: italic; }

  /* ── ЗАМЕНА В РАСПИСАНИИ ── */
  .slot-substituted {
    background: rgba(255, 193, 7, 0.08) !important;
    border-color: rgba(255, 193, 7, 0.35) !important;
  }
  .slot-sub-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    color: rgba(255, 193, 7, 0.75);
    margin-top: 3px;
    cursor: default;
  }
  .slot-sub-badge .sub-icon { font-size: 11px; }

  /* ── ЗАМЕНА (ОТПУСК) — для редактирования недели ── */
  .slot-replacement-empty {
    border: 1px solid rgba(220, 50, 50, 0.6) !important;
    background: rgba(220, 50, 50, 0.08) !important;
  }
  .slot-replacement-filled {
    border: 1px solid rgba(67, 233, 123, 0.7) !important;
    background: rgba(67, 233, 123, 0.08) !important;
  }

  /* ── ON VACATION BADGE ── */
  .on-vacation { font-size: 11px; color: var(--yellow); margin-top: 2px; }

  /* ── DASHBOARD CARDS ── */
  .dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
  @media (max-width: 700px) { .dash-grid { grid-template-columns: 1fr; } }

  /* ── AGREEMENT ROW ── */
  .agreement-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: nowrap; }
  @media (max-width: 600px) {
    .agreement-row { flex-direction: column; align-items: stretch; }
    .agreement-row > div { min-width: 0 !important; width: 100% !important; }
  }

  .dash-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
  }
  .dash-card-title { font-size: 13px; color: var(--text2); margin-bottom: 4px; }
  .dash-card-value { font-weight: 600; font-size: 15px; }
  .dash-section { margin-top: 20px; }
  .dash-section-title { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
  .dash-item { padding: 4px 0; font-size: 13px; border-bottom: 1px solid var(--border); }

  /* ── ПУСТОЕ СОСТОЯНИЕ ── */
  .empty-state { text-align: center; padding: 80px 20px; color: var(--text2); }
  .empty-state h2 { font-size: 22px; margin-bottom: 8px; color: var(--text); }

  /* ── МОДАЛКИ ── */
  .modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.7);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; padding: 16px;
  }
  .modal {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 14px; padding: 28px; width: 100%; max-width: 480px;
    box-shadow: var(--shadow); max-height: 90vh; overflow-y: auto;
  }
  .modal-title { font-size: 18px; font-weight: 700; margin-bottom: 20px; }
  .modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

  /* ── ФОРМЫ ── */
  .form-group { margin-bottom: 14px; }
  .form-label { display: block; font-size: 13px; color: var(--text2); margin-bottom: 6px; }
  .form-input, .form-select {
    width: 100%; background: var(--bg); border: 1px solid var(--border);
    color: var(--text); border-radius: 8px; padding: 9px 12px; font-size: 14px;
    outline: none; transition: border-color 0.15s;
  }
  .form-input:focus, .form-select:focus { border-color: var(--accent); }
  .form-select option { background: var(--surface); }
  .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .form-check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
  .form-check input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }

  /* ── ВКЛАДКИ АДМИНКИ ── */
  .tabs { display: flex; gap: 4px; margin-bottom: 24px; background: var(--surface); padding: 4px; border-radius: 10px; border: 1px solid var(--border); width: fit-content; position: sticky; top: 60px; z-index: 99; }
  .tab { padding: 8px 18px; border-radius: 7px; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--text2); transition: all 0.15s; }
  .tab.active { background: var(--accent); color: #fff; }
  .tab:hover:not(.active) { background: var(--surface2); color: var(--text); }

  /* ── ТАБЛИЦЫ ── */
  .table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
  table { width: 100%; border-collapse: collapse; }
  th { background: var(--surface2); padding: 10px 14px; text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text2); }
  td { padding: 10px 14px; border-top: 1px solid var(--border); font-size: 14px; }
  tr:hover td { background: var(--surface2); }

  /* ── АНАЛИТИКА ── */
  .analytics-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 24px; }
  .analytics-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
  .analytics-name { font-size: 13px; color: var(--text2); margin-bottom: 4px; }
  .analytics-hours { font-size: 28px; font-weight: 700; }
  .analytics-sub { font-size: 12px; color: var(--text2); margin-top: 2px; }

  /* ── BADGE ── */
  .badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 12px; font-weight: 600; }
  .badge-green { background: rgba(67,233,123,0.15); color: var(--green); }
  .badge-red { background: rgba(255,95,109,0.15); color: var(--red); }
  .badge-yellow { background: rgba(255,215,64,0.15); color: var(--yellow); }
  .badge-blue { background: rgba(79,110,247,0.15); color: var(--accent2); }
  .tooltip-wrap { position: relative; display: inline-flex; align-items: center; }
  .tooltip-icon { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; background: var(--surface2); color: var(--text2); font-size: 11px; cursor: help; margin-left: 4px; border: 1px solid var(--border); }
  .tooltip-text { visibility: hidden; opacity: 0; position: fixed; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; font-size: 12px; font-weight: 400; color: var(--text); white-space: pre-line; line-height: 1.6; width: 280px; z-index: 9999; box-shadow: 0 4px 20px rgba(0,0,0,0.5); text-align: left; pointer-events: none; transition: opacity 0.15s; }
  .legend-toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; color: var(--text2); padding: 8px 0; user-select: none; }
  .legend-toggle:hover { color: var(--text); }
  .legend-body { font-size: 12px; color: var(--text2); line-height: 1.8; padding: 10px 16px; background: var(--surface2); border-radius: 8px; margin-top: 6px; }

  /* ── ЛОАДЕР ── */
  .loader { display: flex; align-items: center; justify-content: center; padding: 60px; }
  .spinner { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
  @keyframes spin { to { transform: rotate(360deg); } }

  /* ── ЦВЕТНОЙ ИНДИКАТОР ── */
  .color-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

  /* ── ЛОГИН ── */
  .login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
  .login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 36px; width: 100%; max-width: 360px; box-shadow: var(--shadow); }
  .login-title { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
  .login-sub { color: var(--text2); font-size: 14px; margin-bottom: 24px; }
  .error-msg { background: rgba(255,95,109,0.15); color: var(--red); padding: 10px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 14px; }

  /* ── DATE RANGE ── */
  .date-range { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 20px; }
  .export-btn { margin-left: auto; }

  /* ── TOGGLE (видимость недели) ── */
  .toggle-wrap { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
  .toggle { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
  .toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
  .toggle-slider {
    position: absolute; inset: 0; border-radius: 20px;
    background: var(--border); transition: background 0.2s;
  }
  .toggle-slider::before {
    content: ''; position: absolute;
    width: 14px; height: 14px; border-radius: 50%;
    left: 3px; top: 3px;
    background: var(--text2); transition: all 0.2s;
  }
  .toggle input:checked + .toggle-slider { background: var(--green); }
  .toggle input:checked + .toggle-slider::before { transform: translateX(16px); background: #fff; }
