* { box-sizing: border-box; }
body {
  margin: 0; font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: #f4f5f7; color: #1c1e21; font-size: 15px;
}
a { color: #2f6fed; text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #eceff3; padding: 1px 6px; border-radius: 4px; }

.topbar {
  display: flex; align-items: center; gap: 20px; padding: 12px 20px;
  background: #fff; border-bottom: 1px solid #e3e6ea;
}
.topbar .logo { font-weight: 700; font-size: 18px; color: #1c1e21; }
.topbar nav { display: flex; gap: 16px; }
.badge {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px;
  background: #e5484d; color: #fff; border-radius: 9px;
  font-size: 12px; text-align: center;
}

.container { max-width: 1100px; margin: 24px auto; padding: 0 16px; }
h1 { font-size: 22px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: #6b7280; }
.small { font-size: 13px; }
.error { color: #e5484d; }
.debt { color: #e5484d; font-weight: 600; }

.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; }
.row.gap { gap: 8px; }

.btn, button {
  display: inline-block; padding: 7px 14px; border: 1px solid #d3d8de;
  background: #fff; border-radius: 8px; cursor: pointer; font-size: 14px; color: #1c1e21;
}
button:hover, .btn:hover { background: #f0f2f5; text-decoration: none; }
button.danger { color: #e5484d; border-color: #f3c1c3; }

.card {
  background: #fff; border: 1px solid #e3e6ea; border-radius: 12px;
  padding: 16px; margin: 12px 0;
}
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
input, select, textarea {
  padding: 8px 10px; border: 1px solid #d3d8de; border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff;
}
textarea { width: 100%; min-height: 70px; margin: 6px 0; }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; margin-top: 14px; }
.day {
  background: #fff; border: 1px solid #e3e6ea; border-radius: 12px;
  padding: 10px; min-height: 140px;
}
.day.today { border-color: #2f6fed; box-shadow: 0 0 0 1px #2f6fed; }
.day h3 { display: flex; justify-content: space-between; }

.lesson {
  border: 1px solid #e3e6ea; border-radius: 8px; padding: 7px 9px;
  margin-bottom: 7px; font-size: 13px; background: #fafbfc;
}
.lesson.status-done { border-left: 3px solid #34a853; }
.lesson.status-planned { border-left: 3px solid #2f6fed; }
.lesson.status-cancelled { border-left: 3px solid #9aa0a6; opacity: .65; }
.lesson.status-no_show { border-left: 3px solid #e5484d; }
.lesson.free { border-left: 3px solid #d3d8de; background: #fff; }
.lesson-head { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.lesson .dur { color: #6b7280; font-size: 12px; }
.lesson-actions { display: flex; gap: 4px; margin-top: 5px; }
.lesson-actions button { padding: 2px 8px; font-size: 12px; }
.book-inline { display: flex; gap: 4px; margin-top: 5px; }
.book-inline select { padding: 2px 4px; font-size: 12px; max-width: 110px; }
.book-inline button { padding: 2px 8px; font-size: 12px; }

.tbl { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; }
.tbl th, .tbl td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #eceff3; font-size: 14px; }
.tbl tr:last-child td { border-bottom: none; }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.balance { font-size: 16px; font-weight: 600; }

/* login / booking pages */
.login-page, .book-page {
  display: flex; justify-content: center; align-items: flex-start;
  min-height: 100vh; padding: 40px 16px; background: #f4f5f7;
}
.login-card, .book-card {
  background: #fff; border: 1px solid #e3e6ea; border-radius: 16px;
  padding: 28px; width: 100%; max-width: 420px;
}
.book-card { max-width: 560px; }
.book-card.center { text-align: center; }
.login-card form { display: flex; flex-direction: column; gap: 10px; }
.big { font-size: 20px; font-weight: 700; }
.powered { margin-top: 24px; text-align: center; color: #9aa0a6; font-size: 12px; }

.book-day { margin-bottom: 14px; }
.slots-row { display: flex; flex-wrap: wrap; gap: 8px; }
.slot-pick { border: 1px solid #d3d8de; border-radius: 10px; padding: 0; background: #fff; }
.slot-pick summary {
  padding: 8px 14px; cursor: pointer; font-weight: 600; list-style: none;
}
.slot-pick summary::-webkit-details-marker { display: none; }
.slot-pick[open] summary { border-bottom: 1px solid #eceff3; }
.slot-pick form { display: flex; flex-direction: column; gap: 8px; padding: 10px; min-width: 220px; }

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

@media (prefers-color-scheme: dark) {
  html:not([data-theme]) body { background: #141517; color: #e6e8eb; }
  html:not([data-theme]) a { color: #7ea6ff; }
  html:not([data-theme]) code { background: #26292e; }
  html:not([data-theme]) .topbar { background: #1c1d20; border-bottom-color: #2c2e33; }
  html:not([data-theme]) .topbar .logo { color: #e6e8eb; }
  html:not([data-theme]) .card, .day, .tbl, .lesson.free, .slot-pick { background: #1c1d20; border-color: #2c2e33; }
  html:not([data-theme]) .lesson { background: #1e2023; border-color: #2c2e33; }
  html:not([data-theme]) input, select, textarea { background: #26292e; border-color: #3a3d44; color: #e6e8eb; }
  html:not([data-theme]) .btn, button { background: #26292e; border-color: #3a3d44; color: #e6e8eb; }
  html:not([data-theme]) button:hover, .btn:hover { background: #2f3238; }
  html:not([data-theme]) button.danger { border-color: #6e2f31; }
  html:not([data-theme]) .tbl th, .tbl td { border-bottom-color: #2c2e33; }
  html:not([data-theme]) .day.today { border-color: #7ea6ff; box-shadow: 0 0 0 1px #7ea6ff; }
  html:not([data-theme]) .muted, .lesson .dur, .powered { color: #9aa0a6; }
  html:not([data-theme]) .login-page, .book-page { background: #141517; }
  html:not([data-theme]) .login-card, .book-card { background: #1c1d20; border-color: #2c2e33; }
  html:not([data-theme]) .slot-pick summary { border-bottom-color: #2c2e33; }
}

html[data-theme="dark"] body { background: #141517; color: #e6e8eb; }
html[data-theme="dark"] a { color: #7ea6ff; }
html[data-theme="dark"] code { background: #26292e; }
html[data-theme="dark"] .topbar { background: #1c1d20; border-bottom-color: #2c2e33; }
html[data-theme="dark"] .topbar .logo { color: #e6e8eb; }
html[data-theme="dark"] .card, .day, .tbl, .lesson.free, .slot-pick { background: #1c1d20; border-color: #2c2e33; }
html[data-theme="dark"] .lesson { background: #1e2023; border-color: #2c2e33; }
html[data-theme="dark"] input, select, textarea { background: #26292e; border-color: #3a3d44; color: #e6e8eb; }
html[data-theme="dark"] .btn, button { background: #26292e; border-color: #3a3d44; color: #e6e8eb; }
html[data-theme="dark"] button:hover, .btn:hover { background: #2f3238; }
html[data-theme="dark"] button.danger { border-color: #6e2f31; }
html[data-theme="dark"] .tbl th, .tbl td { border-bottom-color: #2c2e33; }
html[data-theme="dark"] .day.today { border-color: #7ea6ff; box-shadow: 0 0 0 1px #7ea6ff; }
html[data-theme="dark"] .muted, .lesson .dur, .powered { color: #9aa0a6; }
html[data-theme="dark"] .login-page, .book-page { background: #141517; }
html[data-theme="dark"] .login-card, .book-card { background: #1c1d20; border-color: #2c2e33; }
html[data-theme="dark"] .slot-pick summary { border-bottom-color: #2c2e33; }

.theme-toggle { padding: 4px 10px; font-size: 15px; }

@media (max-width: 560px) {
  .week { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; gap: 8px 14px; padding: 10px 14px; }
  .topbar nav { flex-wrap: wrap; gap: 10px; font-size: 14px; }
  .container { padding: 0 10px; }
  .tbl th, .tbl td { padding: 8px 8px; font-size: 13px; }
  .inline-form input, .inline-form select { flex: 1 1 100%; }
  .inline-form button { flex: 1; }
  .row.between { flex-wrap: wrap; gap: 8px; }
}
