:root {
  color-scheme: dark;
  --bg: #081226;
  --surface: rgba(13, 24, 48, 0.78);
  --surface-strong: rgba(18, 33, 64, 0.92);
  --text: #edf4ff;
  --muted: #9eb0cf;
  --line: rgba(135, 171, 233, 0.18);
  --brand: #4f8cff;
  --brand-dark: #2d67d8;
  --success: #67d4a3;
  --shadow: 0 30px 80px rgba(3, 10, 24, 0.45);
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --font-main: "Segoe UI", "Trebuchet MS", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: var(--tg-viewport-stable-height, 100vh);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  font-family: var(--font-main);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(84, 135, 255, 0.38), transparent 28%),
    radial-gradient(circle at 85% 18%, rgba(0, 199, 255, 0.18), transparent 22%),
    radial-gradient(circle at bottom right, rgba(98, 74, 255, 0.2), transparent 30%),
    linear-gradient(180deg, #091224 0%, #0b1730 46%, #050b17 100%);
}

body.modal-open {
  overflow: hidden;
}

img {
  display: block;
  max-width: 100%;
}

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

.app-shell {
  position: relative;
  overflow-x: hidden;
}

.ambient {
  position: fixed;
  z-index: 0;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.45;
}

.ambient-left {
  top: -80px;
  left: -100px;
  background: rgba(60, 115, 255, 0.85);
}

.ambient-right {
  right: -120px;
  bottom: 10%;
  background: rgba(0, 180, 255, 0.58);
}

.container {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 18px 48px;
}

.hero-card,
.panel,
.status-card {
  backdrop-filter: blur(12px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 26px;
}

.hero-header,
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 16px;
}

.avatar {
  width: 72px;
  height: 72px;
  border-radius: 24px;
  object-fit: cover;
  background: #ead9c9;
}

.eyebrow,
.section-label {
  margin: 0 0 6px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 42px);
}

h2 {
  margin-bottom: 12px;
  font-size: clamp(28px, 3.2vw, 38px);
}

h3 {
  margin-bottom: 0;
  font-size: 24px;
}

.role-badge {
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(191, 95, 54, 0.14);
  color: var(--brand-dark);
  font-weight: 700;
}

.tutor-grid {
  display: grid;
  grid-template-columns: 1.3fr 0.9fr;
  gap: 24px;
  margin-top: 28px;
}

.about-text {
  font-size: 17px;
  line-height: 1.65;
  color: #d9e6ff;
}

.photo-frame {
  min-height: 320px;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(31, 60, 118, 0.95), rgba(11, 109, 169, 0.45));
}

.photo-action {
  width: 100%;
  margin-top: 14px;
}

.tutor-photo {
  width: 100%;
  height: 100%;
  min-height: 288px;
  object-fit: cover;
  border-radius: 22px;
  background: #13284c;
}

.status-card {
  margin-top: 22px;
  padding: 18px 22px;
  color: var(--text);
  font-weight: 700;
}

.status-card strong,
.status-card span {
  display: block;
}

.status-card strong {
  margin-bottom: 8px;
  font-size: 18px;
}

.promo-panel {
  margin-top: 22px;
}

.promo-text {
  margin: 18px 0 0;
  max-width: 760px;
  color: #d9e6ff;
  line-height: 1.7;
}

.promo-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.promo-badge,
.slot-discount-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-weight: 700;
}

.promo-badge {
  padding: 10px 14px;
  background: rgba(79, 140, 255, 0.16);
  color: #9fc4ff;
  border: 1px solid rgba(79, 140, 255, 0.24);
}

.promo-status {
  margin: 16px 0 0;
  color: var(--muted);
}

.lesson-price-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-top: 20px;
  padding: 18px 20px;
  border: 1px solid rgba(103, 212, 163, 0.25);
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(103, 212, 163, 0.14), rgba(79, 140, 255, 0.08));
  color: #d9e6ff;
}

.lesson-price-card strong {
  color: var(--success);
  font-size: clamp(20px, 3vw, 28px);
  white-space: nowrap;
}

.slot-discount-badge {
  margin-top: 10px;
  padding: 6px 10px;
  background: rgba(103, 212, 163, 0.14);
  color: var(--success);
  font-size: 12px;
}

.discount-meta {
  margin-top: 6px;
  color: var(--success);
}

.booking-pending,
.booking-confirmed {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 700;
}

.booking-pending {
  color: #ffd58b;
}

.booking-confirmed {
  color: #9fc4ff;
}

.status-card-actions {
  margin-top: 14px;
}

.panel {
  margin-top: 22px;
  padding: 24px;
}

.ghost-button,
.primary-button,
.slot-button,
.danger-button,
.secondary-button {
  border: none;
  border-radius: 18px;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.ghost-button:hover,
.primary-button:hover,
.slot-button:hover,
.danger-button:hover,
.secondary-button:hover {
  transform: translateY(-1px);
}

.ghost-button {
  padding: 12px 16px;
  color: var(--text);
  background: rgba(20, 38, 72, 0.96);
  border: 1px solid var(--line);
}

.primary-button {
  padding: 14px 18px;
  background: var(--brand);
  color: white;
  font-weight: 700;
}

.danger-button {
  padding: 10px 14px;
  background: rgba(255, 99, 132, 0.14);
  color: #ff9db2;
  font-weight: 700;
}

.days-nav {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
}

.days-arrow {
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 16px;
  font-size: 22px;
  line-height: 1;
  flex: 0 0 auto;
}

.days-row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 8px 0 6px;
  margin-top: 0;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  touch-action: pan-x;
  overscroll-behavior-x: contain;
  cursor: grab;
}

.days-row.dragging {
  cursor: grabbing;
  user-select: none;
}

.days-row::-webkit-scrollbar {
  display: none;
}

.day-pill {
  flex: 0 0 auto;
  min-width: 112px;
  padding: 14px 16px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--text);
  cursor: pointer;
  scroll-snap-align: start;
}

.day-pill.active {
  background: linear-gradient(135deg, #4f8cff, #2c6fe7);
  color: white;
}

.slot-button {
  padding: 16px 18px;
  color: var(--text);
  background: rgba(15, 29, 57, 0.96);
  border: 1px solid var(--line);
  text-align: left;
}

.slot-button .slot-meta {
  color: var(--muted);
}

.slots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 22px;
}

.empty-state {
  margin-top: 22px;
  color: var(--muted);
}

.admin-layout,
.admin-tables {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 22px;
}

.admin-intro,
.modal-lead,
.form-hint {
  color: var(--muted);
  line-height: 1.55;
}

.admin-intro {
  margin: 14px 0 0;
}

.admin-menu {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.admin-menu-button {
  display: flex;
  min-height: 170px;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 20px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(145deg, rgba(79, 140, 255, 0.14), transparent 55%),
    var(--surface-strong);
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.admin-menu-button:hover {
  transform: translateY(-3px);
  border-color: rgba(113, 160, 255, 0.52);
  background:
    linear-gradient(145deg, rgba(79, 140, 255, 0.24), transparent 60%),
    var(--surface-strong);
}

.admin-menu-button strong {
  font-size: 17px;
}

.admin-menu-button small {
  color: var(--muted);
  line-height: 1.45;
}

.admin-menu-icon {
  display: grid;
  width: 48px;
  height: 48px;
  margin-bottom: 6px;
  place-items: center;
  border-radius: 16px;
  background: rgba(79, 140, 255, 0.18);
  color: #b8d1ff;
  font-size: 23px;
}

.admin-portfolio {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 22px;
}

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

.card-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.card-stack label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
}

.checkbox-row {
  flex-direction: row !important;
  align-items: center;
  gap: 10px !important;
}

.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  padding: 0;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  color: var(--text);
  background: rgba(9, 18, 38, 0.88);
}

select {
  appearance: none;
  cursor: pointer;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 13px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.modal-card > label,
.modal-card form > label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
}

.file-input {
  position: relative;
  padding: 18px;
  border: 1px dashed rgba(135, 171, 233, 0.28);
  border-radius: 18px;
  background: rgba(10, 20, 42, 0.88);
}

.file-input input {
  padding: 0;
  border: none;
}

.list-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.list-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(10, 20, 42, 0.88);
}

.list-item strong,
.list-item span {
  display: block;
}

.list-item > div:last-child {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
}

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

.student-card {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(220px, 0.8fr);
  gap: 16px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(10, 20, 42, 0.88);
}

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

.student-add-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-top: 20px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface-strong);
}

.student-add-form label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
}

.student-actions {
  display: grid;
  gap: 10px;
}

.discount-editor {
  display: grid;
  grid-template-columns: minmax(130px, 0.7fr) minmax(120px, 1fr);
  gap: 10px;
}

.student-actions input {
  min-width: 0;
}

.assignment-slot {
  display: flex;
  flex-direction: row !important;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
}

.assignment-slot input[type="checkbox"] {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
}

.student-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.secondary-button {
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(20, 38, 72, 0.96);
  color: var(--text);
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.modal {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  inset: 0;
  z-index: 20;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 11, 23, 0.68);
  backdrop-filter: blur(8px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: calc(100vw - 24px);
  width: min(920px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 24px);
  max-height: calc(var(--tg-viewport-stable-height, 100vh) - 24px);
  margin: 12px auto;
  padding: 24px;
  overflow: auto;
  border-radius: var(--radius-xl);
  border: 1px solid var(--line);
  background: rgba(8, 18, 38, 0.96);
  box-shadow: var(--shadow);
}

.admin-modal-card {
  width: min(1080px, calc(100vw - 24px));
}

.admin-about-card,
.admin-slots-card {
  width: min(1240px, calc(100vw - 24px));
}

.modal-content {
  margin-top: 20px;
}

.about-admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(290px, 0.75fr);
  gap: 18px;
  align-items: start;
}

.about-photo-column {
  display: grid;
  gap: 14px;
}

.admin-photo-preview {
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #13284c;
}

.compact-upload h4 {
  margin-bottom: 2px;
}

.slot-manager {
  display: grid;
  grid-template-columns: minmax(250px, 0.34fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.slot-create-card {
  position: sticky;
  top: 0;
}

.form-hint {
  margin: 0;
  font-size: 13px;
}

.calendar-card,
.free-slots-list-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
}

.calendar-toolbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.calendar-toolbar h4 {
  margin: 0;
  text-align: center;
  text-transform: capitalize;
}

.calendar-arrow {
  width: 44px;
  height: 44px;
  padding: 0;
}

.calendar-weekdays,
.admin-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.calendar-weekdays {
  margin-bottom: 8px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  font-weight: 700;
}

.calendar-day {
  display: flex;
  min-width: 0;
  min-height: 104px;
  flex-direction: column;
  align-items: stretch;
  gap: 7px;
  padding: 9px;
  overflow: hidden;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(9, 18, 38, 0.82);
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.calendar-day:not(.calendar-day-empty):hover {
  transform: translateY(-1px);
  border-color: rgba(113, 160, 255, 0.5);
}

.calendar-day.has-slots {
  background: linear-gradient(155deg, rgba(79, 140, 255, 0.2), rgba(9, 18, 38, 0.92));
  border-color: rgba(79, 140, 255, 0.36);
}

.calendar-day.selected {
  box-shadow: inset 0 0 0 2px #67d4a3;
}

.calendar-day-empty {
  opacity: 0.25;
  cursor: default;
  border-style: dashed;
}

.calendar-date-number {
  font-weight: 800;
}

.calendar-times {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.calendar-time {
  padding: 4px 6px;
  border-radius: 8px;
  background: rgba(103, 212, 163, 0.16);
  color: #91e6bd;
  font-size: 11px;
  font-weight: 800;
}

.calendar-no-time {
  color: rgba(158, 176, 207, 0.45);
}

.free-slots-list-card {
  margin-top: 18px;
}

.free-slots-list-card h4 {
  margin-bottom: 14px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.booking-modal-card {
  width: min(560px, calc(100vw - 24px));
}

.booking-modal-text {
  margin-top: 16px;
  color: #d9e6ff;
  line-height: 1.6;
}

.booking-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.portfolio-list {
  display: grid;
  gap: 18px;
  margin-top: 20px;
}

.portfolio-item {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(12, 26, 52, 0.9);
}

.portfolio-item p {
  margin-bottom: 14px;
  color: #d9e6ff;
  line-height: 1.7;
}

.portfolio-photo {
  width: 100%;
  min-height: 240px;
  object-fit: cover;
  border-radius: 18px;
  background: #13284c;
}

@media (max-width: 960px) {
  .tutor-grid,
  .admin-layout,
  .admin-tables,
  .admin-portfolio {
    grid-template-columns: 1fr;
  }

  .hero-header,
  .panel-header,
  .list-item,
  .student-card,
  .modal-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .student-card {
    grid-template-columns: 1fr;
  }

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

  .about-admin-grid,
  .slot-manager {
    grid-template-columns: 1fr;
  }

  .slot-create-card {
    position: static;
  }

  .list-item > div:last-child {
    align-items: flex-start;
  }

  .days-nav {
    grid-template-columns: 1fr;
  }

  .days-arrow {
    display: none;
  }
}

@media (max-width: 620px) {
  .admin-menu {
    grid-template-columns: 1fr;
  }

  .admin-menu-button {
    min-height: 0;
  }

  .lesson-price-card,
  .student-add-form {
    grid-template-columns: 1fr;
  }

  .lesson-price-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .discount-editor {
    grid-template-columns: 1fr;
  }

  .modal-card {
    padding: 18px;
  }

  .calendar-weekdays,
  .admin-calendar {
    gap: 4px;
  }

  .calendar-day {
    min-height: 76px;
    padding: 6px;
    border-radius: 11px;
  }

  .calendar-time {
    padding: 3px 4px;
    font-size: 9px;
  }
}
