:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #d1d5db;
  --primary: #1f4f82;
  --primary-hover: #173d65;
  --active: #2563eb;
  --active-hover: #1d4ed8;
  --danger: #b91c1c;
  --shadow: 0 12px 30px rgba(17, 24, 39, 0.08);
  --soft: #f9fafb;
  --soft-blue: #eff6ff;
  --soft-green: #ecfdf5;
  --soft-orange: #fff3df;
  --orange-border: #f59e0b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--bg);
}

header {
  padding: 24px 32px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

header h1 {
  margin: 0 0 6px;
  font-size: 1.55rem;
  font-weight: 700;
}

header p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.app-menu {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.app-menu a,
.button,
button {
  border: 0;
  border-radius: 9px;
  padding: 10px 14px;
  font-size: 0.93rem;
  font-weight: 700;
  cursor: pointer;
  background: var(--primary);
  color: white;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  line-height: 1.1;
}

.app-menu a:hover,
.button:hover,
button:hover { background: var(--primary-hover); }

.app-menu a.secondary,
.button.secondary,
button.secondary {
  background: #e5e7eb;
  color: #111827;
}

.app-menu a.secondary:hover,
.button.secondary:hover,
button.secondary:hover { background: #d1d5db; }

.app-menu a.active {
  background: var(--active);
  color: white;
}

.app-menu a.active:hover { background: var(--active-hover); }

.app-menu a.hidden { display: none; }

.auth-user-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
  padding: 10px 18px;
  background: #111827;
  color: #f9fafb;
  font: 14px Arial, Helvetica, sans-serif;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.auth-user-bar a { color: #f9fafb; }

.auth-user-bar button,
.auth-user-bar select {
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.86rem;
}

.auth-user-bar button {
  border: 1px solid #9ca3af;
  background: transparent;
  color: #f9fafb;
}

.auth-user-bar select {
  border: 1px solid #9ca3af;
  background: #1f2937;
  color: #f9fafb;
}

main {
  max-width: 1480px;
  margin: 22px auto;
  padding: 0 20px 48px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 18px;
}

.field label {
  display: block;
  color: #374151;
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

select,
input[type="search"],
input[type="text"],
input[type="password"],
input[type="number"],
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 0.95rem;
  background: white;
}

.status,
.empty {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--soft);
  color: var(--muted);
  line-height: 1.45;
  margin: 10px 0;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 12px 0 0;
}

.metric {
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.metric .label {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 800;
  margin-bottom: 4px;
}

.metric .value {
  font-size: 1.24rem;
  font-weight: 800;
  color: var(--text);
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.section-title h2,
.section-title h3 { margin: 0; }

.small-muted {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  min-width: 980px;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  vertical-align: top;
  font-size: 0.92rem;
}

th {
  background: #f3f4f6;
  color: #374151;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

tbody tr { transition: background 0.12s ease; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover,
tbody tr.selected { background: #fbfdff; }
tbody tr.selected { outline: 2px solid rgba(31, 79, 130, 0.18); outline-offset: -2px; }

.hours {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.chip {
  border: 1px solid #dbeafe;
  background: var(--soft-blue);
  color: #1e3a8a;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.chip.green { border-color: #bbf7d0; background: var(--soft-green); color: #166534; }
.chip.orange { border-color: #fed7aa; background: var(--soft-orange); color: #9a3412; }

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

.detail-header h2 { margin: 0 0 4px; }

.ue-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  margin: 14px 0;
  overflow: hidden;
  background: white;
}

.ue-card-header {
  padding: 14px;
  background: #fbfdff;
  border-bottom: 1px solid var(--border);
}

.ue-code { color: var(--primary); font-weight: 800; margin-bottom: 4px; letter-spacing: 0.01em; }
.ue-title,
.teacher-name { font-weight: 800; color: var(--text); }

.formula {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  border-radius: 10px;
  padding: 10px 12px;
  line-height: 1.45;
  margin-top: 10px;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: white;
}

.segmented button {
  border-radius: 0;
  background: white;
  color: #111827;
  border-right: 1px solid var(--border);
}

.segmented button:last-child { border-right: 0; }
.segmented button.active { background: var(--active); color: white; }
.segmented button:disabled { opacity: 0.55; cursor: not-allowed; }

@media (max-width: 900px) {
  header { padding: 20px; }
  main { padding: 0 12px 36px; }
  .detail-header { flex-direction: column; }
  .button, button { width: 100%; }
  .auth-user-bar { flex-wrap: wrap; justify-content: flex-start; }
}

/* UE detail responsive density helpers. These are mirrored in ues.html for immediate page-level priority. */
body.ue-page main {
  width: 100%;
  max-width: none;
}
body.ue-page .table-wrap {
  overflow-x: visible;
}
body.ue-page table {
  min-width: 0;
  table-layout: fixed;
}
