/* ─── Variables ─────────────────────────────────────────────────────────── */
:root {
  --bg:          #f4f6f8;
  --bg-card:     #ffffff;
  --accent:      #2563eb;
  --accent-dark: #1e40af;
  --danger:      #dc2626;
  --success:     #16a34a;
  --text:        #111827;
  --text-muted:  #6b7280;
  --border:      #e5e7eb;
  --nav-bg:      #1a2332;
  --nav-text:    #f9fafb;
  --radius:      12px;
  --shadow:      0 2px 8px rgba(0,0,0,.08);

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 40px;
}

/* ─── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

/* ─── Nav ───────────────────────────────────────────────────────────────── */
.nav-top {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  background: var(--nav-bg); color: var(--nav-text);
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
}
.nav-brand { font-weight: 700; font-size: 18px; letter-spacing: .5px; }
.nav-user { display: flex; align-items: center; gap: var(--space-sm); font-size: 14px; }
.nav-logout { color: #93c5fd; font-size: 13px; }
.nav-logout:hover { color: #fff; }
/** Кнопки на тёмной шапке: иначе .btn--ghost берёт чёрный --text и не видно */
.nav-top .btn,
.nav-top a.btn {
  text-decoration: none;
}
.nav-top .btn--ghost,
.nav-top a.btn--ghost {
  color: var(--nav-text);
  border-color: rgba(255, 255, 255, 0.35);
}
.nav-top .btn--ghost:hover,
.nav-top a.btn--ghost:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.nav-top .btn--sm {
  height: 36px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 600;
}
.nav-brand__person { font-weight: 600; opacity: 0.95; }
/* ─── Layout ────────────────────────────────────────────────────────────── */
.main-content { padding: var(--space-md); max-width: 900px; margin: 0 auto; }

/* ─── Login page ────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--nav-bg);
}
.login-card {
  width: 100%; max-width: 400px; margin: var(--space-md);
  background: var(--bg-card); border-radius: var(--radius);
  padding: var(--space-xl) var(--space-lg);
  box-shadow: var(--shadow);
}
.login-card__logo { text-align: center; margin-bottom: var(--space-lg); }
.logo-text { display: block; font-size: 28px; font-weight: 800; color: var(--accent); }
.logo-sub  { font-size: 13px; color: var(--text-muted); }

/* ─── Form fields ───────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: var(--space-xs); margin-bottom: var(--space-md); }
.field__label { font-size: 14px; font-weight: 500; }
.field__input {
  height: 44px; padding: 0 var(--space-md);
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 16px; outline: none; width: 100%;
  transition: border-color .15s;
}
.field__input:focus { border-color: var(--accent); }
.field__password-wrap { position: relative; }
.field__password-wrap .field__input { padding-right: 44px; }
.field__eye {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: 44px; border: none; background: none; cursor: pointer; font-size: 16px;
}

/* ─── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 44px; padding: 0 var(--space-lg);
  border-radius: 8px; border: none; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: background .15s, opacity .15s;
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-dark); }
.btn--full { width: 100%; }
.btn--danger { background: var(--danger); color: #fff; }
.btn--ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* ─── Alerts ────────────────────────────────────────────────────────────── */
.alert { padding: var(--space-sm) var(--space-md); border-radius: 8px; font-size: 14px; margin-bottom: var(--space-md); }
.alert--error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert--success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.alert--info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* ─── Cards ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card); border-radius: var(--radius);
  padding: var(--space-md); box-shadow: var(--shadow);
  margin-bottom: var(--space-md);
}
.card__title { font-size: 17px; font-weight: 700; margin-bottom: var(--space-sm); }

/* ─── Dashboard grid ────────────────────────────────────────────────────── */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}
.dash-stat { background: var(--bg-card); border-radius: var(--radius); padding: var(--space-md); box-shadow: var(--shadow); text-align: center; }
.dash-stat__value { font-size: 32px; font-weight: 800; color: var(--accent); }
.dash-stat__label { font-size: 13px; color: var(--text-muted); margin-top: var(--space-xs); }

/* ─── Table ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; background: var(--bg-card); }
thead th { background: var(--nav-bg); color: var(--nav-text); padding: var(--space-sm) var(--space-md); text-align: left; font-size: 13px; font-weight: 600; }
tbody td { padding: var(--space-sm) var(--space-md); border-bottom: 1px solid var(--border); font-size: 14px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f9fafb; }

/* ─── Badge ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.badge--green  { background: #dcfce7; color: #166534; }
.badge--red    { background: #fee2e2; color: #991b1b; }
.badge--blue   { background: #dbeafe; color: #1e40af; }
.badge--yellow { background: #fef9c3; color: #854d0e; }
.badge--gray   { background: #f3f4f6; color: #6b7280; }

/* ─── Avatar ────────────────────────────────────────────────────────────── */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--accent); color: #fff;
  font-weight: 700; flex-shrink: 0; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--sm  { width: 32px;  height: 32px;  font-size: 13px; }
.avatar--md  { width: 48px;  height: 48px;  font-size: 18px; }
.avatar--lg  { width: 80px;  height: 80px;  font-size: 28px; }

/* ─── Richcoin balance chip ─────────────────────────────────────────────── */
.coin-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: #fef9c3; color: #854d0e; font-weight: 700;
  padding: 2px 10px; border-radius: 999px; font-size: 14px;
}
.coin-chip::before { content: '₽'; font-size: 12px; }

/* ─── Mobile helpers ────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .main-content { padding: var(--space-sm); }
  .card { padding: var(--space-sm); }
}

/* ─── Кабинет руководителя смены (/shift-lead/session/:id) ───────────────── */
.sl-nav-top {
  flex-wrap: wrap;
  gap: var(--space-sm);
}
.sl-nav-top__start {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}
.sl-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--nav-text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.sl-menu-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}
.sl-nav-home {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  color: #93c5fd;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(147, 197, 253, 0.35);
  text-decoration: none;
  white-space: nowrap;
}
.sl-nav-home:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  text-decoration: none;
}
.sl-nav-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
  flex: 1;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
}
.sl-nav-brand__title {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sl-nav-brand__role {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.65;
  letter-spacing: 0;
}
.sl-nav-brand__person {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.85;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sl-layout {
  display: flex;
  min-height: calc(100vh - 48px);
  position: relative;
}
.sl-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  top: 48px;
  z-index: 150;
  background: rgba(15, 23, 42, 0.45);
}
.sl-layout.sl-nav-open .sl-sidebar-backdrop {
  display: block;
}
.sl-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--border);
  padding: var(--space-md) 0;
  overflow-y: auto;
}
.sl-layout .sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 var(--space-sm);
}
.sl-layout .sidebar-link {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}
.sl-layout .sidebar-link:hover {
  background: var(--bg);
  text-decoration: none;
}
.sl-layout .sidebar-link.active {
  background: #dbeafe;
  color: var(--accent);
}
.sl-main {
  flex: 1;
  min-width: 0;
  padding: var(--space-lg);
  overflow-x: auto;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}
.sl-layout .page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}
.sl-layout .page-title {
  font-size: 22px;
  font-weight: 800;
}

/* Карточки на странице настроек */
.sl-card {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-lg);
  box-shadow: var(--shadow);
}
.sl-card__title {
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 var(--space-xs);
}
.sl-card__lead {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 var(--space-md);
  line-height: 1.45;
}
.sl-form-wide {
  max-width: 640px;
}
.sl-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}
.sl-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

@media (max-width: 900px) {
  .sl-menu-btn {
    display: inline-flex;
  }
  .sl-sidebar {
    position: fixed;
    top: 48px;
    left: 0;
    bottom: 0;
    width: min(288px, 88vw);
    z-index: 160;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: none;
  }
  .sl-layout.sl-nav-open .sl-sidebar {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.12);
  }
  .sl-main {
    padding: var(--space-md);
    max-width: none;
  }
  .sl-grid-3 {
    grid-template-columns: 1fr;
  }
  .sl-grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 901px) {
  .sl-layout .sl-sidebar-backdrop {
    display: none !important;
  }
}

body.sl-menu-open {
  overflow: hidden;
}

/* ─── Modals (общие: shift-lead, counselor и др. без inline-стилей в шаблоне) ─ */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  align-items: flex-start;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top, 0px)) 12px max(28px, env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
}
.modal.open {
  display: flex;
}
.modal.modal--nested {
  z-index: 210;
}
.modal-box {
  background: #fff;
  border-radius: var(--radius);
  padding: var(--space-lg);
  width: 100%;
  max-width: 480px;
  margin: var(--space-md);
}
.modal-box--scrollable {
  max-height: min(90vh, 920px);
  max-height: min(90dvh, 920px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-box--scrollable > .modal-header {
  flex-shrink: 0;
}
.modal-form-stack {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
.modal-scroll-body {
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  padding-right: 0;
}
.modal-footer--sticky {
  flex-shrink: 0;
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}
.modal-header h2 {
  font-size: 18px;
  font-weight: 700;
}
.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
}
.modal-footer {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}
.modal-footer.modal-footer--sticky {
  margin-top: var(--space-md);
}
