*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", sans-serif;
  background: #111;
  color: #eee;
  min-height: 100vh;
}

/* ── Экраны ── */
.screen { display: none; }
.screen.active { display: flex; }

.mobile-menu-btn,
.mobile-menu-backdrop,
.sidebar-close {
  display: none;
}

/* ── Логин ── */
#screen-login {
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background: #111;
}

.login-box {
  background: #1c1c1c;
  border: 1px solid #2a2a2a;
  border-radius: 16px;
  padding: 40px;
  width: 360px;
  text-align: center;
}

.login-logo {
  font-size: 48px;
  margin-bottom: 12px;
}

.login-box h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}

.login-sub {
  color: #888;
  font-size: 14px;
  margin-bottom: 24px;
}

/* ── Основной layout ── */
#screen-main {
  min-height: 100vh;
  flex-direction: row;
}

.sidebar {
  width: 220px;
  min-height: 100vh;
  background: #1a1a1a;
  border-right: 1px solid #2a2a2a;
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  flex-shrink: 0;
}

.sidebar-logo {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  color: #b59e5c;
  padding: 0 20px 24px;
  border-bottom: 1px solid #2a2a2a;
  margin-bottom: 16px;
  letter-spacing: 2px;
}

.nav-item {
  display: block;
  padding: 12px 24px;
  color: #aaa;
  cursor: pointer;
  font-size: 15px;
  transition: 0.2s;
  border-left: 3px solid transparent;
  text-decoration: none;
}

.nav-item:hover { color: #fff; background: #222; }
.nav-item.active { color: #b59e5c; border-left-color: #b59e5c; background: #222; }

.logout-btn {
  margin: auto 20px 0;
  background: none;
  border: 1px solid #333;
  color: #888;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: 0.2s;
}
.logout-btn:hover { border-color: #b59e5c; color: #b59e5c; }

.main-content {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
}

/* ── Страницы ── */
.page { display: none; }
.page.active { display: block; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
}

.page-subtitle {
  color: #888;
  font-size: 14px;
  margin-top: 5px;
  text-transform: capitalize;
}

/* ── Компоненты ── */
.a-input {
  width: 100%;
  background: #222;
  border: 1px solid #333;
  border-radius: 10px;
  color: #fff;
  padding: 12px 14px;
  font-size: 15px;
  margin-bottom: 12px;
  outline: none;
  transition: 0.2s;
}
.a-input:focus { border-color: #b59e5c; }

.a-field {
  display: block;
  margin-bottom: 14px;
}

.a-field span {
  display: block;
  color: #c7c7c7;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 7px;
}

.a-field .a-input,
.a-field .a-select {
  margin-bottom: 0;
}

.a-select {
  background: #222;
  border: 1px solid #333;
  border-radius: 10px;
  color: #fff;
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
  cursor: pointer;
}

.modal-box .a-select {
  width: 100%;
  margin-bottom: 12px;
}

.a-btn {
  width: 100%;
  background: #b59e5c;
  color: #000;
  border: none;
  border-radius: 10px;
  padding: 13px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.2s;
  margin-top: 4px;
}
.a-btn:hover { background: #d4b96a; }
.a-btn.small { width: auto; padding: 8px 18px; font-size: 14px; margin-top: 0; }
.a-btn.secondary { background: #2a2a2a; color: #eee; border: 1px solid #3a3a3a; }
.a-btn.secondary:hover { border-color: #b59e5c; color: #b59e5c; background: #222; }
.a-btn.danger { background: #c0392b; color: #fff; }
.a-btn.danger:hover { background: #e74c3c; }

.icon-btn {
  width: 40px;
  height: 40px;
  background: #222;
  border: 1px solid #333;
  border-radius: 10px;
  color: #b59e5c;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.icon-btn:hover {
  border-color: #b59e5c;
}

.compact-date {
  width: 155px;
  margin-bottom: 0;
}

.photo-picker {
  display: flex;
  gap: 14px;
  align-items: center;
  background: #202020;
  border: 1px solid #333;
  border-radius: 12px;
  margin-bottom: 12px;
  padding: 12px;
}

.photo-picker img {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  object-fit: cover;
  background: #111;
  flex-shrink: 0;
}

.photo-picker-body {
  min-width: 0;
  flex: 1;
}

.photo-picker-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 4px;
}

.photo-picker-sub {
  color: #888;
  font-size: 12px;
  margin-bottom: 10px;
  overflow-wrap: anywhere;
}

.photo-picker-btn {
  display: inline-block;
  text-align: center;
}

.photo-picker-btn input {
  display: none;
}

.a-label {
  font-size: 13px;
  color: #888;
  margin-bottom: 8px;
}

.error-msg {
  color: #e05c5c;
  font-size: 13px;
  margin-bottom: 10px;
  text-align: left;
}

/* ── Журнал записей ── */
.journal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.journal-board {
  min-width: 0;
}

.journal-scroll {
  overflow-x: auto;
  padding-bottom: 8px;
}

.journal-grid {
  display: grid;
  --half-hour-height: 95px;
  grid-template-columns: 74px repeat(var(--specialists), minmax(210px, 1fr));
  min-width: max(100%, calc(74px + var(--specialists) * 220px));
  border: 1px solid #2a2a2a;
  border-radius: 14px;
  background: #151515;
  overflow: hidden;
  align-items: start;
}

.time-head,
.specialist-head {
  position: sticky;
  top: 0;
  z-index: 2;
  min-height: 74px;
  background: #1b1b1b;
  border-bottom: 1px solid #2a2a2a;
}

.specialist-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-left: 1px solid #242424;
  color: #eee;
  font-weight: 700;
  text-align: center;
}

.specialist-head img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  background: #111;
}

.time-cell {
  min-height: 92px;
  padding: 12px 10px;
  color: #888;
  border-top: 1px solid #242424;
  background: #171717;
  font-size: 13px;
}

.journal-cell {
  min-height: 92px;
  padding: 8px;
  border-top: 1px solid #242424;
  border-left: 1px solid #242424;
  background:
    linear-gradient(to bottom, rgba(255,255,255,0.03) 1px, transparent 1px) 0 0 / 100% var(--half-hour-height),
    #181818;
}

.time-rail {
  position: relative;
  background: #171717;
  border-top: 1px solid #242424;
}

.time-mark {
  position: absolute;
  left: 0;
  right: 0;
  padding: 8px 10px 0;
  color: #888;
  border-top: 1px solid #242424;
  font-size: 13px;
}

.journal-column {
  position: relative;
  border-top: 1px solid #242424;
  border-left: 1px solid #242424;
  background:
    linear-gradient(to bottom, rgba(255,255,255,0.045) 1px, transparent 1px) 0 0 / 100% var(--half-hour-height),
    #181818;
}

.journal-free-slot {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 1;
  border: none;
  background: rgba(181, 158, 92, 0.055);
  cursor: pointer;
  transition: background 0.16s ease, outline-color 0.16s ease;
}

.journal-free-slot:hover {
  background: rgba(181, 158, 92, 0.18);
  outline: 1px solid rgba(181, 158, 92, 0.42);
  outline-offset: -1px;
}

.journal-appt {
  position: absolute;
  left: 8px;
  right: 8px;
  z-index: 2;
  background: #a9e4bd;
  color: #173320;
  border-radius: 7px;
  overflow: hidden;
  box-shadow: 0 5px 12px rgba(0,0,0,0.16);
}

.journal-appt.break {
  background: #323232;
  color: #ddd;
}

.journal-appt.break .journal-appt-time {
  background: #555;
}

.journal-appt.break .journal-appt-service {
  color: #aaa;
}

.journal-appt.past {
  opacity: 0.45;
  filter: grayscale(0.25);
}

.journal-appt-time {
  background: #8d61d8;
  color: #fff;
  padding: 4px 28px 4px 8px;
  font-size: 12px;
  font-weight: 800;
}

.journal-appt-client,
.journal-appt-phone,
.journal-appt-service {
  padding: 0 8px;
  font-size: 13px;
  line-height: 17px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.journal-appt-client {
  padding-top: 7px;
  font-weight: 800;
}

.journal-appt-service {
  padding-bottom: 8px;
  color: rgba(23,51,32,0.8);
}

.journal-delete {
  position: absolute;
  top: 2px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
  color: #7b4ecc;
  cursor: pointer;
  line-height: 1;
  font-size: 16px;
}

.slot-step-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 14px;
}

.modal-step-summary {
  background: #202020;
  border: 1px solid #303030;
  border-radius: 10px;
  color: #ddd;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 14px;
  padding: 12px;
}

.modal-step-summary strong {
  color: #b59e5c;
}

.admin-slot-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.slot-pill {
  background: #222;
  border: 1px solid #333;
  border-radius: 10px;
  color: #eee;
  padding: 11px 8px;
  cursor: pointer;
  font-weight: 700;
}

.slot-pill:hover,
.slot-pill.active {
  background: #b59e5c;
  border-color: #b59e5c;
  color: #000;
}

.slot-loading,
.empty-state.compact {
  grid-column: 1 / -1;
  padding: 18px;
  text-align: center;
  color: #888;
  background: #202020;
  border: 1px solid #303030;
  border-radius: 10px;
}

/* ── Карточки специалистов/услуг ── */
.item-card {
  background: #1c1c1c;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.item-card img {
  width: 48px; height: 48px;
  border-radius: 50%;
  object-fit: cover;
}

.item-info { flex: 1; }
.item-name { font-size: 16px; font-weight: 600; }
.item-sub { color: #888; font-size: 14px; margin-top: 3px; }

.item-actions { display: flex; gap: 8px; }

/* ── Услуги специалиста (теги) ── */
.service-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.service-tag {
  background: #2a2a2a;
  border: 1px solid #333;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: 0.2s;
}
.service-tag:hover { border-color: #b59e5c; color: #b59e5c; }
.service-tag.active { background: #b59e5c; color: #000; border-color: #b59e5c; }

/* ── Расписание ── */
.filter-row { display: flex; gap: 10px; align-items: center; }
.schedule-select-row { margin-bottom: 20px; }

.schedule-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.sched-day {
  background: #1c1c1c;
  border: 1px solid #2a2a2a;
  border-radius: 10px;
  padding: 10px 6px;
  text-align: center;
  cursor: pointer;
  transition: 0.2s;
  font-size: 13px;
  color: #eee;
  font-family: inherit;
}
.sched-day:hover { border-color: #b59e5c; }
.sched-day.on  { background: #b59e5c; color: #000; border-color: #b59e5c; font-weight: 700; }
.sched-day.off { opacity: 0.35; }

.sched-day .day-name { font-weight: 600; font-size: 12px; }
.sched-day .day-date { font-size: 12px; color: inherit; margin-top: 4px; }
.sched-day .day-time { font-size: 11px; color: inherit; margin-top: 6px; opacity: 0.78; }

/* ── Расписание по дням недели ── */
.weekday-schedule { margin-top: 20px; }

.weekday-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  background: #1c1c1c;
  border: 1px solid #2a2a2a;
  border-radius: 10px;
  padding: 10px 16px;
}

.weekday-label { width: 36px; font-size: 13px; color: #aaa; }

.weekday-row input {
  background: #222;
  border: 1px solid #333;
  border-radius: 8px;
  color: #fff;
  padding: 6px 10px;
  font-size: 14px;
  width: 90px;
  outline: none;
}
.weekday-row input:focus { border-color: #b59e5c; }

.weekday-row .time-part {
  width: 48px;
  text-align: center;
}

.weekday-row span { color: #666; font-size: 14px; }

/* ── Модалки ── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.7);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-box {
  background: #1c1c1c;
  border: 1px solid #2a2a2a;
  border-radius: 16px;
  padding: 28px;
  width: 440px;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  font-size: 18px;
  font-weight: 700;
}

.modal-header button {
  background: none;
  border: none;
  color: #888;
  font-size: 18px;
  cursor: pointer;
}
.modal-header button:hover { color: #fff; }

/* ── Пустое состояние ── */
.empty-state {
  text-align: center;
  padding: 40px;
  color: #555;
  font-size: 15px;
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: #2a2a2a;
  color: #b59e5c;
  margin-left: 8px;
}

.clients-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 420px) auto;
  gap: 12px;
  align-items: start;
  margin-bottom: 18px;
}

#broadcast-toggle-btn {
  margin-bottom: 14px;
}

.broadcast-panel {
  background: #1c1c1c;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 18px;
}

.textarea {
  min-height: 104px;
  resize: vertical;
  line-height: 1.45;
}

.form-status {
  margin-top: 12px;
  color: #b59e5c;
  font-size: 14px;
}

.form-status.error {
  color: #ff7b7b;
}

.clients-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.client-card {
  display: flex;
  gap: 12px;
  align-items: center;
  background: #1c1c1c;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  padding: 14px;
}

.client-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #2a261b;
  color: #d4b96a;
  font-weight: 800;
  flex-shrink: 0;
}

.client-info {
  min-width: 0;
}

.client-name {
  color: #fff;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.client-phone {
  color: #999;
  font-size: 14px;
  margin-top: 3px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #202020;
  border: 1px solid #333;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
  color: #eee;
  font-weight: 700;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: #b59e5c;
}

.schedule-date-time-row {
  margin-top: 8px;
}

.schedule-date-time-row input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Кнопка удаления связи внутри тега услуги */
.service-tag.active {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tag-delete {
  background: none;
  border: none;
  color: #c0392b;
  cursor: pointer;
  font-size: 12px;
  padding: 0 2px;
  line-height: 1;
  transition: 0.2s;
}

.tag-delete:hover {
  color: #e74c3c;
}

@media (max-width: 760px) {
  body.admin-menu-open {
    overflow: hidden;
  }

  .screen.active {
    flex-direction: column;
  }

  #screen-main {
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden;
    padding-top: 58px;
    position: relative;
  }

  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: max(10px, env(safe-area-inset-top));
    left: 12px;
    z-index: 50;
    width: 42px;
    height: 42px;
    background: #1c1c1c;
    border: 1px solid #333;
    border-radius: 10px;
    color: #b59e5c;
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
  }

  .mobile-menu-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 39;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  #screen-main.menu-open .mobile-menu-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar {
    width: min(82vw, 300px);
    min-height: 100dvh;
    height: 100dvh;
    border-right: 1px solid #2a2a2a;
    border-bottom: none;
    padding: max(18px, env(safe-area-inset-top)) 0 18px;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 40;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 20px 0 40px rgba(0, 0, 0, 0.35);
  }

  #screen-main.menu-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-logo {
    display: block;
    padding: 0 56px 16px 20px;
    margin-bottom: 12px;
    text-align: left;
  }

  .sidebar-close {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: max(12px, env(safe-area-inset-top));
    right: 12px;
    width: 36px;
    height: 36px;
    background: #222;
    border: 1px solid #333;
    border-radius: 10px;
    color: #aaa;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
  }

  .sidebar nav {
    display: block;
    gap: 6px;
    overflow-x: visible;
    padding: 0 12px;
  }

  .nav-item {
    border-left: 3px solid transparent;
    border-radius: 8px;
    display: block;
    padding: 12px 14px;
    font-size: 15px;
    text-align: left;
    white-space: nowrap;
  }

  .logout-btn {
    margin: auto 12px 0;
    padding: 11px;
    position: static;
    width: calc(100% - 24px);
  }

  .main-content {
    padding: 16px 12px;
    width: 100%;
    min-width: 0;
    overflow-x: hidden;
  }

  .page-header,
  .item-card {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .journal-actions,
  .filter-row,
  .clients-toolbar {
    align-items: stretch;
    flex-direction: column;
    justify-content: flex-start;
  }

  .clients-toolbar {
    display: flex;
  }

  .journal-actions .icon-btn,
  .journal-actions .compact-date,
  .journal-actions .a-btn,
  .filter-row .a-btn,
  .filter-row .a-select,
  .clients-toolbar .a-btn {
    width: 100%;
  }

  .journal-actions .icon-btn {
    height: 38px;
  }

  .journal-grid {
    grid-template-columns: 58px repeat(var(--specialists), minmax(176px, 1fr));
    min-width: calc(58px + var(--specialists) * 176px);
  }

  .time-cell,
  .journal-cell {
    min-height: 86px;
  }

  .admin-slot-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .clients-list {
    grid-template-columns: 1fr;
  }

  .item-actions {
    justify-content: flex-start;
  }

  .schedule-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .modal-box {
    width: calc(100vw - 24px);
    max-height: 90vh;
    padding: 20px;
  }

  .a-field {
    margin-bottom: 12px;
  }

  .a-field span {
    font-size: 12px;
  }

  .weekday-row {
    gap: 8px;
    padding: 10px;
  }

  .weekday-row input {
    width: 80px;
  }
}

