/* ------------------------------------------------------------------
   Оформление кабинета. Все цвета вынесены в переменные наверху —
   поменяв их, вы поменяете вид всего сайта.
   ------------------------------------------------------------------ */

:root {
  --bg: #f6f5fb;
  --surface: #ffffff;
  --surface-2: #f2f1f8;
  --ink: #1d1b2e;
  --ink-soft: #6a6683;
  --ink-faint: #9a97ad;
  --line: #e6e4f0;
  --brand: #6c5ce7;
  --brand-dark: #5a4bd4;
  --brand-soft: #efecff;
  --ok: #17a673;
  --ok-soft: #e6f7f0;
  --warn: #d98324;
  --warn-soft: #fdf2e3;
  --danger: #d64550;
  --danger-soft: #fdeced;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 2px 8px rgba(29, 27, 46, .06);
  --shadow-lg: 0 18px 48px rgba(29, 27, 46, .18);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); }

/* ------------------------------------------------------------ шапка --- */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -.01em;
  margin-right: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-dot {
  width: 26px; height: 26px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), #a29bfe);
}

.balance-pill {
  background: var(--brand-soft);
  color: var(--brand-dark);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.balance-pill.is-empty { background: var(--warn-soft); color: var(--warn); }

.who {
  display: flex; align-items: center; gap: 9px;
  font-size: 14px; color: var(--ink-soft);
}
.who img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 22px 20px 80px;
}

/* ------------------------------------------------------------ вкладки - */

.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 5px;
  margin-bottom: 22px;
  overflow-x: auto;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.is-active { background: var(--brand); color: #fff; }

/* -------------------------------------------------------------- блоки - */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card + .card { margin-top: 14px; }

.card-title {
  font-size: 15px; font-weight: 700; margin: 0 0 4px;
}
.card-sub { color: var(--ink-soft); font-size: 13px; margin: 0 0 16px; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); font-size: 13px; }

/* ------------------------------------------------------------ кнопки -- */

.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: .12s;
}
.btn:hover { border-color: #cfcbe4; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-danger { color: var(--danger); border-color: #f1cdd0; background: var(--danger-soft); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--surface-2); }

/* ---------------------------------------------------------- сегменты -- */

.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
}
.segmented button {
  border: 0; background: transparent; font: inherit; font-weight: 600;
  color: var(--ink-soft); padding: 7px 15px; border-radius: 8px; cursor: pointer;
}
.segmented button.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* -------------------------------------------------------------- поля -- */

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }

input[type=text], input[type=url], input[type=number], input[type=date],
input[type=time], select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
textarea { resize: vertical; min-height: 76px; }
.input-sm { padding: 6px 9px; font-size: 13px; }

/* ---------------------------------------------------------- календарь - */

.week-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.week-label { font-weight: 700; }

.days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 900px) { .days { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) { .days { grid-template-columns: repeat(2, 1fr); } }

.day {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 10px;
  min-height: 120px;
}
.day.is-weekend { background: #fbfaff; }
.day.is-today { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }

.day-head { text-align: center; margin-bottom: 10px; }
.day-wd { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); }
.day-date { font-weight: 700; font-size: 14px; }

.slots { display: flex; flex-direction: column; gap: 6px; }

.slot {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 9px;
  padding: 7px 6px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: .12s;
}
.slot.free { border-color: #cfe9dd; background: var(--ok-soft); color: #0f7a55; }
.slot.free:hover { background: #d6f2e6; transform: translateY(-1px); }
.slot.busy, .slot.past { background: var(--surface-2); color: var(--ink-faint); cursor: not-allowed; border-color: transparent; }
.slot.mine { background: var(--brand-soft); color: var(--brand-dark); border-color: #d6d0ff; cursor: default; }
.slot.short { opacity: .55; cursor: not-allowed; }

/* Занятое время можно попросить — такие клетки кликабельны. */
.slot.busy:not([disabled]), .slot.short:not([disabled]) { cursor: pointer; opacity: 1; }
.slot.busy:not([disabled]):hover, .slot.short:not([disabled]):hover {
  background: var(--warn-soft); color: var(--warn); border-color: #f0dcbd;
}
.slot.busy:not([disabled])::after, .slot.short:not([disabled])::after {
  content: '·'; margin-left: 3px; color: var(--warn);
}

.day-empty { text-align: center; color: var(--ink-faint); font-size: 13px; padding: 14px 0; }

/* ------------------------------------------- сетка преподавателя ------- */

.admin-grid {
  display: grid;
  grid-template-columns: 54px repeat(7, minmax(0, 1fr)) 54px;
  gap: 2px 3px;
  user-select: none;
  -webkit-user-select: none;
}

.admin-grid .col-head {
  text-align: center; font-size: 13px; font-weight: 700; padding: 8px 0 10px;
  position: sticky; top: 56px; background: var(--surface); z-index: 6;
  border-radius: 8px; cursor: pointer;
}
.admin-grid .col-head:hover { background: var(--brand-soft); }
.admin-grid .col-head small { display: block; font-weight: 500; color: var(--ink-faint); }
.admin-grid .col-head.is-today { color: var(--brand-dark); }

.admin-grid .corner { position: sticky; top: 56px; background: var(--surface); z-index: 6; }

.admin-grid .hour {
  font-size: 11px; color: var(--ink-faint); line-height: 26px; cursor: pointer;
  text-align: right; padding-right: 8px; border-radius: 6px;
}
.admin-grid .hour.right { text-align: left; padding: 0 0 0 8px; }
.admin-grid .hour:hover { background: var(--brand-soft); color: var(--brand-dark); }
.admin-grid .hour.sharp { color: var(--ink-soft); font-weight: 600; }

.cell {
  height: 26px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid transparent;
  cursor: pointer;
  position: relative;
  transition: background .1s;
}
.cell:hover { border-color: #cfcbe4; }
.cell.is-open { background: var(--ok-soft); border-color: #cfe9dd; }
.cell.is-booked { background: var(--brand); border-color: var(--brand); cursor: default; }
.cell.is-booked::after {
  content: attr(data-student);
  position: absolute; left: 5px; top: 4px; right: 5px;
  font-size: 10px; line-height: 1.4; color: #fff; overflow: hidden; white-space: nowrap;
}
.cell.is-past { opacity: .35; cursor: not-allowed; }
.cell.is-picked {
  border-color: var(--brand);
  box-shadow: inset 0 0 0 2px var(--brand);
  background: var(--brand-soft);
}
.cell.is-picked.is-open { background: #ddf3e9; }

/* Панель действий над выделением */
.selection-bar {
  position: sticky; bottom: 14px; z-index: 20;
  margin-top: 16px;
  background: var(--ink); color: #fff;
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  box-shadow: var(--shadow-lg);
}
.selection-bar[hidden] { display: none; }
.selection-bar .count { font-weight: 700; margin-right: auto; }
.selection-bar .btn { background: rgba(255,255,255,.14); border-color: transparent; color: #fff; }
.selection-bar .btn:hover { background: rgba(255,255,255,.26); }
.selection-bar .btn-open { background: var(--ok); }
.selection-bar .btn-close { background: var(--danger); }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--ink-soft); margin-top: 14px; }
.legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; vertical-align: -2px; margin-right: 6px; }

/* ------------------------------------------------------------- файлы --- */

.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  color: var(--ink-soft);
  cursor: pointer;
  transition: .15s;
  background: var(--surface-2);
}
.dropzone:hover, .dropzone.is-over {
  border-color: var(--brand); background: var(--brand-soft); color: var(--brand-dark);
}
.dropzone strong { display: block; font-size: 15px; color: var(--ink); margin-bottom: 4px; }

.folder-title {
  font-size: 13px; font-weight: 700; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: .04em;
  margin: 18px 0 8px;
}

.file-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  margin-bottom: 8px; background: var(--surface);
}
.file-row:hover { border-color: #cfcbe4; }
.file-ext {
  width: 38px; height: 38px; flex: none; border-radius: 9px;
  background: var(--brand-soft); color: var(--brand-dark);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
}
.file-main { flex: 1; min-width: 0; }
.file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { font-size: 12px; color: var(--ink-faint); }

.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.progress span { display: block; height: 100%; background: var(--brand); width: 0; transition: width .2s; }

/* ------------------------------------------------------------ карточки  */

.booking {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.booking:last-child { border-bottom: 0; }
.booking-when { min-width: 190px; }
.booking-date { font-weight: 700; }
.booking-time { color: var(--ink-soft); font-size: 14px; }
.booking-body { flex: 1; min-width: 0; }
.booking-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.tag {
  display: inline-block; font-size: 12px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-soft);
}
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.danger { background: var(--danger-soft); color: var(--danger); }

/* -------------------------------------------------------------- табл. - */

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-faint); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line);
}
table.data td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }

/* ------------------------------------------------------------- плитки - */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.stat-label { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }

/* ------------------------------------------------------------- модалка  */

.overlay {
  position: fixed; inset: 0; background: rgba(29, 27, 46, .45);
  display: flex; align-items: center; justify-content: center; padding: 18px; z-index: 100;
}
.overlay[hidden] { display: none; }
.modal {
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 460px; padding: 22px; max-height: 90vh; overflow: auto;
}
.modal h3 { margin: 0 0 4px; font-size: 18px; }
.modal .modal-sub { color: var(--ink-soft); font-size: 14px; margin: 0 0 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ------------------------------------------------------------- всплыв. */

.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 14px; box-shadow: var(--shadow-lg); max-width: 360px;
  animation: pop .18s ease-out;
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }

/* ------------------------------------------------------------ вход ---- */

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  background: var(--surface); border-radius: 22px; box-shadow: var(--shadow-lg);
  padding: 38px 34px; width: 100%; max-width: 420px; text-align: center;
}
.login-card h1 { font-size: 24px; margin: 14px 0 6px; letter-spacing: -.02em; }
.login-card p { color: var(--ink-soft); margin: 0 0 26px; }
.login-logo { width: 56px; height: 56px; border-radius: 18px; margin: 0 auto;
  background: linear-gradient(135deg, var(--brand), #a29bfe); }
.login-hint { font-size: 13px; color: var(--ink-faint); margin-top: 22px; line-height: 1.6; }
.dev-box { margin-top: 26px; padding-top: 22px; border-top: 1px dashed var(--line); text-align: left; }

.empty { text-align: center; padding: 40px 20px; color: var(--ink-faint); }
.empty-emoji { font-size: 34px; display: block; margin-bottom: 8px; }
.spinner { text-align: center; padding: 40px; color: var(--ink-faint); }

/* ------------------------------------------------ вход через бота ---- */

.btn-wide { display: block; width: 100%; margin-top: 10px; text-align: center; text-decoration: none; }

.btn-tg {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 13px 16px; font-size: 16px;
  background: #2aabee; border-color: #2aabee; color: #fff;
}
.btn-tg:hover { background: #229ed9; border-color: #229ed9; }
.tg-icon {
  width: 22px; height: 22px; flex: none;
  background: no-repeat center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M9.78 18.65l.28-4.23 7.68-6.92c.34-.31-.07-.46-.52-.19L7.74 13.3 3.64 12c-.88-.25-.89-.86.2-1.3l15.97-6.16c.73-.33 1.43.18 1.15 1.3l-2.72 12.81c-.19.91-.74 1.13-1.5.71L12.6 16.3l-1.99 1.93c-.23.23-.42.42-.83.42z'/%3E%3C/svg%3E");
}

.login-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 22px 0 14px; color: var(--ink-faint); font-size: 13px;
}
.login-divider::before, .login-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--line);
}

.phone-form { display: flex; gap: 8px; }
.phone-form input { flex: 1; min-width: 0; }
.phone-form .btn { white-space: nowrap; }

.wait-spinner {
  width: 40px; height: 40px; margin: 6px auto 16px;
  border: 3px solid var(--brand-soft); border-top-color: #2aabee;
  border-radius: 50%; animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
