:root {
  --bg: #f3f6fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #dbe3ef;
  --accent: #2563eb;
  --accent2: #0f766e;
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #16a34a;
  --shadow: 0 10px 30px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

.container {
  width: min(1180px, calc(100% - 24px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.header {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.header h1 {
  margin: 0;
  font-size: 30px;
}

.header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

@media (max-width: 820px) {
  .grid, .grid-3 { grid-template-columns: 1fr; }
  .header { align-items: flex-start; flex-direction: column; }
}

label {
  display: block;
  font-weight: 700;
  margin: 0 0 8px;
}

input, select, textarea, button {
  font: inherit;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
}

textarea { min-height: 90px; resize: vertical; }

button, .btn {
  border: 0;
  border-radius: 12px;
  padding: 11px 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button.secondary { background: var(--accent2); }
button.light { background: #e5e7eb; color: #111827; }
button.danger { background: var(--danger); }
button.warn { background: var(--warn); }
button:disabled { opacity: .5; cursor: not-allowed; }

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

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 700;
}

.status.open { background: #dcfce7; color: #166534; }
.status.away { background: #fef3c7; color: #92400e; }
.status.closed { background: #fee2e2; color: #991b1b; }

.notice {
  border-left: 5px solid var(--warn);
  background: #fffbeb;
  padding: 14px;
  border-radius: 12px;
  margin-top: 12px;
}

.okbox {
  border-left: 5px solid var(--ok);
  background: #f0fdf4;
  padding: 14px;
  border-radius: 12px;
  margin-top: 12px;
}

.errorbox {
  border-left: 5px solid var(--danger);
  background: #fef2f2;
  padding: 14px;
  border-radius: 12px;
  margin-top: 12px;
}

.slots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.slot {
  background: #eef2ff;
  color: #1e3a8a;
  border: 1px solid #c7d2fe;
}

.slot.busy {
  background: #f3f4f6;
  color: #6b7280;
  border: 1px solid #d1d5db;
  cursor: not-allowed;
}

.small {
  color: var(--muted);
  font-size: 13px;
}

table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
}

th, td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 10px;
  vertical-align: top;
}

th {
  color: #374151;
  background: #f8fafc;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  background: #eef2ff;
  color: #1e3a8a;
  padding: 4px 9px;
  font-size: 13px;
  font-weight: 700;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.tab {
  background: #e5e7eb;
  color: #111827;
}

.tab.active { background: var(--accent); color: #fff; }

.hidden { display: none !important; }

.board {
  min-height: 100vh;
  background: #0f172a;
  color: #fff;
}

.board .container {
  width: min(1300px, calc(100% - 40px));
}

.board h1 {
  font-size: 54px;
  margin: 0 0 10px;
}

.board .card {
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.15);
  color: #fff;
}

.board .big {
  font-size: 52px;
  font-weight: 800;
  line-height: 1.15;
}

.board .medium {
  font-size: 32px;
  font-weight: 700;
}

.board .muted {
  color: rgba(255,255,255,.7);
}

.checklist {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.checkitem {
  display: flex;
  gap: 8px;
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  padding: 10px;
  border-radius: 12px;
}

.checkitem input {
  width: auto;
}


.search-results {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.student-result {
  width: 100%;
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--line);
  justify-content: flex-start;
  text-align: left;
  flex-direction: column;
  align-items: flex-start;
}

.student-result span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.student-title {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 10px;
}

.total-time {
  min-width: 130px;
  text-align: center;
  padding: 12px;
  border-radius: 16px;
  background: #eef2ff;
  color: #1e3a8a;
  border: 1px solid #c7d2fe;
}

.total-time span {
  display: block;
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
}

.total-time small {
  display: block;
  margin-top: 4px;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  border: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 12px;
  padding: 10px;
}

.compact {
  margin-top: 8px;
  padding: 9px;
}

.check-pill {
  display: block;
  border-radius: 999px;
  background: #ecfdf5;
  color: #166534;
  border: 1px solid #bbf7d0;
  padding: 7px 10px;
  margin: 0 0 7px;
  font-weight: 700;
}

@media (max-width: 700px) {
  .student-title {
    align-items: stretch;
    flex-direction: column;
  }

  .total-time {
    text-align: left;
  }
}


.slots-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin: 10px 0 12px;
  color: var(--muted);
  font-size: 14px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  display: inline-block;
  border: 1px solid var(--line);
}

.legend-dot.free {
  background: #dcfce7;
  border-color: #86efac;
}

.legend-dot.busy {
  background: #f3f4f6;
  border-color: #d1d5db;
}

.legend-dot.empty {
  background: #ffffff;
  border-color: #e5e7eb;
}

.slots-grid-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.slots-grid-table {
  width: 100%;
  min-width: 760px;
  border-collapse: separate;
  border-spacing: 0;
}

.slots-grid-table th,
.slots-grid-table td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 0;
  min-width: 150px;
  background: #fff;
}

.slots-grid-table thead th {
  padding: 12px 8px;
  text-align: center;
  font-size: 16px;
  background: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 1;
}

.slots-grid-table .time-col {
  min-width: 90px;
  width: 90px;
  text-align: center;
  font-weight: 700;
  background: #f8fafc;
}

.slots-grid-table tbody .time-col {
  font-size: 14px;
  color: var(--muted);
  padding: 12px 8px;
}

.schedule-empty {
  min-height: 94px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #cbd5e1;
  font-weight: 700;
  background: #fcfcfd;
}

.schedule-cell {
  width: 100%;
  min-height: 94px;
  border: 0;
  border-radius: 0;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 4px;
  text-align: left;
  box-shadow: none;
}

.schedule-cell.free {
  background: #ecfdf5;
  color: #14532d;
}

.schedule-cell.free:hover {
  background: #dcfce7;
}

.schedule-cell.busy {
  background: #f3f4f6;
  color: #6b7280;
}

.schedule-status {
  font-size: 12px;
  font-weight: 700;
}

.schedule-time {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.15;
}

.schedule-label {
  font-size: 12px;
  line-height: 1.25;
  color: inherit;
  opacity: .9;
}

@media (max-width: 820px) {
  .slots-grid-table {
    min-width: 680px;
  }

  .slots-grid-table th,
  .slots-grid-table td {
    min-width: 130px;
  }

  .schedule-cell {
    min-height: 86px;
  }

  .schedule-time {
    font-size: 14px;
  }
}


.wait-box {
  border: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 14px;
  padding: 12px;
  margin: 10px 0 12px;
}

.wait-box.open {
  background: #ecfdf5;
  border-color: #86efac;
  color: #14532d;
}

.wait-box.closed {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}


/* v5: исправление сетки записи — убрали наследование старой карточной сетки */
.booking-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.booking-card {
  width: 100%;
  min-width: 0;
}

.queue-card {
  width: 100%;
}

.slots-box {
  width: 100%;
  min-width: 0;
  display: block;
}

.slots-box .slots-legend {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.slots-box .slots-grid-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.slots-box .slots-grid-table {
  width: max-content;
  min-width: 1000px;
  border-collapse: separate;
  border-spacing: 0;
}

.slots-box .slots-grid-table th,
.slots-box .slots-grid-table td {
  min-width: 150px;
}

.slots-box .slots-grid-table .time-col {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 92px;
  width: 92px;
}

.slots-box .slots-grid-table thead .time-col {
  z-index: 3;
}

.slots-box .schedule-cell {
  white-space: normal;
  overflow: hidden;
}

.slots-box .schedule-label {
  max-height: 34px;
  overflow: hidden;
}

@media (min-width: 980px) {
  .booking-layout {
    grid-template-columns: minmax(0, 2fr) minmax(320px, .8fr);
    align-items: start;
  }
}

@media (max-width: 700px) {
  .slots-box .slots-grid-table {
    min-width: 820px;
  }

  .slots-box .slots-grid-table th,
  .slots-box .slots-grid-table td {
    min-width: 128px;
  }

  .slots-box .slots-grid-table .time-col {
    min-width: 78px;
    width: 78px;
  }
}


.call-banner {
  margin-bottom: 14px;
  border: 2px solid #f59e0b;
  background: #fffbeb;
  color: #92400e;
  padding: 16px;
  border-radius: 14px;
  font-size: 22px;
  font-weight: 800;
  animation: pulseCall 1.2s infinite;
}

@keyframes pulseCall {
  0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.35); }
  70% { box-shadow: 0 0 0 12px rgba(245, 158, 11, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.stat-card .value {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.1;
}

@media (max-width: 900px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}


.notify-setup {
  margin-bottom: 14px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1e3a8a;
  padding: 14px;
  border-radius: 14px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.notify-setup p {
  margin: 4px 0 0;
}

@media (max-width: 700px) {
  .notify-setup {
    align-items: stretch;
    flex-direction: column;
  }
}


.board-call-card {
  border: 2px solid rgba(245, 158, 11, .95) !important;
  background: rgba(245, 158, 11, .16) !important;
  animation: pulseBoardCall 1.4s infinite;
}

.board-call-name {
  font-size: clamp(44px, 7vw, 92px);
  font-weight: 900;
  line-height: 1.05;
}

@keyframes pulseBoardCall {
  0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, .42); }
  70% { box-shadow: 0 0 0 18px rgba(245, 158, 11, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}
