:root {
  /* IPU Brand Refresh (Aug 2021) */
  --ipu-orange: #ff8204;
  --ipu-orange-dark: #e67300;
  --ipu-gray-dark: #555960;
  --ipu-gray-mid: #989aa5;
  --ipu-gray-light: #bbbdc7;
  --ipu-culture: #8bb7c9;
  --ipu-purple: #8e3a87;
  --ipu-white: #ffffff;
  --ipu-black: #000000;

  --bg: #f0f1f4;
  --card: var(--ipu-white);
  --surface: #f7f8fa;
  --text: var(--ipu-gray-dark);
  --muted: var(--ipu-gray-mid);
  --border: var(--ipu-gray-light);
  --accent: var(--ipu-orange);
  --accent-dark: var(--ipu-orange-dark);
  --accent-soft: rgba(255, 130, 4, 0.08);
  --accent-glow: rgba(255, 130, 4, 0.28);
  --danger: var(--ipu-purple);
  --success: #2d8a4e;
  --warning: #b8860b;
  --header-bg: var(--ipu-gray-dark);
  --header-gradient: linear-gradient(128deg, #ff8204 0%, #8e3a87 52%, #e67300 100%);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(85, 89, 96, 0.06);
  --shadow-md: 0 12px 40px rgba(85, 89, 96, 0.12), 0 2px 8px rgba(85, 89, 96, 0.06);
  --shadow-accent: 0 8px 24px var(--accent-glow);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  --active: var(--success);
  --locked: var(--warning);
  --deleted: #b91c1c;
}

html {
  scroll-behavior: smooth;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background:
    radial-gradient(ellipse 80% 50% at 100% -10%, rgba(255, 130, 4, 0.12), transparent 55%),
    radial-gradient(ellipse 60% 40% at 0% 100%, rgba(139, 183, 201, 0.14), transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  font-weight: 400;
  min-height: 100vh;
  padding: clamp(12px, 3vw, 28px);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  border: 1px solid rgba(187, 189, 199, 0.45);
}

.header {
  position: relative;
  background: var(--header-bg);
  color: var(--ipu-white);
  padding: 20px clamp(20px, 4vw, 36px);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}

.header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--header-gradient);
}

.header-content {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-home-link {
  color: inherit;
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}

.header-home-link:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.header-home-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.header-logo {
  display: block;
  height: 52px;
  width: auto;
  flex-shrink: 0;
}

.header h1 {
  grid-column: 2;
  justify-self: center;
  margin: 0;
  font-size: clamp(1.5rem, 3.5vw, 1.85rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ipu-white);
  line-height: 1.2;
}

.header h1 .header-home-link {
  color: var(--ipu-white);
}

.brand-ipu {
  color: var(--accent);
  font-weight: 600;
}

.header-right {
  grid-column: 3;
  justify-self: end;
}

.header-user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-size: 0.8rem;
  line-height: 1.3;
}

.header-user-name {
  color: rgba(255, 255, 255, 0.92);
  font-weight: 500;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

a.header-logout {
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.75rem;
  font-weight: 500;
}

a.header-logout:hover {
  color: var(--ipu-white);
}

.login-panel {
  max-width: 28rem;
  margin: 0 auto;
  text-align: center;
}

.login-panel h2 {
  margin-bottom: 0.5rem;
}

.login-separator {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 1.5rem 0 1.25rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.login-separator::before,
.login-separator::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.login-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 16rem;
  padding: 12px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.login-btn:hover {
  border-color: rgba(255, 130, 4, 0.45);
  box-shadow: var(--shadow-md);
  color: var(--text);
}

.microsoft-logo {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

main.content {
  padding: clamp(24px, 4vw, 40px) clamp(20px, 4vw, 36px);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: clamp(20px, 3vw, 28px);
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.card:hover {
  border-color: rgba(255, 130, 4, 0.35);
  box-shadow: 0 4px 20px rgba(85, 89, 96, 0.08);
}

h1,
h2,
h3 {
  margin-top: 0;
  color: var(--text);
  font-weight: 600;
  letter-spacing: -0.02em;
}

p.muted,
.lede {
  color: var(--muted);
  margin: 0 0 1.25rem;
  font-size: 0.95rem;
  max-width: 44rem;
}

a:not(.btn):not(.header-home-link) {
  color: var(--accent-dark);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.15s var(--ease);
}

a:not(.btn):not(.header-home-link):hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn,
button[type="submit"] {
  display: inline-block;
  background: var(--header-gradient);
  color: var(--ipu-white);
  border: 0;
  border-radius: 999px;
  padding: 11px 22px;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), filter 0.2s var(--ease);
}

.btn:hover:not(:disabled),
button[type="submit"]:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-accent);
  filter: brightness(1.03);
}

.btn:active,
button[type="submit"]:active {
  transform: translateY(0);
  filter: none;
}

.btn:focus-visible,
button[type="submit"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.htmx-request button[type="submit"] {
  opacity: 0.7;
  cursor: wait;
  transform: none;
  box-shadow: none;
}

form.search {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  margin: 0;
}

label.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1 1 16rem;
}

label.field span {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

input[type="text"] {
  font: inherit;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-width: 12rem;
  background: var(--ipu-white);
  color: var(--text);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

input[type="text"]:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}

#results {
  margin-top: 0.25rem;
}

.meta {
  margin: 0 0 0.85rem;
  font-size: 0.9375rem;
  color: var(--muted);
}

.meta strong {
  color: var(--text);
}

.notice {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  margin-bottom: 16px;
  border: 1px solid transparent;
  line-height: 1.5;
}

.notice.error {
  background: rgba(142, 58, 135, 0.08);
  color: #5c2858;
  border-color: rgba(142, 58, 135, 0.25);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9375rem;
}

th,
td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td.name-cell {
  white-space: normal;
  min-width: 10rem;
}

th {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--surface);
  position: sticky;
  top: 0;
}

th:first-child {
  border-radius: var(--radius-sm) 0 0 0;
}

th:last-child {
  border-radius: 0 var(--radius-sm) 0 0;
}

tbody tr {
  transition: background-color 0.15s var(--ease);
}

tbody tr:hover {
  background-color: var(--accent-soft);
}

tbody tr:last-child td {
  border-bottom: 0;
}

.status-pill,
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: capitalize;
}

.status-pill.active,
.badge.active {
  background: rgba(45, 138, 78, 0.1);
  color: var(--success);
  border: 1px solid rgba(45, 138, 78, 0.25);
}

.status-pill.locked,
.badge.locked {
  background: rgba(184, 134, 11, 0.12);
  color: var(--warning);
  border: 1px solid rgba(184, 134, 11, 0.28);
}

.status-pill.deleted,
.badge.deleted {
  background: rgba(142, 58, 135, 0.1);
  color: var(--danger);
  border: 1px solid rgba(142, 58, 135, 0.25);
}

.campus-user {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

mark.hl {
  background: #fde68a;
  color: var(--text);
  padding: 0 0.12em;
  border-radius: 2px;
  font-weight: 600;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

a mark.hl,
.status-pill mark.hl,
code mark.hl {
  color: var(--text);
  font-weight: 700;
}

code {
  background: var(--surface);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.85em;
  border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

footer {
  padding: clamp(20px, 3vw, 28px) clamp(20px, 4vw, 36px);
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.85rem;
  color: var(--muted);
}

footer dl {
  margin: 0;
}

footer dt {
  font-weight: 600;
  display: inline;
  color: var(--text);
}

footer dd {
  display: inline;
  margin: 0 1rem 0 0.35rem;
}

footer .status {
  margin-top: 0.75rem;
  font-size: 0.8rem;
}

.htmx-indicator {
  display: none;
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.75rem;
}

.htmx-request .htmx-indicator {
  display: block;
}

@media (max-width: 768px) {
  .header {
    grid-template-columns: 1fr;
    text-align: center;
    padding: 18px 16px 20px;
  }

  .header-content {
    justify-self: center;
  }

  .header h1 {
    grid-column: 1;
  }

  .header-right {
    display: none;
  }

  form.search {
    flex-direction: column;
    align-items: stretch;
  }
}
