:root {
  --background: 210 40% 98%;
  --foreground: 222 47% 11%;

  --card: 0 0% 100%;
  --card-foreground: 222 47% 11%;

  --primary: 235 85% 66%;
  --primary-foreground: 0 0% 100%;

  --secondary: 220 24% 95%;
  --secondary-foreground: 222 47% 11%;

  --muted: 220 24% 96%;
  --muted-foreground: 222 15% 42%;

  --accent: 235 85% 60%;
  --accent-foreground: 0 0% 100%;

  --destructive: 355 85% 52%;
  --destructive-foreground: 0 0% 100%;

  --border: 220 20% 89%;
  --input: 220 20% 89%;
  --ring: 235 85% 60%;

  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-pill: 999px;

  --text-secondary: 222 15% 42%;
  --text-tertiary: 222 12% 56%;

  --shadow-card: 0 8px 24px hsl(222 35% 25% / 0.08);
  --shadow-popover: 0 16px 40px hsl(222 35% 25% / 0.14);
  --glow-accent: 0 0 12px hsl(235 85% 66% / 0.35);

  --sidebar-background: 0 0% 100%;
  --sidebar-width-collapsed: 72px;
  --sidebar-width-expanded: 264px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Inter", "SF Pro Display", system-ui, sans-serif;
  color: hsl(var(--foreground));
  background-color: hsl(var(--background));
  min-height: 100vh;
  letter-spacing: -0.01em;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ---------- Layout shell ---------- */

.app-shell {
  position: relative;
  display: flex;
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
}

.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 20;
  width: var(--sidebar-width-collapsed);
  background: hsl(var(--sidebar-background));
  border-right: 1px solid hsl(var(--border));
  padding: 24px 12px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-x: hidden;
  overflow-y: auto;
  transition: width 0.2s ease-in-out;
}

.app-shell.sidebar-open .app-sidebar {
  width: var(--sidebar-width-expanded);
  padding: 24px 20px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(15, 23, 42, 0.06);
  background: rgba(15, 23, 42, 0.02);
  border-radius: var(--radius-md);
  padding: 8px 12px;
}

.sidebar-logo img {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
}

.sidebar-logo-text {
  display: none;
  white-space: nowrap;
}

.app-shell.sidebar-open .sidebar-logo-text {
  display: block;
}

.sidebar-logo-text p:first-child {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4em;
  color: hsl(var(--text-tertiary));
}

.sidebar-logo-text p:last-child {
  margin: 2px 0 0;
  font-size: 10px;
  line-height: 1.2;
  color: hsl(var(--text-tertiary));
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 44px;
  padding: 0 10px;
  border-radius: 12px;
  color: hsl(var(--text-secondary));
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-link svg {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.sidebar-link span {
  display: none;
}

.app-shell.sidebar-open .sidebar-link span {
  display: inline;
}

.sidebar-link:hover {
  background: #eef1f6;
  color: hsl(var(--foreground));
}

.sidebar-link.active {
  background: #5b64ff;
  color: #fff;
}

/* ---------- Content area ---------- */

.app-content {
  position: relative;
  z-index: 10;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin-left: var(--sidebar-width-collapsed);
  transition: margin-left 0.2s ease-in-out;
}

.app-shell.sidebar-open .app-content {
  margin-left: var(--sidebar-width-expanded);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 15;
  width: 100%;
  border-bottom: 1px solid hsl(var(--border));
  background: hsla(0, 0%, 100%, 0.85);
  backdrop-filter: blur(24px);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.header-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  width: 48px;
  border-radius: var(--radius-md);
  border: 1px solid hsl(var(--border));
  background: transparent;
  color: hsl(var(--text-secondary));
  cursor: pointer;
}

.header-toggle:hover {
  border-color: hsl(var(--text-tertiary));
}

.header-toggle svg {
  width: 20px;
  height: 20px;
}

.header-toggle .icon-left {
  display: none;
}

.app-shell.sidebar-open .header-toggle .icon-left {
  display: inline-flex;
}

.app-shell.sidebar-open .header-toggle .icon-right {
  display: none;
}

.header-search {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.header-search svg {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: hsl(var(--text-tertiary));
  pointer-events: none;
}

.header-search input {
  width: 100%;
  height: 48px;
  border-radius: var(--radius-pill);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
  padding: 0 48px;
  font-size: 14px;
}

.header-search input::placeholder {
  color: hsl(var(--text-tertiary));
}

.header-search input:focus {
  outline: none;
  border-color: hsl(var(--accent));
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid transparent;
  cursor: pointer;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-secondary {
  background: #eef1f6;
  border-color: hsl(var(--border));
  color: hsl(var(--foreground));
}

.btn-secondary:hover {
  background: #e2e6ee;
}

.btn-primary {
  background: #5b64ff;
  color: #fff;
  box-shadow: var(--glow-accent);
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.btn-danger {
  background: hsl(var(--destructive) / 0.1);
  border-color: hsl(var(--destructive) / 0.35);
  color: hsl(var(--destructive));
}

.btn-danger:hover {
  background: hsl(var(--destructive) / 0.18);
}

.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-pill);
  background: #5b64ff;
  color: #fff;
  font-weight: 600;
  font-size: 14px;
}

.app-main {
  position: relative;
  z-index: 10;
  flex: 1;
  width: 100%;
  padding: 24px;
}

@media (min-width: 640px) {
  .app-main {
    padding: 24px 40px;
  }
}

/* ---------- Page header ---------- */

.page-title {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
}

.page-subtitle {
  margin: 4px 0 0;
  font-size: 14px;
  color: hsl(var(--text-secondary));
}

/* ---------- Cards / stats ---------- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 16px;
  margin-top: 24px;
}

@media (min-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1280px) {
  .stats-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

.stat-card {
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  border-radius: var(--radius-md);
  padding: 20px 24px;
  box-shadow: var(--shadow-card);
}

.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.stat-card-label {
  font-size: 13px;
  font-weight: 500;
  color: hsl(var(--text-secondary));
}

.stat-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
}

.stat-card-icon svg {
  width: 16px;
  height: 16px;
}

.stat-card-value {
  margin: 12px 0 0;
  font-size: 28px;
  font-weight: 600;
  font-family: "JetBrains Mono", "SF Mono", monospace;
}

.stat-color-blue { background: rgba(59, 130, 246, 0.12); color: #2563eb; }
.stat-color-green { background: rgba(34, 197, 94, 0.12); color: #16a34a; }
.stat-color-purple { background: rgba(168, 85, 247, 0.12); color: #9333ea; }
.stat-color-orange { background: rgba(249, 115, 22, 0.12); color: #ea580c; }
.stat-color-indigo { background: rgba(99, 102, 241, 0.12); color: #4f46e5; }
.stat-color-cyan { background: rgba(6, 182, 212, 0.12); color: #0891b2; }
.stat-color-yellow { background: rgba(234, 179, 8, 0.12); color: #ca8a04; }
.stat-color-emerald { background: rgba(16, 185, 129, 0.12); color: #059669; }
.stat-color-pink { background: rgba(236, 72, 153, 0.12); color: #db2777; }
.stat-color-violet { background: rgba(139, 92, 246, 0.12); color: #7c3aed; }

.placeholder-card {
  margin-top: 24px;
  border: 1px dashed hsl(var(--border));
  border-radius: var(--radius-md);
  padding: 48px 24px;
  text-align: center;
  color: hsl(var(--text-secondary));
}

/* ---------- CRUD ---------- */

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-head-section {
  margin-top: 32px;
}

.page-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.related-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.related-link {
  height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  background: #eef1f6;
  color: hsl(var(--text-secondary));
  font-size: 13px;
  font-weight: 500;
}

.related-link:hover {
  background: #e2e6ee;
  color: hsl(var(--foreground));
}

.btn-sm {
  height: 32px;
  padding: 0 12px;
}

.btn-para {
  height: 36px;
  padding: 0 16px;
  border-radius: var(--radius-pill);
  background: #4f7dfa;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.btn-para:hover {
  filter: brightness(1.05);
}

.btn-para svg {
  width: 14px;
  height: 14px;
}

.text-secondary {
  color: hsl(var(--text-secondary));
}

/* ---------- Info callout ---------- */

.info-callout {
  margin-top: 20px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--secondary));
  border-radius: var(--radius-md);
  padding: 16px 20px;
}

.info-callout-title {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: hsl(var(--foreground));
}

.info-callout ul {
  margin: 0;
  padding-left: 18px;
  color: hsl(var(--text-secondary));
  font-size: 13px;
  line-height: 1.6;
}

/* ---------- Accordion ---------- */

.accordion-card {
  margin-top: 24px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.accordion-head {
  display: grid;
  grid-template-columns: 28px 2.2fr 2fr 1.6fr auto;
  gap: 16px;
  padding: 14px 24px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: hsl(var(--text-tertiary));
  border-bottom: 1px solid hsl(var(--border));
}

.accordion-row {
  border-bottom: 1px solid hsl(var(--border));
}

.accordion-row:last-child {
  border-bottom: none;
}

.accordion-summary {
  display: grid;
  grid-template-columns: auto 2.2fr 2fr 1.6fr auto;
  align-items: center;
  gap: 16px;
  padding: 18px 24px;
  cursor: pointer;
  list-style: none;
}

.accordion-summary::-webkit-details-marker {
  display: none;
}

.accordion-summary::marker {
  content: '';
}

.accordion-chevron {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: hsl(var(--secondary));
  color: hsl(var(--text-secondary));
}

.accordion-chevron svg {
  width: 14px;
  height: 14px;
  transition: transform 0.15s ease;
}

.accordion-row[open] .accordion-chevron svg {
  transform: rotate(180deg);
}

.accordion-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
  color: hsl(var(--text-secondary));
}

.accordion-col-shift {
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

.shift-avatar {
  display: inline-flex;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.12);
  color: #4f46e5;
  font-weight: 600;
}

.shift-name {
  display: block;
  color: hsl(var(--foreground));
  font-weight: 600;
}

.shift-id {
  display: block;
  font-size: 12px;
  color: hsl(var(--text-tertiary));
}

.para-count {
  color: #16a34a;
  font-weight: 500;
}

.para-preview {
  font-size: 12px;
  color: hsl(var(--text-tertiary));
}

.accordion-col-action {
  justify-content: center;
}

.accordion-body {
  padding: 0 24px 24px;
}

.accordion-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.info-card {
  border: 1px solid hsl(var(--border));
  background: hsl(var(--secondary));
  border-radius: var(--radius-md);
  padding: 16px;
}

.info-card-label {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: hsl(var(--text-tertiary));
}

.info-card-title {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 600;
  color: hsl(var(--foreground));
}

.info-card-text {
  margin: 0;
  font-size: 13px;
  color: hsl(var(--text-secondary));
}

.info-card .para-preview {
  color: #16a34a;
  font-size: 13px;
  margin-bottom: 12px;
}

.info-card .btn {
  margin-top: 4px;
}

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

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.badge-morning {
  background: rgba(6, 182, 212, 0.12);
  color: #0e7490;
}

.badge-afternoon {
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
}

.badge-evening {
  background: rgba(139, 92, 246, 0.12);
  color: #6d28d9;
}

/* ---------- Modal extras ---------- */

.modal-subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  color: hsl(var(--text-secondary));
}

.modal-body-head {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}

.table-card {
  margin-top: 24px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 480px;
}

.data-table th {
  text-align: left;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: #5b64ff;
  padding: 0 16px;
  height: 48px;
  border-bottom: none;
}

.data-table thead th:first-child {
  border-top-left-radius: var(--radius-md);
}

.data-table thead th:last-child {
  border-top-right-radius: var(--radius-md);
}

.data-table td {
  padding: 0 16px;
  height: 68px;
  border-bottom: 1px solid hsl(var(--border));
  font-size: 14px;
}

.data-table tbody tr:nth-child(even) {
  background: hsl(var(--secondary) / 0.6);
}

.data-table tbody tr:hover {
  background: #eef2f8;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table th.col-actions {
  text-align: center;
}

.col-actions {
  white-space: nowrap;
  text-align: center;
}

.col-index {
  width: 1%;
  white-space: nowrap;
  text-align: center;
  color: hsl(var(--text-tertiary));
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: hsl(var(--text-secondary));
  margin: 0 4px;
  cursor: pointer;
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

.icon-btn:hover {
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
}

.icon-btn-danger:hover {
  background: hsl(var(--destructive) / 0.12);
  color: hsl(var(--destructive));
}

.empty-row {
  text-align: center;
  color: hsl(var(--text-tertiary));
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
  font-size: 13px;
  color: hsl(var(--text-secondary));
}

.pagination a {
  color: hsl(var(--accent));
  font-weight: 500;
}

.crud-form {
  margin-top: 24px;
  max-width: 560px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-card);
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-row label {
  font-size: 13px;
  font-weight: 500;
  color: hsl(var(--text-secondary));
}

.input-field,
.input-select {
  height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
  padding: 0 14px;
  font-size: 14px;
  font-family: inherit;
}

.input-field:focus,
.input-select:focus {
  outline: none;
  border-color: hsl(var(--accent));
}

textarea.input-field {
  height: auto;
  min-height: 88px;
  padding: 10px 14px;
  resize: vertical;
}

.field-error {
  margin: 0;
  font-size: 12px;
  color: hsl(var(--destructive));
}

.form-errors {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: hsl(var(--destructive) / 0.08);
}

.form-errors .field-error {
  font-size: 13px;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.delete-confirm-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

/* ---------- Modal ---------- */

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
}

.modal-box {
  position: relative;
  z-index: 1;
  width: min(720px, 94vw);
  max-height: 88vh;
  overflow-y: auto;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-popover);
}

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

.modal-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: hsl(var(--text-secondary));
  cursor: pointer;
}

.modal-close svg {
  width: 18px;
  height: 18px;
}

.modal-close:hover {
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
}

.modal-form {
  margin-top: 0;
  max-width: none;
  border: none;
  background: none;
  padding: 0;
  box-shadow: none;
}

.modal-body p {
  color: hsl(var(--text-secondary));
  margin: 0;
}

/* ---------- Timetable / chessboard ---------- */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
  margin-top: 24px;
  padding: 20px 24px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 170px;
}

.filter-field label {
  font-size: 13px;
  font-weight: 500;
  color: hsl(var(--text-secondary));
}

.filter-submit {
  min-width: 0;
}

.legend {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  background: #eef1f6;
  font-size: 13px;
  font-weight: 500;
  color: hsl(var(--text-secondary));
}

.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
}

.legend-dot-free {
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

.legend-dot-busy {
  background: #ef4444;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}

.placeholder-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 12px;
  color: hsl(var(--text-tertiary));
}

.chessboard {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.floor-row {
  display: flex;
  align-items: stretch;
  gap: 16px;
}

.floor-label {
  flex: 0 0 84px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: var(--radius-md);
  background: hsl(var(--secondary));
  border: 1px solid hsl(var(--border));
}

.floor-number {
  font-family: "JetBrains Mono", "SF Mono", monospace;
  font-size: 24px;
  font-weight: 600;
  color: hsl(var(--foreground));
  line-height: 1;
}

.floor-suffix {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: hsl(var(--text-tertiary));
}

.floor-rooms {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 12px;
  padding: 4px 0;
}

.room-cell {
  position: relative;
  width: 148px;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  border: 1px solid hsl(var(--border));
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.room-cell:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
  z-index: 5;
}

.room-cell-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
  color: hsl(var(--text-tertiary));
}

.room-cell-header svg {
  width: 16px;
  height: 16px;
}

.room-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.room-free {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.3);
}

.room-free .room-status-dot {
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

.room-busy {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
}

.room-busy .room-status-dot {
  background: #ef4444;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}

.room-name {
  font-weight: 600;
  font-size: 15px;
}

.room-size {
  font-size: 12px;
  color: hsl(var(--text-secondary));
}

.room-occupancy {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.room-occupancy-bar {
  flex: 1;
  height: 6px;
  border-radius: var(--radius-pill);
  background: #ef4444;
  overflow: hidden;
}

.room-occupancy-fill {
  display: block;
  height: 100%;
  background: #22c55e;
  border-radius: var(--radius-pill);
}

.room-occupancy-label {
  font-size: 11px;
  font-weight: 600;
  color: hsl(var(--text-secondary));
  white-space: nowrap;
}

.room-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 12px);
  transform: translateX(-50%) translateY(4px);
  min-width: 200px;
  background: hsl(222 47% 14%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: var(--shadow-popover);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 20;
}

.room-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: hsl(222 47% 14%);
}

.room-tooltip-title {
  font-weight: 600;
  color: #fff !important;
  padding-bottom: 6px;
  margin-bottom: 6px !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.room-tooltip p {
  margin: 0 0 4px;
  font-size: 12px;
  color: #fff;
}

.room-tooltip p:last-child {
  margin-bottom: 0;
}

.room-tooltip strong {
  color: rgba(255, 255, 255, 0.65);
  font-weight: 500;
  margin-right: 4px;
}

.room-cell:hover .room-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 640px) {
  .floor-row {
    flex-direction: column;
  }

  .floor-label {
    flex-direction: row;
    justify-content: center;
    gap: 8px;
    padding: 8px;
  }
}

a.room-cell {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

/* ---------- Tabs (buildings / weekdays) ---------- */

.building-tabs,
.weekday-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}

.building-tab,
.weekday-tab {
  height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 0 18px;
  border-radius: var(--radius-pill);
  background: #eef1f6;
  color: hsl(var(--text-secondary));
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
}

.building-tab:hover,
.weekday-tab:hover {
  background: #e2e6ee;
  color: hsl(var(--foreground));
}

.building-tab.active,
.weekday-tab.active {
  background: #5b64ff;
  color: #fff;
  border-color: transparent;
}

/* ---------- Room day timeline ---------- */

.timeline-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.timeline-zoom-hint {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  color: hsl(var(--text-secondary));
  font-size: 12px;
}

.timeline-zoom-hint svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: hsl(var(--accent));
}

.day-timeline {
  margin-top: 12px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 20px 24px;
  max-height: 70vh;
  overflow-y: auto;
}

.timeline-columns-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  background: hsl(var(--card));
  padding-bottom: 12px;
  margin-bottom: 10px;
  border-bottom: 1px solid hsl(var(--border));
}

.timeline-labels-head {
  flex: 0 0 56px;
}

.timeline-day-head {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: hsl(var(--text-secondary));
}

.timeline-day-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 6px;
  color: hsl(var(--text-tertiary));
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.timeline-day-head:hover .timeline-day-add {
  opacity: 1;
}

.timeline-day-add:hover {
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
}

.timeline-day-head-today {
  display: inline-flex;
  margin: 0 auto;
  color: hsl(var(--foreground));
}

.timeline-day-head-today::after {
  content: '';
  display: block;
  width: 20px;
  height: 3px;
  margin: 6px auto 0;
  border-radius: var(--radius-pill);
  background: #5b64ff;
}

.timeline-body {
  display: flex;
}

.timeline-labels {
  position: relative;
  flex: 0 0 56px;
}

.timeline-label {
  position: absolute;
  left: 0;
  right: 12px;
  transform: translateY(-50%);
  font-size: 11px;
  color: hsl(var(--text-tertiary));
  font-family: "JetBrains Mono", "SF Mono", monospace;
  transition: top 0.12s ease;
}

.timeline-label-hour {
  color: hsl(var(--text-secondary));
  font-weight: 600;
}

.timeline-track {
  position: relative;
  flex: 1;
  border-left: 1px solid hsl(var(--border));
  transition: background-color 0.15s ease;
}

.timeline-track-today {
  background: rgba(91, 100, 255, 0.05);
}

.timeline-gridline {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: hsl(var(--border));
  transition: top 0.12s ease;
}

.timeline-gridline-hour {
  background: hsl(var(--text-tertiary) / 0.4);
}

.timeline-lesson {
  position: absolute;
  left: 6px;
  right: 6px;
  overflow: hidden;
  display: flex;
  align-items: stretch;
  gap: 8px;
  border-radius: var(--radius-sm);
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.25);
  box-shadow: 0 4px 14px hsl(222 35% 25% / 0.1);
  transition: top 0.12s ease, height 0.12s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.timeline-lesson:hover {
  transform: translateY(-1px) scale(1.01);
  box-shadow: 0 8px 20px hsl(222 35% 25% / 0.16);
  z-index: 3;
}

.timeline-lesson-accent {
  flex: 0 0 3px;
  border-radius: var(--radius-pill);
  background: #818cf8;
}

.timeline-lesson-body {
  flex: 1;
  min-width: 0;
  padding: 6px 8px 6px 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.timeline-lesson-time {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  color: #4338ca;
  font-family: "JetBrains Mono", "SF Mono", monospace;
}

.timeline-lesson-subject {
  margin: 2px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: hsl(var(--foreground));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timeline-lesson-meta {
  margin: 2px 0 0;
  font-size: 11px;
  color: hsl(var(--text-secondary));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timeline-lesson-actions {
  position: absolute;
  top: 2px;
  right: 2px;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.timeline-lesson:hover .timeline-lesson-actions {
  opacity: 1;
}

.icon-btn-sm {
  width: 24px;
  height: 24px;
  margin: 0;
  background: hsl(var(--card) / 0.9);
  backdrop-filter: blur(2px);
}

.icon-btn-sm svg {
  width: 13px;
  height: 13px;
}

/* ---------- Month calendar ---------- */

.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 24px;
}

.calendar-month-label {
  min-width: 160px;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  color: hsl(var(--foreground));
}

.month-calendar {
  margin-top: 16px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.month-calendar-head {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: #5b64ff;
}

.month-calendar-head span {
  padding: 10px 0;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

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

.month-calendar-cell {
  position: relative;
  min-height: 96px;
  padding: 8px;
  border-right: 1px solid hsl(var(--border));
  border-bottom: 1px solid hsl(var(--border));
}

.month-calendar-cell:nth-child(7n) {
  border-right: none;
}

.month-calendar-cell-muted {
  background: hsl(var(--secondary) / 0.4);
  color: hsl(var(--text-tertiary));
}

.month-calendar-cell-today .month-calendar-date {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-pill);
  background: #5b64ff;
  color: #fff;
}

.month-calendar-cell-active {
  background: rgba(99, 102, 241, 0.06);
}

.month-calendar-date {
  font-size: 13px;
  font-weight: 600;
  color: hsl(var(--text-secondary));
}

.month-calendar-lesson {
  margin-top: 6px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.25);
}

.month-calendar-lesson-time {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  color: #4338ca;
  font-family: "JetBrains Mono", "SF Mono", monospace;
}

.month-calendar-lesson-room {
  margin: 2px 0 0;
  font-size: 11px;
  color: hsl(var(--text-secondary));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.month-calendar-lesson-actions {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.month-calendar-cell:hover .month-calendar-lesson-actions {
  opacity: 1;
}
