* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--page-bg, #f4f6fb);
  color: var(--text-color, #1f2937);
  font-family: var(--font-family, Arial, sans-serif);
  font-size: var(--font-size, 14px);
}
a { color: inherit; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: var(--header-bg, #2347c5);
  color: var(--header-text, #fff);
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.brand { font-size: 20px; font-weight: 700; text-decoration: none; }
.topbar nav { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.topbar nav a { color: var(--header-text, #fff); text-decoration: none; font-weight: 600; }
.user-badge { padding: 4px 8px; border: 1px solid rgba(255,255,255,.5); border-radius: 999px; }
.session-timer {
  background: #f8fafc;
  border-bottom: 1px solid var(--border-color, #d0d7e2);
  padding: 8px 20px;
}
.session-timer-inner {
  max-width: 1560px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 700;
}
.session-bar-track {
  flex: 1 1 auto;
  min-width: 140px;
  height: 10px;
  background: #dbe4ef;
  border-radius: 999px;
  overflow: hidden;
}
.session-bar-fill {
  display: block;
  width: 100%;
  height: 100%;
  background: #22c55e;
  border-radius: inherit;
  transition: width .25s linear;
}
.page { padding: 18px; max-width: 1560px; margin: 0 auto; }
.card {
  background: var(--calendar-bg, #fff);
  border: 1px solid var(--border-color, #d0d7e2);
  border-radius: var(--radius, 8px);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.narrow { max-width: 520px; margin: 40px auto; }
h1, h2, h3 { margin: 0 0 10px; }
.muted { color: #64748b; }
.btn, button.btn {
  display: inline-block;
  border: 0;
  border-radius: 7px;
  background: #1463ff;
  color: #fff;
  padding: 9px 12px;
  text-decoration: none;
  cursor: pointer;
  font-weight: 700;
}
.btn.secondary { background: #e7eefc; color: #163b7a; }
.btn.secondary.current-week-btn { background: #fb5d5d; color: #f1f1f1; }
.btn.secondary.current-week-btn:hover { background: #f74242; }
.btn.danger { background: #d12828; }
.btn.warning { background: #c66a00; }
.btn.small { padding: 6px 9px; font-size: 12px; }
.form-grid { display: grid; gap: 12px; }
.form-grid label { display: grid; gap: 5px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--border-color, #d0d7e2);
  border-radius: 7px;
  padding: 9px;
  font: inherit;
  background: #fff;
}
textarea { min-height: 120px; resize: vertical; }
.notice {
  padding: 12px;
  border-radius: var(--radius, 8px);
  margin-bottom: 14px;
  background: #fff8d8;
  border: 1px solid #f2d46f;
}
.notice.success { background: #e8f8ef; border-color: #6ed39b; }
.notice.error { background: #ffebeb; border-color: #f39a9a; }
.service-message { background: #fff3c4; }
.calendar-toolbar, .mobile-week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.calendar-month {
  display: grid;
  grid-template-columns: repeat(7, minmax(160px, 1fr));
  gap: 10px;
}
.calendar-week { display: none; }
.mobile-week-nav { display: none; }
.day-card {
  background: var(--calendar-bg, #fff);
  border: 1px solid var(--border-color, #d0d7e2);
  border-radius: var(--radius, 8px);
  padding: 8px;
  min-height: 310px;
}
.day-card.outside-month { opacity: .55; }
.day-card.today {
  border: 3px solid #d60000;
  box-shadow: 0 0 0 2px rgba(214,0,0,.12);
  scroll-margin-top: 80px;
}
.day-card.current-week-start {
  scroll-margin-top: 80px;
}
.day-card h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
  color: var(--header-bg, #2347c5);
  border-bottom: 1px solid var(--border-color, #d0d7e2);
  padding-bottom: 6px;
  margin-bottom: 8px;
}
.day-card h3 span { font-size: 22px; }
.slot-group {
  border: 1px solid var(--border-color, #d0d7e2);
  border-radius: var(--radius, 8px);
  padding: 6px;
  margin-bottom: 8px;
}
.slot-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 12px;
  margin-bottom: 5px;
}
.slot-title span { color: #64748b; font-weight: 600; }
.slot-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 36px;
  border: 1px solid var(--border-color, #d0d7e2);
  border-radius: calc(var(--radius, 8px) - 2px);
  padding: 5px 6px;
  margin: 4px 0;
  overflow: hidden;
}
.slot-box strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.slot-box small { display: block; color: #475569; }
.slot-box.free { background: var(--free-bg, #fff); }
.slot-box.booked { background: var(--booked-bg, #41b883); color: #062b18; }
.slot-box.blocked { background: var(--blocked-bg, #c66a00); color: #fff; }
.slot-box.blocked small { color: #fff7ed; }
.slot-box.disabled { background: var(--disabled-bg, #e7e7e7); color: #64748b; }
.slot-box.openable { cursor: pointer; }
.slot-box.openable:hover { outline: 2px solid rgba(35, 71, 197, .35); }
.icon-btn {
  flex: 0 0 auto;
  border: 1px solid rgba(0,0,0,.15);
  background: rgba(255,255,255,.85);
  border-radius: 6px;
  width: 27px;
  height: 27px;
  cursor: pointer;
  position: relative;
  z-index: 2;
}
.modal-backdrop[hidden] { display: none !important; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 1000;
}
.modal {
  background: #fff;
  color: #1f2937;
  max-width: 560px;
  width: 100%;
  border-radius: 12px;
  padding: 18px;
  position: relative;
  box-shadow: 0 25px 70px rgba(0,0,0,.3);
}
.modal-close {
  position: absolute;
  right: 12px;
  top: 10px;
  border: 0;
  background: transparent;
  font-size: 28px;
  cursor: pointer;
}
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 9px; border-bottom: 1px solid var(--border-color, #d0d7e2); text-align: left; vertical-align: top; }
th { background: #f3f6fb; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.color-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.calendar-footer-tools {
  display: flex;
  justify-content: center;
  padding: 24px 0 10px;
}
.go-top-btn {
  width: 58px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 3px;
  background: #e8e8e8;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
  transition: transform .18s ease, background .18s ease;
}
.go-top-btn svg {
  width: 28px;
  height: 28px;
  fill: #6b7280;
}
.go-top-btn:hover {
  background: #dedede;
  transform: translateY(-2px);
}
.go-top-btn:focus-visible {
  outline: 2px solid #6b7280;
  outline-offset: 3px;
}

@media (max-width: 760px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .session-timer { padding: 8px 10px; }
  .session-timer-inner { align-items: flex-start; flex-direction: column; gap: 6px; }
  .session-bar-track { width: 100%; }
  .page { padding: 10px; }
  .calendar-month { display: none; }
  .calendar-week { display: grid; gap: 10px; }
  .mobile-week-nav { display: flex; }
  .calendar-toolbar { align-items: flex-start; flex-direction: column; }
  .day-card { min-height: auto; }
  .slot-box strong { max-width: none; }
}
