:root {
  --bg: #f4f5f7;
  --surface: #fff;
  --text: #1a1d24;
  --text-muted: #5c6370;
  --border: #e2e5eb;
  --aub: #b0102f;
  --aub-dark: #8c0c26;
  --accent: #0f6fde;
  --shadow: 0 1px 2px rgba(26, 29, 36, 0.06), 0 4px 12px rgba(26, 29, 36, 0.06);
  --radius: 12px;
  --font: "DM Sans", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}

/* Boot / loading (matches public shell text from my.aub.ac.uk) */
.boot {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

.boot.done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.boot-inner {
  text-align: center;
  max-width: 280px;
  padding: 2rem;
}

.boot-brand {
  margin: 0 0 1.25rem;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.boot-status {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.boot-bar {
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.boot-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--aub), #e85a6e);
  transition: width 0.12s linear;
}

.boot-pct {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

/* App shell */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.65rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1.75rem;
  flex-wrap: wrap;
}

.logo-link {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  text-decoration: none;
  color: inherit;
}

.logo-mark {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--aub);
}

.logo-sub {
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.topnav {
  display: flex;
  gap: 0.25rem;
}

.topnav-link {
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
}

.topnav-link:hover {
  color: var(--text);
  background: var(--bg);
}

.topnav-link.is-active {
  color: var(--aub);
  background: rgba(176, 16, 47, 0.08);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-width: 200px;
}

.search-icon {
  flex-shrink: 0;
  color: var(--text-muted);
}

.search-input {
  border: none;
  background: transparent;
  font: inherit;
  color: var(--text);
  width: 100%;
  min-width: 0;
}

.search-input:focus {
  outline: none;
}

.search-input::placeholder {
  color: #9aa0a8;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--bg);
  color: var(--text);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.6rem 0.25rem 0.25rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font: inherit;
  cursor: pointer;
}

.user-chip:hover {
  border-color: #cfd3dc;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--aub), #e85a6e);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

.main {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 3rem;
}

.main-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.75rem;
}

.greeting {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subgreet {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.inline-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.inline-link:hover {
  text-decoration: underline;
}

.main-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn {
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
}

.btn-primary {
  background: var(--aub);
  color: #fff;
  border-color: var(--aub);
}

.btn-primary:hover {
  background: var(--aub-dark);
  border-color: var(--aub-dark);
}

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--bg);
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

@media (min-width: 640px) {
  .tiles {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-height: 132px;
  padding: 1rem 1rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  border-left: 4px solid var(--tile-accent, var(--border));
  position: relative;
  overflow: hidden;
}

.tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(26, 29, 36, 0.1);
  border-color: #d5d9e0;
}

.tile:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.tile-icon-wrap {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--tile-accent) 14%, white);
  color: var(--tile-accent);
  margin-bottom: 0.75rem;
}

.tile-icon-wrap svg {
  width: 22px;
  height: 22px;
}

.tile-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.tile-desc {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.tile[data-hidden="true"] {
  display: none;
}

.site-footer {
  padding: 1rem 1.5rem 1.5rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.site-footer a {
  color: var(--text-muted);
}

.site-footer a:hover {
  color: var(--accent);
}

/* Timetable / calendar (local mock, styled with dashboard tokens) */
.back-to-dash {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.65rem 0.45rem 0.35rem;
  margin-right: 0.25rem;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
}

.back-to-dash:hover {
  color: var(--text);
  background: var(--bg);
}

.cal-page {
  max-width: 1280px;
}

.cal-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.cal-page-title {
  font-size: 1.5rem;
}

.cal-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.cal-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.25rem;
  margin-bottom: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.cal-legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c);
  margin-right: 0.35rem;
  vertical-align: middle;
}

.cal-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.cal-shell {
  --cal-body-h: 540px;
  --cal-hour-slots: 8;
  display: flex;
  min-width: 720px;
}

.cal-time-col {
  flex-shrink: 0;
  width: 3.25rem;
  border-right: 1px solid var(--border);
}

.cal-time-col-head {
  height: 48px;
  border-bottom: 1px solid var(--border);
}

.cal-time-slots {
  position: relative;
  height: var(--cal-body-h);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

/* Hour labels at i/8 of column height — matches .cal-day-body hour lines (8 bands, 09:00–17:00) */
.cal-time-slots .cal-time-label {
  position: absolute;
  right: 0.4rem;
  left: 0;
  margin: 0;
  padding: 0;
  line-height: 1;
  text-align: right;
  white-space: nowrap;
}

.cal-time-slots .cal-time-label:nth-child(1) {
  top: 0;
  transform: translateY(0);
}

.cal-time-slots .cal-time-label:nth-child(2) {
  top: calc(100% * 1 / var(--cal-hour-slots));
  transform: translateY(-50%);
}

.cal-time-slots .cal-time-label:nth-child(3) {
  top: calc(100% * 2 / var(--cal-hour-slots));
  transform: translateY(-50%);
}

.cal-time-slots .cal-time-label:nth-child(4) {
  top: calc(100% * 3 / var(--cal-hour-slots));
  transform: translateY(-50%);
}

.cal-time-slots .cal-time-label:nth-child(5) {
  top: calc(100% * 4 / var(--cal-hour-slots));
  transform: translateY(-50%);
}

.cal-time-slots .cal-time-label:nth-child(6) {
  top: calc(100% * 5 / var(--cal-hour-slots));
  transform: translateY(-50%);
}

.cal-time-slots .cal-time-label:nth-child(7) {
  top: calc(100% * 6 / var(--cal-hour-slots));
  transform: translateY(-50%);
}

.cal-time-slots .cal-time-label:nth-child(8) {
  top: calc(100% * 7 / var(--cal-hour-slots));
  transform: translateY(-50%);
}

.cal-time-slots .cal-time-label:nth-child(9) {
  top: 100%;
  transform: translateY(-100%);
}

.cal-days {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
}

.cal-day {
  border-right: 1px solid var(--border);
  min-width: 0;
}

.cal-day:last-child {
  border-right: none;
}

.cal-day-head {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text);
  border-bottom: 2px solid #5c2d91;
  background: color-mix(in srgb, #5c2d91 6%, white);
}

.cal-day-body {
  position: relative;
  height: var(--cal-body-h);
  background-image: repeating-linear-gradient(
    to bottom,
    var(--border) 0,
    var(--border) 1px,
    transparent 1px,
    transparent calc(var(--cal-body-h) / 16)
  );
  background-size: 100% var(--cal-body-h);
}

.cal-event {
  position: absolute;
  left: 4px;
  right: 4px;
  top: calc(var(--t) * 1%);
  height: calc(var(--h) * 1%);
  min-height: 36px;
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  background: color-mix(in srgb, var(--c) 18%, white);
  border-left: 3px solid var(--c);
  box-shadow: 0 1px 3px rgba(26, 29, 36, 0.08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.cal-event-time {
  font-size: 0.65rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.cal-event-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
}

.cal-event-meta {
  font-size: 0.68rem;
  color: var(--text-muted);
  line-height: 1.2;
}
