:root {
  --bg: #f5f6f8;
  --card-bg: #ffffff;
  --border: #e3e5e9;
  --text: #1a1d24;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #dc2626;

  --shift-first: #38bdf8;
  --shift-second: #fbbf24;
  --shift-night: #22c55e;
  --shift-weekend: #6b21a8;
  --shift-off: #d1d5db;

  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* ---- Логин ---- */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px;
  width: 100%;
  max-width: 380px;
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 600;
}

.subtitle {
  color: var(--text-muted);
  margin: 0 0 24px;
  font-size: 14px;
}

#login-form label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

#login-form input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  background: #fafafa;
}

#login-form input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}

#login-form button {
  width: 100%;
  padding: 11px;
  margin-top: 6px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

#login-form button:hover {
  background: var(--accent-hover);
}

.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin-top: 10px;
  min-height: 18px;
}

/* ---- Топбар ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-left h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

#user-badge {
  font-size: 13px;
  color: var(--text-muted);
}

#month-select {
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 14px;
  background: #fafafa;
}

/* ---- Легенда ---- */
.legend {
  display: flex;
  gap: 20px;
  padding: 14px 28px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.shift-first { background: var(--shift-first); }
.shift-second { background: var(--shift-second); }
.shift-night { background: var(--shift-night); }
.shift-weekend { background: var(--shift-weekend); }
.shift-off { background: var(--shift-off); }

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

table {
  border-collapse: collapse;
  width: 100%;
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

th, td {
  border: 1px solid var(--border);
  text-align: center;
  padding: 0;
  font-size: 13px;
}

th {
  background: #fafbfc;
  color: var(--text-muted);
  font-weight: 500;
  padding: 10px 6px;
  position: sticky;
  top: 0;
}

.name-cell {
  text-align: left !important;
  padding: 10px 14px !important;
  font-weight: 500;
  white-space: nowrap;
  position: sticky;
  left: 0;
  background: var(--card-bg);
  min-width: 160px;
}

.day-cell {
  min-width: 42px;
  height: 42px;
  cursor: default;
  transition: filter 0.1s;
}

.day-cell.editable {
  cursor: pointer;
}

.day-cell.editable:hover {
  filter: brightness(0.95);
}

.day-cell-inner {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
}

.day-cell.shift-first .day-cell-inner { background: color-mix(in srgb, var(--shift-first) 30%, white); }
.day-cell.shift-second .day-cell-inner { background: color-mix(in srgb, var(--shift-second) 30%, white); }
.day-cell.shift-night .day-cell-inner { background: color-mix(in srgb, var(--shift-night) 30%, white); }
.day-cell.shift-weekend .day-cell-inner { background: color-mix(in srgb, var(--shift-weekend) 22%, white); color: color-mix(in srgb, var(--shift-weekend) 85%, black); font-weight: 600; }
.day-cell.shift-off .day-cell-inner { background: color-mix(in srgb, var(--shift-off) 50%, white); color: var(--text-muted); }

.weekend-col {
  background: #fdf2f8;
  box-shadow: inset 0 0 0 9999px rgba(219, 39, 119, 0.035);
}

th.weekend-col {
  background: #fce7f3;
  color: #9d174d;
}

.remove-emp-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  margin-left: 8px;
}

.remove-emp-btn:hover {
  color: var(--danger);
}

/* ---- Кнопки ---- */
.primary-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
}
.primary-btn:hover { background: var(--accent-hover); }

.secondary-btn {
  background: #eef2ff;
  color: var(--accent);
  border: none;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
  margin: 0 28px 28px;
}
.secondary-btn:hover { background: #e0e7ff; }

.ghost-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}
.ghost-btn:hover { background: #f4f4f5; }

.icon-btn {
  background: #f4f4f5;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}
.icon-btn:hover { background: #ebebec; }

/* ---- Модалки ---- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.modal-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 340px;
  box-shadow: var(--shadow);
}

.modal-card h3 {
  margin: 0 0 18px;
  font-size: 17px;
}

.modal-card label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.modal-card input,
.modal-card select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

@media (max-width: 600px) {
  .topbar, .legend, .table-wrap {
    padding-left: 16px;
    padding-right: 16px;
  }
  .login-card {
    padding: 28px 22px;
  }
}
