/* Layout */
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  background: var(--bg-inverse); color: var(--fg-inverse);
}
.topbar .brand {
  font-weight: var(--fw-extra); letter-spacing: var(--ls-wide);
  color: var(--accent); text-decoration: none; font-size: var(--t-h5);
}
.topbar nav { display: flex; gap: var(--space-4); margin-left: auto; }
.topbar nav a {
  color: var(--cream-100); text-decoration: none; font-size: var(--t-small);
  font-weight: var(--fw-medium); opacity: .8;
}
.topbar nav a:hover, .topbar nav a.active { opacity: 1; color: var(--accent); }
.page { padding: var(--space-5); max-width: 1400px; margin: 0 auto; }

/* Controls */
.btn {
  font: inherit; font-weight: var(--fw-semibold); font-size: var(--t-small);
  border: 1px solid var(--border-strong); background: var(--bg-elevated);
  color: var(--fg); border-radius: var(--r-md); padding: 8px 14px; cursor: pointer;
  transition: all var(--t-fast) var(--ease-out);
}
.btn:hover { border-color: var(--navy-400); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn-accent:hover { background: var(--accent-hover); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
input, select {
  font: inherit; font-size: var(--t-small); padding: 7px 10px;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--bg-elevated); color: var(--fg);
}
input:focus, select:focus { outline: none; box-shadow: var(--shadow-focus); }
label { font-size: var(--t-caption); color: var(--fg-muted); display: block; margin-bottom: 2px; }
.row { display: flex; gap: var(--space-3); align-items: end; flex-wrap: wrap; }

/* Cards / tables */
.card {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--space-4); box-shadow: var(--shadow-xs);
}
table.list { width: 100%; border-collapse: collapse; font-size: var(--t-small); }
table.list th {
  text-align: left; font-size: var(--t-eyebrow); letter-spacing: var(--ls-eyebrow);
  text-transform: uppercase; color: var(--fg-subtle);
  padding: 8px; border-bottom: 1px solid var(--border-strong);
}
table.list td { padding: 8px; border-bottom: 1px solid var(--border); }

/* Schedule grid */
.grid-wrap { overflow-x: auto; }
.sgrid { display: grid; gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
.sgrid .head {
  background: var(--navy-700); color: var(--cream-100); padding: 8px;
  font-size: var(--t-small); font-weight: var(--fw-semibold); text-align: center;
}
.sgrid .timecell {
  background: var(--cream-100); color: var(--fg-subtle);
  font-size: var(--t-caption); padding: 2px 6px; text-align: right;
}
.sgrid .col { position: relative; background: var(--bg-elevated); }
.sgrid .col .slotline { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--slate-100); }
.lesson {
  position: absolute; left: 3px; right: 3px; border-radius: var(--r-sm);
  padding: 4px 6px; font-size: var(--t-caption); line-height: 1.25;
  color: var(--navy-800); cursor: pointer; overflow: hidden;
  box-shadow: var(--shadow-xs); border-left: 4px solid rgba(0,0,0,.25);
}
.lesson .g { font-weight: var(--fw-bold); }
.lesson.cancelled { opacity: .45; text-decoration: line-through; }
.lesson.detached { outline: 2px dotted var(--warning); }
.lesson.projected {
  opacity: .55; box-shadow: none; cursor: default;
  border: 1px dashed rgba(16, 28, 50, .45); border-left: 4px dashed rgba(16, 28, 50, .45);
}

/* Modal */
.modal-back {
  position: fixed; inset: 0; background: rgba(16,28,50,.5);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  background: var(--bg-elevated); border-radius: var(--r-xl);
  padding: var(--space-6); width: min(440px, 92vw); box-shadow: var(--shadow-lg);
}
.modal h3 { margin-bottom: var(--space-3); }
.err { color: var(--danger); font-size: var(--t-small); margin-top: var(--space-2); }
.warn { color: var(--warning); font-size: var(--t-small); margin-top: var(--space-2); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  background: var(--lime-100); color: var(--navy-800); border-radius: var(--r-pill);
  padding: 2px 10px; font-size: var(--t-caption); font-weight: var(--fw-semibold);
}

/* Month calendar */
.month {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px;
  background: var(--border); border: 1px solid var(--border);
  border-radius: var(--r-md); overflow: hidden;
}
.month-head {
  background: var(--navy-700); color: var(--cream-100); text-align: center;
  padding: 6px; font-size: var(--t-caption); font-weight: var(--fw-semibold);
}
.month-cell {
  background: var(--bg-elevated); min-height: 98px; padding: 4px 5px;
  cursor: pointer; transition: background var(--t-fast) var(--ease-out);
}
.month-cell:hover { background: var(--lime-100); }
.month-cell.out { background: var(--cream-100); }
.month-cell.out .month-daynum { color: var(--slate-400); }
.month-cell.today { box-shadow: inset 0 0 0 2px var(--accent); }
.month-daynum { font-size: var(--t-caption); font-weight: var(--fw-semibold); text-align: right; color: var(--fg-muted); }
.month-chip {
  display: flex; align-items: center; gap: 4px; font-size: 11px; line-height: 1.45;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.month-chip .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.month-chip .mc-t { overflow: hidden; text-overflow: ellipsis; }
.month-more { font-size: 10px; color: var(--fg-subtle); margin-top: 2px; }

/* Period agenda (horizontal day columns) */
.period-strip { display: flex; gap: 8px; padding-bottom: 8px; }
.period-col {
  flex: 0 0 155px; background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--r-md); overflow: hidden; align-self: flex-start;
}
.period-col.today { border-color: var(--accent); box-shadow: var(--shadow-focus); }
.period-head {
  background: var(--navy-700); color: var(--cream-100); padding: 6px 8px;
  font-size: var(--t-caption); font-weight: var(--fw-semibold); cursor: pointer;
}
.period-empty { color: var(--fg-subtle); text-align: center; padding: 14px 0; font-size: var(--t-caption); }
.period-item { border-left: 4px solid var(--slate-300); padding: 5px 8px; border-bottom: 1px solid var(--border); }
.pi-time { font-weight: var(--fw-bold); font-size: var(--t-caption); }
.pi-g { font-size: var(--t-small); }
.pi-r { font-size: var(--t-caption); color: var(--fg-subtle); }

/* Year heatmap (rooms × days) */
.year { display: flex; flex-direction: column; gap: 2px; width: max-content; }
.year-row { display: flex; gap: 2px; align-items: center; }
.year-label {
  flex: 0 0 96px; position: sticky; left: 0; z-index: 2; background: var(--bg);
  font-size: var(--t-caption); font-weight: var(--fw-semibold);
  padding-right: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.year-cell { flex: 0 0 7px; height: 20px; border-radius: 2px; background: var(--cream-200); }
.year-row .year-cell:not(.head) { cursor: pointer; }
.year-cell.head {
  height: 14px; background: transparent; font-size: 9px; color: var(--fg-subtle);
  overflow: visible; white-space: nowrap;
}
.year-cell.monthstart { box-shadow: inset 1px 0 0 var(--slate-400); }
.year-cell.today { outline: 2px solid var(--navy-700); outline-offset: -1px; }
.year-cell.h0 { background: var(--cream-200); }
.year-cell.h1 { background: var(--lime-100); }
.year-cell.h2 { background: var(--lime-300); }
.year-cell.h3 { background: var(--lime-500); }
.year-cell.h4 { background: var(--lime-700); }
.year-legend { display: flex; align-items: center; gap: 5px; margin-top: 14px; }
.year-legend .year-cell { flex: 0 0 16px; height: 16px; cursor: default; }
