/* Tutor Hub — чёрный с приглушённым оранжевым */
:root {
  --board: #1e1e1e;
  --board-dark: #151515;
  --board-light: #2a2622;
  --frame: #2b1e14;
  --chalk: #ece6df;
  --chalk-dim: #a89c90;
  --chalk-faint: rgba(236, 230, 223, 0.12);
  --yellow: #c9772f;
  --red: #d9705f;
  --bubble-in: rgba(236, 230, 223, 0.07);
  --bubble-out: rgba(201, 119, 47, 0.22);
  --free: #6f9a5b;
  --free-text: #a9c79a;
  --font: "Caveat", "Comic Sans MS", cursive;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--board-dark);
  color: var(--chalk);
  font-family: var(--font-ui);
  font-size: 16px;
}
button, input, select, textarea { font: inherit; color: inherit; }
button {
  background: var(--yellow); color: #1a120b; border: 0; border-radius: 8px;
  padding: 9px 16px; cursor: pointer; font-weight: 600;
}
button:hover { filter: brightness(1.07); }
button:disabled { opacity: .5; cursor: default; }
button.ghost { background: transparent; color: var(--chalk-dim); border: 1px solid var(--chalk-faint); }
button.danger { background: transparent; color: var(--red); border: 1px solid var(--red); }
input, select, textarea {
  background: rgba(0, 0, 0, .18); border: 1px solid var(--chalk-faint); border-radius: 8px;
  padding: 9px 12px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--yellow); outline-offset: -1px; }
select option { background: var(--board-dark); }
.hidden { display: none !important; }
.muted { color: var(--chalk-dim); font-size: 14px; }
.error { color: var(--red); min-height: 1.3em; font-size: 14px; }

/* Вход */
.login {
  min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px;
}
.login form {
  width: 100%; max-width: 360px; background: var(--board); border: 1px solid var(--chalk-faint); border-top: 4px solid var(--yellow);
  border-radius: 6px; padding: 28px 24px; display: grid; gap: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,.4);
}
.login h1 { font-family: var(--font); font-size: 44px; margin: 0; text-align: center; font-weight: 700; color: var(--yellow); }
.login p { margin: 0 0 6px; text-align: center; }

/* Каркас кабинета */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: var(--frame); color: #fff8ec; border-bottom: 2px solid var(--yellow);
}
.topbar .brand { font-family: var(--font); font-size: 28px; font-weight: 700; color: var(--yellow); }
.topbar .spacer { flex: 1; }
.topbar button { padding: 6px 12px; }
.topbar .notify.on { border-color: var(--yellow); color: var(--yellow) !important; }
@media (max-width: 760px) { .topbar .notify { order: 10; width: 100%; } }
.tabs { display: flex; gap: 6px; }
.tabs button { background: transparent; color: #fff8ec; border: 1px solid rgba(255,255,255,.35); }
.tabs button.active { background: var(--yellow); color: #1a120b; border-color: var(--yellow); }
.badge { font-size: 13px; padding: 3px 9px; border-radius: 999px; background: rgba(0,0,0,.25); }
.badge.ok { background: rgba(120, 200, 120, .35); }
.badge.bad { background: rgba(229, 122, 106, .45); }

.main { flex: 1; display: flex; min-height: 0; background: var(--board); }
.sidebar {
  width: 300px; border-right: 1px solid var(--chalk-faint); overflow-y: auto; flex-shrink: 0;
}
.sidebar .item {
  padding: 12px 16px; border-bottom: 1px solid var(--chalk-faint); cursor: pointer;
}
.sidebar .item:hover { background: var(--board-light); }
.sidebar .item.active { background: var(--board-light); box-shadow: inset 4px 0 var(--yellow); }
.sidebar .name { font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.sidebar .name small { color: var(--chalk-dim); font-weight: 400; white-space: nowrap; }
.ch { display: inline-block; font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 4px; vertical-align: 2px; letter-spacing: .3px; }
.ch-telegram { background: #2f5d7c; color: #d6ecfa; }
.ch-vk { background: #3d5a85; color: #e3ecfa; }
.chat-head h2 .ch { font-family: var(--font-ui); font-size: 12px; vertical-align: 5px; }
.sidebar .preview {
  color: var(--chalk-dim); font-size: 14px; margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar .empty { padding: 24px 16px; color: var(--chalk-dim); }

.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-bottom: 1px solid var(--chalk-faint);
}
.chat-head h2 { font-family: var(--font); font-size: 30px; margin: 0; flex: 1; font-weight: 700; }
.chat-head .back { display: none; }
.placeholder { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--chalk-dim); font-family: var(--font); font-size: 28px; padding: 16px; text-align: center; }
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.msg {
  max-width: min(75%, 560px); padding: 8px 12px; border-radius: 12px; background: var(--bubble-in);
  align-self: flex-start; white-space: pre-wrap; word-wrap: break-word;
}
.msg.out { align-self: flex-end; background: var(--bubble-out); }
.msg .meta { font-size: 12px; color: var(--chalk-dim); margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; }
.msg.hiddenmsg { opacity: .55; border: 1px dashed var(--chalk-dim); }
.msg .tag { color: var(--yellow); }
.msg img { max-width: 100%; max-height: 320px; border-radius: 8px; display: block; cursor: zoom-in; }
.msg a { color: var(--yellow); }
.day { align-self: center; font-size: 13px; color: var(--chalk-dim); padding: 4px 10px; }
.composer { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--chalk-faint); }
.composer textarea { resize: none; height: 46px; max-height: 160px; }

/* Панели администратора */
.panel { flex: 1; overflow-y: auto; padding: 16px; }
.card { background: var(--board-dark); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.card h3 { margin: 0 0 12px; font-family: var(--font); font-size: 26px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row > label { flex: 1 1 180px; display: grid; gap: 4px; font-size: 14px; color: var(--chalk-dim); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--chalk-faint); vertical-align: middle; }
th { color: var(--chalk-dim); font-weight: 500; font-size: 14px; }
td .actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.client-edit { padding: 12px 16px; border-bottom: 1px solid var(--chalk-faint); }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; z-index: 10; cursor: zoom-out; }
.lightbox img { max-width: 95vw; max-height: 95vh; }

/* Расписание */
.sched-toolbar { margin-bottom: 12px; max-width: 320px; }
.sched-toolbar label { display: grid; gap: 4px; font-size: 14px; color: var(--chalk-dim); }
.sched-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.day-col { background: var(--board-dark); border-radius: 10px; padding: 8px; min-height: 120px; display: flex; flex-direction: column; gap: 6px; }
.day-head { display: flex; align-items: center; justify-content: space-between; font-weight: 600; font-size: 14px; padding: 2px 2px 4px; }
.day-head .add { padding: 0 9px; font-size: 18px; line-height: 26px; }
.day-empty { font-size: 13px; padding: 4px 2px; }
.slot {
  border-left: 4px solid var(--slot); background: color-mix(in srgb, var(--slot) 18%, transparent);
  border-radius: 6px; padding: 6px 8px; cursor: pointer; font-size: 14px;
}
.slot:hover { background: color-mix(in srgb, var(--slot) 28%, transparent); }
.slot-time { font-weight: 600; }
.slot-client, .slot-tutor { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-tutor { color: var(--chalk-dim); font-size: 12px; }
.slot.free, .hg-block.free {
  --slot: var(--free); border-style: dashed; border-width: 1px 1px 1px 4px; border-color: var(--free);
}
.slot.free .slot-client { color: var(--free-text); }

.sched-toolbar { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; max-width: none; }
.sched-toolbar label { min-width: 220px; }
.seg { display: inline-flex; border: 1px solid var(--chalk-faint); border-radius: 8px; overflow: hidden; }
.seg button { background: transparent; color: var(--chalk-dim); border-radius: 0; padding: 7px 14px; font-weight: 500; }
.seg button.on { background: var(--yellow); color: #1a120b; }

/* Сетка по часам */
.hg-wrap { overflow-x: auto; }
.hg { display: grid; grid-template-columns: 52px repeat(7, minmax(90px, 1fr)); gap: 0 4px; min-width: 700px; }
.hg-head { height: 34px; display: flex; align-items: center; justify-content: space-between; font-weight: 600; font-size: 14px; padding: 0 2px; }
.hg-head .add { padding: 0 8px; font-size: 16px; line-height: 22px; }
.hg-body { position: relative; }
.hg-day .hg-body {
  background: var(--board-dark); border-radius: 8px;
  background-image: repeating-linear-gradient(to bottom, var(--chalk-faint) 0, var(--chalk-faint) 1px, transparent 1px, transparent 48px);
}
.hg-hour { position: absolute; right: 6px; transform: translateY(-50%); font-size: 12px; color: var(--chalk-dim); }
.hg-hour:first-child { transform: none; }
.hg-block {
  position: absolute; border-left: 4px solid var(--slot); border-radius: 6px; padding: 2px 6px;
  background: color-mix(in srgb, var(--slot) 30%, var(--board-dark)); font-size: 12px; line-height: 1.3;
  overflow: hidden; cursor: pointer;
}
.hg-block:hover { filter: brightness(1.15); z-index: 2; }
.hg-block.free { background: color-mix(in srgb, var(--free) 16%, var(--board-dark)); color: var(--free-text); }
.hg-block .slot-tutor { display: block; }
.legend { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--chalk-dim); margin-top: 10px; }
.legend .lg { width: 14px; height: 14px; border-radius: 3px; display: inline-block; margin-left: 8px; }
.legend .lg:first-child { margin-left: 0; }
.lg.free { border: 1px dashed var(--free); background: color-mix(in srgb, var(--free) 16%, transparent); }
.lg.busy { background: var(--yellow); }

/* Кто свободен */
.finder .row > label { flex: 1 1 140px; }
.found { margin-top: 12px; display: grid; gap: 6px; }
.found-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; background: rgba(255,255,255,.04); }
.found-row button { padding: 5px 10px; }
.found-ok { color: var(--free-text); font-weight: 600; }
.found-none { color: var(--red); font-weight: 600; }
.found-sub { margin-top: 6px; }
.hint { font-size: 13px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 16px; }
.modal-card { background: var(--board); border: 1px solid var(--chalk-faint); border-top: 4px solid var(--yellow); border-radius: 10px; padding: 20px; width: 100%; max-width: 400px; display: grid; gap: 12px; }
.modal-card h3 { margin: 0; font-family: var(--font); font-size: 28px; color: var(--yellow); }
.modal-card label { display: grid; gap: 4px; font-size: 14px; color: var(--chalk-dim); }
.modal-card .row > label { flex: 1 1 120px; }
.modal-actions { display: flex; gap: 8px; align-items: center; }
.modal-actions .spacer { flex: 1; }
.swatches { display: flex; gap: 8px; }
.swatch { width: 30px; height: 30px; border-radius: 50%; padding: 0; border: 2px solid transparent; }
.swatch.on { border-color: var(--chalk); }

@media (max-width: 1000px) {
  .sched-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

@media (max-width: 760px) {
  .sidebar { width: 100%; border-right: 0; }
  .main.chat-open .sidebar { display: none; }
  .main:not(.chat-open) .chat { display: none; }
  .chat-head .back { display: inline-block; }
  .msg { max-width: 88%; }
  .topbar { flex-wrap: wrap; }
  .table-wrap { overflow-x: auto; }
  .day-col { min-height: 0; }
}

/* Плашки об оплатах */
.pay-news-box { display: flex; flex-direction: column; gap: 6px; padding: 0 12px; }
.pay-news-box:empty { display: none; }
.pay-news { display: flex; align-items: center; gap: 12px; justify-content: space-between; padding: 10px 14px;
  border-radius: 10px; font-family: var(--font-ui); font-size: 15px; color: var(--chalk); }
.pay-news.ok { background: rgba(111, 154, 91, .28); border: 1px solid var(--free); }
.pay-news.warn { background: rgba(217, 112, 95, .25); border: 1px solid var(--red); }
.pay-news button { color: var(--chalk); flex: none; }

/* Вкладка «Уроки» в кабинете репетитора */
.panel.lessons { overflow: auto; font-family: var(--font-ui); }
.lesson-form { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.lesson-form select, .lesson-form input { padding: 10px; font-size: 16px; }
.lesson-table { width: 100%; border-collapse: collapse; margin-bottom: 18px; }
.lesson-table th, .lesson-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--chalk-faint); }
.lesson-table .bad { color: var(--red); }
.earn-cards { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0; }
.earn-cards div { flex: 1 1 140px; padding: 12px; border: 1px solid var(--chalk-faint); border-radius: 8px; }
.earn-cards span { display: block; font-size: 13px; opacity: .8; }
.earn-cards b { font-size: 22px; }
.earn-details { margin-bottom: 18px; }
.earn-details summary { cursor: pointer; margin-bottom: 8px; }
.lesson-msg { margin: 4px 0 14px; color: var(--chalk); min-height: 1.2em; }
@media (max-width: 600px) {
  .lesson-table th, .lesson-table td { padding: 6px 4px; font-size: 13px; }
}
.composer .attach { font-size: 22px; padding: 0 10px; color: var(--chalk); flex: none; }
