:root {
  color-scheme: light;
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-strong: #f0f3ef;
  --text: #20211f;
  --muted: #676b64;
  --line: #d9ded6;
  --green: #16834a;
  --green-soft: #e4f5eb;
  --amber: #b9780b;
  --amber-soft: #fff0cd;
  --red: #bf3030;
  --red-soft: #ffe2e2;
  --black: #111111;
  --shadow: 0 18px 45px rgba(22, 27, 22, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 27px;
  line-height: 1.12;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
}

h3 {
  font-size: 16px;
}

.top-actions,
.legend,
.section-head,
.status-strip {
  display: flex;
  align-items: center;
}

.top-actions {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.mode-badge {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--surface-strong);
  font-size: 14px;
  font-weight: 800;
}

.button {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 38px;
  padding: 0 14px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
}

.button:hover {
  border-color: #b6bfb2;
}

.button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.button.primary {
  background: var(--black);
  color: #fff;
  border-color: var(--black);
}

.button.secondary {
  background: #e8ece7;
}

.button.ghost {
  background: transparent;
}

.button.danger {
  border-color: #f0baba;
  color: #9b1f1f;
  background: #fff7f7;
}

.button.wide {
  width: 100%;
}

.shell {
  width: min(1420px, calc(100vw - 40px));
  margin: 24px auto 56px;
}

.status-strip {
  justify-content: space-between;
  gap: 20px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 4px;
}

.legend {
  gap: 14px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.dot {
  width: 9px;
  height: 9px;
  display: inline-block;
  border-radius: 999px;
  margin-right: 6px;
}

.dot.green {
  background: var(--green);
}

.dot.amber {
  background: var(--amber);
}

.dot.red {
  background: var(--red);
}

.login-panel {
  margin-top: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.login-form {
  display: grid;
  grid-template-columns: minmax(220px, 340px) auto;
  gap: 12px;
  align-items: end;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.calendar-area,
.detail-panel,
.admin-bookings {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.calendar-area,
.detail-panel {
  padding: 18px;
}

.admin-bookings {
  margin-top: 18px;
  padding: 18px;
}

.section-head {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-head p {
  color: var(--muted);
  margin-top: 4px;
  font-size: 14px;
}

.section-head.compact {
  align-items: flex-start;
}

.calendar-stack {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.month-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.month-title {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-weight: 900;
}

.weekday-row,
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekday-row span {
  min-height: 34px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  background: #fafbf9;
}

.day-cell {
  border: 0;
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
  background: #fff;
  min-height: 88px;
  padding: 8px;
  text-align: left;
  cursor: default;
  color: var(--muted);
}

.day-cell:nth-child(7n) {
  border-right: 0;
}

.day-cell.has-slot {
  cursor: default;
  color: var(--text);
}

.day-cell.has-slot.can-select {
  cursor: pointer;
}

.day-cell.selected {
  outline: 3px solid #111;
  outline-offset: -3px;
}

.day-cell.empty {
  background: #fafafa;
}

.day-cell.available {
  background: var(--green-soft);
}

.day-cell.almost_full {
  background: var(--amber-soft);
}

.day-cell.full {
  background: var(--red-soft);
}

.day-number {
  font-size: 18px;
  font-weight: 900;
}

.day-meta {
  margin-top: 12px;
  font-size: 12px;
  line-height: 1.35;
  font-weight: 800;
}

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

.contact-panel {
  display: grid;
  gap: 10px;
  padding: 4px 2px;
}

.contact-panel p {
  color: var(--muted);
  line-height: 1.65;
}

.slot-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  display: grid;
  gap: 9px;
}

.slot-card.available {
  border-left: 6px solid var(--green);
}

.slot-card.almost_full {
  border-left: 6px solid var(--amber);
}

.slot-card.full {
  border-left: 6px solid var(--red);
}

.slot-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.slot-time {
  font-size: 18px;
  font-weight: 900;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.pill.available {
  color: #0f6b3b;
  background: var(--green-soft);
}

.pill.almost_full {
  color: #855400;
  background: var(--amber-soft);
}

.pill.full {
  color: #9b1f1f;
  background: var(--red-soft);
}

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

.booking-form {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  display: grid;
  gap: 12px;
}

.student-fields {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 800;
  color: var(--muted);
  font-size: 13px;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 11px;
}

input:focus,
select:focus {
  outline: 3px solid rgba(17, 17, 17, 0.14);
  border-color: #111;
}

.check-row {
  grid-template-columns: 20px 1fr;
  align-items: center;
  color: var(--text);
}

.check-row input {
  width: 18px;
  min-height: 18px;
  padding: 0;
}

.inline-message {
  color: var(--muted);
  font-size: 13px;
  min-height: 18px;
}

.inline-message.error {
  color: var(--red);
  font-weight: 800;
}

.inline-message.success {
  color: var(--green);
  font-weight: 800;
}

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

.booking-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(220px, 1.5fr) minmax(180px, 1.2fr) minmax(260px, 1.3fr);
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.booking-row strong {
  display: block;
}

.booking-row span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.secret-text {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  word-break: break-all;
}

.booking-actions {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: end;
}

.move-field {
  min-width: 0;
}

.move-field select {
  min-width: 0;
}

.empty-state {
  border: 1px dashed #c3c9bf;
  border-radius: 8px;
  padding: 24px;
  background: #fafbf9;
  color: var(--muted);
  display: grid;
  gap: 6px;
}

.empty-state strong {
  color: var(--text);
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
  }

  .booking-row {
    grid-template-columns: 1fr;
  }

  .booking-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .topbar,
  .status-strip,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .shell {
    width: min(100vw - 24px, 1420px);
    margin-top: 14px;
  }

  .topbar {
    padding: 14px;
  }

  .login-form {
    grid-template-columns: 1fr;
  }

  .calendar-stack {
    grid-template-columns: 1fr;
  }

  .day-cell {
    min-height: 74px;
    padding: 7px;
  }
}
