:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #242838;
  --border: #2e3347;
  --text: #e4e6f0;
  --text2: #8b8fa8;
  --accent: #6c5ce7;
  --green: #00b894;
  --green-bg: rgba(0,184,148,0.12);
  --orange: #fdcb6e;
  --orange-bg: rgba(253,203,110,0.12);
  --cyan: #81ecec;
  --red: #e17055;
  --red-bg: rgba(225,112,85,0.15);
  --blue: #74b9ff;
  --blue-bg: rgba(116,185,255,0.12);
  --pink: #fd79a8;
  --purple-bg: rgba(108,92,231,0.12);
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
}
* { margin:0; padding:0; box-sizing:border-box; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 280px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
}
.sidebar h1 {
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.main {
  margin-left: 280px;
  flex: 1;
  padding: 24px 32px;
  min-width: 0;
}
.section-divider {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 8px;
}
.section-divider h3 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Store cards */
.store-card {
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
}
.store-card:hover { border-color: var(--border); }
.store-card.active { border-color: var(--accent); background: rgba(108,92,231,0.08); }
.store-card h3 { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.store-card .meta { font-size: 12px; color: var(--text2); }
.store-header { display: flex; align-items: center; justify-content: space-between; }
.store-header .btn-sm { padding: 2px 6px; font-size: 12px; opacity: 0; transition: opacity 0.15s; }
.store-card:hover .store-header .btn-sm { opacity: 1; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #5a4bd6; }
.btn-ghost { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-danger:hover { background: rgba(225,112,85,0.25); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: 14px;
  padding: 28px;
  min-width: 400px;
  max-width: 500px;
  width: 90%;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.modal h2 { font-size: 18px; margin-bottom: 20px; }
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-group input, .form-group select {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.form-group input:focus, .form-group select:focus { border-color: var(--accent); }
.checkbox-group { margin-bottom: 16px; }
.checkbox-label { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; color: var(--text); }
.checkbox-label input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }

/* Employee list */
.emp-list { display: flex; flex-direction: column; gap: 6px; }
.emp-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--surface2);
  border-radius: 8px;
  font-size: 13px;
}
.emp-item .name { display: flex; align-items: center; gap: 8px; }
.emp-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.emp-stats { font-size: 11px; color: var(--text2); margin-top: 2px; }

/* Top bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.nav-month { display: flex; align-items: center; gap: 12px; }
.nav-month h2 { font-size: 22px; min-width: 200px; text-align: center; }
.actions { display: flex; gap: 8px; }

/* Schedule grid */
.schedule-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}
.schedule-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}
.schedule-table th,
.schedule-table td {
  padding: 8px 4px;
  text-align: center;
  font-size: 12px;
  border: 1px solid var(--border);
}
.schedule-table thead th {
  background: var(--surface2);
  font-weight: 600;
  color: var(--text2);
  position: sticky;
  top: 0;
  z-index: 10;
}
.schedule-table thead th.weekend { background: rgba(225,112,85,0.08); color: var(--red); }
.schedule-table .emp-name {
  text-align: left;
  padding-left: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface2);
  min-width: 120px;
  position: sticky;
  left: 0;
  z-index: 5;
}
.schedule-table thead th:first-child { position: sticky; left: 0; z-index: 15; }
.schedule-table td.cell {
  cursor: pointer;
  transition: all 0.1s;
  min-width: 32px;
}
.schedule-table td.cell:hover { outline: 2px solid var(--accent); outline-offset: -2px; z-index: 2; }

.cell.work        { background: var(--green-bg); color: var(--green); }
.cell.substitute  { box-shadow: inset 0 0 0 2px var(--cyan); background: rgba(129,236,236,0.1); }
.cell.off          { background: var(--red-bg); color: var(--red); }
.cell.manual-off   { background: rgba(253,121,168,0.15); color: var(--pink); }

/* Время в ячейке: число сверху и снизу */
.cell .time {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.15;
  font-weight: 700;
  font-size: 11px;
}
.cell .time .t-from { opacity: 1; }
.cell .time .t-to   { opacity: 0.75; }
.cell .time .t-dash { font-size: 8px; opacity: 0.4; line-height: 0; }
.cell.today         { box-shadow: inset 0 0 0 2px var(--accent); }
.cell .shift-label  { font-size: 9px; opacity: 0.8; }

.day-header .day-num { font-size: 14px; font-weight: 700; color: var(--text); }
.day-header .day-name { font-size: 10px; color: var(--text2); }
.day-header .pay-badge { font-size: 10px; line-height: 1; text-align: center; }
.day-header.weekend .day-num { color: var(--red); }

/* Coverage row */
.coverage-row td { font-weight: 700 !important; background: var(--surface2) !important; font-size: 13px !important; }
.sub-row td { border-top: 1px dashed var(--cyan); }
.sub-cell { background: rgba(129,236,236,0.08) !important; cursor: help; }
.sub-cell:hover { background: rgba(129,236,236,0.18) !important; }
.coverage-ok   { color: var(--green) !important; }
.coverage-warn { color: var(--orange) !important; }
.coverage-bad  { color: var(--red) !important; }

/* Stats bar */
.stats-bar { display: flex; gap: 12px; margin-top: 20px; flex-wrap: wrap; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 150px;
  flex: 1;
}
.stat-card h4 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text2); margin-bottom: 8px; }
.stat-card .value { font-size: 24px; font-weight: 700; }
.stat-card .detail { font-size: 12px; color: var(--text2); margin-top: 4px; }

/* Legend */
.legend { display: flex; gap: 16px; margin-bottom: 16px; font-size: 12px; color: var(--text2); flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-swatch { width: 16px; height: 16px; border-radius: 4px; }

/* Empty state */
.empty-state { text-align: center; padding: 80px 20px; color: var(--text2); }
.empty-state .icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; color: var(--text); margin-bottom: 8px; }
.empty-state p { font-size: 14px; margin-bottom: 24px; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 2000;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* Print */
@page {
  size: landscape;
  margin: 8mm;
}
@media print {
  /* Скрываем всё кроме графика */
  .sidebar, .actions, .btn, .stats-bar, .legend, .nav-month, .toast, .modal-overlay, .top-bar { display: none !important; }
  .main { margin-left: 0 !important; padding: 8px !important; }

  /* Тёмный фон как в приложении */
  body { background: #0f1117 !important; color: #e4e6f0 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .app { display: block !important; }

  /* Таблица */
  .schedule-wrapper {
    border: 1px solid #2e3347 !important;
    background: #1a1d27 !important;
    overflow: visible !important;
  }
  .schedule-table { min-width: 0 !important; width: 100% !important; }
  .schedule-table th, .schedule-table td {
    border: 1px solid #2e3347 !important;
    padding: 4px 3px !important;
    font-size: 9px !important;
  }
  .schedule-table thead th {
    background: #242838 !important;
    color: #8b8fa8 !important;
  }
  .schedule-table .emp-name {
    background: #242838 !important;
    color: #e4e6f0 !important;
  }

  /* Убираем dim-эффекты */
  .next-period, .past-period, .future-month { opacity: 1 !important; }

  /* Скрываем колонку часов и строку покрытия */
  .print-hide-col { display: none !important; }
}

/* Responsive */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
}

/* Future month (dimmed) */
.future-month {
  opacity: 0.4;
}

/* Past period (greyed out) */
.past-period {
  opacity: 0.45;
}
.past-period .time {
  opacity: 0.7;
}
.day-header.past-period .day-num,
.day-header.past-period .day-name {
  color: var(--text2) !important;
}

/* Next period (greyed out after 15th) */
.next-period {
  opacity: 0.4;
}
.next-period .time {
  opacity: 0.7;
}
.day-header.next-period .day-num,
.day-header.next-period .day-name {
  color: var(--text2) !important;
}
.day-header.future-month .day-num,
.day-header.future-month .day-name {
  color: var(--text2) !important;
}
.future-month-sep {
  border-left: 2px solid var(--accent) !important;
}
