/* Soul Spa — фирменные цвета: #6d7e65 (шалфей), #f2e7c3 (крем), белый */
:root {
  --sage: #6d7e65;
  --sage-dark: #5a6954;
  --sage-darker: #4c5947;
  --cream: #f2e7c3;
  --cream-soft: #faf6e9;
  --ink: #1d1d1f;
  --gray: #86868b;
  --line: #e5e5e7;
  --bg: #f5f5f7;
  --white: #fff;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 14px rgba(0,0,0,.05);
  /* Статусы записей */
  --st-booked: #4a7fb5;
  --st-confirmed: #3e9d94;
  --st-arrived: #55a06a;
  --st-no_show: #c4574e;
  --st-cancelled: #9a9aa0;
  --slot-h: 28px; /* 30 минут */
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* ---------- Вход ---------- */
.login-screen {
  height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--cream-soft), var(--white) 55%, #eef0ec);
}
.login-card {
  width: 340px; background: var(--white); border-radius: 18px; box-shadow: var(--shadow);
  padding: 40px 32px; text-align: center;
}
.login-logo { font-size: 30px; font-weight: 700; letter-spacing: .5px; color: var(--ink); }
.login-logo span { color: var(--sage); }
.login-sub { color: var(--gray); margin: 6px 0 26px; }
.login-card input {
  width: 100%; margin-bottom: 12px; padding: 11px 14px; font-size: 15px;
  border: 1px solid var(--line); border-radius: var(--radius); outline: none; background: var(--white);
}
.login-card input:focus { border-color: var(--sage); box-shadow: 0 0 0 3px rgba(109,126,101,.15); }
.login-error { color: #c4574e; margin-bottom: 10px; font-size: 13px; }

/* ---------- Каркас ---------- */
.app { display: flex; height: 100vh; }
.sidebar {
  width: 200px; flex: none; background: var(--sage); color: var(--white);
  display: flex; flex-direction: column; padding: 18px 10px 14px;
}
.sidebar-logo { font-size: 19px; font-weight: 700; padding: 0 12px 20px; }
.sidebar-logo span { color: var(--cream); }
.nav-item {
  display: block; padding: 9px 12px; margin-bottom: 2px;
  border-radius: 7px; color: rgba(255,255,255,.85); cursor: pointer; user-select: none;
  text-decoration: none; font-weight: 500; font-size: 13px;
}
.nav-item:hover { background: var(--sage-dark); color: var(--white); }
.nav-item.active { background: var(--sage-darker); color: var(--white); }
/* Мини-календарь загруженности */
.mini-cal { margin: 0 6px 14px; padding: 0 4px 12px; border-bottom: 1px solid rgba(255,255,255,.18); }
.mini-cal-head {
  display: flex; align-items: center; justify-content: space-between;
  color: var(--white); margin-bottom: 6px; padding: 0 4px;
}
.mini-cal-head button {
  background: none; border: none; color: rgba(255,255,255,.7);
  cursor: pointer; font: inherit; font-size: 15px; padding: 0 8px;
}
.mini-cal-head button:hover { color: var(--white); }
#mc-title { font-size: 12.5px; font-weight: 600; }
.mc-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px 2px; }
.mc-dow { font-size: 9.5px; color: rgba(255,255,255,.55); text-align: center; padding: 2px 0; }
.mc-day {
  width: 22px; height: 22px; line-height: 22px; border-radius: 50%;
  font-size: 10.5px; text-align: center; color: var(--white);
  cursor: pointer; margin: 0 auto; background: rgba(255,255,255,.07);
}
.mc-day:hover { background: rgba(255,255,255,.3); }
.mc-day.mc-l1 { background: #7fa95c; }
.mc-day.mc-l2 { background: #d9b342; color: #40350e; }
.mc-day.mc-l3 { background: #cf6547; }
.mc-day.mc-today { box-shadow: 0 0 0 1.5px var(--cream); }
.mc-day.mc-sel { background: var(--white); color: var(--sage-darker); font-weight: 700; }
.mc-day.mc-dis { opacity: .35; cursor: default; }
.mc-day.mc-dis:hover { background: rgba(255,255,255,.07); }
.mc-day.mc-empty { visibility: hidden; }

.sidebar-bottom { margin-top: auto; padding: 12px; border-top: 1px solid rgba(255,255,255,.18); }
.user-name { font-weight: 600; }
.user-role { font-size: 12px; color: var(--cream); margin: 2px 0 8px; }
.logout { color: rgba(255,255,255,.7); cursor: pointer; font-size: 13px; }
.logout:hover { color: var(--white); }

.main { flex: 1; overflow: auto; display: flex; flex-direction: column; }
.view { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 20px; background: var(--white); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.date-nav { display: flex; align-items: center; gap: 8px; }
.date-label { font-size: 15px; font-weight: 500; margin-left: 6px; cursor: pointer; }
.date-label:hover { color: var(--sage); }
.date-input {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; background: var(--white);
}
#date-input {
  position: absolute; width: 1px; height: 1px; opacity: 0;
  pointer-events: none; padding: 0; border: 0;
}
.date-dash { color: var(--gray); }

/* ---------- Кнопки ---------- */
.btn {
  font: inherit; font-weight: 500; padding: 8px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--white); color: var(--ink);
}
.btn:hover { background: var(--bg); }
.btn:disabled { opacity: .4; cursor: default; }
.btn-icon { width: 34px; padding: 8px 0; text-align: center; }
.btn-primary { background: var(--sage); border-color: var(--sage); color: var(--white); }
.btn-primary:hover { background: var(--sage-dark); }
.btn-danger { background: var(--white); border-color: #e0b4b0; color: #c4574e; }
.btn-danger:hover { background: #fdf3f2; }
.btn-block { width: 100%; }
.btn-small { padding: 4px 10px; font-size: 13px; }

/* ---------- Календарь ---------- */
.calendar { flex: 1; overflow: auto; background: var(--white); }
.cal-grid { display: flex; min-width: fit-content; }
.cal-times { width: 56px; flex: none; border-right: 1px solid var(--line); }
.cal-times .cal-head { border-bottom: 1px solid var(--line); }
.cal-time {
  height: calc(var(--slot-h) * 2); font-size: 11px; color: var(--gray);
  text-align: right; padding: 2px 8px 0 0; border-top: 1px solid var(--line);
}
.cal-col { flex: 1 0 170px; min-width: 170px; border-right: 1px solid var(--line); }
.cal-head {
  height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; border-bottom: 1px solid var(--line); background: var(--cream-soft);
  position: sticky; top: 0; z-index: 3; font-weight: 600;
}
.cal-head .cal-head-sub { font-size: 11px; font-weight: 400; color: var(--gray); }
.cal-body { position: relative; }
.cal-slot { height: var(--slot-h); border-top: 1px solid #f1f1f3; }
.cal-slot.hour { border-top: 1px solid var(--line); }
.cal-body:hover .cal-slot:hover { background: var(--cream-soft); cursor: pointer; }
.cal-card {
  position: absolute; left: 3px; right: 3px; border-radius: 7px; padding: 4px 8px;
  font-size: 12px; line-height: 1.3; overflow: hidden; cursor: pointer;
  border-left: 3px solid var(--st-booked); background: #eef3f9; z-index: 2;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.cal-card:hover { filter: brightness(.97); }
.cal-card .cc-time { font-weight: 600; }
.cal-card .cc-prepaid {
  float: right; font-size: 10.5px; font-weight: 700; color: #2e7d4f;
  background: rgba(85,160,106,.16); border-radius: 4px; padding: 0 5px;
}
.cal-card .cc-new {
  display: inline-block; font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .3px; color: var(--white); background: var(--sage);
  border-radius: 3px; padding: 0 4px; margin-right: 4px; vertical-align: middle;
}
.cal-card .cc-client { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-card .cc-service { color: #555; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-card.st-booked    { border-left-color: var(--st-booked);    background: #edf3fa; }
.cal-card.st-confirmed { border-left-color: var(--st-confirmed); background: #eaf6f5; }
.cal-card.st-arrived   { border-left-color: var(--st-arrived);   background: #edf6ef; }
.cal-card.st-no_show   { border-left-color: var(--st-no_show);   background: #faeeed; text-decoration: line-through; }
.cal-card.st-cancelled { border-left-color: var(--st-cancelled); background: #f2f2f4; color: var(--gray); text-decoration: line-through; }
/* Цвет по типу пакета важнее статуса (кроме отменённых/неявок) */
.cal-card.pass-abonement:not(.st-cancelled):not(.st-no_show) {
  border-left-color: #b23b30; background: #f7e4e2;
}
.cal-card.pass-certificate:not(.st-cancelled):not(.st-no_show) {
  border-left-color: #7c7c86; background: #eaeaee;
}
.cal-card .cc-pass { font-size: 10.5px; color: #444; }
.cal-empty {
  padding: 60px; text-align: center; color: var(--gray);
}

/* ---------- Таблицы ---------- */
.table-wrap { padding: 20px; overflow-x: auto; }
.table {
  width: 100%; border-collapse: collapse; background: var(--white);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .4px;
  color: var(--gray); background: var(--cream-soft); padding: 9px 12px;
  border-bottom: 1px solid var(--line);
}
.table td { padding: 9px 12px; border-bottom: 1px solid #f1f1f3; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: var(--cream-soft); }
.list-count { font-size: 12px; color: var(--gray); margin-bottom: 8px; }
.pager { display: flex; justify-content: center; align-items: center; gap: 4px; flex-wrap: wrap; padding: 16px 0; }
.pager button {
  min-width: 34px; height: 34px; padding: 0 8px; border: 1px solid var(--line);
  background: var(--white); border-radius: 7px; cursor: pointer; font: inherit; color: var(--ink);
}
.pager button:hover:not(:disabled) { background: var(--cream-soft); }
.pager button.active { background: var(--sage); border-color: var(--sage); color: var(--white); }
.pager button:disabled { opacity: .4; cursor: default; }
.pager .pager-gap { color: var(--gray); padding: 0 2px; }
.search-input {
  flex: 1; max-width: 380px; padding: 9px 14px; font: inherit;
  border: 1px solid var(--line); border-radius: 8px; outline: none;
}
.search-input:focus { border-color: var(--sage); box-shadow: 0 0 0 3px rgba(109,126,101,.15); }

/* ---------- Карточки-показатели ---------- */
.cards { display: flex; gap: 14px; padding: 20px 20px 0; flex-wrap: wrap; }
.card {
  flex: 1; min-width: 160px; background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px;
}
.card .card-label { font-size: 11px; color: var(--gray); text-transform: uppercase; letter-spacing: .4px; }
.card .card-value { font-size: 22px; font-weight: 700; margin-top: 4px; }
.card .card-value small { font-size: 14px; color: var(--gray); font-weight: 400; }
.report-tables { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; padding: 20px; }
.report-tables h3 { margin-bottom: 10px; font-size: 15px; }

/* ---------- Панель справа (drawer) ---------- */
.drawer-overlay, .modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 20;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 400px; max-width: 92vw;
  background: var(--white); z-index: 21; box-shadow: -8px 0 30px rgba(0,0,0,.12);
  display: flex; flex-direction: column;
}
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line); background: var(--cream-soft);
}
.drawer-title { font-size: 17px; font-weight: 700; }
.drawer-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.drawer-actions { display: flex; gap: 10px; margin-top: 16px; }
.drawer-actions .btn { flex: 1; padding: 10px; }

.field { display: block; margin-bottom: 12px; position: relative; }
.field span { display: block; font-size: 12px; color: var(--gray); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 12px; font: inherit; border: 1px solid var(--line);
  border-radius: 8px; outline: none; background: var(--white);
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--sage); box-shadow: 0 0 0 3px rgba(109,126,101,.15);
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-error { color: #c4574e; font-size: 13px; margin-top: 8px; }

.dropdown {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 30; background: var(--white);
  border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow);
  max-height: 220px; overflow-y: auto;
}
.dropdown-item { padding: 9px 12px; cursor: pointer; }
.dropdown-item:hover { background: var(--cream-soft); }
.dropdown-item .di-phone { color: var(--gray); font-size: 12px; }
.dropdown-item.di-new { color: var(--sage); font-weight: 600; border-top: 1px solid var(--line); }
.chosen-client {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--cream-soft); border: 1px solid var(--cream); border-radius: 8px;
  padding: 9px 12px; margin-bottom: 12px;
}
.chosen-client b { display: block; }
.chosen-client small { color: var(--gray); }
.chosen-client a { color: var(--sage); cursor: pointer; font-size: 13px; }
.new-client { background: var(--cream-soft); border-radius: 8px; padding: 12px 12px 2px; margin-bottom: 12px; }
.wa-btn {
  display: block; text-align: center; text-decoration: none; margin-bottom: 12px;
  padding: 9px 12px; border-radius: 8px; font-weight: 600;
  background: #25d366; color: #fff;
}
.wa-btn:hover { background: #1eb658; }

/* ---------- Модальное окно ---------- */
.modal-overlay { display: flex; align-items: center; justify-content: center; }
.modal {
  width: 400px; max-width: 92vw; background: var(--white); border-radius: 14px;
  overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-body { padding: 18px 20px; }

/* ---------- Вкладки ---------- */
.tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 10px; }
.tab {
  font: inherit; font-weight: 500; border: none; background: transparent; padding: 7px 14px;
  border-radius: 7px; cursor: pointer; color: var(--gray);
}
.tab.active { background: var(--white); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

/* ---------- Статусные метки ---------- */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 600;
  color: var(--white);
}
.badge.st-booked { background: var(--st-booked); }
.badge.st-confirmed { background: var(--st-confirmed); }
.badge.st-arrived { background: var(--st-arrived); }
.badge.st-no_show { background: var(--st-no_show); }
.badge.st-cancelled { background: var(--st-cancelled); }

@media (max-width: 760px) {
  .sidebar { width: 148px; padding: 14px 8px 12px; }
}
