/* ===== Смена CRM — стили ===== */

:root {
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #dbeafe;
  --accent-softer: #eff6ff;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --weekend: #fdf3f3;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.07), 0 1px 2px rgba(15, 23, 42, 0.05);
}

* { box-sizing: border-box; }

/* Атрибут hidden всегда сильнее любых display-правил ниже */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

/* ===== Шапка ===== */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  font-size: 19px;
  font-weight: 700;
  padding: 14px 0;
  white-space: nowrap;
}

.brand span { color: var(--accent); }

.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
}

.tab {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font: inherit;
  font-weight: 500;
  color: var(--muted);
  padding: 16px 14px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s;
}

.tab:hover { color: var(--text); }

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ===== Основное ===== */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.panel { display: none; }
.panel.active { display: block; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
}

h2 {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 16px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 12px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ===== Кнопки ===== */
.btn {
  appearance: none;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
}
.btn.primary:hover { background: var(--accent-hover); }

.btn.ghost {
  background: var(--card);
  border-color: var(--border);
  color: var(--text);
}
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }

.btn.danger {
  background: var(--card);
  border-color: var(--danger);
  color: var(--danger);
}
.btn.danger:hover { background: var(--danger-soft); }

.btn.small {
  padding: 4px 10px;
  font-size: 13px;
  border-radius: 6px;
}

/* ===== Таблицы ===== */
.table-wrap {
  overflow-x: auto;
  padding: 4px 0;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--accent-softer); }

.data-table tfoot td {
  font-weight: 700;
  border-top: 2px solid var(--border);
  border-bottom: none;
  background: #f8fafc;
}

.col-actions { width: 1%; }

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.cell-strong { font-weight: 600; }
.cell-muted { color: var(--muted); font-size: 13px; }

.deleted-badge {
  color: var(--muted);
  font-size: 12px;
}

/* смена, которую сотрудник запросил удалить (ждёт решения админа) */
.request-badge {
  display: inline-block;
  color: #b45309;
  background: #fef3c7;
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.shift-chip.requested {
  opacity: .55;
  text-decoration: line-through;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 32px 16px;
  margin: 0;
}

/* ===== Фильтры ===== */
.filters {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.filters label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

/* ===== Поля форм ===== */
input[type="text"],
input[type="number"],
input[type="date"],
input[type="time"],
select {
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ===== График ===== */
.month-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.month-label {
  font-weight: 600;
  min-width: 140px;
  text-align: center;
}

.schedule-wrap { padding: 0; }

.schedule-table {
  border-collapse: collapse;
  font-size: 12px;
  width: 100%;
}

.schedule-table th,
.schedule-table td {
  border: 1px solid var(--border);
  text-align: center;
  vertical-align: top;
  min-width: 36px;
  padding: 2px;
}

.schedule-table thead th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--muted);
  padding: 6px 2px;
  position: sticky;
  top: 0;
}

.schedule-table thead th .dow {
  display: block;
  font-size: 10px;
  font-weight: 400;
  text-transform: lowercase;
}

.schedule-table .emp-col {
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  padding: 8px 12px;
  min-width: 160px;
  max-width: 200px;
  position: sticky;
  left: 0;
  background: var(--card);
  z-index: 5;
  border-right: 2px solid var(--border);
}

.schedule-table thead .emp-col { z-index: 6; background: #f8fafc; }

.schedule-table td.day-cell {
  cursor: pointer;
  height: 44px;
  transition: background .1s;
}

.schedule-table td.day-cell:hover { background: var(--accent-softer); }

.schedule-table .weekend { background: var(--weekend); }
.schedule-table thead th.weekend { color: #b91c1c; }

.schedule-table .today { box-shadow: inset 0 0 0 2px var(--accent); }

.shift-chip {
  display: block;
  background: var(--accent-soft);
  color: #1e40af;
  border-radius: 5px;
  padding: 4px;
  margin: 1px 0;
  font-size: 11px;
  line-height: 1.3;
  min-height: 24px;
  box-sizing: border-box;
  white-space: nowrap;
  cursor: pointer;
}

.shift-chip:hover { background: var(--accent); color: #fff; }

.shift-chip.mine {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.schedule-table .emp-col.me { color: var(--accent); }

/* ===== Роли: сотруднику админские элементы не показываем ===== */
body.role-employee .admin-only { display: none !important; }

/* у сотрудника в графике кликабельны только своя строка и свои смены */
body.role-employee .schedule-table td.day-cell:not(.clickable),
body.role-employee .shift-chip:not(.mine) { cursor: default; }
body.role-employee .schedule-table td.day-cell:not(.clickable):hover { background: inherit; }
body.role-employee .schedule-table td.day-cell.weekend:not(.clickable):hover { background: var(--weekend); }
body.role-employee .shift-chip:not(.mine):hover { background: var(--accent-soft); color: #1e40af; }

/* ===== Вход и шапка пользователя ===== */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}


.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
  width: min(360px, 100%);
  margin: 0;
}

.login-brand {
  padding: 0 0 4px;
  font-size: 24px;
  text-align: center;
}

.login-card .hint { text-align: center; margin-bottom: 20px; }

.login-card label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 12px;
}

.login-card label input {
  display: block;
  width: 100%;
  margin-top: 4px;
  color: var(--text);
}

.login-card input[type="password"] {
  font: inherit;
  font-size: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.login-btn { width: 100%; margin-top: 4px; }

dialog input[type="password"] {
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.user-box {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.25;
  min-width: 0;
}

#user-name {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

#user-role { font-size: 12px; }

/* ===== Отчёт ===== */
.report-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* ===== Диалоги ===== */
dialog {
  border: none;
  border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
  padding: 24px;
  width: min(440px, calc(100vw - 32px));
  color: var(--text);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

dialog form { margin: 0; }

dialog label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 12px;
}

dialog label input,
dialog label select {
  display: block;
  width: 100%;
  margin-top: 4px;
  color: var(--text);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.form-error {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}

.shift-preview {
  background: var(--accent-softer);
  border: 1px solid var(--accent-soft);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 12px;
  min-height: 20px;
}

.shift-preview strong { color: var(--accent); }

.dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  margin-top: 8px;
}

.dialog-actions .spacer { flex: 1; }

/* ===== Адаптивность ===== */
@media (max-width: 768px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: 0 16px;
  }

  .brand { padding: 12px 0 4px; }

  .topbar { position: relative; }

  .user-box {
    position: absolute;
    top: 8px;
    right: 12px;
  }

  #user-name { max-width: 130px; }

  .tabs {
    width: 100%;
    -webkit-overflow-scrolling: touch;
  }

  .tab { padding: 10px 12px 12px; }

  main { padding: 16px 12px; }

  .filters { gap: 10px; }
  .filters label { flex-direction: column; align-items: flex-start; gap: 4px; width: 100%; }
  .filters select { width: 100%; }

  .form-row { grid-template-columns: 1fr; gap: 0; }

  .panel-head { flex-direction: column; align-items: stretch; }
  .panel-head .btn { width: 100%; }
  .month-nav { justify-content: space-between; }
  .report-controls { width: 100%; }
  .report-controls select { flex: 1; }
}
