/* ============================================================
   ATLAS PSU - main-style.css
   Genetic Algorithm Faculty Workload System
   Palawan State University · College of Information Technology
   Design language unified with IARMS PSU design system.
   ============================================================ */

/* ============================================================
   0. GOOGLE FONTS IMPORT
   ============================================================ */
/* Self-hosted fonts (assets/fonts, SIL Open Font License; licenses sit next to the files). No request goes to Google. */
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/dm-sans-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/dm-sans-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/dm-sans-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'DM Sans'; font-style: italic; font-weight: 400; font-display: swap; src: url('../fonts/dm-sans-latin-400-italic.woff2') format('woff2'); }

/* ============================================================
   1. CSS DESIGN TOKENS
   Rust Orange / Slate Gray / Off-White - ATLAS PSU brand
   ============================================================ */
:root {

  /* Primary - Rust Orange (ATLAS brand #c0440a) */
  --clr-primary-50:  #fff3ee;
  --clr-primary-100: #ffe3d5;
  --clr-primary-200: #ffc4a3;
  --clr-primary-300: #ff9e6e;
  --clr-primary-400: #e8693a;
  --clr-primary-500: #c0440a;
  --clr-primary-600: #9a3608;
  --clr-primary-700: #762806;
  --clr-primary-800: #531b04;

  /* Accent - warm amber */
  --clr-accent-500: #b45309;
  --clr-accent-100: #fef3c7;

  /* Success / Warning / Danger */
  --clr-success-500: #22c55e;
  --clr-success-100: #dcfce7;
  --clr-warning-500: #f59e0b;
  --clr-warning-100: #fef3c7;
  --clr-danger-500:  #ef4444;
  --clr-danger-100:  #fee2e2;

  /* Slate Gray neutrals */
  --clr-gray-900: #1a130e;

  /* Semantic surface tokens - Off-White base */
  --bg-page:        #f5f2ef;
  --bg-white:       #fffefb;
  --bg-surface:     #fffefb;
  --bg-surface-2:   #f9f6f2;
  --bg-surface-3:   #f0edea;
  --bg-subtle:      #faf7f5;
  --bg-overlay:     rgba(26, 19, 14, 0.45);

  --border-subtle:  #e8e2db;
  --border:         #d4cbc2;
  --border-default: #d4cbc2;
  --border-strong:  #a89e94;

  --text-primary:   #1a130e;
  --text-secondary: #524840;
  --text-muted:     #6e6358;
  --text-inverse:   #fffefb;
  --text-link:      var(--clr-primary-600);

  /* Brand shorthands (ATLAS compat) */

  --nav-bg:         rgba(255, 254, 251, 0.94);
  --nav-border:     rgba(212, 203, 194, 0.7);
  --nav-shadow:     none;

  --card-bg:        #fffefb;

  --input-bg:           #fffefb;
  --input-border:       #d4cbc2;
  --input-focus-border: var(--clr-primary-500);
  --accent-rgb:         192, 68, 10;   /* r, g, b of --clr-primary-500; the department blocks at the end of this file override it */
  --input-focus-ring:   rgba(192, 68, 10, 0.15);

  /* Elevation shadows */
  --shadow-pop: 0 8px 24px rgba(26, 19, 14, 0.14);
  --shadow-lg:  var(--shadow-pop);
  --shadow-xl:  var(--shadow-pop);
  --focus-ring: 0 0 0 3px var(--input-focus-ring);

  /* Text that sits on a solid accent fill, and the chart palette (read by main-script.js) */
  --on-accent: #ffffff;
  --btn-hover: var(--clr-primary-600);   /* hover fill for solid orange buttons (white text) */
  --chart-ink: #1a130e; --chart-tooltip-text: #fffefb; --chart-muted: #6e6358; --chart-grid: #ece6df; --chart-surface: #ffffff;
  --chart-ok: #2a7f86; --chart-warn: #d9922b; --chart-bad: #b4372b;
  --chart-s1: #9a3608; --chart-s2: #2a7f86; --chart-s3: #e8693a; --chart-s4: #5b6b7a; --chart-s5: #d9a066;
  --chart-s6: #7fb0b3; --chart-s7: #6e6358; --chart-s8: #c0440a; --chart-s9: #a7c4c6; --chart-s10: #e9c9a8;

  /* Typography */
  --font-sans:    'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: var(--font-sans);
  --font-mono:    var(--font-sans);
  --text-xs: 0.75rem; --text-sm: 0.8125rem; --text-base: 0.875rem; --text-md: 1rem;
  --text-lg: 1.25rem; --text-xl: 1.5rem; --text-stat: 1.75rem;

  /* Spacing scale: 4, 8, 12, 16, 24, 32, 48 */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;

  /* Border radius (corporate: small) */
  --radius-sm:    6px;
  --radius-md:    8px;
  --radius-lg:    12px;
  --radius-sheet: 16px;
  --radius-xl:    var(--radius-lg);
  --radius-2xl:   var(--radius-lg);
  --radius-full:  9999px;

  /* Transitions */
  --transition-fast: 0.12s ease;
  --transition-base: 0.22s ease;
  --transition-slow: 0.4s ease;

  /* Navbar */
  --nav-h:         3.5rem;
}

/* ============================================================
   2. RESET & BASE
   ============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-page);
  overflow: hidden;
}

img, svg {
  display: block;
  max-width: 100%;
}

button {
  font-family: inherit;
  cursor: pointer;
}

a {
  color: var(--text-link);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--clr-primary-700);
}

ul, ol {
  list-style: none;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

fieldset {
  border: none;
}

hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: var(--space-) 0;
}

/* ============================================================
   3. UTILITY CLASSES
   ============================================================ */

.hidden {
  display: none !important;
}

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

.mt-16 { margin-top: var(--space-4); }
.mb-24 { margin-bottom: var(--space-5); }
.btn-full { width: 100%; }

/* ============================================================
   4. TYPOGRAPHY SCALE
   ============================================================ */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: 600;
  line-height: 1.25;
  color: var(--text-primary);
  letter-spacing: -0.015em;
}

h1 { font-size: var(--text-xl); }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-md); }
h4 { font-size: var(--text-base); }

p {
  color: var(--text-secondary);
  font-size: var(--text-base);
  line-height: 1.65;
}

code, pre {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  background: var(--bg-surface-3);
  border-radius: var(--radius-sm);
}

code {
  padding: 0.125rem var(--space-2);
}

/* Sort arrow (tables) */
.sort-arrow {
  font-size: var(--text-xs);
  opacity: 0.95;
  margin-left: var(--space-1);
}

/* ============================================================
   5. TOP NAVBAR
   ============================================================ */
.top-navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: var(--nav-h);
  background: var(--nav-bg);
  border-bottom: 1px solid var(--nav-border);
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  gap: var(--space-4);
  transition: background var(--transition-slow), border-color var(--transition-slow);
}

/* Nav left / right */
.nav-left {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  min-width: 0;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

/* Brand */
.nav-brand-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
  text-decoration: none;
}

.brand {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--clr-primary-600);
  white-space: nowrap;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}

/* Nav menu */
.nav-menu {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-menu::-webkit-scrollbar { display: none; }

.nav-item {
  padding: 0.3125rem 0.75rem;
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
  cursor: pointer;
  border: none;
  background: none;
  user-select: none;
  font-family: inherit;
}

.nav-item:hover {
  background: var(--bg-surface-3);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--clr-primary-50);
  color: var(--clr-primary-600);
  font-weight: 600;
}

/* lp-nav (index.html) - unified with top-navbar */
.lp-nav {
  left: 0;
  right: 0;
  gap: var(--space-4);
}

.lp-nav-left,
.lp-nav-right {
  display: flex;
  align-items: center;
}

/* Nav search */

/* Profile dropdown */
.nav-item.dropdown {
  position: relative;
  padding: var(--space-1);
  background: none;
  border: none;
}

.profile-pic {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border-default);
  cursor: pointer;
  display: block;
  object-fit: cover;
  transition: border-color var(--transition-fast);
}

.profile-pic:hover {
  border-color: var(--clr-primary-400);
}

.nav-item.dropdown .dropdown-content {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  left: auto;
  min-width: 160px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  padding: var(--space-2);
  z-index: 2000;
  animation: dropdown-in 0.15s ease;
}

@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.nav-item.dropdown.open .dropdown-content { display: block; }

.nav-item.dropdown .dropdown-content div,
.nav-item.dropdown .dropdown-content a {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.75rem;
  font-size: var(--text-base);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), color var(--transition-fast);
  text-decoration: none;
  cursor: pointer;
}

.nav-item.dropdown .dropdown-content div:hover,
.nav-item.dropdown .dropdown-content a:hover {
  background: var(--bg-surface-3);
  color: var(--text-primary);
}

/* ============================================================
   6. PANELS LAYOUT
   ============================================================ */
.panels-wrapper {
  margin-top: var(--nav-h);
  overflow: hidden;
  padding: var(--space-4) var(--space-4) 0;
}

.panels-container {
  height: 100%;
  position: relative;
}

.panel {
  display: none;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: var(--space-6) var(--space-6);
  position: relative;
  animation: panel-fade-in 0.25s ease;
}

@keyframes panel-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.panel.active {
  display: block;
}

/* ============================================================
   7. PAGE HEADER & SECTION HEADINGS
   ============================================================ */
.page-header {
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 2px solid var(--border-subtle);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header > div:first-child,
.page-header > h2:only-child,
.page-header > h2:first-child {
  flex: 1;
  min-width: 0;
}

.page-header h2,
.page-header > div h2 {
  margin-bottom: var(--space-2);
  font-size: var(--text-xl);
}

.page-header p,
.page-header > div p {
  max-width: 680px;
  color: var(--text-secondary);
}

.section-heading {
  margin: var(--space-5) 0 var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  
  
  font-family: var(--font-sans);
}

.section-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--space-6) 0;
}

/* ============================================================
   8. BUTTONS
   ============================================================ */
button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.5rem var(--space-4);
  font-size: var(--text-base);
  font-weight: 500;
  font-family: var(--font-sans);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition:
    background-color var(--transition-fast),
    color var(--transition-fast),
    border-color var(--transition-fast),
    box-shadow var(--transition-fast),
    transform var(--transition-fast),
    opacity var(--transition-fast);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
  line-height: 1.4;
  /* Default to primary */
  background: var(--clr-primary-500);
  color: #fff;
}

button:hover,
.btn:hover {
  background: var(--btn-hover);
}

button:active,
.btn:active {
  transform: scale(0.97);
}

button:disabled,
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

button:focus-visible,
.btn:focus-visible {
  outline: 2.5px solid var(--clr-primary-400);
  outline-offset: 2px;
}

/* Secondary */
.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-default);
}
.btn-secondary:hover {
  background: var(--bg-surface-3);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

/* Remove / Delete */
.btn-delete {
  background: var(--bg-surface);
  color: #dc2626;
  border-color: #fca5a5;
  font-size: var(--text-sm);
  padding: 0.3rem var(--space-4);
}
.btn-delete:hover {
  background: var(--clr-danger-100);
  border-color: var(--clr-danger-500);
  color: #991b1b;
}

/* Edit faculty */
.btn-edit-faculty {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.3rem var(--space-4);
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: var(--font-sans);
  background: var(--clr-primary-500);
  color: #fff;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
  white-space: nowrap;
}
.btn-edit-faculty:hover {
  background: var(--clr-primary-600);
}

/* ============================================================
   9. INPUTS & SELECTS & FORMS
   ============================================================ */
input[type="text"],
input[type="number"],
input[type="password"],
select,
textarea {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-base);
  font-family: var(--font-sans);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  background: var(--input-bg);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  width: 100%;
}

input[type="text"]::placeholder,
input[type="number"]::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  border-color: var(--input-focus-border);
  box-shadow: var(--focus-ring);
}

input[readonly] {
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  cursor: default;
}

/* Checkbox */
input[type="checkbox"] {
  width: auto;
  cursor: pointer;
  accent-color: var(--clr-primary-500);
}

/* ============================================================
   10. TABLES (generic)
   ============================================================ */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}

thead {
  background: var(--bg-surface-2);
}

thead th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  
  
  white-space: nowrap;
  border-bottom: 1px solid var(--border-default);
}

thead th[data-key] { cursor: pointer; user-select: none; }
thead th[data-key]:hover {
  background: var(--clr-primary-50);
  color: var(--clr-primary-600);
}

tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
}

tbody tr:last-child { border-bottom: none; }

tbody tr:hover { background: var(--bg-surface-2); }

td {
  padding: var(--space-2) var(--space-4);
  color: var(--text-primary);
  vertical-align: middle;
}

/* Table wrapper */
.faculty-scroll-wrap {
  overflow-x: auto;
  overflow-y: visible;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
}

/* ============================================================
   11. BADGES
   ============================================================ */

/* Status badges */
.units-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.units-ok     { background: var(--clr-success-100); color: #065f46; }
.units-max    { background: var(--clr-warning-100); color: #92400e; }
.units-over   { background: var(--clr-danger-100);  color: #991b1b; }

/* ============================================================
   12. DASHBOARD - STAT CARDS
   ============================================================ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  transition: box-shadow var(--transition-base), transform var(--transition-base);
}

.stat-label {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.stat-value {
  font-size: var(--text-stat);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: var(--space-1);
  letter-spacing: -0.02em;
}

.stat-sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ============================================================
   13. DASHBOARD CHART CARD
   ============================================================ */
.dashboard-chart-card {
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: box-shadow var(--transition-base);
}

.dashboard-chart-card h3 {
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}

/* When h3 is inside .dashboard-card-header, parent handles the border */
.dashboard-card-header h3 {
  padding-bottom: 0;
  border-bottom: none;
}

.chart-canvas-wrap {
  position: relative;
  height: 300px;
}

/* ============================================================
   14. FACULTY ASSIGNMENTS SUMMARY
   ============================================================ */
.faculty-assignments-container {
  min-height: 80px;
}

.fac-assign-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-3);
  padding: var(--space-1) 0;
}

.fac-assign-card {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  background: var(--bg-surface-2);
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.fac-assign-card:hover {
  border-color: var(--clr-primary-200);
}

.fac-assign-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  background: var(--clr-primary-100);
  color: var(--clr-primary-700);
  font-size: var(--text-xs);
  font-weight: 600;
  flex-shrink: 0;
}

.fac-assign-name {
  min-width: 0;
}

.empty-state-msg {
  color: var(--text-muted);
  font-size: var(--text-base);
  font-style: italic;
  padding: var(--space-4) 0;
  text-align: center;
}

/* ============================================================
   15. WORKLOAD PANEL
   ============================================================ */
.workload-grid {
  display: grid;
  gap: var(--space-4);
  align-items: start;
}

.workload-controls-card {
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  text-align: center;
  position: sticky;
  top: var(--space-4);
}

.ga-image {
  width: 80px;
  border-radius: var(--radius-lg);
  margin: 0 auto var(--space-3);
}

.subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}

/* Advanced settings */

.workload-result-card {
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  min-height: 300px;
  transition: box-shadow var(--transition-base);
}

.workload-result-card h3 {
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}

/* ============================================================
   16. GA LOADING STATE
   ============================================================ */
.ga-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-6) 0;
}

.ga-loading.hidden { display: none; }

.loader-row {
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.loader-box {
  text-align: center;
}

.loader-box p {
  font-size: var(--text-base);
  color: var(--text-secondary);
  margin-top: var(--space-2);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-default);
  border-top-color: var(--clr-primary-500);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

.mini-chart-wrapper {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-surface-2);
  overflow: hidden;
}

#gaProgressContainer {
  width: 100%;
  max-width: 420px;
}

#gaProgressBar {
  height: 6px;
  background: var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

#gaProgressContainer { display: flex; align-items: center; gap: var(--space-3); }
#gaProgressContainer #gaProgressBar { flex: 1 1 auto; min-width: 0; }
#cancelRunBtn { flex: 0 0 auto; min-height: 44px; justify-content: center; cursor: pointer; touch-action: manipulation; }
#cancelRunBtn[hidden] { display: none; }
#cancelRunBtn:disabled { cursor: default; opacity: 0.7; }

#gaProgressBar .fill {
  height: 100%;
  width: 0%;
  transition: width 0.2s linear, background-color 0.2s linear;
  border-radius: var(--radius-sm);
  background: var(--clr-primary-500);
}

/* GA Schedule Table row colors */
#gaScheduleTable tbody tr:hover { filter: brightness(0.97); }

/* ============================================================
   17. FACULTY TABLE
   ============================================================ */

/* Column widths */

/* Availability column header layout */
.avail-th {
  vertical-align: top !important;
  padding-bottom: var(--space-2) !important;
}

.avail-th-label {
  display: block;
  margin-bottom: var(--space-2);
}

/* Select-All buttons row - same 6-column grid as avail-checkboxes */
.avail-select-all-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  min-width: 300px;
}

.btn-select-day {
  padding: 0.18rem 0;
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid var(--clr-primary-300, #c4a882);
  background: var(--clr-primary-100, #f5ebe0);
  color: var(--clr-primary-800, #6b3a00);
  cursor: pointer;
  white-space: nowrap;
  text-align: center;
  line-height: 1.6;
  transition: background var(--transition-fast), border-color var(--transition-fast), transform 80ms;
  user-select: none;
}

.btn-select-day:hover {
  background: var(--clr-primary-200, #e8d5bc);
  border-color: var(--clr-primary-500, #a0622a);
}

.btn-select-day:active {
  transform: scale(0.95);
}

/* Availability checkboxes - same 6-column grid as the header buttons */
.avail-checkboxes {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  min-width: 300px;
}

.avail-checkboxes label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  color: var(--text-primary);
  padding: 0.2rem 0.25rem;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
  white-space: nowrap;
}

.avail-checkboxes label:hover {
  background: var(--clr-primary-50);
}

.avail-checkboxes input[type="checkbox"] {
  width: auto;
  cursor: pointer;
}

/* ============================================================
   18. SPECIALIZATION MULTI-SELECT DROPDOWN
   Fixed positioning so it escapes table/panel clipping
   ============================================================ */
.multi-select-dropdown {
  position: relative;
  width: 100%;
}

.dropdown-btn {
  padding: 0.5rem var(--space-4);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  background: var(--input-bg);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  color: var(--text-primary);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  user-select: none;
  text-align: left;
  width: 100%;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.dropdown-btn:hover {
  border-color: var(--clr-primary-400);
}

.dropdown-btn:focus {
  outline: none;
  border-color: var(--input-focus-border);
  box-shadow: var(--focus-ring);
}

/* Fixed-position dropdown panel (escapes all parent clipping) */
.dropdown-content {
  display: none;
  position: fixed;
  width: 300px;
  max-height: 260px;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  z-index: 9999;
  padding: var(--space-2) 0 0;
}

.dropdown-content::-webkit-scrollbar { width: 5px; }
.dropdown-content::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: var(--radius-full);
}

.multi-select-dropdown.open .dropdown-content {
  display: flex;
  flex-direction: column;
}

.dropdown-content label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  cursor: pointer;
  color: var(--text-primary);
  flex-shrink: 0;
  transition: background var(--transition-fast);
}

.dropdown-content label:hover {
  background: var(--clr-primary-50);
  color: var(--clr-primary-700);
}

.dropdown-content label input[type="checkbox"] {
  width: auto;
  cursor: pointer;
  flex-shrink: 0;
}

.dropdown-ok-btn {
  position: sticky;
  bottom: 0;
  width: 100%;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  padding: 0.5rem var(--space-4);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  border-top: 1px solid var(--border-subtle);
  background: var(--clr-primary-500);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: auto;
  transition: background var(--transition-fast);
}

.dropdown-ok-btn:hover {
  background: var(--btn-hover);
}

/* ============================================================
   19. SUBJECTS TABLE
   ============================================================ */
#subjectsTable { min-width: 800px; }

#subjectsTable input[type="number"],
#subjectsTable input[type="text"],
#subjectsTable select {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
}

#subjectsContainer {
  margin-top: var(--space-5);
}

#subjectsContainer h3 {
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  
  
}

#subjectsContainer table {
  margin-bottom: var(--space-5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* ============================================================
   20. REPORTS PANEL
   ============================================================ */
.reports-charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.chart-card {
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: box-shadow var(--transition-base);
}

.chart-card h3 {
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}

.chart-card .chart-canvas-wrap { height: 260px; }

.export-buttons {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-4);
  margin-bottom: var(--space-2);
}

.sheet-opts { border: 0; padding: 0; margin: 0 0 var(--space-3); display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.sheet-opts legend { width: 100%; padding: 0; margin-bottom: var(--space-1); font-weight: 600; }
.sheet-opts label { display: inline-flex; align-items: center; gap: var(--space-1); }

/* ============================================================
   21. REPORTS SUMMARY - card-per-faculty layout
   ============================================================ */

/* Outer wrapper replaces the old flat table */
.summary-faculty-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-top: var(--space-2);
}

/* One card per faculty member */
.summary-faculty-card {
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow var(--transition-base);
}

/* Card header: avatar + name/count + units badge + edit button */
.summary-fac-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4);
}

.summary-fac-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--clr-primary-100);
  color: var(--clr-primary-700);
  font-size: var(--text-base);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: -0.01em;
}

.summary-fac-info {
  flex: 1;
  min-width: 0;
}

.summary-fac-name {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.summary-fac-count, .summary-fac-hours {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 1px;
}

.summary-fac-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* Assignments table inside card */
.summary-assignments-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  table-layout: fixed;
}

.summary-assignments-table col.col-subject  { width: auto; }
.summary-assignments-table col.col-schedule { width: 190px; }
.summary-assignments-table col.col-room     { width: 230px; }

.summary-assignments-table thead th {
  padding: 0.5rem 1rem;
  font-size: var(--text-xs);
  font-weight: 600;
  
  
  color: var(--text-muted);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
}

.summary-assignments-table thead th:not(:first-child) { text-align: center; }
.summary-assignments-table tbody td:not(:first-child) { text-align: center; }

.summary-assignments-table tbody td {
  padding: var(--space-3) 1rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

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

.summary-assignments-table tbody tr:hover { background: var(--bg-surface-2); }

/* ============================================================
   23. FACULTY TIMETABLE
   ============================================================ */
.timetable-outer {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}

.timetable-scroll {
  width: 100%;
}

.timetable-grid {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.timetable-grid thead th {
  padding: 0.5rem var(--space-3);
  font-size: var(--text-xs);
  text-align: center;
  background: var(--bg-surface-2);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.tt-time-col { width: 70px; }
/* GF-09: a day with no class is a slim column; the other days share the rest */
.wk-day-off, .tt-day-off, .tt-day-col.tt-day-off { width: 2.25rem; box-sizing: border-box; }
.week-table thead th.wk-day-off, .timetable-grid thead th.tt-day-off { padding-left: 0; padding-right: 0; overflow: hidden; }
.timetable-grid.has-off .tt-day-col:not(.tt-day-off) { width: auto; }
.timetable-grid .tt-entry, .timetable-grid .tt-entry > * { overflow-wrap: anywhere; min-width: 0; }
.tt-day-col  { width: calc((100% - 70px) / 6); }

.tt-time-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  padding: 0.375rem var(--space-1);
  background: var(--bg-surface-2);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.tt-cell {
  padding: var(--space-1);
  vertical-align: top;
  border: 1px solid var(--border-subtle);
  min-height: 50px;
}

.tt-empty  { background: var(--bg-page); }
.tt-filled { background: var(--bg-surface); }

.tt-entry {
  margin-bottom: var(--space-1);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  font-size: var(--text-xs);
  line-height: 1.4;
}

.tt-faculty-tag {
  font-weight: 600;
  font-size: var(--text-xs);
}

.tt-subject-tag {
  color: var(--text-primary);
  font-size: var(--text-xs);
}

/* ============================================================
   24. EDIT MODAL - expanded for full faculty editing
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  border: 1px solid var(--border-subtle);
  width: 100%;
  max-width: 680px;
  margin: 0 var(--space-4);
  transform: translateY(-12px) scale(0.98);
  transition:
    transform 0.2s ease,
    opacity 0.18s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-overlay.open .modal-card {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface-2);
  flex-shrink: 0;
}

.modal-label {
  font-size: var(--text-xs);
  font-weight: 600;
  
  
  color: var(--clr-primary-600);
  margin-bottom: var(--space-1);
}

.modal-header h3 {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  margin: 0;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: var(--text-xl);
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.125rem var(--space-2);
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
}

.modal-close-btn:hover {
  background: var(--bg-surface-3);
  color: var(--text-primary);
}

.modal-body {
  padding: var(--space-4) var(--space-5);
}

.modal-form-group {
  margin-bottom: var(--space-4);
}

.modal-form-group label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.modal-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.modal-input-wrap input[type="number"] {
  flex: 1;
  padding: var(--space-2) 2.75rem var(--space-2) var(--space-4);
  font-size: var(--text-md);
  font-weight: 600;
  border: 2px solid var(--input-border);
  border-radius: var(--radius-lg);
  background: var(--input-bg);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
  width: 100%;
}

.modal-input-wrap input[type="number"]:focus {
  border-color: var(--clr-primary-500);
  box-shadow: var(--focus-ring);
}

.modal-input-suffix {
  position: absolute;
  right: 0.875rem;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  pointer-events: none;
}

.modal-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-2);
  line-height: 1.55;
}

.modal-info-strip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--clr-primary-50);
  border: 1px solid rgba(var(--accent-rgb), 0.18);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--clr-primary-700);
  font-weight: 500;
}

.modal-info-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background: var(--clr-primary-500);
  flex-shrink: 0;
}

.modal-footer {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface-2);
  flex-shrink: 0;
}

.modal-footer button {
  min-width: 100px;
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-base);
}

/* Modal section divider */
.modal-section-divider {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: var(--space-4) 0 var(--space-4);
}

.modal-section-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

/* Assignment editor rows inside modal */
.modal-assignment-list {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.modal-assignment-list::-webkit-scrollbar { width: 4px; }
.modal-assignment-list::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: var(--radius-sm); }

.modal-assign-row {
  align-items: center;
}

.modal-assign-row select,
.modal-assign-row input[type="text"] {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast);
}

.modal-assign-row select:focus,
.modal-assign-row input[type="text"]:focus {
  border-color: var(--clr-primary-500);
}

.modal-assign-delete {
  background: none;
  border: 1px solid var(--border-default);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-md);
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
  flex-shrink: 0;
}

.modal-assign-delete:hover {
  background: var(--clr-danger-100);
  color: var(--bad);
  border-color: var(--clr-danger-500);
}

.modal-add-assignment-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding: 0.4rem var(--space-4);
  font-size: var(--text-sm);
  font-weight: 600;
  background: none;
  border: 1.5px dashed var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  width: 100%;
  justify-content: center;
  transition: border-color var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}

.modal-add-assignment-btn:hover {
  border-color: var(--clr-primary-400);
  color: var(--clr-primary-600);
  background: var(--clr-primary-50);
}

/* Two-col grid for units + modal inline fields */

@media (max-width: 560px) {
  .modal-assign-row { grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; }
  .modal-assign-delete { grid-column: 2; grid-row: 2; justify-self: end; }
  .modal-card { max-width: calc(100vw - 2rem); }
}

/* ============================================================
   25. TOAST NOTIFICATION
   ============================================================ */
.toast-notif {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--clr-gray-900);
  color: var(--text-inverse);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  font-family: var(--font-sans);
  box-shadow: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 30000;
}

.toast-notif.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================================
   26. FAIRNESS REPORT
   ============================================================ */
.fairness-report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.fairness-card {
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-4) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  transition: box-shadow var(--transition-base), transform var(--transition-base);
}

.fairness-card-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.fairness-card-value {
  font-size: var(--text-stat);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.fairness-card-sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Per-faculty match table */

.match-yes     { font-weight: 600; }
.match-partial { font-weight: 600; }
.match-no      { font-weight: 600; }

/* CHED constraint note */

/* ============================================================
   27. FOCUS STATES (Accessibility)
   ============================================================ */
:focus-visible {
  border-radius: var(--radius-sm);
}

button:focus-visible,
a:focus-visible {
  outline: 2.5px solid var(--clr-primary-400);
  outline-offset: 3px;
}

/* ============================================================
   28. SCROLLBAR (global - subtle)
   ============================================================ */
/* Scrollbar rules live in ONE place: the --sb-* tokens and the shared rule set at the end of ui2-foundation.css (U5-01).
   Only the thin list variants (.dropdown-content, .modal-assignment-list) and the hidden rails stay local. */

/* ============================================================
   29. LOGIN PAGE (pages/login.html)
   ============================================================ */

body.page-login {
  overflow: auto;
  min-height: 100vh;
  min-height: 100dvh;
  height: auto;
  background: var(--bg-page);
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Landing nav */

/* Hero */
.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-7) var(--space-5) var(--space-7);
}

.hero h1 {
  font-family: var(--font-sans);
  font-size: var(--text-stat);
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: -0.025em;
  line-height: 1.15;
  max-width: 720px;
  margin-bottom: var(--space-4);
}

.hero h1 span { color: var(--clr-primary-500); }

.hero > p {
  font-size: var(--text-md);
  color: var(--text-secondary);
  max-width: 540px;
  line-height: 1.75;
  margin-bottom: var(--space-6);
}

.btn-outline {
  background: var(--bg-surface);
  color: var(--text-primary);
  padding: 0.75rem var(--space-6);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: 600;
  font-family: var(--font-sans);
  text-decoration: none;
  border: 1px solid var(--border-default);
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.btn-outline:hover {
  background: var(--bg-surface-3);
  border-color: var(--border-strong);
}

.btn-advanced-settings {
  margin-top: 8px;
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-secondary);
  border-color: var(--border-color);
  justify-content: center;
}
.btn-advanced-settings:hover {
  color: var(--clr-primary-700);
  border-color: var(--clr-primary-400);
  background: var(--clr-primary-50);
}

/* Hero badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.35rem 1rem;
  background: var(--clr-primary-50);
  color: var(--clr-primary-600);
  border: 1px solid rgba(var(--accent-rgb), 0.22);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  
  
  margin-bottom: var(--space-5);
}

/* Features section */

/* Landing footer */

/* ============================================================
   30. LOGIN PAGE (login.html)
   ============================================================ */
.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-6);
  width: 100%;
  max-width: 440px;
}

.login-card h1 {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: var(--space-2);
  letter-spacing: -0.02em;
  font-family: var(--font-sans);
}

.login-card .subtitle {
  font-size: var(--text-base);
  color: var(--text-muted);
  text-align: center;
  margin-bottom: var(--space-6);
}

.login-card label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-1);
}

.login-card input[type="text"],
.login-card input[type="password"],
.login-card select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
  font-family: var(--font-sans);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  background: var(--input-bg);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  margin-bottom: var(--space-4);
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
}

.login-card input:focus,
.login-card select:focus {
  border-color: var(--input-focus-border);
  box-shadow: var(--focus-ring);
}

.select-wrap {
  position: relative;
  margin-bottom: var(--space-4);
}

.select-wrap select { margin-bottom: 0; }

.select-wrap::after {
  content: '▾';
  position: absolute;
  right: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: var(--text-base);
}

.btn-login-submit {
  width: 100%;
  padding: var(--space-3);
  background: var(--clr-primary-500);
  color: #fff;
  font-size: var(--text-base);
  font-weight: 600;
  font-family: var(--font-sans);
  border: 1px solid var(--clr-primary-500);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
  margin-top: var(--space-1);
}

.btn-login-submit:hover {
  background: var(--btn-hover);
  border-color: var(--clr-primary-600);
}

.error-msg {
  background: var(--clr-danger-100);
  border: 1px solid #fca5a5;
  color: #b91c1c;
  font-size: var(--text-sm);
  padding: 0.5rem var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  display: none;
}

.error-msg.show { display: block; }

.brand-top {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--clr-primary-600);
  text-align: center;
  margin-bottom: var(--space-4);
  letter-spacing: -0.01em;
  font-family: var(--font-sans);
}

/* ============================================================
   31. RESPONSIVE - TABLET (≤ 1100px)
   ============================================================ */
@media (max-width: 1100px) {
  .workload-controls-card { position: static; }
  .reports-charts-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: 1fr 1fr; }
}

/* ============================================================
   32. RESPONSIVE - MOBILE (≤ 768px)
   ============================================================ */
@media (max-width: 767px) {
  :root {
    --nav-h:         3.25rem;
  }

  .top-navbar {
    padding: 0 var(--space-4);
  }

  .nav-menu {
    gap: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  .nav-item {
    flex-shrink: 0;
  }

  .panels-wrapper { padding: var(--space-3) var(--space-3) 0; }

  .panel { padding: var(--space-4) var(--space-4); }

  .stat-value { font-size: var(--text-stat); }

  .reports-charts-grid { grid-template-columns: 1fr; }

  .export-buttons { flex-direction: column; }
  .export-buttons button { width: 100%; }

  .modal-card { margin: 0 var(--space-4); }

  .hero { padding: var(--space-7) var(--space-4) var(--space-6); }
  .hero h1 { font-size: var(--text-stat); }

  .loader-row { gap: var(--space-4); flex-wrap: wrap; justify-content: center; }
}

/* ============================================================
   33. RESPONSIVE - SMALL MOBILE (≤ 480px)
   ============================================================ */
@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr; }
  .fairness-report-grid { grid-template-columns: 1fr 1fr; }
  .fac-assign-grid { grid-template-columns: 1fr; }
  .workload-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   34. PRINT STYLES
   ============================================================ */
@media print {
  .top-navbar,
  .export-buttons,
  .workload-controls-card { display: none !important; }

  body {
    background: white;
    color: black;
    font-size: 11pt;
    overflow: auto;
    height: auto;
  }

  .panel {
    border: none;
    box-shadow: none;
    padding: 0;
    border-radius: 0;
  }

  .panels-wrapper {
    height: auto;
    overflow: visible;
    padding: 0;
    margin: 0;
  }

  .stat-card,
  .chart-card,
  .workload-result-card,
  .dashboard-chart-card,
  .fairness-card {
    box-shadow: none;
    border: 1px solid #ccc;
    break-inside: avoid;
  }
}
/* ============================================================
   PHASE 3 - Section Badges, Dashboard Schedule Emphasis
   ============================================================ */

/* Section badge (IT1B1, IT2B1, etc.) */
.section-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--clr-primary-50);
  border: 1px solid rgba(var(--accent-rgb), 0.25);
  color: var(--clr-primary-700);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.section-cell {
  white-space: nowrap;
}

.subject-year-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-3);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 600;
  margin-left: 4px;
  white-space: nowrap;
  vertical-align: middle;
}

/* Dashboard schedule card - emphasized (shown first) */
.dashboard-schedule-card {
  margin-bottom: var(--space-4);
}

.dashboard-chart-secondary {
  margin-top: var(--space-2);
}

/* Dashboard card header with subtitle */
.dashboard-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}

.dashboard-card-header h3 {
  margin-bottom: var(--space-1);
}

/* Class type badge (LECTURE / LAB) */
.class-type-tag {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  
  
}

/* Updated subject type tags for new classification */

/* ============================================================
   PHASE 2 UI - Room Management, Class Sizes, Soft Constraints
   ============================================================ */

/* ── Room Management ── */
.rooms-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

@media (max-width: 767px) {
  .rooms-grid { grid-template-columns: 1fr; }
}

.room-section-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

.room-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}

.room-section-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  
  
}

.room-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-height: 320px;
  overflow-y: auto;
}

.room-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
}

.room-item input[type="text"] {
  flex: 1;
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  width: auto;
}

.room-item input[type="text"]:focus {
  border-color: var(--input-focus-border);
  box-shadow: var(--focus-ring);
  outline: none;
}

.room-item-del {
  background: none;
  border: none;
  color: var(--bad);
  cursor: pointer;
  padding: 0.125rem var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-md);
  line-height: 1;
  flex-shrink: 0;
  transition: background var(--transition-fast);
}
.room-item-del:hover { background: var(--clr-danger-100); }

/* ── Class Sizes Table ── */
#classSizesTable input[type="text"],
#classSizesTable input[type="number"] {
  width: 100%;
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-base);
  min-width: 80px;
}

/* ── Soft Constraints ── */
.soft-constraint-select-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

.soft-constraint-form {
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
}

.sc-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4) var(--space-5);
  margin-bottom: var(--space-4);
}

@media (max-width: 767px) {
  .sc-form-grid { grid-template-columns: 1fr; }
}

.sc-leave-section {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-4) var(--space-5);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-subtle);
}

@media (max-width: 900px) {
  .sc-leave-section { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
  .sc-leave-section { grid-template-columns: 1fr; }
}

.sc-checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
}

.sc-checkbox-label input[type="checkbox"] {
  width: auto;
  cursor: pointer;
}

.date-list-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.date-entry {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.date-entry input[type="date"],
.date-entry input[type="text"] {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  min-width: 0;
  width: auto;
}

.date-entry-del {
  background: none;
  border: none;
  color: var(--bad);
  cursor: pointer;
  padding: 0.125rem var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  flex-shrink: 0;
  transition: background var(--transition-fast);
}
.date-entry-del:hover { background: var(--clr-danger-100); }

.sc-day-restrict {
  margin-top: var(--space-2);
}

/* ── Timetable room display ── */
.tt-room-tag {
  font-size: var(--text-xs);
  color: var(--clr-primary-600);
  background: var(--clr-primary-50);
  border-radius: var(--radius-sm);
  padding: 0.1rem 0.35rem;
  margin-top: 2px;
  display: inline-block;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.tt-class-tag {
  font-size: var(--text-xs);
  font-weight: 600;
  
  
  padding: 0.1rem 0.3rem;
  border-radius: var(--radius-sm);
  margin-bottom: 2px;
  display: inline-block;
}

/* Schedule display format: Prof X: IT101 LECTURE for Subject - time */

/* Room badge in reports */
.room-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-3);
  border: 1px solid var(--border-subtle);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--clr-primary-700);
  white-space: nowrap;
}

/* Conflict highlight */

/* Class size section key badge */
.cs-key-badge {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--clr-primary-700);
  background: var(--clr-primary-50);
  border: 1px solid rgba(192,68,10,0.2);
  border-radius: var(--radius-sm);
  padding: 0.125rem 0.5rem;
}
/* ── fac-assign-list item with slot/room/class_type ── */

.fac-assign-item-inner {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

/* ============================================================
   ACADEMIC MODE - SEMESTER BADGE & PANEL CONTEXT
   ============================================================ */

/* Navbar semester badge */

/* Sem context badge in panel header */
.sem-context-badge {
  display: inline-flex;
  align-items: center;
  padding: 0;
  background: none;
  color: var(--text-secondary);
  font-size: var(--text-base);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 4px;
}
.sem-context-badge::before {
  display: none;
}

#engineSettingsCard {
  max-width: 100%;
}

#engineSettingsCard .engine-settings-row {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0;
}

#engineSettingsCard .engine-settings-col {
  flex: 1;
  display: grid;
  gap: 16px;
  align-items: start;
}

#engineSettingsCard .engine-settings-col:first-child {
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: auto 1fr;
  padding-right: var(--space-6);
}

#engineSettingsCard .engine-settings-col:last-child {
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: auto 1fr;
  padding-left: var(--space-6);
}

#engineSettingsCard .engine-settings-section-label {
  grid-column: 1 / -1;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0;
}

#engineSettingsCard .engine-settings-divider {
  width: 1px;
  background: var(--border-subtle);
  flex-shrink: 0;
}

#engineSettingsCard .modal-form-group {
  margin: 0;
}




@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.75); }
}



@keyframes fade-in-out {
  0% { opacity: 0; transform: translateY(-4px); }
  15% { opacity: 1; transform: translateY(0); }
  75% { opacity: 1; }
  100% { opacity: 0; }
}


@media (max-width: 600px) {
  .sem-context-badge {
    font-size: var(--text-xs);
  }
}

/* ============================================================
   PHASE 3 - Dot marker, GA table section col, UX polish
   ============================================================ */

/* Dot marker for faculty assignment list items */

/* GA schedule table - section column */
#gaScheduleTable .section-cell {
  white-space: nowrap;
}
#gaScheduleTable .section-badge {
  margin-right: 2px;
}

/* Fac-assign section badge spacing */
.fac-assign-meta .section-badge {
  font-size: var(--text-xs);
  padding: 0.1rem 0.4rem;
}

/* Reports summary: section tags inline */

/* Panel header h2 stronger weight */
.page-header h2,
.page-header > div h2 {
  font-weight: 600;
}

/* Workload result card - tighter header spacing */
.workload-result-card h3 {
  font-weight: 600;
  color: var(--text-primary);
}

/* Schedule table - emphasize faculty name */
#gaScheduleTable td:first-child {
  font-weight: 600;
  color: var(--text-primary);
}

/* Reports summary table faculty column */
#reportsSummaryTable td:first-child strong {
  font-size: var(--text-base);
}

/* Empty state better padding in schedule cards */
.dashboard-schedule-card .empty-state-msg {
  padding: var(--space-6) 0;
  font-size: var(--text-base);
}

/* Stat card value color for overload */
#statOverloaded {
  color: var(--bad);
}

/* Stat sub label improvement */
.stat-label {
  font-size: var(--text-xs);
}

/* Timetable section tag (IT1B1 etc.) */
.tt-section-tag {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--clr-primary-700);
  background: var(--clr-primary-50);
  border: 1px solid rgba(192,68,10,0.2);
  border-radius: var(--radius-sm);
  padding: 0.1rem 0.35rem;
  margin-bottom: 2px;
  letter-spacing: 0.03em;
}

/* Curriculum summary - full-width stacked tables */
.curriculum-summary-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  margin-top: var(--space-4);
}

.curriculum-group {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.curriculum-header {
  padding: 0.5rem 1rem;
  font-size: var(--text-xs);
  font-weight: 600;
  
  
  color: var(--text-muted);
  background: var(--bg-surface-2);
  border-bottom: 1px solid var(--border-subtle);
}

.curriculum-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
  background: var(--bg-surface);
}

.curriculum-table thead th {
  background: var(--bg-surface-2);
  padding: 0.5rem var(--space-4);
  font-size: var(--text-xs);
  font-weight: 600;
  
  
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-default);
}

.curriculum-table td {
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.curriculum-table tbody tr:last-child td { border-bottom: none; }
.curriculum-table tbody tr:hover { background: var(--bg-surface-2); }

.txt-center { text-align: center; }
.font-mono  { font-family: var(--font-sans); }

/* ============================================================
   FAC-ASSIGN CARD - POLISHED LAYOUT (patched)
   ============================================================ */

/* Header: name + count stacked, units badge + edit button right-aligned */
.fac-assign-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}
.fac-assign-header-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  gap: 1px;
}
.fac-assign-name {
  font-weight: 600;
  font-size: var(--text-base);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: unset;
}
.fac-assign-count {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 500;
}

/* Compact edit button in card header */
.fac-assign-header .btn-edit-faculty {
  padding: 0.2rem 0.55rem;
  font-size: var(--text-xs);
  border-radius: var(--radius-md);
  flex-shrink: 0;
  opacity: 0.95;
  transition: opacity var(--transition-fast), background var(--transition-fast);
}
.fac-assign-header .btn-edit-faculty:hover { opacity: 1; }

/* List item row */
.fac-assign-item-full {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border-subtle);
}
.fac-assign-item-full:last-child { border-bottom: none; }

/* Color dot indicating LECTURE vs LAB */
.fac-assign-ct-dot {
  flex-shrink: 0;
  border-radius: 50%;
}

/* Subject name */
.fac-assign-subject-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Meta row: type tag + section + slot + room */
.fac-assign-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: var(--space-1);
}
.fac-assign-section {
  font-size: var(--text-xs) !important;
  padding: 0.1rem 0.35rem !important;
}
.fac-assign-room {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--clr-primary-600);
  background: var(--clr-primary-50);
  border: 1px solid var(--clr-primary-100);
  border-radius: var(--radius-sm);
  padding: 1px var(--space-2);
  white-space: nowrap;
}

/* ============================================================
   INDEX (LANDING PAGE) - lp-* rules
   Nav unified with .top-navbar design tokens
   ============================================================ */

/* ── NAV ── */
.lp-nav {
  background: var(--nav-bg);
  border-bottom: 1px solid var(--nav-border);
  padding: 0 var(--space-4);
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1000;
  transition: background var(--transition-slow), border-color var(--transition-slow);
}

.lp-nav-left {
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.lp-logo-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
  text-decoration: none;
}

.lp-brand {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--clr-primary-600);
  line-height: 1.2;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.lp-brand-sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 400;
  line-height: 1.2;
}

.lp-nav-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.lp-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--border-default);
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid var(--border-default);
  transition: border-color var(--transition-fast);
}

.lp-avatar:hover { border-color: var(--clr-primary-400); }

.lp-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ── HERO ── */
.lp-hero {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: var(--space-6);
  padding: 64px 72px 60px;
  max-width: 1300px;
  margin: 0 auto;
  width: 100%;
}

.lp-hero-title {
  font-family: var(--font-sans);
  font-size: clamp(2.2rem, 4.5vw, 3.6rem);
  font-weight: 400;
  line-height: 1.12;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  margin-bottom: var(--space-3);
}

.lp-hero-subtitle {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--clr-primary-500);
  margin-bottom: var(--space-5);
  letter-spacing: 0.01em;
}

.lp-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--clr-primary-500);
  color: #fff;
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: 600;
  text-decoration: none;
  transition: background var(--transition-fast), transform 0.1s;
  margin-bottom: var(--space-6);
}

.lp-cta:hover {
  background: var(--btn-hover);
}

.lp-cta-arrow { font-size: var(--text-md); }

/* ── HERO RIGHT CARD ── */
.lp-hero-right {
  display: flex;
  justify-content: center;
  align-items: center;
}

.lp-visual-card {
  width: 100%;
  max-width: 340px;
  aspect-ratio: 1 / 1;
  background: var(--clr-primary-50);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: var(--space-6);
}

.lp-visual-icon {
  width: 80px;
  height: 80px;
  background: rgba(var(--accent-rgb), 0.10);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lp-visual-icon svg {
  width: 40px;
  height: 40px;
  stroke: var(--clr-primary-500);
  stroke-width: 1.5;
  fill: none;
}

/* ── FOOTER ── */
.lp-footer {
  background: var(--bg-white);
  border-top: 1px solid var(--border-default);
  padding: 16px var(--space-4);
  text-align: center;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Body layout for landing page */
body:has(.lp-nav) {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ── LANDING RESPONSIVE ── */
@media (max-width: 820px) {
  .lp-hero {
    grid-template-columns: 1fr;
    padding: var(--space-6) var(--space-4);
    text-align: center;
  }
  .lp-hero-right { display: none; }
}
/* ============================================================
   ROOM CAPACITY - Settings Room Management
   ============================================================ */

.room-capacity-legend {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.room-cap-legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.room-cap-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.dot-rec { background: var(--clr-success-500); }
.dot-max { background: var(--clr-danger-500); }

.room-cap-col-labels {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 0.625rem var(--space-1);
  font-size: var(--text-xs);
  font-weight: 600;
  
  
  color: var(--text-muted);
}
.room-cap-col-labels span:first-child { flex: 2; min-width: 0; }
.room-cap-col-labels span:nth-child(2),
.room-cap-col-labels span:nth-child(3) {
  width: 62px;
  flex-shrink: 0;
  text-align: center;
}
.room-cap-col-spacer {
  width: 1.625rem; /* matches delete button footprint */
  flex-shrink: 0;
}

/* Room item with capacity fields */
.room-item .room-cap-input {
  width: 62px;
  flex-shrink: 0;
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  text-align: center;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text-primary);
  -moz-appearance: textfield;
}
.room-item .room-cap-input::-webkit-inner-spin-button,
.room-item .room-cap-input::-webkit-outer-spin-button { opacity: 0.4; }

.room-item .room-rec-input { border-color: var(--clr-success-500); }
.room-item .room-rec-input:focus {
  border-color: var(--clr-success-500);
  box-shadow: var(--focus-ring);
  outline: none;
}

.room-item .room-max-input { border-color: var(--clr-danger-500); }
.room-item .room-max-input:focus {
  border-color: var(--clr-danger-500);
  box-shadow: var(--focus-ring);
  outline: none;
}

/* ============================================================
   CAPACITY METRICS DASHBOARD CARD
   ============================================================ */

.capacity-summary-card {
  margin-bottom: var(--space-5);
}

.capacity-metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
  margin-top: var(--space-4);
}

@media (max-width: 860px) {
  .capacity-metrics-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .capacity-metrics-grid { grid-template-columns: 1fr; }
}

.capacity-metric-tile {
  padding: var(--space-4) var(--space-4);
  border: 1px solid var(--border-subtle);
  text-align: center;
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.capacity-ok   { background: var(--clr-success-100); border-color: var(--clr-success-500); }
.capacity-warn { background: var(--clr-warning-100); border-color: var(--clr-warning-500); }
.capacity-hard { background: var(--clr-danger-100);  border-color: var(--clr-danger-500); }
.capacity-total {
  background: var(--bg-surface-2);
  border-color: var(--border-default, var(--border-subtle));
}

.capacity-metric-value {
  font-size: var(--text-stat);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.capacity-metric-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.capacity-metric-pct {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
}

/* Overall status badge */
.capacity-overall-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.badge-ok   { background: var(--clr-success-100); color: #166534; }
.badge-warn { background: var(--clr-warning-100); color: #92400e; }
.badge-hard { background: var(--clr-danger-100);  color: #991b1b; }

/* Hard violations list */
.capacity-violations-list {
  margin-top: var(--space-4);
}

.capacity-violations-header {
  font-size: var(--text-xs);
  font-weight: 600;
  
  
  padding: var(--space-2) var(--space-3);
}

.capacity-violation-row {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--clr-danger-100);
  font-size: var(--text-sm);
}
.capacity-violation-row:last-child { border-bottom: none; }

.viol-room {
  font-weight: 600;
  color: var(--bad);
  white-space: nowrap;
  min-width: 80px;
}

.viol-detail {
  flex: 1;
  color: var(--text-secondary);
}

.viol-counts {
  display: inline-block;
  margin-left: var(--space-2);
  background: var(--clr-danger-100);
  color: #991b1b;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 1px var(--space-2);
  border-radius: var(--radius-sm);
}

/* ============================================================
   CAPACITY ANALYTICS TABLES & STUDENT COUNT TAG
   ============================================================ */
.cap-details-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}
.cap-details-table thead th {
  text-align: left;
  padding: var(--space-2) var(--space-4);
  background: var(--bg-surface-2);
  border-bottom: 1px solid var(--border-default);
  font-weight: 600;
  color: var(--text-muted);
  font-size: var(--text-xs);
  
  
}
.cap-details-table tbody td {
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
.cap-details-table tbody tr:hover { background: var(--bg-surface-2); }

.student-count-tag {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.1rem 0.4rem;
  vertical-align: middle;
}

/* ============================================================
   RESPONSIVE LAYER - all devices (appended)
   ============================================================ */
html { -webkit-tap-highlight-color: transparent; }
body { height: 100vh; height: 100dvh; }
body.page-index { overflow: auto; height: auto; min-height: 100vh; min-height: 100dvh; }
body.page-login { min-height: 100dvh; padding: var(--space-4); }
.panels-wrapper {
  height: calc(100vh - var(--nav-h)); height: calc(100dvh - var(--nav-h));
}
.panel { padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom, 0px)); }
.modal-card { max-height: 90vh; max-height: 90dvh; }
.dropdown-content { min-width: 240px; max-width: calc(100vw - 16px); }
.toast-notif { white-space: normal; max-width: 92vw; text-align: center; }
.fac-assign-grid { grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); }
#gaTableWrapper, #fairnessPerFaculty { overflow-x: auto; -webkit-overflow-scrolling: touch; }
#gaScheduleTable { min-width: 780px; }
#fairnessPerFaculty table { min-width: 520px; }
#facultyTable { min-width: 900px; }
#classSizesTable { min-width: 460px; }
.summary-faculty-card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.summary-assignments-table { min-width: 560px; }
.faculty-scroll-wrap, .timetable-outer { -webkit-overflow-scrolling: touch; }
img, canvas { max-width: 100%; }

@media (min-width: 1800px) {
  html { font-size: 16px; }
}   /* U6-02: the .panels-container max-width 1760px rule was removed, the shared --page-max column replaces it */

@media (pointer: coarse) {
  button, .btn, .nav-item, select, input[type="text"], input[type="number"], input[type="password"] { min-height: 40px; }
  input[type="checkbox"] { width: 20px; height: 20px; }
  .stat-card:hover, .fairness-card:hover, .fac-assign-card:hover, .capacity-metric-tile:hover, .btn-edit-faculty:hover { transform: none; }
}

@media (max-width: 1024px) {
  .nav-left { gap: var(--space-4); }
  .panel { padding: var(--space-5) var(--space-5); }
  .lp-hero { padding: 48px var(--space-6); gap: 24px; }
  #engineSettingsCard .engine-settings-row .engine-settings-col:first-child { grid-template-columns: repeat(2, 1fr); }
  #engineSettingsCard .engine-settings-row .engine-settings-col:last-child { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  #engineSettingsCard .engine-settings-row { flex-direction: column; }
  #engineSettingsCard .engine-settings-row .engine-settings-col { padding: 0 !important; }
  #engineSettingsCard .engine-settings-divider { width: 100%; height: 1px; margin: var(--space-4) 0; }
}

@media (max-width: 767px) {
  :root { --nav-h: calc(5.25rem + env(safe-area-inset-top, 0px)); }
  html { font-size: 14px; }
  .top-navbar {
    height: var(--nav-h); flex-wrap: wrap; align-content: flex-start;
    padding: env(safe-area-inset-top, 0px) max(var(--space-3), env(safe-area-inset-right)) 0 max(var(--space-3), env(safe-area-inset-left));
    gap: 0 var(--space-2);
  }
  .nav-left { display: contents; }
  .nav-brand-wrap { order: 1; height: 2.75rem; }
  .nav-right { order: 2; height: 2.75rem; margin-left: auto; }
  .nav-menu { order: 3; flex: 0 0 100%; height: 2.5rem; -webkit-overflow-scrolling: touch; }
  .nav-item { font-size: var(--text-sm); padding: 0.375rem 0.75rem; }
  .panels-wrapper { padding: var(--space-2) max(var(--space-2), env(safe-area-inset-right)) 0 max(var(--space-2), env(safe-area-inset-left)); }
  .panel { padding: var(--space-4) var(--space-4) calc(var(--space-6) + env(safe-area-inset-bottom, 0px)); border-radius: var(--radius-sheet) var(--radius-sheet) 0 0; }
  input[type="text"], input[type="number"], input[type="password"], input[type="date"], select, textarea { font-size: var(--text-md); }
  .chart-canvas-wrap { height: 240px; }
  .chart-card .chart-canvas-wrap { height: 220px; }
  .dashboard-chart-card, .chart-card, .workload-result-card, .workload-controls-card { padding: var(--space-4); }
  .summary-fac-header { flex-wrap: wrap; padding: var(--space-3) var(--space-4); }
  .summary-fac-actions { margin-left: auto; }
  .modal-assign-row { grid-template-columns: 1fr 1fr; }
  .modal-assign-delete { justify-self: end; }
  .modal-body, .modal-header, .modal-footer { padding-left: var(--space-4); padding-right: var(--space-4); }
  .modal-footer button { flex: 1; }
  .soft-constraint-select-row { flex-direction: column; align-items: stretch; }
  #scFacultySelect { max-width: none !important; width: 100%; }
  .soft-constraint-form { padding: var(--space-4); }
  .room-cap-col-labels span:nth-child(2), .room-cap-col-labels span:nth-child(3) { width: 52px; }
  .room-item .room-cap-input { width: 52px; }
  .page-header { gap: var(--space-2); }
  .lp-hero { padding: 32px var(--space-4); }
  .lp-hero-title { font-size: clamp(1.9rem, 8vw, 2.6rem); }
  .lp-nav { padding: env(safe-area-inset-top, 0px) var(--space-4) 0; height: calc(var(--nav-h) - 2.5rem); min-height: 3.25rem; }
  .login-card { padding: var(--space-5) var(--space-4); }
  #engineSettingsCard .engine-settings-row .engine-settings-col:first-child,
  #engineSettingsCard .engine-settings-row .engine-settings-col:last-child { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 520px) {
  .brand { font-size: var(--text-base); }
  .stat-value, .fairness-card-value, .capacity-metric-value { font-size: var(--text-xl); }
  .capacity-metrics-grid { grid-template-columns: 1fr 1fr; }
  .panel { padding: var(--space-4) var(--space-3) calc(var(--space-6) + env(safe-area-inset-bottom, 0px)); }
  .modal-card { margin: 0 var(--space-2); max-width: calc(100vw - 1rem); }
  .modal-assign-delete { justify-self: stretch; width: 100%; }
  .sc-form-grid, .sc-leave-section { grid-template-columns: 1fr; }
  #engineSettingsCard .engine-settings-row .engine-settings-col:first-child,
  #engineSettingsCard .engine-settings-row .engine-settings-col:last-child { grid-template-columns: 1fr; }
  .avail-select-all-row, .avail-checkboxes { min-width: 260px; }
  .loader-row { flex-direction: column; gap: var(--space-4); }
  .mini-chart-wrapper canvas { max-width: 100%; height: auto !important; }
  .login-card { padding: var(--space-4) var(--space-4); border-radius: var(--radius-lg); }
  .lp-brand-sub { display: none; }
  .lp-cta { width: 100%; justify-content: center; }
  .export-buttons button { width: 100%; }
}

@media (max-width: 360px) {
  .fairness-report-grid, .capacity-metrics-grid { grid-template-columns: 1fr; }
}

@media (max-height: 480px) and (orientation: landscape) {
  :root { --nav-h: 3rem; }
  .top-navbar { flex-wrap: nowrap; height: var(--nav-h); }
  .nav-left { display: flex; min-width: 0; gap: var(--space-3); }
  .nav-brand-wrap, .nav-right { height: auto; }
  .nav-menu { order: 0; flex: 0 1 auto; height: auto; }
  .panel { padding-top: var(--space-3); }
  body.page-login { align-items: flex-start; }
  .login-card { margin: var(--space-2) auto; }
  .lp-hero { padding: var(--space-4) var(--space-4); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* ============================================================
   MOBILE / DEVICE SCALE TUNING (readable sizes)
   ============================================================ */
@media (min-width: 601px) and (max-width: 1100px) {
  .stats-row { grid-template-columns: repeat(3, 1fr); }
  .stat-card { padding: var(--space-4); }
}

@media (max-width: 900px) {
  html { font-size: 15px; }
  body { font-size: var(--text-md); }
  .nav-brand-wrap img.psu-logo { width: 32px; height: 32px; }

  /* minimum readable text (>= 12px) for tiny labels/badges */
  .section-badge, .class-type-tag, .student-count-tag, .viol-counts, .units-badge, .fac-assign-slot, .fac-assign-room, .fac-assign-count, .fac-assign-section, .tt-entry, .tt-faculty-tag, .tt-subject-tag, .tt-room-tag, .tt-class-tag, .tt-section-tag, .tt-time-label, .stat-label, .modal-label, .modal-section-label, .room-cap-col-labels, .capacity-metric-label, .fairness-card-label, .fairness-card-sub, .stat-sub, .summary-fac-count, .lp-brand-sub, .summary-assignments-table thead th, .curriculum-table thead th, .cap-details-table thead th, .subject-year-badge, .capacity-overall-badge, .btn-select-day { font-size: var(--text-sm) !important; }
  .fac-assign-subject-name, .summary-subj-name { font-size: var(--text-base); }
  .fac-assign-meta { gap: var(--space-2); }
  .timetable-grid { font-size: var(--text-sm); }

  .modal-assign-delete, .room-item-del, .date-entry-del { min-width: 44px; min-height: 44px; }
  .dropdown-content label, .avail-checkboxes label { min-height: 40px; }
  .btn-edit-faculty { min-height: 40px; padding: 0.4rem 0.9rem; }
  .btn-delete { min-height: 40px; }
}

@media (pointer: coarse) {
  button, .btn, .nav-item, select, input[type="text"], input[type="number"], input[type="password"], input[type="date"] { min-height: 44px; }
  .btn-select-day { min-height: 36px; }
}

@media (max-width: 600px) {
  .stats-row { grid-template-columns: 1fr; gap: var(--space-3); }
  .stat-card { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-4); }
  .stat-card .stat-label, .stat-card .stat-sub { margin: 0; }
  .stat-card .stat-value { order: 3; margin: 0; }
  .stat-card > div:nth-child(1) { flex: 1; }
  .page-header h2 { font-size: var(--text-xl); }
  .page-header p { font-size: var(--text-base); }
  .sem-context-badge { margin-top: 0; }
  .workload-controls-card .ga-image { width: 64px; }
  .btn { padding: 0.65rem 1rem; }
  .export-buttons { gap: var(--space-2); }
  .toast-notif { bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px)); font-size: var(--text-base); }
  .chart-canvas-wrap { height: 220px; }
}

@media (max-width: 360px) {
  html { font-size: 14px; }
  .brand { font-size: var(--text-sm); }
}

@media (min-width: 901px) and (max-width: 1280px) {
  .panel { padding: var(--space-5) var(--space-6); }
  .nav-left { gap: var(--space-4); }
  .nav-item { padding: 0.3125rem 0.625rem; font-size: var(--text-sm); }
}

/* ============================================================
   WORKLOAD PANEL - mobile overflow fix
   ============================================================ */
.workload-grid { grid-template-columns: 260px minmax(0, 1fr); }
.workload-grid > * { min-width: 0; }
.workload-result-card { max-width: 100%; overflow: hidden; }
.panel { overflow-x: hidden; }

@media (max-width: 1100px) {
  .workload-grid { grid-template-columns: minmax(0, 1fr); }
  .workload-controls-card {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
    gap: var(--space-3) var(--space-4); padding: var(--space-4);
  }
  .workload-controls-card .ga-image { margin: 0; width: 64px; }
  .workload-controls-card .subtitle { margin: 0; text-align: left; }
  .workload-controls-card .btn,
  .workload-controls-card .btn-full { width: auto; flex: 1 1 200px; }
}

@media (max-width: 900px) {
  .page-header > div:first-child { flex: 1 1 100%; }
  .page-header p { max-width: 100%; }
  #gaTableWrapper { margin: 0 calc(var(--space-2) * -1); padding: 0 var(--space-2); }
}

@media (max-width: 600px) {
  .workload-controls-card { flex-direction: column; text-align: center; }
  .workload-controls-card .subtitle { text-align: center; }
  .workload-controls-card .btn,
  .workload-controls-card .btn-full { width: 100%; flex: 0 0 auto; }
  .workload-result-card { padding: var(--space-4) var(--space-3); min-height: 0; }
  .workload-result-card h3 { font-size: var(--text-md); }
  .ga-loading { padding: var(--space-4) 0; }
  .ga-loading .loader-row { flex-direction: column; }
  #gaProgressContainer { width: 100%; flex-direction: column; align-items: stretch; }
  #gaProgressContainer #gaProgressBar { flex: 0 0 auto; }
  #cancelRunBtn { width: 100%; }
}

/* Department banner (dashboard) */
.dept-banner {
  display: flex; align-items: center; gap: var(--space-3);
  margin-bottom: var(--space-4); padding: 0; color: var(--clr-primary-600);
}
.dept-banner svg { flex-shrink: 0; }
.dept-banner-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.dept-banner-label { font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.dept-banner-text strong { font-size: var(--text-md); color: var(--text-primary); overflow-wrap: anywhere; }
@media print { .dept-banner { display: none; } }

/* ============================================================
   MOBILE: tables become cards (no horizontal scrolling),
   dropdown becomes a bottom sheet
   ============================================================ */

@media (max-width: 767px) {

  .faculty-scroll-wrap, #gaTableWrapper, #fairnessPerFaculty, .summary-faculty-card, .dashboard-chart-card > div[style*="overflow-x"] {
    overflow: visible !important; margin: 0; padding-left: 0; padding-right: 0;
  }
  .faculty-scroll-wrap { border: 0; background: none; box-shadow: none; }
  .summary-faculty-card { overflow: hidden !important; }
  input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
  input[type="number"]::-webkit-outer-spin-button, input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

  /* multi-select specialization -> bottom sheet */
  .multi-select-dropdown.open .dropdown-content {
    position: fixed !important; left: 0 !important; right: 0 !important; top: auto !important; bottom: 0 !important;
    width: 100% !important; max-width: 100%; max-height: 65vh; max-height: 65dvh; z-index: 10000 !important;
    border-radius: var(--radius-sheet) var(--radius-sheet) 0 0; padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: var(--shadow-pop);
  }
  .dropdown-content label { min-height: 48px; padding: 0 var(--space-4); font-size: var(--text-md); }
  .dropdown-ok-btn { position: sticky; bottom: 0; margin: var(--space-2) var(--space-4) var(--space-3); min-height: 48px; width: calc(100% - 2 * var(--space-4)); }

  /* availability */
  .avail-checkboxes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; min-width: 0 !important; }
  .avail-checkboxes label { justify-content: center; min-height: 44px; border: 1px solid var(--border-default); border-radius: var(--radius-md); }
  .avail-select-all-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; min-width: 0 !important; margin-top: var(--space-2); }
  .btn-select-day { min-height: 40px; }
}

@media (max-width: 767px) {
#gaScheduleTable, #gaScheduleTable tbody, #gaScheduleTable tbody tr, #gaScheduleTable td { display: block; }
#gaScheduleTable { width: 100%; min-width: 0 !important; table-layout: auto; border: 0; background: none; }
#gaScheduleTable colgroup { display: none; }
#gaScheduleTable thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
#gaScheduleTable tbody { display: grid; gap: var(--space-3); }
#gaScheduleTable tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3) 12px; padding: var(--space-4); background: var(--card-bg); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); }
#gaScheduleTable td { padding: 0; border: 0; background: none; min-width: 0; text-align: left !important; white-space: normal; overflow-wrap: anywhere; font-size: var(--text-base); }
#gaScheduleTable td::before { display: block; margin-bottom: var(--space-1); font-size: var(--text-xs); font-weight: 600;   color: var(--text-muted); }
#gaScheduleTable td[colspan] { grid-column: 1 / -1; text-align: center !important; }
#gaScheduleTable td[colspan]::before { content: none; }
#gaScheduleTable td:nth-child(1)::before { content: none; }
#gaScheduleTable td:nth-child(2)::before { content: none; }
#gaScheduleTable td:nth-child(1) { grid-column: 1 / -1; }
#gaScheduleTable td:nth-child(2) { grid-column: 1 / -1; }
#gaScheduleTable td:nth-child(3) { grid-column: 1 / -1; }
#gaScheduleTable td:nth-child(9) { grid-column: 1 / -1; }
#gaScheduleTable td input[type="text"], #gaScheduleTable td input[type="number"], #gaScheduleTable td select, #gaScheduleTable td .dropdown-btn, #gaScheduleTable td .multi-select-dropdown { width: 100%; max-width: none !important; }
#gaScheduleTable td button.row-action-btn { width: 100%; min-height: 44px; }
#gaScheduleTable td:nth-child(1) { font-size: var(--text-md); font-weight: 600; }
#roomUtilCapTable, #roomUtilCapTable tbody, #roomUtilCapTable tbody tr, #roomUtilCapTable td { display: block; }
#roomUtilCapTable { width: 100%; min-width: 0 !important; table-layout: auto; border: 0; background: none; }
#roomUtilCapTable colgroup { display: none; }
#roomUtilCapTable thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
#roomUtilCapTable tbody { display: grid; gap: var(--space-3); }
#roomUtilCapTable tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3) 12px; padding: var(--space-4); background: var(--card-bg); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); }
#roomUtilCapTable td { padding: 0; border: 0; background: none; min-width: 0; text-align: left !important; white-space: normal; overflow-wrap: anywhere; font-size: var(--text-base); }
#roomUtilCapTable td::before { display: block; margin-bottom: var(--space-1); font-size: var(--text-xs); font-weight: 600;   color: var(--text-muted); }
#roomUtilCapTable td[colspan] { grid-column: 1 / -1; text-align: center !important; }
#roomUtilCapTable td[colspan]::before { content: none; }
#roomUtilCapTable td:nth-child(1)::before { content: none; }
#roomUtilCapTable td:nth-child(2)::before { content: "Assigned"; }
#roomUtilCapTable td:nth-child(3)::before { content: "Occupancy"; }
#roomUtilCapTable td:nth-child(4)::before { content: "Recommended cap"; }
#roomUtilCapTable td:nth-child(5)::before { content: "Max cap"; }
#roomUtilCapTable td:nth-child(1) { grid-column: 1 / -1; }
#roomUtilCapTable td input[type="text"], #roomUtilCapTable td input[type="number"], #roomUtilCapTable td select, #roomUtilCapTable td .dropdown-btn, #roomUtilCapTable td .multi-select-dropdown { width: 100%; max-width: none !important; }
#roomUtilCapTable td button.row-action-btn { width: 100%; min-height: 44px; }

#capacityDetailsTable, #capacityDetailsTable tbody, #capacityDetailsTable tbody tr, #capacityDetailsTable td { display: block; }
#capacityDetailsTable { width: 100%; min-width: 0 !important; table-layout: auto; border: 0; background: none; }
#capacityDetailsTable colgroup { display: none; }
#capacityDetailsTable thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
#capacityDetailsTable tbody { display: grid; gap: var(--space-3); }
#capacityDetailsTable tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3) 12px; padding: var(--space-4); background: var(--card-bg); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); }
#capacityDetailsTable td { padding: 0; border: 0; background: none; min-width: 0; text-align: left !important; white-space: normal; overflow-wrap: anywhere; font-size: var(--text-base); }
#capacityDetailsTable td::before { display: block; margin-bottom: var(--space-1); font-size: var(--text-xs); font-weight: 600;   color: var(--text-muted); }
#capacityDetailsTable td[colspan] { grid-column: 1 / -1; text-align: center !important; }
#capacityDetailsTable td[colspan]::before { content: none; }
#capacityDetailsTable td:nth-child(1)::before { content: "Room"; }
#capacityDetailsTable td:nth-child(2)::before { content: "Section"; }
#capacityDetailsTable td:nth-child(3)::before { content: "Subject"; }
#capacityDetailsTable td:nth-child(4)::before { content: "Students"; }
#capacityDetailsTable td:nth-child(5)::before { content: "Recommended"; }
#capacityDetailsTable td:nth-child(6)::before { content: "Maximum"; }
#capacityDetailsTable td:nth-child(7)::before { content: "Utilization"; }
#capacityDetailsTable td:nth-child(8)::before { content: "Status"; }
#capacityDetailsTable td:nth-child(3) { grid-column: 1 / -1; }
#capacityDetailsTable td:nth-child(8) { grid-column: 1 / -1; }
#capacityDetailsTable td input[type="text"], #capacityDetailsTable td input[type="number"], #capacityDetailsTable td select, #capacityDetailsTable td .dropdown-btn, #capacityDetailsTable td .multi-select-dropdown { width: 100%; max-width: none !important; }
#capacityDetailsTable td button.row-action-btn { width: 100%; min-height: 44px; }

.summary-assignments-table, .summary-assignments-table tbody, .summary-assignments-table tbody tr, .summary-assignments-table td { display: block; }
.summary-assignments-table { width: 100%; min-width: 0 !important; table-layout: auto; border: 0; background: none; }
.summary-assignments-table colgroup { display: none; }
.summary-assignments-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.summary-assignments-table tbody { display: grid; gap: var(--space-3); }
.summary-assignments-table tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3) 12px; padding: var(--space-4); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); }
.summary-assignments-table td { padding: 0; border: 0; background: none; min-width: 0; text-align: left !important; white-space: normal; overflow-wrap: anywhere; font-size: var(--text-base); }
.summary-assignments-table td::before { display: block; margin-bottom: var(--space-1); font-size: var(--text-xs); font-weight: 600;   color: var(--text-muted); }
.summary-assignments-table td[colspan] { grid-column: 1 / -1; text-align: center !important; }
.summary-assignments-table td[colspan]::before { content: none; }
.summary-assignments-table td:nth-child(1)::before { content: none; }
.summary-assignments-table td:nth-child(2)::before { content: "Schedule"; }
.summary-assignments-table td:nth-child(3)::before { content: "Room"; }
.summary-assignments-table td:nth-child(1) { grid-column: 1 / -1; }
.summary-assignments-table td input[type="text"], .summary-assignments-table td input[type="number"], .summary-assignments-table td select, .summary-assignments-table td .dropdown-btn, .summary-assignments-table td .multi-select-dropdown { width: 100%; max-width: none !important; }
.summary-assignments-table td button.row-action-btn { width: 100%; min-height: 44px; }
.summary-assignments-table tbody { padding: var(--space-3); }
.summary-assignments-table tbody tr { box-shadow: none; }
.summary-assignments-table td:nth-child(1) { font-weight: 600; }
#fairnessPerFaculty table, #fairnessPerFaculty table tbody, #fairnessPerFaculty table tbody tr, #fairnessPerFaculty table td { display: block; }
#fairnessPerFaculty table { width: 100%; min-width: 0 !important; table-layout: auto; border: 0; background: none; }
#fairnessPerFaculty table colgroup { display: none; }
#fairnessPerFaculty table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
#fairnessPerFaculty table tbody { display: grid; gap: var(--space-3); }
#fairnessPerFaculty table tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3) 12px; padding: var(--space-4); background: var(--card-bg); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); }
#fairnessPerFaculty table td { padding: 0; border: 0; background: none; min-width: 0; text-align: left !important; white-space: normal; overflow-wrap: anywhere; font-size: var(--text-base); }
#fairnessPerFaculty table td::before { display: block; margin-bottom: var(--space-1); font-size: var(--text-xs); font-weight: 600;   color: var(--text-muted); }
#fairnessPerFaculty table td[colspan] { grid-column: 1 / -1; text-align: center !important; }
#fairnessPerFaculty table td[colspan]::before { content: none; }
#fairnessPerFaculty table td:nth-child(1)::before { content: none; }
#fairnessPerFaculty table td:nth-child(2)::before { content: "Workload status"; }
#fairnessPerFaculty table td:nth-child(3)::before { content: "Total classes"; }
#fairnessPerFaculty table td:nth-child(4)::before { content: "Specialization accuracy"; }
#fairnessPerFaculty table td:nth-child(1) { grid-column: 1 / -1; }
#fairnessPerFaculty table td:nth-child(4) { grid-column: 1 / -1; }
#fairnessPerFaculty table td input[type="text"], #fairnessPerFaculty table td input[type="number"], #fairnessPerFaculty table td select, #fairnessPerFaculty table td .dropdown-btn, #fairnessPerFaculty table td .multi-select-dropdown { width: 100%; max-width: none !important; }
#fairnessPerFaculty table td button.row-action-btn { width: 100%; min-height: 44px; }
#fairnessPerFaculty table td:nth-child(1) { font-weight: 600; }
#facultyTable, #facultyTable tbody, #facultyTable tbody tr, #facultyTable td { display: block; }
#facultyTable { width: 100%; min-width: 0 !important; table-layout: auto; border: 0; background: none; }
#facultyTable colgroup { display: none; }
#facultyTable tbody { display: grid; gap: var(--space-3); }
#facultyTable tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3) 12px; padding: var(--space-4); background: var(--card-bg); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); }
#facultyTable td { padding: 0; border: 0; background: none; min-width: 0; text-align: left !important; white-space: normal; overflow-wrap: anywhere; font-size: var(--text-base); }
#facultyTable td::before { display: block; margin-bottom: var(--space-1); font-size: var(--text-xs); font-weight: 600;   color: var(--text-muted); }
#facultyTable td[colspan] { grid-column: 1 / -1; text-align: center !important; }
#facultyTable td[colspan]::before { content: none; }
#facultyTable td:nth-child(1)::before { content: "Name"; }
#facultyTable td:nth-child(2)::before { content: "Specialization"; }
#facultyTable td:nth-child(3)::before { content: "Max units"; }
#facultyTable td:nth-child(4)::before { content: "Overload buffer"; }
#facultyTable td:nth-child(5)::before { content: "Availability"; }
#facultyTable td:nth-child(6)::before { content: none; }
#facultyTable td:nth-child(1) { grid-column: 1 / -1; }
#facultyTable td:nth-child(2) { grid-column: 1 / -1; }
#facultyTable td:nth-child(5) { grid-column: 1 / -1; }
#facultyTable td:nth-child(6) { grid-column: 1 / -1; }
#facultyTable td input[type="text"], #facultyTable td input[type="number"], #facultyTable td select, #facultyTable td .dropdown-btn, #facultyTable td .multi-select-dropdown { width: 100%; max-width: none !important; }
#facultyTable td button.row-action-btn { width: 100%; min-height: 44px; }
#facultyTable thead { position: static; width: auto; height: auto; overflow: visible; clip: auto; display: block; margin-bottom: var(--space-3); }
#facultyTable thead tr { display: block; }
#facultyTable thead th { display: none; }
#facultyTable thead th.avail-th { display: block; padding: var(--space-3) var(--space-4); background: var(--bg-surface-2); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); }
#facultyTable thead .avail-th-label::after { content: " (apply to all faculty)"; font-weight: 400; color: var(--text-muted); text-transform: none; letter-spacing: 0; }
#subjectsTable, #subjectsTable tbody, #subjectsTable tbody tr, #subjectsTable td { display: block; }
#subjectsTable { width: 100%; min-width: 0 !important; table-layout: auto; border: 0; background: none; }
#subjectsTable colgroup { display: none; }
#subjectsTable thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
#subjectsTable tbody { display: grid; gap: var(--space-3); }
#subjectsTable tbody tr { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--space-3) 12px; padding: var(--space-4); background: var(--card-bg); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); }
#subjectsTable td { padding: 0; border: 0; background: none; min-width: 0; text-align: left !important; white-space: normal; overflow-wrap: anywhere; font-size: var(--text-base); }
#subjectsTable td::before { display: block; margin-bottom: var(--space-1); font-size: var(--text-xs); font-weight: 600;   color: var(--text-muted); }
#subjectsTable td[colspan] { grid-column: 1 / -1; text-align: center !important; }
#subjectsTable td[colspan]::before { content: none; }
#subjectsTable td:nth-child(1)::before { content: "Year"; }
#subjectsTable td:nth-child(2)::before { content: "Semester"; }
#subjectsTable td:nth-child(3)::before { content: "Subject name"; }
#subjectsTable td:nth-child(4)::before { content: "Type"; }
#subjectsTable td:nth-child(5)::before { content: "Lec units"; }
#subjectsTable td:nth-child(6)::before { content: "Lab units"; }
#subjectsTable td:nth-child(7)::before { content: "Total"; }
#subjectsTable td:nth-child(8)::before { content: none; }
#subjectsTable td:nth-child(1) { grid-column: span 3; }
#subjectsTable td:nth-child(2) { grid-column: span 3; }
#subjectsTable td:nth-child(3) { grid-column: span 6; }
#subjectsTable td:nth-child(4) { grid-column: span 6; }
#subjectsTable td:nth-child(5) { grid-column: span 2; }
#subjectsTable td:nth-child(6) { grid-column: span 2; }
#subjectsTable td:nth-child(7) { grid-column: span 2; }
#subjectsTable td:nth-child(8) { grid-column: span 6; }
#subjectsTable td input[type="text"], #subjectsTable td input[type="number"], #subjectsTable td select, #subjectsTable td .dropdown-btn, #subjectsTable td .multi-select-dropdown { width: 100%; max-width: none !important; }
#subjectsTable td button.row-action-btn { width: 100%; min-height: 44px; }
#subjectsTable td.total-cell { font-weight: 600; }
#classSizesTable, #classSizesTable tbody, #classSizesTable tbody tr, #classSizesTable td { display: block; }
#classSizesTable { width: 100%; min-width: 0 !important; table-layout: auto; border: 0; background: none; }
#classSizesTable colgroup { display: none; }
#classSizesTable thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
#classSizesTable tbody { display: grid; gap: var(--space-3); }
#classSizesTable tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3) 12px; padding: var(--space-4); background: var(--card-bg); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); }
#classSizesTable td { padding: 0; border: 0; background: none; min-width: 0; text-align: left !important; white-space: normal; overflow-wrap: anywhere; font-size: var(--text-base); }
#classSizesTable td::before { display: block; margin-bottom: var(--space-1); font-size: var(--text-xs); font-weight: 600;   color: var(--text-muted); }
#classSizesTable td[colspan] { grid-column: 1 / -1; text-align: center !important; }
#classSizesTable td[colspan]::before { content: none; }
#classSizesTable td:nth-child(1)::before { content: "Section"; }
#classSizesTable td:nth-child(2)::before { content: "Year"; }
#classSizesTable td:nth-child(3)::before { content: "Block"; }
#classSizesTable td:nth-child(4)::before { content: "Class size"; }
#classSizesTable td:nth-child(5)::before { content: none; }
#classSizesTable td:nth-child(5) { grid-column: 1 / -1; }
#classSizesTable td input[type="text"], #classSizesTable td input[type="number"], #classSizesTable td select, #classSizesTable td .dropdown-btn, #classSizesTable td .multi-select-dropdown { width: 100%; max-width: none !important; }
#classSizesTable td button.row-action-btn { width: 100%; min-height: 44px; }

}

/* ============================================================
   FLAT LAYOUT: white page, no big enclosing cards
   ============================================================ */
html, body:has(.top-navbar) { background: #fff; }
.panels-wrapper { background: #fff; padding-left: 0; padding-right: 0; }
.panel {
  background: transparent; border: 0; border-radius: 0; box-shadow: none;
  padding-left: max(var(--space-6), env(safe-area-inset-left, 0px));
  padding-right: max(var(--space-6), env(safe-area-inset-right, 0px));
}
.dashboard-chart-card, .dashboard-chart-card:hover,
.workload-result-card, .workload-result-card:hover,
.chart-card, .chart-card:hover {
  background: transparent !important; border: 0 !important; box-shadow: none !important;
  padding-left: 0; padding-right: 0; border-radius: 0;
}

/* ============================================================
   SCROLLBARS: easier to see and grab (desktop native)
   ============================================================ */
/* (scrollbar look: see the shared tokens in ui2-foundation.css) */

/* ============================================================
   TOUCH: draggable scroll handle (injected by script)
   ============================================================ */
.scroll-handle { display: none; }
@media (max-width: 767px), (pointer: coarse) {
  .panel { scrollbar-width: none; }
  .panel::-webkit-scrollbar { display: none; width: 0; }
  .panel { padding-left: max(var(--space-4), env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px)); }
  .scroll-handle {
    display: block; position: fixed; right: 0; width: 28px; z-index: 900; pointer-events: none;
    top: calc(var(--nav-h) + 6px); bottom: calc(6px + env(safe-area-inset-bottom, 0px));
    opacity: 0; transition: opacity 0.25s;
  }
  .scroll-handle.can { opacity: 0.5; }
  .scroll-handle.can.on, .scroll-handle.can.drag { opacity: 1; }
  .sh-thumb {
    position:  absolute;
    right:  3px;
    width:  5px;
    min-height:  40px;
    border-radius: 999px;
    pointer-events:  auto;
    touch-action:  none;
    background:  var(--border-strong);
    transition:  width 0.15s, background 0.15s;
  }
  .sh-thumb::before { content: ""; position: absolute; top: 0; bottom: 0; left: -10px; right: -10px; }
  .scroll-handle.drag .sh-thumb {
    width:  8px;
    background:  var(--clr-primary-500); }
}
@media (max-width: 520px) {
  .panel { padding-left: max(14px, env(safe-area-inset-left, 0px)); }
}

/* ============================================================
   MOBILE: long result lists collapse into named dropdowns
   ============================================================ */
.m-acc { display: none; }
@media (max-width: 767px) {
  .m-acc {
    display: flex; align-items: center; gap: var(--space-3); width: 100%; min-height: 52px;
    margin: var(--space-2) 0 var(--space-3); padding: 0 var(--space-4);
    background: var(--bg-surface-2); color: var(--text-primary);
    border: 1px solid var(--border-default); border-radius: var(--radius-lg);
    font-size: var(--text-md); font-weight: 600; text-align: left; box-shadow: none;
  }
  .m-acc:hover { background: var(--bg-surface-3); }
  .m-acc[hidden] { display: none; }
  .m-acc[aria-expanded="true"] { background: var(--clr-primary-50); border-color: var(--clr-primary-600); }
  .m-acc-title { flex: 1; min-width: 0; }
  .m-acc-count { min-width: 28px; padding: 2px var(--space-3); border-radius: var(--radius-sm); background: var(--clr-primary-50); color: var(--clr-primary-600); font-size: var(--text-sm); text-align: center; }
  .m-acc[aria-expanded="true"] .m-acc-count { background: #fff; }
  .m-acc-chev { width: 10px; height: 10px; margin: -4px 4px 0 0; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); transition: transform 0.2s; }
  .m-acc[aria-expanded="true"] .m-acc-chev { transform: rotate(-135deg); margin-top: 4px; }
  .m-closed { display: none !important; }

  /* curriculum groups: each year/semester is its own dropdown */
  .curriculum-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: 52px; cursor: pointer; }
  .curriculum-header::after { content: attr(data-count) "  \25BE"; font-size: var(--text-sm); font-weight: 600; color: var(--clr-primary-600); white-space: nowrap; }
  .curriculum-group.open .curriculum-header::after { content: attr(data-count) "  \25B4"; }
  .curriculum-group:not(.open) .curriculum-table { display: none; }
  .curriculum-table, .curriculum-table tbody, .curriculum-table tr, .curriculum-table td { display: block; width: 100%; min-width: 0; }
  .curriculum-table thead { display: none; }
  .curriculum-table tbody tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2) var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border-subtle); }
  .curriculum-table td { padding: 0; border: 0; text-align: left !important; font-size: var(--text-base); overflow-wrap: anywhere; }
  .curriculum-table td:nth-child(1), .curriculum-table td:nth-child(2) { grid-column: 1 / -1; }
  .curriculum-table td:nth-child(n+3)::before { display: block; font-size: var(--text-xs); font-weight: 600;   color: var(--text-muted); }
  .curriculum-table td:nth-child(3)::before { content: "Lec"; }
  .curriculum-table td:nth-child(4)::before { content: "Lab"; }
  .curriculum-table td:nth-child(5)::before { content: "Hours"; }
}

/* ============================================================
   MOBILE: button rows wrap instead of overflowing
   ============================================================ */
@media (max-width: 767px) {
  .panel div[style*="display:flex"] { flex-wrap: wrap !important; }
  .panel div[style*="display:flex"][style*="gap:10px"] { gap: var(--space-2) !important; }
  .panel div[style*="display:flex"][style*="gap:10px"] > .btn {
    flex: 1 1 calc(50% - var(--space-2)); min-width: 0; white-space: normal; text-align: center; justify-content: center;
  }
  .panel div[style*="display:flex"][style*="gap:10px"] > .btn:first-child { flex-basis: 100%; }
  .panel .btn { max-width: 100%; }
  .panel .btn[style*="padding:0.3rem"] { min-height: 44px; padding: 0.5rem 1rem !important; font-size: var(--text-base) !important; }
}

/* ============================================================
   LOGIN PAGE: role switch, tabs, conditional fields
   ============================================================ */
.login-back {
  display: inline-flex; align-items: center; min-height: 44px; margin-bottom: var(--space-1);
  font-size: var(--text-base); font-weight: 600; color: var(--text-muted); text-decoration: none;
}
.login-back:hover { color: var(--clr-primary-600); }

.role-switch { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); margin-bottom: var(--space-4); padding: 4px; background: var(--bg-surface-3); border-radius: var(--radius-lg); }
.seg-btn {
  min-height: 44px; background: transparent; color: var(--text-secondary);
  border: 0; border-radius: var(--radius-md); box-shadow: none; font-size: var(--text-base); font-weight: 600;
}
.seg-btn:hover { background: rgba(255, 255, 255, 0.6); }
.seg-btn.active { background: var(--bg-surface); color: var(--clr-primary-600); box-shadow: 0 0 0 1px var(--border-default); }

.auth-tabs { display: flex; margin-bottom: var(--space-4); border-bottom: 1px solid var(--border-subtle); }
.tab-btn {
  flex: 1; min-height: 44px; background: transparent; color: var(--text-muted);
  border: 0; border-bottom: 3px solid transparent; border-radius: 0; box-shadow: none; font-size: var(--text-base); font-weight: 600;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--clr-primary-600); border-bottom-color: var(--clr-primary-600); }

#authForm .only-faculty { display: block; }
#authForm[data-role="chairperson"] .only-faculty,
#authForm[data-role="faculty"] .only-chair,
#authForm[data-mode="signin"] .only-signup { display: none; }
.login-manual[hidden] { display: none; }

.login-card .login-field { margin-bottom: var(--space-4); }
.login-card .login-field input,
.login-card .login-field select,
.login-card .login-field .select-wrap { margin-bottom: 0; }
.login-card .login-field .login-manual { margin-top: var(--space-2); }

.pw-wrap { position: relative; }
.login-card .pw-wrap input { padding-right: 4.5rem; }
.pw-toggle {
  position: absolute; top: 50%; right: 4px; transform: translateY(-50%);
  min-height: 36px; padding: 0 0.75rem; background: transparent; color: var(--clr-primary-600);
  border: 0; box-shadow: none; font-size: var(--text-sm); font-weight: 600;
}
.login-card .btn-login-submit { min-height: 48px; margin-top: var(--space-2); }
@media (max-width: 520px) {
  .login-card input[type="text"], .login-card input[type="password"], .login-card select { font-size: var(--text-md); min-height: 44px; }
}

/* ============================================================
   FAMILIAR UI: icons, tooltips, status chips, empty states
   ============================================================ */
.nav-menu .nav-item { display: inline-flex; align-items: center; gap: 8px; }
.nav-ic { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.title-ic { width: 26px; height: 26px; flex-shrink: 0; fill: none; stroke: var(--clr-primary-600); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.page-header h2 { display: flex; align-items: center; gap: var(--space-3); }

.info-tip {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; margin-left: var(--space-2); border-radius: 50%;
  background: var(--clr-primary-50); color: var(--clr-primary-600);
  font-size: var(--text-xs); font-weight: 600; font-style: normal; letter-spacing: 0; text-transform: none; line-height: 1;
  cursor: help; vertical-align: middle;
}
.info-tip::after {
  content: attr(data-tip); position: absolute; left: -8px; bottom: calc(100% + 8px); z-index: 60;
  width: max-content; max-width: min(240px, 70vw); padding: 8px var(--space-3);
  background: var(--clr-gray-900); color: var(--text-inverse); border-radius: var(--radius-md);
  font-size: var(--text-sm); font-weight: 500; line-height: 1.4; text-align: left; white-space: normal;
  opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.15s;
}
.info-tip:hover::after, .info-tip:focus::after { opacity: 1; visibility: visible; }
.info-tip:focus { outline: none; box-shadow: var(--focus-ring); }

.status-chip {
  display: inline-flex; align-items: center; gap: var(--space-2); padding: 4px 12px; border-radius: var(--radius-sm);
  background: #dcfce7; color: #166534; font-size: var(--text-sm); font-weight: 600; white-space: nowrap;
}
.status-chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #22c55e; }

.empty-state-msg::before {
  content: ""; display: block; width: 40px; height: 40px; margin: 0 auto var(--space-2);
  background: no-repeat center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a89f94' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='22 12 16 12 14 15 10 15 8 12 2 12'/%3E%3Cpath d='M5.45 5.11L2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z'/%3E%3C/svg%3E");
}

.lp-pills { display: flex; flex-wrap: wrap; gap: var(--space-3); margin: 0 0 var(--space-5); padding: 0; list-style: none; }
.lp-pills li {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px var(--space-4); border-radius: var(--radius-sm);
  background: var(--clr-primary-50); color: var(--clr-primary-600); font-size: var(--text-base); font-weight: 600;
}
.lp-pill-ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lp-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.lp-cta.lp-cta-alt { background: var(--bg-surface); color: var(--clr-primary-600); border: 1px solid var(--clr-primary-400); box-shadow: none; }
.lp-cta.lp-cta-alt:hover { background: var(--clr-primary-50); }

/* ============================================================
   MOBILE NAVIGATION (<= 900px): top bar + bottom tab bar
   ============================================================ */
.bottom-nav { display: none; }

@media (max-width: 900px) {
  :root {
    --nav-h: calc(3.5rem + env(safe-area-inset-top, 0px));
    --bottom-nav-h: calc(3.5rem + env(safe-area-inset-bottom, 0px));
  }
  .top-navbar { flex-wrap: nowrap; align-content: center; height: var(--nav-h); }
  .nav-left { display: flex; align-items: center; gap: var(--space-2); flex: 1; min-width: 0; }
  .nav-brand-wrap { order: 0; height: auto; }
  .nav-menu { display: none; }
  .nav-right { display: flex; order: 2; height: auto; margin-left: auto; }

  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000; height: var(--bottom-nav-h);
    padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
    background: var(--bg-surface); border-top: 1px solid var(--border-subtle); box-shadow: none;
  }
  .bn-item {
    position: relative; flex: 1; min-width: 0; min-height: 0; padding: 0; gap: 2px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: transparent; color: var(--text-muted); border: 0; border-radius: 0; box-shadow: none;
    font-size: var(--text-xs); font-weight: 600;
  }
  .bn-item:hover { background: transparent; color: var(--text-primary); }
  .bn-item.active { color: var(--clr-primary-600); }
  .bn-item.active::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: var(--clr-primary-600); }
  .bn-ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

  .panels-wrapper { height: calc(100vh - var(--nav-h) - var(--bottom-nav-h)); height: calc(100dvh - var(--nav-h) - var(--bottom-nav-h)); }
  .panel { padding-bottom: var(--space-5); }
  .scroll-handle { bottom: calc(var(--bottom-nav-h) + 6px); }
  .toast-notif { bottom: calc(var(--bottom-nav-h) + var(--space-4)); }
}

@media (max-width: 900px) and (max-height: 480px) and (orientation: landscape) {
  :root { --nav-h: calc(3rem + env(safe-area-inset-top, 0px)); --bottom-nav-h: calc(3rem + env(safe-area-inset-bottom, 0px)); }
}

/* ============================================================
   ACCESSIBILITY AND FEEDBACK
   ============================================================ */
:focus-visible { outline: 2px solid var(--clr-primary-600); outline-offset: 2px; }
button:active:not(:disabled), .btn:active { filter: brightness(0.94); }

/* ============================================================
   FLAGSHIP THEME: calm status colors, neutral chips, tidy cards
   ============================================================ */
:root {
  --ok: #1f6a70;   --ok-soft: #e3f0f1;
  --warn: #8f5a12; --warn-soft: #fbf0dc;
  --bad: #a02f24;  --bad-soft: #f9e6e3;
  --chip-bg: #f3efea; --chip-text: #5a5047;
}

/* status pills */
.badge-ok, .badge-warn, .badge-hard, .units-badge, .capacity-overall-badge {
  display: inline-flex; align-items: center; gap: var(--space-2); padding: var(--space-1) var(--space-3); border: 0; border-radius: var(--radius-sm);
  font-size: var(--text-xs); font-weight: 600; line-height: 1.4; white-space: nowrap;
}
.badge-ok, .units-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn, .units-max { background: var(--warn-soft); color: var(--warn); }
.badge-hard, .units-over { background: var(--bad-soft); color: var(--bad); }
.match-yes { color: var(--ok); }
.match-partial { color: var(--warn); }
.match-no { color: var(--bad); }

/* class type: text with a dot */
.class-type-tag, .tt-class-tag {
  display: inline-flex; align-items: center; gap: var(--space-2); padding: 0; background: none; border: 0;
  font-size: var(--text-xs); font-weight: 600;   color: var(--ok);
}
.class-type-tag::before, .tt-class-tag::before { content: ""; border-radius: 50%; background: currentColor; }
.class-type-tag.lab, .tt-class-tag.lab { color: var(--clr-primary-600); }

/* neutral chips */
.section-badge, .room-badge, .student-count-tag, .subject-year-badge, .fac-assign-room, .fac-assign-section,
.tt-room-tag, .tt-section-tag, #gaScheduleTable .section-badge, .fac-assign-meta .section-badge {
  display: inline-flex; align-items: center; padding: 2px 8px; background: var(--chip-bg); color: var(--chip-text);
  border: 0; border-radius: var(--radius-md); font-family: var(--font-sans); font-size: var(--text-xs); font-weight: 600; white-space: nowrap;
}

/* time slots: plain text, no per-day colors */
.fac-assign-slot {
  display: inline-block; padding: 0; background: none; border: 0; border-radius: 0;
  font-family: var(--font-sans); font-size: var(--text-sm); font-weight: 500; color: var(--text-secondary);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* tables and timetable */
.timetable-grid thead th { color: var(--text-muted); }
.tt-cell.tt-filled { background: var(--card-bg); }
.tt-entry { background: var(--card-bg); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); }
.tt-faculty-tag { color: var(--clr-primary-600); }

/* capacity overview */
.capacity-ok, .capacity-warn, .capacity-hard, .capacity-total { background: var(--card-bg); border: 1px solid var(--border-subtle); }
.capacity-metric-tile { border-radius: var(--radius-lg); }
.capacity-ok .capacity-metric-value { color: var(--ok); }
.capacity-warn .capacity-metric-value { color: var(--warn); }
.capacity-hard .capacity-metric-value { color: var(--bad); }
.capacity-violations-list { background: var(--card-bg); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); overflow: hidden; }
.capacity-violations-header { background: var(--bad-soft); color: var(--bad); border-bottom: 0; }

/* schedule summary cards */
.fac-assign-card, .summary-faculty-card { background: var(--card-bg); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); }
.summary-fac-header { background: transparent; border-bottom: 1px solid var(--border-subtle); }
.btn-edit-faculty, .fac-assign-header .btn-edit-faculty {
  background: var(--clr-primary-50); color: var(--clr-primary-600); border: 0; box-shadow: none;
}
.btn-edit-faculty:hover, .fac-assign-header .btn-edit-faculty:hover { background: var(--clr-primary-100); color: var(--clr-primary-600); }

/* ============================================================
   MOBILE: app-style cards (rounded blocks, one hero card, pill buttons)
   ============================================================ */
@media (max-width: 767px) {
  .stats-row { grid-template-columns: 1fr 1fr; gap: var(--space-3); }
  .stat-card { display: block; padding: var(--space-4); background: var(--bg-surface-2); border: 0; border-radius: var(--radius-lg); }
  .stat-card .stat-value { margin: var(--space-1) 0; font-size: var(--text-stat); }
  .stats-row:not(.fs-stats) .stat-card:nth-child(3) { grid-column: 1 / -1; order: -1; background: var(--clr-primary-600); }
  .stats-row:not(.fs-stats) .stat-card:nth-child(3) .stat-value { font-size: var(--text-stat); color: #fff; }
  .stats-row:not(.fs-stats) .stat-card:nth-child(3) .stat-label,
  .stats-row:not(.fs-stats) .stat-card:nth-child(3) .stat-sub { color: var(--on-accent); }
  .capacity-metrics-grid { gap: var(--space-3); }
  .capacity-metric-tile { padding: var(--space-4); border: 0; background: var(--bg-surface-2); border-radius: var(--radius-lg); }
  .fac-assign-card, .summary-faculty-card { border: 0; background: var(--bg-surface-2); border-radius: var(--radius-lg); }
  .summary-assignments-table tbody tr, #gaScheduleTable tbody tr, #roomUtilCapTable tbody tr, #capacityDetailsTable tbody tr, #facultyTable tbody tr, #subjectsTable tbody tr, #classSizesTable tbody tr {
    border: 0; background: var(--bg-surface-2); border-radius: var(--radius-lg);
  }
  .summary-assignments-table tbody tr { background: var(--card-bg); }
  .btn, .btn-login-submit { border-radius: var(--radius-md); }
  .page-header h2 { font-size: var(--text-xl); }
}

/* ============================================================
   SCHEDULE SUMMARY (reports) AND EDIT MODAL: roomier layout
   ============================================================ */
.summary-assignments-table td { padding: 16px var(--space-4); vertical-align: middle; }
.summary-assignments-table th { padding-left: var(--space-4); padding-right: var(--space-4); }
.summary-subj-name { font-size: var(--text-base); font-weight: 600; color: var(--text-primary); }
.summary-subj-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: var(--space-2); }
.summary-slot-day { font-size: var(--text-base); font-weight: 600; color: var(--text-primary); }
.summary-slot-time { margin-top: 2px; font-size: var(--text-sm); color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.summary-room { font-size: var(--text-base); font-weight: 600; color: var(--text-primary); }
.summary-room-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: var(--space-2); }
.summary-students { font-size: var(--text-sm); color: var(--text-secondary); }

/* muted type dots */
.fac-assign-ct-dot { width: 6px; height: 6px; margin-top: var(--space-2); background: var(--border-default); }
.ct-dot-lecture { background: #a9c7c9; }
.ct-dot-lab { background: #e0b9a6; }
.class-type-tag::before, .tt-class-tag::before { width: 5px; height: 5px; opacity: 0.55; }

/* edit-assignment modal */
.modal-body { flex: 1; overflow-y: auto; }
.modal-assignment-list { gap: var(--space-4); max-height: none; overflow: visible; padding-right: 0; }
.modal-assign-row {
  position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4);
  padding: var(--space-4) var(--space-4); background: var(--bg-surface-2); border: 0; border-radius: var(--radius-lg);
}
.modal-assign-field { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.modal-assign-field > span { font-size: var(--text-xs); font-weight: 600;   color: var(--text-muted); }
.modal-assign-subject { grid-column: 1 / -1; margin-right: 44px; }
.modal-assign-row select { min-height: 44px; padding: 0.5rem 0.75rem; font-size: var(--text-base); border-radius: var(--radius-md); }
.modal-assign-delete { position: absolute; top: var(--space-3); right: var(--space-3); width: 36px; height: 36px; min-width: 0; min-height: 0; border-radius: 50%; }
@media (max-width: 520px) {
  .modal-assign-row { grid-template-columns: 1fr; padding: var(--space-4); }
  .modal-assign-subject { grid-column: auto; }
}

/* ============================================================
   NIGHT THEME (data-theme="dark", set by app-core.js)
   ============================================================ */
[data-theme="dark"] {
  color-scheme: dark;
  --clr-primary-50: #3a2218; --clr-primary-100: #4a2a1d; --clr-primary-200: #6b3a26; --clr-primary-300: #8a4a30;
  --clr-primary-600: #f08a5d; --clr-primary-700: #f7c2a8; --clr-primary-800: #ffdccb; --clr-gray-900: #f3ece4;
  --clr-accent-500: #f0b97a; --clr-accent-100: rgba(217, 146, 43, 0.4);
  --clr-success-100: rgba(34, 197, 94, 0.16); --clr-warning-100: rgba(217, 146, 43, 0.18); --clr-danger-100: rgba(239, 68, 68, 0.22);
  --clr-danger-500: #f87171;
  --btn-hover: #9a3608;
  --chart-ink: #f3ece4; --chart-tooltip-text: #1a130e; --chart-muted: #b8ac9f; --chart-grid: #3f352d; --chart-surface: #1f1914;
  --chart-ok: #4fb3bb; --chart-warn: #e8b25a; --chart-bad: #f08a7e;
  --chart-s1: #e8693a; --chart-s2: #4fb3bb; --chart-s3: #f0a47a; --chart-s4: #8aa0b3; --chart-s5: #e0b27a;
  --chart-s6: #9fcfd2; --chart-s7: #a99d90; --chart-s8: #c0440a; --chart-s9: #7fb0b3; --chart-s10: #e9c9a8;
  --bg-page: #17120f; --bg-white: #1f1914; --bg-surface: #1f1914; --bg-surface-2: #261f19; --bg-surface-3: #2e261f; --bg-subtle: #221b16;
  --bg-overlay: rgba(0, 0, 0, 0.6);
  --border-subtle: #352c25; --border: #4a3f35; --border-default: #4a3f35; --border-strong: #6b5e52;
  --text-primary: #f3ece4; --text-secondary: #cfc4b8; --text-muted: #a99d90; --text-inverse: #1a130e;
  --nav-bg: rgba(31, 25, 20, 0.96); --nav-border: rgba(74, 63, 53, 0.8); --nav-shadow: none;
  --card-bg: #1f1914; --input-bg: #261f19; --input-border: #4a3f35; --input-focus-ring: rgba(240, 138, 93, 0.28);
  --shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.55);
  --ok: #7fcfd5; --ok-soft: rgba(42, 127, 134, 0.24); --warn: #e8b25a; --warn-soft: rgba(217, 146, 43, 0.2);
  --bad: #f08a7e; --bad-soft: rgba(180, 55, 43, 0.28); --chip-bg: #2e261f; --chip-text: #d6cbbf;
}
html[data-theme="dark"], html[data-theme="dark"] body:has(.top-navbar), html[data-theme="dark"] .panels-wrapper { background: var(--bg-page); }
[data-theme="dark"] .btn-delete { color: #f58f86; }
[data-theme="dark"] .btn-delete:hover { color: #f19a93; }
[data-theme="dark"] .units-ok { color: #7ad9bb; }
[data-theme="dark"] .units-max { color: #f0b97a; }
[data-theme="dark"] .units-over { color: #f19a93; }
[data-theme="dark"] .error-msg { color: #f19a93; }
[data-theme="dark"] .badge-ok { color: #8fd9a8; }
[data-theme="dark"] .badge-warn { color: #f0b97a; }
[data-theme="dark"] .badge-hard { color: #f19a93; }
[data-theme="dark"] .viol-counts { color: #f19a93; }
[data-theme="dark"] html, [data-theme="dark"] body:has(.top-navbar) { background: var(--bg-page); }
[data-theme="dark"] .panels-wrapper { background: var(--bg-page); }
@media (max-width: 767px) { [data-theme="dark"] .m-acc[aria-expanded="true"] .m-acc-count { background: var(--bg-surface); } }
[data-theme="dark"] .status-chip { background: rgba(34, 197, 94, 0.18); }
[data-theme="dark"] .status-chip { color: #8fd9a8; }
[data-theme="dark"] .btn-edit-faculty:hover, [data-theme="dark"] .fac-assign-header .btn-edit-faculty:hover { background: var(--clr-primary-100); }

/* explicit solid accents stay readable in the night theme */
@media (max-width: 767px) {
  [data-theme="dark"] .stats-row:not(.fs-stats) .stat-card:nth-child(3),
  [data-theme="dark"] .stats-row:not(.fs-stats) .stat-card:nth-child(3) .stat-label,
  [data-theme="dark"] .stats-row:not(.fs-stats) .stat-card:nth-child(3) .stat-sub,
  [data-theme="dark"] .stats-row:not(.fs-stats) .stat-card:nth-child(3) .stat-value { color: var(--on-accent); }
}
[data-theme="dark"] .bn-item.active::before { background: var(--clr-primary-600); }
[data-theme="dark"] .btn, [data-theme="dark"] .btn-login-submit, [data-theme="dark"] .app-btn-primary { color: #fff; }

/* ============================================================
   PREFERENCES: text size and motion
   ============================================================ */
html[data-text="small"] { font-size: 13px; }
html[data-text="large"] { font-size: 16px; }
@media (max-width: 900px) { html[data-text="large"] { font-size: 17px; } }
html[data-motion="reduce"] *, html[data-motion="reduce"] *::before, html[data-motion="reduce"] *::after {
  animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important;
}

/* ============================================================
   TOP BAR: centered sticky navigation (desktop), back / title / menu (mobile)
   ============================================================ */
.nav-back, .nav-title, .nav-more { display: none; }

@media (min-width: 901px) {
  .top-navbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--space-4); }
  .nav-left { display: contents; }
  .nav-brand-wrap { justify-self: start; }
  .nav-menu { justify-self: center; }
  .nav-right { justify-self: end; }
}

@media (max-width: 900px) {
  .top-navbar {
    display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: var(--space-2);
    padding: env(safe-area-inset-top, 0px) max(var(--space-3), env(safe-area-inset-right, 0px)) 0 max(var(--space-3), env(safe-area-inset-left, 0px));
  }
  .nav-left, .nav-right { display: none; }
  .nav-back, .nav-more {
    display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; min-height: 0; padding: 0;
    background: transparent; color: var(--text-primary); border: 0; border-radius: 50%; box-shadow: none; text-decoration: none;
  }
  .nav-back:hover, .nav-more:hover { background: var(--bg-surface-3); }
  .nav-back.is-hidden { visibility: hidden; }
  .nav-back svg, .nav-more svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .nav-title { display: block; overflow: hidden; text-align: center; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-md); font-weight: 600; color: var(--text-primary); }
  }

/* ============================================================
   MOBILE GESTURES: swipe between sections, pull down to refresh
   ============================================================ */
.ptr { display: none; }
@media (max-width: 900px) {
  .panel { animation: none; touch-action: pan-y; overscroll-behavior: contain; }
  .ptr {
    display: flex; align-items: center; justify-content: center; position: fixed; z-index: 900;
    top: var(--nav-h); left: 50%; width: 36px; height: 36px; border-radius: 50%; opacity: 0; pointer-events: none;
    background: var(--bg-surface); color: var(--clr-primary-600); box-shadow: none;
    transform: translate3d(-50%, 0, 0) scale(0.6);
  }
  .ptr svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
  .ptr.spin svg { animation: ptr-spin 0.7s linear infinite; transform: none !important; }
}
@keyframes ptr-spin { to { transform: rotate(360deg); } }

/* Department notices and course flags */
.dept-notice { margin: 0 0 12px; padding: 8px 12px; font-size: var(--text-sm); color: var(--text-primary); background: var(--warn-soft, rgba(217, 146, 43, 0.14)); border-radius: var(--radius-lg); }
.dept-notice[hidden] { display: none; }
.course-flag { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; margin-left: var(--space-2); font-size: var(--text-xs); font-weight: 600; color: #fff; background: #d9922b; border-radius: 50%; cursor: help; vertical-align: middle; }
/* Coverage summary (Part 5) */
.coverage-summary { margin: 0 0 12px; padding: 8px 12px; border-radius: var(--radius-lg); font-size: var(--text-base); border: 1px solid var(--border, #d0d5dd); }
.coverage-summary.hidden { display: none; }
.coverage-summary.coverage-ok { border-color: #2e9e5b; }
.coverage-summary.coverage-warn { border-color: #d98a00; }
.coverage-summary details { margin-top: var(--space-2); }
.coverage-summary ul { margin: var(--space-2) 0 0 var(--space-4); padding: 0; }
.solver-summary { margin: 8px 0; font-size: var(--text-sm); color: var(--text-muted); text-align: center; }
/* ===== Icons: assets/images/icons/*.svg drawn as masks so they take the text colour (light and dark) ===== */
.ic { display: inline-block; flex-shrink: 0; background-color: currentColor; -webkit-mask: center / contain no-repeat; mask: center / contain no-repeat; }
.ic-dashboard { -webkit-mask-image: url("../images/icons/dashboard.svg"); mask-image: url("../images/icons/dashboard.svg"); }
.ic-optimize { -webkit-mask-image: url("../images/icons/optimize.svg"); mask-image: url("../images/icons/optimize.svg"); }
.ic-reports { -webkit-mask-image: url("../images/icons/reports.svg"); mask-image: url("../images/icons/reports.svg"); }
.ic-export { -webkit-mask-image: url("../images/icons/export.svg"); mask-image: url("../images/icons/export.svg"); }
.ic-charts { -webkit-mask-image: url("../images/icons/charts.svg"); mask-image: url("../images/icons/charts.svg"); }
.ic-fairness { -webkit-mask-image: url("../images/icons/fairness.svg"); mask-image: url("../images/icons/fairness.svg"); }
.ic-room-cap { -webkit-mask-image: url("../images/icons/room-cap.svg"); mask-image: url("../images/icons/room-cap.svg"); }
.ic-summary { -webkit-mask-image: url("../images/icons/summary.svg"); mask-image: url("../images/icons/summary.svg"); }
.ic-faculty { -webkit-mask-image: url("../images/icons/faculty.svg"); mask-image: url("../images/icons/faculty.svg"); }
.ic-reference { -webkit-mask-image: url("../images/icons/reference.svg"); mask-image: url("../images/icons/reference.svg"); }
.ic-help { -webkit-mask-image: url("../images/icons/help.svg"); mask-image: url("../images/icons/help.svg"); }
.ic-inputs { -webkit-mask-image: url("../images/icons/inputs.svg"); mask-image: url("../images/icons/inputs.svg"); }
.ic-rooms { -webkit-mask-image: url("../images/icons/rooms.svg"); mask-image: url("../images/icons/rooms.svg"); }
.ic-building { -webkit-mask-image: url("../images/icons/building.svg"); mask-image: url("../images/icons/building.svg"); }
.ic-back { -webkit-mask-image: url("../images/icons/back.svg"); mask-image: url("../images/icons/back.svg"); }
.ic-menu { -webkit-mask-image: url("../images/icons/menu.svg"); mask-image: url("../images/icons/menu.svg"); }
.ic-calendar { -webkit-mask-image: url("../images/icons/calendar.svg"); mask-image: url("../images/icons/calendar.svg"); }
.ic-refresh { -webkit-mask-image: url("../images/icons/refresh.svg"); mask-image: url("../images/icons/refresh.svg"); }
.title-ic.ic { background-color: var(--clr-primary-600); }
.dept-banner .ic { width: 20px; height: 20px; }
.nav-back .ic, .nav-more .ic { width: 24px; height: 24px; }
.ptr .ic { width: 20px; height: 20px; }
.ptr.spin .ic { animation: ptr-spin 0.7s linear infinite; transform: none !important; }

/* ---------- Saved runs (Part 17) ---------- */
.save-run-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin: 0 0 12px; padding: var(--space-3) 12px;
  border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); background: var(--bg-subtle); }
.save-run-bar.hidden { display: none; }
.save-run-bar label { font-weight: 600; color: var(--text-secondary); }
.save-run-bar input { flex: 1 1 220px; min-width: 0; padding: 8px var(--space-3); border: 1px solid var(--input-border); border-radius: var(--radius-lg);
  background: var(--input-bg); color: var(--text-primary); }
.run-banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-lg); border: 1px solid #d97706; background: rgba(217, 119, 6, 0.14); color: var(--text-primary); font-weight: 600; }
.run-banner.hidden { display: none; }
.ref-run-box { display: flex; flex-direction: column; gap: var(--ui-sp-2); width: 100%; margin: 0 0 var(--ui-sp-3); padding: var(--ui-sp-3);
  border-radius: var(--radius-lg); background: var(--ui-info-bg); color: var(--ui-info-fg); text-align: left; }
.ref-run-box.hidden { display: none; }
.ref-run-chip { display: flex; align-items: flex-start; gap: var(--ui-sp-2); font-size: var(--ui-fs-2); }
.ref-run-chip .ic { flex-shrink: 0; width: 1.125rem; height: 1.125rem; margin-top: 0.15rem; }
.ref-run-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; line-height: 1.35; padding-top: 0.1rem; }
.ref-run-lead { font-weight: 500; }
.ref-run-name { font-weight: 700; }
.ref-run-clear { flex-shrink: 0; min-height: 44px; margin: -0.6rem -0.5rem -0.6rem 0; padding: 0 var(--ui-sp-3); border: 0; background: none; color: inherit;
  font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; border-radius: var(--radius-md); box-shadow: none; transform: none; filter: none; }
.ref-run-box .ref-run-clear:hover, .ref-run-box .ref-run-clear:active, .ref-run-box .ref-run-clear:focus { background: none; color: inherit; border: 0; box-shadow: none; filter: none; transform: none; }
.ref-run-box .ref-run-clear:hover { text-decoration-thickness: 2px; }
.ref-run-box .ref-run-clear:focus-visible, .ref-run-stable:has(input:focus-visible) { outline: 2px solid currentColor; outline-offset: 2px; }
.ref-run-stable { display: flex; align-items: center; gap: var(--ui-sp-2); min-height: 44px; font-size: var(--ui-fs-2); font-weight: 500; cursor: pointer; border-radius: var(--radius-md); }
.ref-run-stable input { flex-shrink: 0; width: 1.25rem; height: 1.25rem; margin: 0; accent-color: var(--ui-info-fg); }
.run-start-tag { display: block; width: fit-content; margin-top: 4px; padding: 1px var(--ui-sp-2); border-radius: var(--radius-md);
  background: var(--ui-info-bg); color: var(--ui-info-fg); font-size: var(--text-sm); font-weight: 600; }
/* DIFF-01: pick two saved runs and compare them */
.run-pick { display: flex; width: fit-content; align-items: center; gap: var(--ui-sp-2); min-height: 44px; margin-top: var(--ui-sp-1); font-weight: 500; font-size: var(--text-sm); cursor: pointer; }
.run-pick input { flex-shrink: 0; width: 1.25rem; height: 1.25rem; margin: 0; accent-color: var(--ui-info-fg); }
.run-pick:has(input:focus-visible) { outline: 2px solid currentColor; outline-offset: 2px; border-radius: var(--radius-md); }
.run-compare-bar { display: flex; align-items: center; flex-wrap: wrap; gap: var(--ui-sp-2) var(--ui-sp-3); margin: 0 0 var(--space-3); }
.run-compare-bar[hidden] { display: none; }
.run-compare-text { flex: 1 1 14rem; min-width: 0; margin: 0; font-size: var(--ui-fs-2); color: var(--text-secondary); overflow-wrap: anywhere; }
.run-compare-bar .btn { min-height: 44px; }
.run-diff-runs { display: flex; flex-direction: column; gap: var(--ui-sp-1); margin: 0 0 var(--ui-sp-3); font-size: var(--ui-fs-2); overflow-wrap: anywhere; }
.run-diff-counts { display: flex; flex-wrap: wrap; gap: var(--ui-sp-2); margin: 0 0 var(--ui-sp-4); padding: 0; list-style: none; }
.run-diff-counts li { padding: var(--ui-sp-1) var(--ui-sp-3); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); font-size: var(--ui-fs-2); }
.run-diff-n { font-weight: 700; font-variant-numeric: tabular-nums; }
.run-diff-none { margin: 0; font-size: var(--ui-fs-2); color: var(--text-secondary); }
.run-diff-group { margin: 0 0 var(--ui-sp-4); }
.run-diff-group h3 { margin: 0 0 var(--ui-sp-2); font-size: var(--text-base); overflow-wrap: anywhere; }
.run-diff-count { font-size: var(--ui-fs-1); font-weight: 500; color: var(--text-muted); }
.run-diff-group ul { margin: 0; padding: 0; list-style: none; }
.run-diff-group li { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--ui-sp-1) var(--ui-sp-2); padding: var(--ui-sp-2) 0; border-bottom: 1px solid var(--border-subtle); font-size: var(--ui-fs-2); }
.run-diff-what { font-weight: 600; overflow-wrap: anywhere; }
.run-diff-text { flex: 1 1 100%; min-width: 0; color: var(--text-secondary); overflow-wrap: anywhere; }
.saved-runs-card { margin-top: var(--space-5); padding: 16px; border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); background: var(--card-bg); }
.saved-runs-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.saved-runs-head h3 { margin: 0; }
.saved-runs-scroll { max-height: 440px; overflow: auto; }
#savedRunsTable { width: 100%; border-collapse: collapse; min-width: 720px; }
#savedRunsTable th, #savedRunsTable td { padding: 8px var(--space-3); text-align: left; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
#savedRunsTable thead th { position: sticky; top: 0; background: var(--card-bg); z-index: 1; }
#savedRunsTable tbody tr.run-on-screen td, #savedRunsTable tbody tr.run-on-screen:hover td { background: var(--bg-subtle); }
.run-label { font-weight: 600; max-width: 240px; overflow-wrap: anywhere; }
.run-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); min-height: 30px; align-items: center; }
.run-none { font-size: var(--text-sm); color: var(--text-muted); }
#savedRunsTable tbody tr, #savedRunsTable tbody td { background: transparent; }
#savedRunsTable tbody tr:hover td { background: var(--bg-surface-2); }
.run-actions .btn { padding: 4px var(--space-3); font-size: var(--text-sm); }
.run-badge { display: inline-block; padding: 2px var(--space-3); border-radius: var(--radius-sm); font-size: var(--text-xs); font-weight: 600; border: 1px solid currentColor; }
.run-draft { color: #78716c; background: rgba(120, 113, 108, 0.14); }
.run-saved { color: #2563eb; background: rgba(37, 99, 235, 0.14); }
.run-approved { color: #16a34a; background: rgba(22, 163, 74, 0.16); }
/* ============================================================
   UI POLISH: saved runs on phones, one spinner, smooth motion, menu entrance
   (every colour is a theme variable, so the night theme follows)
   ============================================================ */
@keyframes atlas-spin { to { transform: rotate(360deg); } }
@keyframes atlas-rise { from { opacity: 0; transform: translate3d(0, 14px, 0); } to { opacity: 1; transform: none; } }
@keyframes atlas-slide-in { from { opacity: 0; transform: translate3d(28px, 0, 0); } to { opacity: 1; transform: none; } }
@keyframes atlas-fade { from { opacity: 0; } to { opacity: 1; } }

html { -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
@media (pointer: coarse) { html, body { overscroll-behavior-y: none; } }
button, .btn, [role="button"], a, label, select, summary { touch-action: manipulation; }
.btn, .app-btn, .app-nav-link, .auth-btn { transition: transform 0.15s ease, background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease; }
.btn:active:not(:disabled), .app-btn:active:not(:disabled), .auth-btn:active:not(:disabled) { transform: scale(0.97); }
.app-nav-link:active { transform: scale(0.985); }
:focus-visible { outline: 2px solid var(--clr-primary-500); outline-offset: 2px; }
button:disabled, .btn:disabled { cursor: not-allowed; }

/* the same ring as the optimization spinner, for buttons that are working */
.is-busy::before {
  content: ""; display: inline-block; width: 14px; height: 14px; margin-right: 8px; vertical-align: -2px; box-sizing: border-box;
  border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: atlas-spin 0.7s linear infinite;
}
.spinner-sm { display: inline-block; width: 18px; height: 18px; box-sizing: border-box; border: 2.5px solid var(--border-default); border-top-color: var(--clr-primary-500); border-radius: 50%; animation: atlas-spin 0.8s linear infinite; vertical-align: -4px; }

/* pull to refresh: the ring spins while the page refreshes, then "Refreshed" confirms it */
.ptr.spin .ic { display: none; }
.ptr.spin::after {
  content: ""; width: 20px; height: 20px; box-sizing: border-box; border: 2.5px solid var(--border-default);
  border-top-color: var(--clr-primary-500); border-radius: 50%; animation: atlas-spin 0.7s linear infinite;
}
.ptr-done {
  position: fixed; z-index: 900; left: 50%; top: calc(var(--nav-h, 56px) + 10px); padding: var(--space-2) 16px; border-radius: 999px;
  font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); background: var(--bg-surface); border: 1px solid var(--border-subtle);
  box-shadow: none; opacity: 0; transform: translate3d(-50%, -10px, 0); transition: opacity 0.3s ease, transform 0.3s ease; pointer-events: none;
}
.ptr-done.on { opacity: 1; transform: translate3d(-50%, 0, 0); }

/* saved runs: pointer-friendly hidden table and a card list on phones */
#savedRunsTable[hidden] { display: none; }
.run-actions .btn { min-height: 34px; }
@media (max-width: 767px) {
  .saved-runs-card { padding: var(--space-4); border-radius: var(--radius-lg); }
  .saved-runs-head { flex-wrap: wrap; }
  .saved-runs-scroll { max-height: 70vh; max-height: 70dvh; overflow-x: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
  #savedRunsTable { display: block; width: 100%; min-width: 0; }
  #savedRunsTable thead { display: none; }
  #savedRunsTable tbody { display: flex; flex-direction: column; gap: var(--space-3); }
  #savedRunsTable tbody tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-2) 12px; align-items: start; padding: 12px;
    border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); background: var(--bg-surface-2);
    transition: background-color 0.25s ease, border-color 0.25s ease;
  }
  #savedRunsTable tbody tr.run-on-screen { background: var(--bg-subtle); border-color: var(--clr-primary-300); }
  #savedRunsTable tbody tr td,
  #savedRunsTable tbody tr:hover td,
  #savedRunsTable tbody tr.run-on-screen td,
  #savedRunsTable tbody tr.run-on-screen:hover td { padding: 0; border: 0; background: transparent; }
  #savedRunsTable td.run-label { grid-column: 1; grid-row: 1; max-width: none; font-size: var(--text-base); line-height: 1.3; }
  #savedRunsTable td:nth-child(6) { grid-column: 2; grid-row: 1; justify-self: end; }
  #savedRunsTable td[data-label] {
    grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
    font-size: var(--text-sm); color: var(--text-secondary); text-align: right;
  }
  #savedRunsTable td[data-label]::before { content: attr(data-label); flex: none; color: var(--text-muted); font-weight: 600; text-align: left; }
  #savedRunsTable td:last-child { grid-column: 1 / -1; margin-top: var(--space-2); }
  .run-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(78px, 1fr)); gap: 8px; }
  .run-actions .btn { width: 100%; min-height: 42px; justify-content: center; }
  .run-none { text-align: center; padding: 8px 0; }
  input, select, textarea { font-size: var(--text-md); }           /* stops the phone zooming in on focus */
}

/* menu page: the list slides in and each row rises one after the other */
@media (max-width: 900px) {
  body[data-page="menu"] .app-shell { animation: atlas-slide-in 0.38s var(--ease-ui, cubic-bezier(0.4, 0, 0.2, 1)) both; }
  body[data-page="menu"] .app-nav-link { animation: atlas-rise 0.46s var(--ease-ui, cubic-bezier(0.4, 0, 0.2, 1)) both; }
  body[data-page="menu"] .app-nav-link:nth-child(1) { animation-delay: 0.04s; }
  body[data-page="menu"] .app-nav-link:nth-child(2) { animation-delay: 0.08s; }
  body[data-page="menu"] .app-nav-link:nth-child(3) { animation-delay: 0.12s; }
  body[data-page="menu"] .app-nav-link:nth-child(4) { animation-delay: 0.16s; }
  body[data-page="menu"] .app-nav-link:nth-child(5) { animation-delay: 0.2s; }
  body[data-page="menu"] .app-nav-link:nth-child(6) { animation-delay: 0.24s; }
  body[data-page="menu"] .app-nav-link:nth-child(n+7) { animation-delay: 0.28s; }
  body[data-page="menu"] .app-top { animation: atlas-fade 0.3s ease both; }
}
body.page-app:not([data-page="menu"]) .app-card { animation: atlas-rise 0.4s var(--ease-ui, cubic-bezier(0.4, 0, 0.2, 1)) both; }
body.page-app:not([data-page="menu"]) .app-card:nth-of-type(2) { animation-delay: 0.05s; }
body.page-app:not([data-page="menu"]) .app-card:nth-of-type(3) { animation-delay: 0.1s; }
body.page-app:not([data-page="menu"]) .app-card:nth-of-type(n+4) { animation-delay: 0.14s; }
.saved-runs-card, .stat-card { transition: box-shadow 0.25s ease, border-color 0.25s ease; }

html[data-motion="reduce"] *, html[data-motion="reduce"] *::before, html[data-motion="reduce"] *::after { animation-duration: 0.001ms !important; animation-delay: 0s !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
html[data-motion="reduce"] .spinner, html[data-motion="reduce"] .ptr.spin::after, html[data-motion="reduce"] .is-busy::before, html[data-motion="reduce"] .spinner-sm { animation-duration: 1.2s !important; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }


/* a hidden tooltip must not widen the page (application pages) */
.info-tip::after { display: none; }
.info-tip:hover::after, .info-tip:focus::after { display: block; }
.info-tip::after { max-width: min(240px, calc(100vw - 48px)); }
.app-shell, .app-content { min-width: 0; }
/* Part 24: a professor with no specialization (only electives can be assigned) */
#facultyTable tbody tr.no-specialization { background: rgba(217, 119, 6, 0.10); }
#facultyTable .spec-hint { margin-top: 4px; font-size: var(--text-xs); color: #b45309; }
[data-theme="dark"] #facultyTable .spec-hint { color: #fbbf24; }

/* ============================================================
   UI-1 FOUNDATION (see ATLAS_UI_Spec.md)
   ============================================================ */
/* UI tokens */
:root {
  --ui-sp-1: var(--space-1); --ui-sp-2: var(--space-2); --ui-sp-3: var(--space-3); --ui-sp-4: var(--space-4); --ui-sp-5: var(--space-5); --ui-sp-6: var(--space-6);
  --ui-fs-1: var(--text-xs); --ui-fs-2: var(--text-base); --ui-fs-3: var(--text-md); --ui-fs-4: var(--text-lg); --ui-fs-5: var(--text-xl); --ui-fs-6: var(--text-stat);
  --ui-radius: var(--radius-md); --ui-radius-lg: var(--radius-lg);
  --ui-shadow-1: none;
  --ui-shadow-2: var(--shadow-pop);
  --ui-success-bg: #e3f3e8; --ui-success-fg: #1c5b33;
  --ui-warning-bg: #fbf0dc; --ui-warning-fg: #7a4d0c;
  --ui-danger-bg:  #f9e6e3; --ui-danger-fg:  #8f271d;
  --ui-info-bg:    #e3f0f1; --ui-info-fg:    #17585e;
  --ui-ease: 160ms ease;
}
[data-theme="dark"] {
  --ui-success-bg: rgba(34, 197, 94, 0.18); --ui-success-fg: #8fd9a8;
  --ui-warning-bg: rgba(217, 146, 43, 0.2); --ui-warning-fg: #f0b97a;
  --ui-danger-bg:  rgba(180, 55, 43, 0.28); --ui-danger-fg:  #f4a39a;
  --ui-info-bg:    rgba(42, 127, 134, 0.24); --ui-info-fg:    #9fd6db;
}

.ui-card { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--ui-radius-lg); box-shadow: none; padding: var(--ui-sp-4); }
.ui-chip { display: inline-flex; align-items: center; gap: var(--ui-sp-1); padding: 2px var(--ui-sp-2); border-radius: var(--radius-md); background: var(--chip-bg); color: var(--chip-text); font-size: var(--ui-fs-1); font-weight: 600; line-height: 1.5; white-space: nowrap; }
.ui-chip.is-success { background: var(--ui-success-bg); color: var(--ui-success-fg); }
.ui-chip.is-warning { background: var(--ui-warning-bg); color: var(--ui-warning-fg); }
.ui-chip.is-danger { background: var(--ui-danger-bg); color: var(--ui-danger-fg); }
.ui-chip.is-info { background: var(--ui-info-bg); color: var(--ui-info-fg); }
.ui-row { display: flex; align-items: center; gap: var(--ui-sp-3); padding: var(--ui-sp-3) 0; border-bottom: 1px solid var(--border-subtle); font-size: var(--ui-fs-2); min-width: 0; }
.ui-row:last-child { border-bottom: 0; }
.ui-row .ui-num { margin-left: auto; text-align: right; font-variant-numeric: tabular-nums; }

.ui-state { display: flex; flex-direction: column; align-items: flex-start; gap: var(--ui-sp-2); padding: var(--ui-sp-4); color: var(--text-secondary); font-size: var(--ui-fs-2); }
.ui-state p { margin: 0; }
.ui-state.is-error { background: var(--ui-danger-bg); color: var(--ui-danger-fg); border-radius: var(--ui-radius); }
.ui-skeleton { display: flex; flex-direction: column; gap: var(--ui-sp-3); padding: var(--ui-sp-4); }
.ui-skeleton span { display: block; height: 14px; border-radius: var(--ui-radius); background: var(--bg-surface-3); animation: ui-pulse 1.4s ease-in-out infinite; }
.ui-skeleton span:nth-child(2) { width: 80%; }
.ui-skeleton span:nth-child(3) { width: 60%; }
@keyframes ui-pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

.ui-capped-head { display: flex; align-items: center; flex-wrap: wrap; gap: var(--ui-sp-2) var(--ui-sp-3); margin-bottom: var(--ui-sp-2); font-size: var(--ui-fs-2); color: var(--text-secondary); }
.ui-capped-head .ui-capped-count { font-variant-numeric: tabular-nums; }
.ui-capped-head .ui-capped-filter { flex: 1 1 140px; max-width: 240px; min-height: var(--ctl-min, 2.75rem); padding: 0 var(--ui-sp-3); font: inherit; color: var(--text-primary); background: var(--input-bg, var(--bg-surface)); border: 1px solid var(--border-input, var(--border)); border-radius: var(--ui-radius); }
.btn-ghost { background: transparent; color: var(--text-primary); border: 1px solid transparent; }
.btn-ghost:hover { background: var(--bg-surface-3); }
.btn-danger { background: var(--ui-danger-fg); color: var(--bg-surface); border: 1px solid transparent; }
.ui-capped-toggle { min-height: 44px; margin-top: var(--ui-sp-2); }
@media (min-width: 768px) { .ui-capped-toggle { min-height: 36px; } }

.ui-sheet-ov { position: fixed; inset: 0; z-index: 2147483000; background: var(--bg-overlay); opacity: 0; transition: opacity var(--ui-ease); }
.ui-sheet-ov.on { opacity: 1; }
.ui-sheet { position: fixed; z-index: 2147483001; display: flex; flex-direction: column; background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-pop); outline: 0;
  left: 0; right: 0; bottom: 0; max-height: 88vh; border-radius: var(--radius-sheet) var(--radius-sheet) 0 0; transform: translateY(100%); transition: transform 200ms ease; padding-bottom: env(safe-area-inset-bottom, 0px); }
.ui-sheet.on { transform: none; }
@media (min-width: 768px) {
  .ui-sheet { left: auto; top: 0; bottom: 0; width: min(440px, 100vw); max-height: none; border-radius: var(--radius-lg) 0 0 var(--radius-lg); transform: translateX(100%); padding-bottom: 0; }
}
.ui-sheet-head { display: flex; align-items: center; gap: var(--ui-sp-3); padding: var(--ui-sp-4); border-bottom: 1px solid var(--border-subtle); }
.ui-sheet-title { flex: 1; margin: 0; font-size: var(--ui-fs-4); font-weight: 600; }
.ui-sheet-close { min-width: 44px; min-height: 44px; }
.ui-sheet-body { flex: 1; overflow: auto; padding: var(--ui-sp-4); }

@media (prefers-reduced-motion: reduce) {
  .ui-sheet, .ui-sheet-ov, .ui-skeleton span { transition: none; animation: none; }
}
html[data-motion="reduce"] .ui-sheet, html[data-motion="reduce"] .ui-sheet-ov, html[data-motion="reduce"] .ui-skeleton span { transition: none; animation: none; }


/* ============================================================
   UI-8: period chip, step guide, reports charts
   ============================================================ */
.period-chip { display: inline-flex; align-items: center; gap: var(--ui-sp-2); min-height: 44px; max-width: 100%; padding: 0 var(--ui-sp-3); border-radius: var(--radius-md); background: var(--ui-info-bg); color: var(--ui-info-fg); font-size: var(--ui-fs-2); font-weight: 600; text-decoration: none; }
.period-chip[hidden] { display: none; }
.period-chip-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.period-chip-change { flex-shrink: 0; padding-left: var(--ui-sp-2); border-left: 1px solid currentColor; text-decoration: underline; }
.period-chip:hover .period-chip-change { text-decoration-thickness: 2px; }
.period-chip:focus-visible { outline: 2px solid var(--clr-primary-500); outline-offset: 2px; }

.step-guide { margin: 0 0 var(--ui-sp-4); padding: var(--ui-sp-4); background: var(--card-bg); border: 1px solid var(--border-subtle); border-radius: var(--ui-radius-lg); }
.step-guide-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--ui-sp-3); margin-bottom: var(--ui-sp-3); }
.step-guide-head h3 { margin: 0; padding: 0; border: 0; font-size: var(--ui-fs-4); }
.step-guide-sub { margin: var(--ui-sp-1) 0 0; font-size: var(--ui-fs-2); color: var(--text-secondary); }
.step-bar { height: 8px; margin-bottom: var(--ui-sp-4); border-radius: var(--radius-sm); background: var(--bg-surface-3); overflow: hidden; }
.step-bar-fill { height: 100%; width: 0; background: var(--clr-primary-500); transition: width 160ms ease; }
.step-list { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--ui-sp-3); margin: 0; padding: 0; list-style: none; }
.step-card { display: flex; flex-direction: column; align-items: flex-start; gap: var(--ui-sp-2); min-width: 0; padding: var(--ui-sp-3); border: 1px solid var(--border-subtle); border-radius: var(--ui-radius-lg); background: var(--bg-surface-2); }
.step-card.is-current { border-color: var(--clr-primary-500); background: var(--card-bg); }
.step-mark { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--border-strong); font-size: var(--ui-fs-1); font-weight: 600; color: var(--text-secondary); }
.step-card.is-done .step-mark { background: var(--ui-success-bg); border-color: var(--ui-success-fg); color: var(--ui-success-fg); }
.step-card.is-current .step-mark { border-color: var(--clr-primary-500); color: var(--clr-primary-600); }
.step-title { margin: 0; font-size: var(--ui-fs-2); font-weight: 600; color: var(--text-primary); }
.step-desc { margin: 0; font-size: var(--ui-fs-2); line-height: 1.4; color: var(--text-secondary); overflow-wrap: anywhere; }
.step-note { margin: 0; padding: var(--ui-sp-1) var(--ui-sp-2); border-radius: var(--ui-radius); background: var(--ui-warning-bg); color: var(--ui-warning-fg); font-size: var(--ui-fs-1); font-weight: 600; }
.step-card .btn { margin-top: auto; min-height: 44px; width: 100%; }
@media (min-width: 768px) { .step-card .btn { min-height: 36px; } }
@media (max-width: 1100px) { .step-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .step-list { grid-template-columns: 1fr; } .step-guide-head { flex-direction: column; } }

.reports-charts-grid { align-items: start; }
.chart-sub { margin: calc(-1 * var(--ui-sp-2)) 0 var(--ui-sp-3); font-size: var(--ui-fs-2); color: var(--text-secondary); }
.chart-sub:empty { display: none; }
.reports-charts-grid .chart-card { min-width: 0; }
.reports-charts-grid .chart-card .chart-canvas-wrap { height: 360px; }
.reports-charts-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.donut-wrap { display: flex; flex-direction: column; align-items: center; gap: var(--ui-sp-3); }
.donut-wrap.ui-hide { display: none; }
.donut-canvas { position: relative; width: min(100%, 260px); aspect-ratio: 1; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; text-align: center; }
.donut-center strong { font-size: var(--ui-fs-6); line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.donut-center span { font-size: var(--ui-fs-1); color: var(--text-secondary); }
.fit-legend { display: grid; gap: var(--ui-sp-1); width: 100%; margin: 0; padding: 0; list-style: none; }
.fit-legend li { display: flex; align-items: center; gap: var(--ui-sp-2); min-height: 28px; font-size: var(--ui-fs-2); color: var(--text-primary); }
.fit-legend .fit-count { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.fit-swatch { flex-shrink: 0; width: 12px; height: 12px; background: var(--sw); }
.fit-swatch.is-fits { border-radius: 50%; }
.fit-swatch.is-above { border-radius: var(--radius-sm); }
.fit-swatch.is-over { transform: rotate(45deg) scale(0.9); }
#reportsFitState:empty { display: none; }
@media (max-width: 900px) { .reports-charts-grid { grid-template-columns: 1fr; } .reports-charts-grid .chart-card .chart-canvas-wrap { height: 320px; } }

.result-heading { margin: 0 0 var(--ui-sp-2); font-size: var(--ui-fs-3); font-weight: 600; color: var(--text-primary); }
.result-coverage { margin: 0 0 var(--ui-sp-3); padding: var(--ui-sp-2) var(--ui-sp-3); border: 1px solid var(--ui-success-fg); border-radius: var(--ui-radius); font-size: var(--ui-fs-2); color: var(--text-primary); }
.result-coverage.is-incomplete { border-color: var(--ui-warning-fg); }
.check-filter { margin-top: var(--ui-sp-1); padding: 0; min-height: 44px; font: inherit; font-size: var(--ui-fs-2); font-weight: 600; color: inherit; background: none; border: 0; text-decoration: underline; cursor: pointer; }
@media (min-width: 768px) { .check-filter { min-height: 28px; } }
.check-filter:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
/* ============================================================
   UI-3: results and reports presentation
   ============================================================ */
.ui-hide { display: none !important; }
.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; }

/* Result header */
.result-head { margin-bottom: var(--ui-sp-4); }
.result-head h3 { margin: 0; padding: 0; }
.result-period, .result-meta { margin: var(--ui-sp-1) 0 0; font-size: var(--ui-fs-2); color: var(--text-secondary); }
.result-period:empty, .result-meta:empty { display: none; }

/* One row of checks */
.result-checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--ui-sp-3); margin: 0 0 var(--ui-sp-4); }
.result-checks.hidden { display: none; }
.check-card { display: flex; flex-direction: column; align-items: flex-start; gap: var(--ui-sp-1); padding: var(--ui-sp-3) var(--ui-sp-4); border-radius: var(--ui-radius-lg); min-width: 0; }
.check-card.is-success { background: var(--ui-success-bg); color: var(--ui-success-fg); }
.check-card.is-warning { background: var(--ui-warning-bg); color: var(--ui-warning-fg); }
.check-card.is-danger  { background: var(--ui-danger-bg);  color: var(--ui-danger-fg); }
.check-status { font-size: var(--ui-fs-1); font-weight: 600;   }
.check-text { margin: 0; font-size: var(--ui-fs-3); font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.check-sub { margin: 0; font-size: var(--ui-fs-2); line-height: 1.4; }
.check-jump { margin-top: var(--ui-sp-2); min-height: 44px; }
@media (min-width: 768px) { .check-jump { min-height: 36px; } }

.not-covered { margin: 0 0 var(--ui-sp-4); padding: var(--ui-sp-3) var(--ui-sp-4); border: 1px solid var(--border-subtle); border-radius: var(--ui-radius-lg); }
.not-covered.hidden { display: none; }
.not-covered-title { margin: 0 0 var(--ui-sp-2); font-size: var(--ui-fs-2); font-weight: 600; color: var(--text-primary); text-transform: none; letter-spacing: 0; }

/* Filter chips */
.result-filters { display: flex; flex-wrap: wrap; gap: var(--ui-sp-2); margin: 0 0 var(--ui-sp-3); }
.result-filters.hidden { display: none; }
.filter-chip { display: inline-flex; align-items: center; gap: var(--ui-sp-2); min-height: 44px; padding: 0 var(--ui-sp-4); font: inherit; font-size: var(--ui-fs-2); font-weight: 600; color: var(--text-primary); background: var(--bg-surface); border: 1px solid var(--border-default, var(--border-subtle)); border-radius: var(--radius-md); cursor: pointer; transition: background-color var(--ui-ease), border-color var(--ui-ease); }
.filter-chip:hover { background: var(--bg-surface-3); }
.filter-chip:focus-visible { outline: 2px solid var(--clr-primary-500); outline-offset: 2px; }
.filter-chip[aria-pressed="true"] { background: var(--clr-primary-500); border-color: var(--clr-primary-500); color: #fff; }
.filter-count { font-variant-numeric: tabular-nums; font-weight: 600; }
@media (min-width: 768px) { .filter-chip { min-height: 36px; } }

/* Result list */
#gaState:empty { display: none; }
#gaScheduleTable { table-layout: fixed; width: 100%; }
#gaScheduleTable th, #gaScheduleTable td { text-align: left; vertical-align: middle; overflow-wrap: anywhere; }
#gaScheduleTable th.num, #gaScheduleTable td.num { text-align: right; font-variant-numeric: tabular-nums; }
#gaScheduleTable th:nth-child(1) { width: 17%; }
#gaScheduleTable th:nth-child(2) { width: 20%; }
#gaScheduleTable th:nth-child(3) { width: 9%; }
#gaScheduleTable th:nth-child(4) { width: 9%; }
#gaScheduleTable th:nth-child(5) { width: 14%; }
#gaScheduleTable th:nth-child(6) { width: 9%; }
#gaScheduleTable th:nth-child(7) { width: 15%; }
#gaScheduleTable th:nth-child(8) { width: 7%; }
#gaScheduleTable tbody tr { border-bottom: 1px solid var(--border-subtle); }
.fit-count { font-variant-numeric: tabular-nums; margin-right: var(--ui-sp-1); }
.ga-edit { min-height: 36px; padding: 0 var(--ui-sp-3); font: inherit; font-size: var(--ui-fs-2); font-weight: 600; color: var(--clr-primary-600, var(--clr-primary-500)); background: transparent; border: 1px solid transparent; border-radius: var(--ui-radius); cursor: pointer; }
.ga-edit:hover { background: var(--bg-surface-3); }
.ga-edit:focus-visible { outline: 2px solid var(--clr-primary-500); outline-offset: 2px; }

@media (max-width: 767px) {
  #gaScheduleTable, #gaScheduleTable tbody { display: block; width: 100%; }
  #gaScheduleTable thead { display: none; }
  #gaScheduleTable tbody tr { display: block; padding: var(--ui-sp-4); }
  #gaScheduleTable tbody td { display: flex; justify-content: flex-start; align-items: baseline; gap: var(--ui-sp-3); width: 100%; padding: var(--ui-sp-1) 0; border: 0; text-align: left !important; }
  #gaScheduleTable tbody td::before { content: attr(data-label); flex: 0 0 8rem; color: var(--text-muted); font-weight: 600; font-size: var(--ui-fs-2); text-align: left; }
  #gaScheduleTable tbody td:nth-child(1)::before, #gaScheduleTable tbody td:nth-child(2)::before { content: none; }
  #gaScheduleTable tbody td[data-label="Edit"] { justify-content: flex-end; }
  #gaScheduleTable tbody td[data-label="Edit"]::before { content: none; }
  #gaScheduleTable .ga-edit { min-height: 44px; }
  #gaTableWrapper { overflow: visible; }
}

/* Reports: one chart, one headline */
#reportsChartState:empty { display: none; }
.fairness-report { margin-bottom: var(--ui-sp-5); }
.fairness-headline { padding: var(--ui-sp-5); background: var(--card-bg); border: 1px solid var(--border-subtle); border-radius: var(--ui-radius-lg); margin-bottom: var(--ui-sp-3); }
.fairness-headline-value { font-size: var(--ui-fs-6); font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.fairness-headline-value.good, .fairness-headline-value.warning, .fairness-headline-value.danger { color: var(--text-primary); }
.fairness-band { display: inline-block; margin-top: var(--ui-sp-2); padding: 2px var(--ui-sp-2); border-radius: var(--ui-radius); font-size: var(--ui-fs-2); font-weight: 600; background: var(--chip-bg); color: var(--chip-text); }
.fairness-headline-value.good ~ .fairness-band { background: var(--ui-success-bg); color: var(--ui-success-fg); }
.fairness-headline-value.warning ~ .fairness-band { background: var(--ui-warning-bg); color: var(--ui-warning-fg); }
.fairness-headline-value.danger ~ .fairness-band { background: var(--ui-danger-bg); color: var(--ui-danger-fg); }
.fairness-headline-sentence { margin: var(--ui-sp-2) 0 0; font-size: var(--ui-fs-2); color: var(--text-secondary); }
.fairness-quiet-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--ui-sp-3); }
.fairness-metric { display: flex; flex-direction: column; gap: var(--ui-sp-1); padding: var(--ui-sp-3); border-top: 1px solid var(--border-subtle); min-width: 0; }
.fairness-metric-label { font-size: var(--ui-fs-1); color: var(--text-muted); }
.fairness-metric-value { font-size: var(--ui-fs-3); font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.summary-wrap { min-width: 0; }
#fairnessPerFaculty .ui-capped-head, .summary-wrap .ui-capped-head { padding: 0 0 var(--ui-sp-2); }
#fairnessPerFaculty .ui-state, #reportsSummaryState .ui-state, #reportsChartState .ui-state, #gaState .ui-state { background: var(--bg-surface-2); border-radius: var(--ui-radius-lg); }
#gaState .ui-state.is-error, #reportsChartState .ui-state.is-error, #reportsSummaryState .ui-state.is-error { background: var(--ui-danger-bg); }
@media (max-width: 480px) { .fairness-quiet-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Subject summary (grouped by year and semester): fixed columns, text left, numbers right */
.curriculum-table { table-layout: fixed; }
.curriculum-table thead th, .curriculum-table tbody td { text-align: left; height: 44px; box-sizing: border-box; }
.curriculum-table thead th.num, .curriculum-table tbody td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.curriculum-table thead th:nth-child(1) { width: auto; }
.curriculum-table thead th:nth-child(2) { width: 24%; }
.curriculum-table thead th:nth-child(3), .curriculum-table thead th:nth-child(4) { width: 72px; }
.curriculum-table thead th:nth-child(5) { width: 88px; }
.curriculum-table tbody td:first-child { overflow-wrap: anywhere; }
/* ============================================================
   UI-4: weekly grid (read only)
   ============================================================ */
.workload-result-card[data-view="week"] #gaTableWrapper,
.workload-result-card[data-view="week"] #resultFilters { display: none !important; }

.result-viewbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--ui-sp-3); margin: 0 0 var(--ui-sp-3); }
.result-viewbar.hidden { display: none; }
.view-switch { display: inline-flex; padding: 2px; border: 1px solid var(--border-default); border-radius: var(--ui-radius); background: var(--bg-surface-2); }
.view-switch-btn { min-height: 44px; min-width: 72px; padding: 0 var(--ui-sp-4); border: 0; border-radius: var(--radius-md); background: transparent; color: var(--text-secondary); font: inherit; font-size: var(--ui-fs-2); font-weight: 600; cursor: pointer; transition: background var(--ui-ease), color var(--ui-ease); }
.view-switch-btn[aria-pressed="true"] { background: var(--bg-surface); color: var(--clr-primary-600); box-shadow: 0 0 0 1px var(--border-default); }
@media (min-width: 768px) { .view-switch-btn { min-height: 36px; } }
.week-pickers { display: flex; flex-wrap: wrap; gap: var(--ui-sp-2); flex: 1 1 240px; min-width: 0; }
.week-pickers select { flex: 1 1 140px; min-width: 0; max-width: 100%; min-height: 44px; font-size: var(--ui-fs-2); }
@media (min-width: 768px) { .week-pickers select { min-height: 36px; } }

.week-wrap { min-width: 0; max-width: 100%; }
.week-scroll { overflow: visible; max-width: 100%; border: 1px solid var(--border-subtle); border-radius: var(--ui-radius-lg); }
.week-table { width: 100%; min-width: 0; border-collapse: collapse; table-layout: fixed; }
.week-table th, .week-table td { border: 1px solid var(--border-subtle); padding: var(--ui-sp-1); vertical-align: top; font-size: var(--ui-fs-1); }
.week-table thead th { padding: var(--ui-sp-2); text-align: center; font-weight: 600; color: var(--text-primary); background: var(--bg-surface-2); }
.week-table thead th.wk-corner, .week-table tbody th { width: 88px; }
.week-table tbody th { padding: var(--ui-sp-2); text-align: right; font-weight: 500; color: var(--text-secondary); white-space: nowrap; font-variant-numeric: tabular-nums; background: var(--bg-surface-2); }
.week-table td.wk-empty { background: transparent; }
.week-table td.wk-has { background: var(--bg-surface); }

.wk-class { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; min-width: 0; margin: 0; padding: var(--ui-sp-1) var(--ui-sp-2); border: 1px solid var(--clr-primary-500); border-radius: var(--radius-md); background: var(--clr-primary-50); color: var(--text-primary); font: inherit; font-size: var(--ui-fs-1); line-height: 1.35; text-align: left; box-shadow: none; white-space: normal; overflow-wrap: anywhere; }
.wk-class + .wk-class { margin-top: var(--ui-sp-1); }
.week-wrap .wk-class.btn-edit-faculty { min-height: 0; padding: var(--ui-sp-1) var(--ui-sp-2); background: var(--clr-primary-50); color: var(--text-primary); font-size: var(--ui-fs-1); font-weight: 400; border-radius: var(--radius-md); transform: none; cursor: pointer; transition: background var(--ui-ease); }
.week-wrap .wk-class.btn-edit-faculty:hover { background: var(--bg-surface-3); color: var(--text-primary); }
.wk-class[role="group"] { cursor: default; }
.wk-class.is-flag { border-left-color: var(--ui-danger-fg); }
.wk-code { font-weight: 600; font-size: var(--ui-fs-1); }
.wk-line { color: var(--text-secondary); }
.wk-tags { display: flex; flex-wrap: wrap; gap: var(--ui-sp-1); margin-top: 2px; }
.week-wrap .wk-class:focus-visible, .week-tab:focus-visible, .view-switch-btn:focus-visible, .week-scroll:focus-visible, .week-day:focus-visible { outline: 2px solid var(--clr-primary-600); outline-offset: 2px; }

.week-tabs { display: flex; gap: var(--ui-sp-1); margin-bottom: var(--ui-sp-3); }
.week-tab { position: relative; flex: 1 1 0; min-width: 0; min-height: 44px; padding: 0; border: 1px solid var(--border-subtle); border-radius: var(--ui-radius); background: var(--bg-surface); color: var(--text-secondary); font: inherit; font-size: var(--ui-fs-2); font-weight: 600; cursor: pointer; transition: background var(--ui-ease), color var(--ui-ease); }
.week-tab[aria-selected="true"] { background: var(--clr-primary-50); color: var(--clr-primary-600); border-color: var(--clr-primary-600); }
.wk-dot { position: absolute; left: 50%; bottom: 5px; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; background: transparent; }
.wk-dot.on { background: currentColor; }
.week-day { display: flex; flex-direction: column; min-width: 0; }
.wk-row { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: var(--ui-sp-2); align-items: start; padding: var(--ui-sp-2) 0; border-top: 1px solid var(--border-subtle); min-width: 0; }
.wk-row:first-child { border-top: 0; }
.wk-time { padding-top: var(--ui-sp-1); font-size: var(--ui-fs-1); color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.week-wrap .wk-row .wk-class.btn-edit-faculty, .wk-row .wk-class { min-height: 44px; font-size: var(--ui-fs-2); }
.wk-row .wk-code { font-size: var(--ui-fs-2); }
.wk-day-empty { margin: var(--ui-sp-4) 0; color: var(--text-secondary); font-size: var(--ui-fs-2); }
.wk-unplaced { margin-top: var(--ui-sp-4); padding-top: var(--ui-sp-3); border-top: 1px solid var(--border-subtle); }
.wk-unplaced h4 { margin: 0 0 var(--ui-sp-2); font-size: var(--ui-fs-2); }

[data-theme="dark"] .week-wrap .wk-class.btn-edit-faculty, [data-theme="dark"] .week-wrap .wk-class { background: var(--bg-surface-3); color: var(--text-primary); }
[data-theme="dark"] .week-wrap .wk-class.btn-edit-faculty:hover { background: var(--bg-surface-2); }
[data-theme="dark"] .week-tab[aria-selected="true"] { background: var(--bg-surface-3); }
@media (prefers-reduced-motion: reduce) { .week-wrap *, .view-switch-btn, .week-tab { transition: none !important; } }
[data-motion="reduce"] .week-wrap *, [data-motion="reduce"] .view-switch-btn, [data-motion="reduce"] .week-tab { transition: none !important; }
/* ============================================================
   UI-5: moving classes
   ============================================================ */
.week-scroll { position: relative; }
.week-wrap .wk-class.wk-move { min-height: 0; padding: var(--ui-sp-1) var(--ui-sp-2); background: var(--clr-primary-50); color: var(--text-primary); font-size: var(--ui-fs-1); font-weight: 400; border-radius: var(--radius-md); transform: none; cursor: grab; transition: background var(--ui-ease), opacity var(--ui-ease); -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.week-wrap .wk-class.wk-move:hover { background: var(--bg-surface-3); color: var(--text-primary); }
.week-wrap .wk-row .wk-class.wk-move { min-height: 44px; font-size: var(--ui-fs-2); }
[data-theme="dark"] .week-wrap .wk-class.wk-move { background: var(--bg-surface-3); color: var(--text-primary); }
[data-theme="dark"] .week-wrap .wk-class.wk-move:hover { background: var(--bg-surface-2); }
.wk-class.wk-move:focus-visible { outline: 2px solid var(--clr-primary-600); outline-offset: 2px; }
.wk-class.is-lifted { opacity: .35; }
.wk-ghost { position: fixed; z-index: 2147483100; margin: 0; pointer-events: none; cursor: grabbing; opacity: .95; box-shadow: var(--shadow-pop); background: var(--bg-surface) !important; border: 1px solid var(--clr-primary-600); }
body.mv-dragging { cursor: grabbing; -webkit-user-select: none; user-select: none; }
.week-scroll.wk-dragging td.wk-empty, .week-scroll.wk-dragging td.wk-has { opacity: .5; }
.wk-ok { position: absolute; z-index: 2; box-sizing: border-box; display: flex; align-items: flex-start; justify-content: center; padding-top: var(--ui-sp-1); border: 2px dashed var(--clr-primary-600); border-radius: var(--radius-md); background: var(--bg-surface); opacity: .96; pointer-events: none; }
.wk-ok-text { font-size: var(--ui-fs-1); font-weight: 600; color: var(--text-primary); }
.wk-ok.is-over { border-style: solid; background: var(--clr-primary-50); }
[data-theme="dark"] .wk-ok.is-over { background: var(--bg-surface-3); }
.mv-flash { outline: 2px solid var(--clr-primary-600); outline-offset: 2px; animation: mv-flash 1.2s ease-out; }
@keyframes mv-flash { from { background: var(--clr-primary-100, var(--clr-primary-50)); } to { background: var(--clr-primary-50); } }
@media (prefers-reduced-motion: reduce) { .mv-flash { animation: none; } .wk-ghost { transition: none !important; } }
[data-motion="reduce"] .mv-flash { animation: none; }
.mv-reason { position: fixed; z-index: 2147483200; max-width: min(320px, calc(100vw - 16px)); padding: var(--ui-sp-2) var(--ui-sp-3); border: 1px solid var(--ui-danger-fg); border-radius: var(--ui-radius); background: var(--bg-surface); color: var(--text-primary); font-size: var(--ui-fs-2); box-shadow: var(--shadow-pop); }
.edit-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--ui-sp-2); margin: var(--ui-sp-2) 0; }
.edit-bar.hidden { display: none; }
.edit-bar .btn { min-height: 44px; }
.edit-hint { flex: 1 1 220px; min-width: 0; font-size: var(--ui-fs-1); color: var(--text-secondary); }
.mv-sheet { display: flex; flex-direction: column; gap: var(--ui-sp-3); }
.mv-facts { margin: 0; }
.mv-facts > div { display: flex; gap: var(--ui-sp-3); padding: var(--ui-sp-2) 0; border-bottom: 1px solid var(--border-subtle); font-size: var(--ui-fs-2); }
.mv-facts dt { flex: 0 0 84px; color: var(--text-secondary); }
.mv-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.mv-note { color: var(--text-secondary); font-size: var(--ui-fs-1); }
.mv-field { display: flex; flex-direction: column; gap: var(--ui-sp-1); }
.mv-field label { font-size: var(--ui-fs-2); font-weight: 600; }
.mv-field select { min-height: 44px; width: 100%; font: inherit; }
.mv-help { font-size: var(--ui-fs-1); color: var(--text-secondary); }
.mv-reasons { margin: var(--ui-sp-1) 0 0; padding-left: var(--ui-sp-4); font-size: var(--ui-fs-2); }
.mv-help .mv-reasons { font-size: var(--ui-fs-1); }
.mv-status { min-height: 24px; font-size: var(--ui-fs-2); }
.mv-actions { display: flex; justify-content: flex-end; gap: var(--ui-sp-2); }
.mv-actions .btn { min-height: 44px; min-width: 96px; }
.mv-spin { display: inline-block; width: 14px; height: 14px; margin-right: var(--ui-sp-2); vertical-align: -2px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: mv-spin .8s linear infinite; }
@keyframes mv-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .mv-spin { animation: none; border-right-color: currentColor; } }
.mv-strip { position: fixed; z-index: 2147483050; left: var(--ui-sp-2); right: var(--ui-sp-2); bottom: calc(var(--bottom-nav-h, 56px) + env(safe-area-inset-bottom, 0px) + var(--ui-sp-2)); padding: var(--ui-sp-3); border: 1px solid var(--border-default); border-radius: var(--ui-radius-lg); background: var(--bg-surface); box-shadow: var(--shadow-pop); touch-action: none; }
.mv-strip-title { margin: 0 0 var(--ui-sp-2); font-size: var(--ui-fs-2); font-weight: 600; }
.mv-strip-days, .mv-strip-times { display: grid; gap: var(--ui-sp-1); }
.mv-strip-days { grid-template-columns: repeat(6, minmax(0, 1fr)); margin-bottom: var(--ui-sp-2); }
.mv-strip-times { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
.mv-zone-day, .mv-zone { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 44px; padding: var(--ui-sp-1); border: 1px solid var(--border-default); border-radius: var(--radius-md); font-size: var(--ui-fs-2); text-align: center; background: var(--bg-surface); }
.mv-zone small, .mv-zone-day small { font-size: var(--ui-fs-1); color: var(--text-secondary); min-height: 14px; }
.mv-zone-day.is-current { border-color: var(--clr-primary-600); border-width: 2px; font-weight: 600; }
.mv-zone.is-valid { border: 2px dashed var(--clr-primary-600); }
.mv-zone.is-valid.is-over { border-style: solid; background: var(--clr-primary-50); }
[data-theme="dark"] .mv-zone.is-valid.is-over { background: var(--bg-surface-3); }
.mv-zone.is-off, .mv-zone-day.is-off { opacity: .6; }
/* ============================================================
   UI-6: read-only entity lists, groups and the edit panel
   ============================================================ */
.model-table { display: none !important; }
.ent-head { display: flex; align-items: center; flex-wrap: wrap; gap: var(--ui-sp-2) var(--ui-sp-3); margin-bottom: var(--ui-sp-3); }
.ent-head .section-heading { margin: 0; flex: 1 1 auto; }
.save-status { display: inline-flex; align-items: center; gap: var(--ui-sp-2); font-size: var(--ui-fs-2); color: var(--text-secondary); }
.save-status[data-state="error"] { color: var(--ui-danger-fg); font-weight: 600; }
.save-status .save-retry { min-height: 32px; padding: 0 var(--ui-sp-3); }
.ent-list, .ent-list-in { display: flex; flex-direction: column; margin-bottom: var(--ui-sp-4); }
.ent-row { display: flex; align-items: center; gap: var(--ui-sp-3); padding: var(--ui-sp-3) 0; border-bottom: 1px solid var(--border-subtle); min-width: 0; }
.ent-row:last-child { border-bottom: 0; }
.ent-main { flex: 1 1 200px; min-width: 0; }
.ent-title { font-size: var(--ui-fs-3); font-weight: 600; color: var(--text-primary); overflow-wrap: anywhere; }
.ent-chips, .ent-days { display: flex; flex-wrap: wrap; gap: var(--ui-sp-1); margin-top: var(--ui-sp-1); }
.ent-days { margin-top: 0; flex: 0 1 auto; justify-content: flex-start; min-width: 96px; }
.ent-muted { font-size: var(--ui-fs-2); color: var(--text-secondary); }
.ent-num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.ent-load { display: flex; flex-direction: column; align-items: flex-end; min-width: 64px; }
.ent-code { font-variant-numeric: tabular-nums; font-size: var(--ui-fs-2); color: var(--text-secondary); min-width: 72px; }
.ent-units { display: flex; gap: var(--ui-sp-3); font-size: var(--ui-fs-2); color: var(--text-secondary); }
.ent-units .ent-total { color: var(--text-primary); font-weight: 600; }
.ent-cap { font-size: var(--ui-fs-2); color: var(--text-secondary); min-width: 110px; }
.ent-actions { display: flex; align-items: center; gap: var(--ui-sp-1); margin-left: auto; }
.ent-actions .btn { min-height: 36px; }
.ent-del { min-width: 36px; padding: 0; justify-content: center; color: var(--ui-danger-fg); }
.ent-avatar { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--chip-bg); color: var(--chip-text); font-size: var(--ui-fs-2); font-weight: 600; }
.day-chip { min-width: 24px; justify-content: center; }
.ent-groups { display: flex; flex-direction: column; gap: var(--ui-sp-2); margin-bottom: var(--ui-sp-4); }
.ent-group { border: 1px solid var(--border-subtle); border-radius: var(--ui-radius); background: var(--bg-surface); }
.ent-group-h { margin: 0; }
.ent-group-btn { display: flex; align-items: center; justify-content: space-between; gap: var(--ui-sp-3); width: 100%; min-height: 44px; padding: 0 var(--ui-sp-4); font: inherit; font-weight: 600; color: var(--text-primary); background: transparent; border: 0; cursor: pointer; text-align: left; }
.ent-group-btn::after { content: ""; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform var(--ui-ease); flex: 0 0 auto; }
.ent-group-btn[aria-expanded="true"]::after { transform: rotate(45deg); }
.ent-group-name { flex: 1; }
.ent-group-btn:focus-visible, .ent-row .btn:focus-visible, .pf-pill:focus-visible { outline: 2px solid var(--accent, currentColor); outline-offset: 2px; }
.ent-group-body { padding: 0 var(--ui-sp-4); border-top: 1px solid var(--border-subtle); }
.ent-group-body[hidden] { display: none; }
.rooms-grid .ent-row { gap: var(--ui-sp-2); }

.pf { display: flex; flex-direction: column; gap: var(--ui-sp-4); }
.pf-group { border: 0; padding: 0; margin: 0; min-width: 0; }
.pf-group legend { padding: 0; margin-bottom: var(--ui-sp-2); font-size: var(--ui-fs-2); font-weight: 600; color: var(--text-secondary); text-transform: none; }
.pf-two { display: grid; grid-template-columns: 1fr 1fr; gap: var(--ui-sp-3); }
.pf-field { display: flex; flex-direction: column; gap: var(--ui-sp-1); margin-bottom: var(--ui-sp-3); min-width: 0; }
.pf-field label { font-size: var(--ui-fs-2); font-weight: 600; color: var(--text-primary); }
.pf-field input, .pf-field select { width: 100%; min-height: 44px; padding: 0 var(--ui-sp-3); font: inherit; font-size: var(--text-md); color: var(--text-primary); background: var(--input-bg, var(--bg-surface)); border: 1px solid var(--border); border-radius: var(--ui-radius); box-sizing: border-box; }
.pf-field input[readonly] { background: var(--bg-surface-3); color: var(--text-secondary); }
.pf-field input[aria-invalid="true"], .pf-field select[aria-invalid="true"] { border-color: var(--ui-danger-fg); }
.pf-hint { margin: 0; font-size: var(--ui-fs-1); color: var(--text-secondary); }
.pf-err { margin: 0; padding: var(--ui-sp-1) var(--ui-sp-2); border-radius: var(--ui-radius); background: var(--ui-danger-bg); color: var(--ui-danger-fg); font-size: var(--ui-fs-2); }
.pf-err[hidden] { display: none; }
.pf-pills { display: flex; flex-wrap: wrap; gap: var(--ui-sp-2); }
.pf-pill { min-height: 44px; min-width: 44px; padding: 0 var(--ui-sp-3); font: inherit; font-size: var(--ui-fs-2); font-weight: 600; color: var(--text-primary); background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--ui-radius); cursor: pointer; }
.pf-pill[aria-pressed="true"] { background: var(--ui-info-bg); color: var(--ui-info-fg); border-color: var(--ui-info-fg); }
.pf-pill[aria-pressed="true"] { border-width: 2px; font-weight: 600; }
.pf-pill[aria-pressed="true"]::before { content: ""; display: inline-block; width: 5px; height: 9px; margin: 0 var(--ui-sp-2) 2px 0; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); }
.pf-actions { position: sticky; bottom: calc(-1 * var(--ui-sp-4)); display: flex; justify-content: flex-end; gap: var(--ui-sp-2); padding: var(--ui-sp-3) 0; background: var(--bg-surface); border-top: 1px solid var(--border-subtle); }
.pf-actions .btn { min-height: 44px; }
.fp-list { display: grid; grid-template-columns: minmax(0, 11rem) minmax(0, 1fr); gap: var(--ui-sp-2) var(--ui-sp-3); margin: 0; }
.fp-list dt { font-size: var(--ui-fs-2); font-weight: 600; color: var(--text-secondary); }
.fp-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; color: var(--text-primary); }
.fp-chips { display: flex; flex-wrap: wrap; gap: var(--ui-sp-1); }
.fp-rows { display: flex; flex-direction: column; gap: var(--ui-sp-1); }
.svc-sec { margin-top: var(--ui-sp-5, 1.5rem); padding-top: var(--ui-sp-4); border-top: 1px solid var(--border-subtle); }
.svc-sec > .pf-hint { margin-bottom: var(--ui-sp-3); }
.svc-row .ent-code { min-width: 5.5rem; overflow-wrap: anywhere; }

@media (max-width: 767px) {
  .ent-row { flex-wrap: wrap; }
  .ent-main { flex-basis: calc(100% - 56px); }
  .ent-load { align-items: flex-start; flex-direction: row; gap: var(--ui-sp-1); }
  .ent-actions .btn { min-height: 44px; }
  .ent-del { min-width: 44px; }
  .ent-sub .ent-code { min-width: 0; }
  .ent-sub .ent-main { flex-basis: 100%; }
  .ent-room .ent-main { flex-basis: 100%; }
  .pf-two { grid-template-columns: 1fr; }
  .fp-list { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .fp-list dd { margin-bottom: var(--ui-sp-3); }
  .ent-head .btn { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) { .ent-group-btn::after { transition: none; } }
/* ============================================================
   UI-7: touch targets and reduced motion (checked by tests/test_ui_smoke.py)
   ============================================================ */
@media (max-width: 767px) {
  .btn, button, select, summary,
  input[type="text"], input[type="search"], input[type="date"], input[type="number"], input[type="email"], input[type="password"] { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}.result-checks .result-heading, .result-checks .result-coverage { grid-column: 1 / -1; margin-bottom: 0; }

/* UI-8: result cards and chart colors as in the main redesign */
.result-checks { padding: var(--ui-sp-4); border: 1px solid var(--border-subtle); border-radius: var(--ui-radius-lg); background: var(--card-bg); align-items: stretch; }
.result-checks.hidden { display: none; }
.result-checks .result-heading { margin: 0; }
#resultCoverage:empty { display: none; }
#resultCoverage .result-coverage { margin: 0 0 var(--ui-sp-3); border: 1px solid var(--ok); border-radius: var(--ui-radius); padding: var(--ui-sp-2) var(--ui-sp-3); background: var(--card-bg); }
#resultCoverage .result-coverage.is-incomplete { border-color: var(--warn); }
.check-card { flex-direction: row; align-items: flex-start; gap: var(--ui-sp-3); color: var(--text-primary); }
.check-card.is-success { background: var(--ok-soft); color: var(--text-primary); }
.check-card.is-warning { background: var(--warn-soft); color: var(--text-primary); }
.check-card.is-danger { background: var(--bad-soft); color: var(--text-primary); }
.check-ic { flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; font-size: var(--ui-fs-2); font-weight: 600; color: var(--card-bg); }
.check-card.is-success .check-ic { background: var(--ok); }
.check-card.is-warning .check-ic { background: var(--warn); }
.check-card.is-danger .check-ic { background: var(--bad); }
.check-body { display: flex; flex-direction: column; gap: var(--ui-sp-1); min-width: 0; }
.check-sub { color: var(--text-secondary); }
.check-filter { color: var(--clr-primary-600); }
.fit-swatch, .fit-swatch.is-fits, .fit-swatch.is-above, .fit-swatch.is-over { border-radius: 50%; transform: none; }
.page-sub { margin: var(--ui-sp-1) 0 0; font-size: var(--ui-fs-2); color: var(--text-secondary); }
.solver-label { margin: var(--ui-sp-3) 0 0; font-size: var(--ui-fs-1); font-weight: 600;   color: var(--text-secondary); text-align: center; }

.result-checks { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.result-checks:has(.check-card:nth-child(5)) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 900px) { .result-checks, .result-checks:has(.check-card:nth-child(5)) { grid-template-columns: 1fr; } }

/* UI-8: exact look of the period chip and the three result cards */
:root {
  --chip-p-bg: #fdefe7; --chip-p-fg: #6e2308; --chip-p-link: #a4573a;
  --rc-wrap-bg: #fffdf9; --rc-wrap-bd: #efe8df;
  --rc-ok-bg: #e0eef0; --rc-ok-ic: #1f6a70;
  --rc-bad-bg: #f8e4e2; --rc-bad-ic: #a02f24;
  --rc-warn-bg: #fbeed9; --rc-warn-ic: #8f5a12;
  --rc-ink: #1a130e; --rc-sub: #5f554b; --rc-link: #9a3608; --rc-cov: #2f8f5b;
}
[data-theme="dark"] {
  --chip-p-bg: rgba(217, 100, 40, 0.18); --chip-p-fg: #f6c9b4; --chip-p-link: #f0a98a;
  --rc-wrap-bg: var(--card-bg); --rc-wrap-bd: var(--border-subtle);
  --rc-ok-bg: rgba(42, 127, 134, 0.24); --rc-ok-ic: #7fcfd5;
  --rc-bad-bg: rgba(180, 55, 43, 0.28); --rc-bad-ic: #f08a7e;
  --rc-warn-bg: rgba(217, 146, 43, 0.2); --rc-warn-ic: #e8b25a;
  --rc-ink: #f3ece4; --rc-sub: #c9beb2; --rc-link: #f0a98a; --rc-cov: #6fcf97;
}
.page-header .period-chip { display: inline-flex; align-items: center; gap: 12px; min-height: 36px; padding: 0 16px; border-radius: var(--radius-md); background: var(--chip-p-bg); color: var(--chip-p-fg); font-size: var(--text-sm); font-weight: 600; text-decoration: none; white-space: nowrap; }
.page-header .period-chip .period-chip-text { overflow: hidden; text-overflow: ellipsis; }
.page-header .period-chip .period-chip-change { height: 18px; padding: 0 0 0 12px; border-left: 1px solid var(--chip-p-fg); color: var(--chip-p-link); font-weight: 500; text-decoration: none; line-height: 18px; }
.page-header .period-chip:hover .period-chip-change { text-decoration: underline; }
@media (max-width: 600px) { .page-header .period-chip { min-height: 44px; } }

.workload-result-card .result-checks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding: var(--space-5); margin: 0 0 var(--space-4); background: var(--rc-wrap-bg); border: 1px solid var(--rc-wrap-bd); border-radius: var(--radius-lg); }
.workload-result-card .result-checks:has(.check-card:nth-child(5)) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.workload-result-card .result-checks .result-heading { grid-column: 1 / -1; margin: 0 0 2px; font-size: var(--text-md); font-weight: 600; color: var(--rc-ink); }
.workload-result-card .check-card { display: flex; flex-direction: row; align-items: flex-start; gap: 12px; padding: var(--space-4); border-radius: var(--radius-lg); color: var(--rc-ink); }
.workload-result-card .check-card.is-success { background: var(--rc-ok-bg); }
.workload-result-card .check-card.is-danger { background: var(--rc-bad-bg); }
.workload-result-card .check-card.is-warning { background: var(--rc-warn-bg); }
.workload-result-card .check-ic { flex: 0 0 26px; width: 26px; height: 26px; border-radius: 50%; font-size: var(--text-base); font-weight: 600; line-height: 26px; text-align: center; color: #fff; }
[data-theme="dark"] .workload-result-card .check-ic { color: #1a130e; }
.workload-result-card .is-success .check-ic { background: var(--rc-ok-ic); }
.workload-result-card .is-danger .check-ic { background: var(--rc-bad-ic); }
.workload-result-card .is-warning .check-ic { background: var(--rc-warn-ic); }
.workload-result-card .check-text { margin: 0; font-size: var(--text-base); font-weight: 600; line-height: 1.5; color: var(--rc-ink); }
.workload-result-card .check-sub { margin: 4px 0 0; font-size: var(--text-sm); line-height: 1.5; color: var(--rc-sub); }
.workload-result-card .check-filter { margin: var(--space-3) 0 0; min-height: 0; padding: 0; font-size: var(--text-sm); font-weight: 600; color: var(--rc-link); background: none; border: 0; text-decoration: underline; cursor: pointer; }
@media (max-width: 900px) { .workload-result-card .result-checks, .workload-result-card .result-checks:has(.check-card:nth-child(5)) { grid-template-columns: 1fr; padding: 16px; } .workload-result-card .check-filter { min-height: 44px; } }
#resultCoverage .result-coverage { border: 1px solid var(--rc-cov); border-radius: var(--radius-lg); background: transparent; color: var(--rc-ink); font-size: var(--text-base); }

/* UI-8: step guide, exact look */
.step-guide[hidden] { display: none; }
.step-guide { padding: var(--space-5); margin: 0 0 var(--space-4); background: var(--rc-wrap-bg, var(--card-bg)); border: 1px solid var(--rc-wrap-bd, var(--border-subtle)); border-radius: var(--radius-lg); }
.step-guide-head h3 { font-size: var(--text-md); font-weight: 600; color: var(--text-primary); }
.step-guide-sub { font-size: var(--text-sm); color: var(--text-secondary); }
#stepGuideCount { padding: 4px 12px; border-radius: var(--radius-sm); background: #fde8e0; color: #a03a12; font-size: var(--text-xs); font-weight: 600; }
[data-theme="dark"] #stepGuideCount { background: rgba(217, 100, 40, 0.2); color: #f6c9b4; }
.step-bar { height: 6px; margin: 16px 0 var(--space-4); border-radius: var(--radius-sm); background: var(--bg-surface-3); }
.step-bar-fill { border-radius: var(--radius-sm); background: var(--clr-primary-500); }
.step-list { gap: var(--space-4); }
.step-card { gap: 8px; padding: var(--space-4); min-height: 150px; border: 1px solid transparent; border-radius: var(--radius-lg); background: var(--bg-surface-2); }
.step-card.is-current { background: #fdeee8; border-color: var(--clr-primary-500); }
[data-theme="dark"] .step-card.is-current { background: rgba(217, 100, 40, 0.14); }
.step-mark { width: 24px; height: 24px; border: 1px solid var(--border-strong); background: transparent; font-size: var(--text-xs); font-weight: 500; color: var(--text-secondary); }
.step-card.is-done .step-mark { border-color: transparent; background: var(--rc-ok-bg, var(--ui-success-bg)); color: var(--rc-ok-ic, var(--ui-success-fg)); }
.step-card.is-current .step-mark { border-color: var(--clr-primary-500); color: var(--clr-primary-600); }
.step-title { margin: 4px 0 0; }
.step-title-link { padding: 0; min-height: 0; font: inherit; font-size: var(--text-base); font-weight: 600; text-align: left; color: var(--text-primary); background: none; border: 0; cursor: pointer; }
.step-title-link:hover { text-decoration: underline; }
.step-title-link:focus-visible { outline: 2px solid var(--clr-primary-500); outline-offset: 2px; }
.step-desc { font-size: var(--text-xs); color: var(--text-secondary); }
.step-note { padding: var(--space-2) var(--space-3); border-radius: var(--radius-lg); background: var(--rc-warn-bg, var(--ui-warning-bg)); color: var(--rc-warn-ic, var(--ui-warning-fg)); font-size: var(--text-xs); font-weight: 600; }
.step-card .step-go { width: auto; margin-top: auto; padding: 0 var(--space-4); min-height: 36px; border-radius: var(--radius-lg); }
@media (max-width: 600px) { .step-card { min-height: 0; } .step-card .step-go { min-height: 44px; } .step-title-link { min-height: 44px; } }

/* UI-8: period chip, smaller, same on every header */
.page-header .period-chip { position: relative; align-self: center; flex: 0 0 auto; box-sizing: border-box; height: 30px; min-height: 0; max-width: 100%; padding: 0 var(--space-4); gap: var(--space-3); font-size: var(--text-xs); line-height: 1; }
.page-header .period-chip .period-chip-change { height: 14px; padding-left: var(--space-3); line-height: 14px; font-size: var(--text-xs); }
.page-header .period-chip::after { content: ""; position: absolute; inset: -7px 0; }
@media (max-width: 600px) { .page-header .period-chip { min-height: 0; } }
/* ============================================================
   UI-9 STAGE A: one token set, one look (flat, minimalist, corporate)
   ============================================================ */
:root { --page-gutter: var(--space-4); --card-pad: var(--space-4); --control-h: 44px; --border-token: 1px solid var(--border-default); }
@media (min-width: 768px) { :root { --page-gutter: var(--space-5); --card-pad: var(--space-5); --control-h: 40px; } }
@media (min-width: 1024px) { :root { --page-gutter: var(--space-6); } }

body { line-height: 1.5; }
h1, h2, h3, h4, h5, h6, .stat-value, .fairness-card-value, .capacity-metric-value { line-height: 1.25; }
button, input, select, textarea, optgroup { font-family: inherit; }
table, th, td, .stat-value, .fairness-card-value, .capacity-metric-value, .stat-card, canvas { font-variant-numeric: tabular-nums; }
th, td { font-family: inherit; }
.page-header h2, .page-header > div h2 { font-weight: 600; }
.stat-value, .fairness-card-value, .capacity-metric-value { font-weight: 600; }

/* eyebrow label: the only uppercase text */
.stat-label, .dept-banner-label, .capacity-metric-label, .fairness-card-label, .modal-section-label,
#engineSettingsCard .engine-settings-section-label {
  font-size: var(--text-xs); font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted);
}

/* flat cards and buttons: no lift, no shadow */
.stat-card, .workload-controls-card, .saved-runs-card,
.fairness-card, .fac-assign-card, .summary-faculty-card, .capacity-metric-tile, .login-card, .app-card {
  box-shadow: none; border: var(--border-token); border-radius: var(--radius-lg); background: var(--card-bg);
}
.stat-card:hover, .chart-card:hover, .fairness-card:hover, .fac-assign-card:hover, .summary-faculty-card:hover,
.capacity-metric-tile:hover, .saved-runs-card:hover, .btn:hover, .btn-edit-faculty:hover { transform: none; box-shadow: none; }
.stat-card, .workload-controls-card, .saved-runs-card { padding: var(--card-pad); }

/* buttons: one height, flat, small radius */
.btn, .btn-login-submit, .app-btn, .auth-btn { min-height: var(--control-h); border-width: 1px; border-radius: var(--radius-md); box-shadow: none; }
.login-card .btn-login-submit { min-height: var(--control-h); }
.btn:disabled, .btn[disabled], .btn-login-submit:disabled { cursor: not-allowed; opacity: 0.55; }
.btn:focus-visible, .btn-login-submit:focus-visible { box-shadow: var(--focus-ring); }

/* inputs */
input[type="text"], input[type="number"], input[type="password"], input[type="email"], input[type="search"], select, textarea {
  border-width: 1px; border-radius: var(--radius-md); font-size: var(--text-base);
}
@media (max-width: 767px) {
  input[type="text"], input[type="number"], input[type="password"], input[type="email"], input[type="search"], select, textarea { font-size: var(--text-md); }
}

/* status chips: flat fill, 1px border, text label */
.badge-ok, .badge-warn, .badge-hard, .units-badge, .capacity-overall-badge, .status-chip, .run-badge {
  border: 1px solid currentColor; border-radius: var(--radius-sm); font-weight: 500;
}
@supports (color: color-mix(in srgb, red 50%, blue)) {
  .badge-ok, .badge-warn, .badge-hard, .units-badge, .capacity-overall-badge, .status-chip, .run-badge { border-color: color-mix(in srgb, currentColor 35%, transparent); }
}

/* step guide: white cards, 2px accent only on the current step */
.step-card { background: var(--card-bg); border: 1px solid var(--border-default); border-radius: var(--radius-lg); }
.step-card.is-current, [data-theme="dark"] .step-card.is-current { background: var(--card-bg); border: 2px solid var(--clr-primary-500); padding: calc(var(--space-4) - 1px); }
.step-guide { border-radius: var(--radius-lg); }
.step-card .step-go { border-radius: var(--radius-md); }
[data-theme="dark"] #stepGuideCount { background: var(--bg-surface-3); color: var(--text-secondary); }

/* dialogs and sheets: only these get the one shadow */
.modal-card { border: var(--border-token); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); }
@media (max-width: 767px) { .modal-card { border-radius: var(--radius-sheet) var(--radius-sheet) 0 0; } }
.toast-notif { border: var(--border-token); border-radius: var(--radius-md); box-shadow: none; }
.dropdown-content { border-radius: var(--radius-md); box-shadow: var(--shadow-pop); }

/* ============================================================
   UI-9 STAGE B: phone layout (under 768 px). Desktop is unchanged.
   ============================================================ */
.step-guide-toggle, .m-more, .m-details-cell, .m-period-change { display: none; }
@media (max-width: 767px) {
  /* show more or less */
  .m-clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }
  .m-more { display: inline-flex; align-items: center; min-height: var(--control-h); padding: 0; background: none; border: 0; font: inherit; font-size: var(--text-base); font-weight: 500; color: var(--text-link); cursor: pointer; }
  .m-more[hidden] { display: none; }

  /* collapsible cards: header row with a chevron */
  .m-collapse-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: var(--control-h); margin-bottom: 0; cursor: pointer; }
  .m-collapse-head::after { content: ""; flex: 0 0 auto; width: 8px; height: 8px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); transition: transform 160ms ease; }
  .m-collapse-head[aria-expanded="true"]::after { transform: rotate(-135deg); }
  .m-collapse-head:focus-visible { outline: 2px solid var(--clr-primary-500); outline-offset: 2px; }
  .app-card.m-collapsed > :not(h2) { display: none !important; }

  /* period card: text plus Change */
  .m-period-change { display: inline-flex; min-height: var(--control-h); margin-bottom: var(--space-3); }
  #periodCard:not(.m-period-open) .m-period-form { display: none; }

  /* dashboard step guide: current step only, the rest on request */
  .step-guide:not(.is-expanded) .step-card:not(.is-current) { display: none; }
  .step-guide-toggle { display: inline-flex; width: 100%; margin-top: var(--space-3); min-height: var(--control-h); }
  .step-card { min-height: 0; }
  .step-card .step-go { width: 100%; min-height: var(--control-h); }

  /* three stat tiles become one card with three rows */
  .stats-row { display: block; border: var(--border-token); border-radius: var(--radius-lg); background: var(--card-bg); overflow: hidden; }
  .stats-row .stat-card { border: 0; border-radius: 0; background: transparent; border-bottom: 1px solid var(--border-subtle); padding: var(--space-3) var(--space-4); }
  .stats-row .stat-card:last-child { border-bottom: 0; }
  .stats-row .stat-sub { display: none; }

  /* All, Lectures, Labs as a segmented control */
  .result-filters { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0; border: var(--border-token); border-radius: var(--radius-md); overflow: hidden; background: var(--card-bg); }
  .result-filters .filter-chip { justify-content: center; border: 0; border-radius: 0; border-right: 1px solid var(--border-default); min-width: 0; padding: 0 var(--space-2); }
  .result-filters .filter-chip:last-child { border-right: 0; }

  /* stacked rows: three fields, details on request */
  #gaScheduleTable tbody tr:not(.m-open) td.m-extra { display: none; }
  #gaScheduleTable td.m-details-cell { display: block; grid-column: 1 / -1; padding-top: 0; }
  #gaScheduleTable td.m-details-cell::before { content: none; }
  .m-details-btn { min-height: var(--control-h); padding: 0; justify-content: flex-start; font-weight: 500; color: var(--text-link); }

  /* touch targets */
  .btn, .app-btn, .auth-btn, .filter-chip, .view-switch-btn, .week-tab, .step-title-link { min-height: var(--control-h); }
  .ui-capped-toggle { width: 100%; min-height: var(--control-h); }

  /* bottom sheet: rounded top corners, room for the home indicator, dvh not vh */
  .ui-sheet { max-height: 92vh; max-height: 92dvh; padding-bottom: env(safe-area-inset-bottom, 0px); border-radius: var(--radius-sheet) var(--radius-sheet) 0 0; }
  .ui-sheet-body { overscroll-behavior: contain; }
  .modal-card { max-height: 92vh; max-height: 92dvh; }
}
@media (max-width: 767px) {
  /* saved runs: name, date, status, coverage; the rest behind Actions */
  #savedRunsTable td[data-label="Ran by"], #savedRunsTable td[data-label="Balance"] { display: none; }
  #savedRunsTable .m-actions-btn { width: 100%; }
  #savedRunsTable tr:not(.m-actions-open) .run-actions { display: none; }
  #savedRunsTable .run-actions { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-2); }
  #savedRunsTable .run-actions .btn { width: 100%; min-height: var(--control-h); }
}
@media (max-width: 767px) {
  #reportsBarWrap.is-phone-bars { height: calc(var(--bar-rows, 5) * 44px + 56px); }
  .fit-legend { display: flex; flex-direction: column; gap: 0; }
  .fit-legend li { display: flex; align-items: center; gap: var(--space-3); min-height: var(--control-h); border-bottom: 1px solid var(--border-subtle); font-variant-numeric: tabular-nums; }
}
@media (min-width: 768px) { .m-actions-btn { display: none; } }
@media (max-width: 767px) {
  /* edit sheet: full height, Save and Cancel always reachable */
  .ui-sheet:has(.pf) { height: 100vh; height: 100dvh; max-height: none; border-radius: 0; }
  .ui-sheet .pf-actions { position: sticky; bottom: 0; display: flex; gap: var(--space-3); padding: var(--space-3) 0; background: var(--bg-surface); border-top: 1px solid var(--border-subtle); }
  .ui-sheet .pf-actions .btn { flex: 1; }
  .app-nav-link, .app-row { min-height: 48px; }
  .fit-count { margin-left: auto; }
}

/* ============================================================
   UI-9 STAGE B (part 2): filter sheet, faculty day list, tablet
   ============================================================ */
.m-filter-btn { display: none; }
@media (max-width: 767px) {
  /* filters and sorts: one trigger, the controls live in the bottom sheet */
  .m-filter-btn { display: inline-flex; align-items: center; justify-content: flex-start; width: 100%; min-height: var(--control-h); }
  .m-sheet-src:not(.m-in-sheet) { display: none !important; }
  .m-sheet-form { display: flex; flex-direction: column; gap: var(--space-4); }
  .m-sheet-form .m-sheet-src { display: flex; flex-direction: column; gap: var(--space-4); flex: none; width: 100%; }
  .m-sheet-form select { flex: none; width: 100%; max-width: none; min-height: var(--control-h); font-size: var(--text-md); }
  .m-sheet-form label.sr-only { position: static; width: auto; height: auto; margin: 0 0 var(--space-1); overflow: visible; clip: auto; white-space: normal; font-size: var(--text-sm); font-weight: 500; color: var(--text-secondary); }
  .m-sheet-form .fs-field { margin: 0; }
  .m-sheet-apply { width: 100%; min-height: var(--control-h); }
  .result-viewbar .m-filter-btn { flex: 1 1 100%; }
  /* faculty day list */
  .fs-day-items .fs-class { margin-bottom: var(--space-2); }
  .fs-day-items .ui-capped-head { margin-top: var(--space-2); }
}
/* tablet: charts side by side, cap of 10 comes from the shared capped list */
@media (min-width: 768px) and (max-width: 1100px) {
  .reports-charts-grid { grid-template-columns: 1fr 1fr; gap: var(--space-4); }
  .reports-charts-grid .chart-card .chart-canvas-wrap { height: 240px; }
}

/* ============================================================
   UI-9 STAGE B (part 3): tablet class list with details pane, sheet picker
   ============================================================ */
.ga-detail { display: none; }
@media (min-width: 768px) and (max-width: 1023px) {
  .ga-split { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--space-4); align-items: start; }
  .ga-split > * { min-width: 0; }
  .ga-split .ga-detail:not([hidden]) { display: block; position: sticky; top: var(--space-4); padding: var(--space-4); background: var(--card-bg); border: var(--border-token); border-radius: var(--radius-lg); }
  .ga-split:has(> #gaTableWrapper.ui-hide) .ga-detail { display: none; }
  .ga-detail-title { margin: 0 0 var(--space-2); font-size: var(--text-md); font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
  .ga-detail-list { margin: 0; }
  .ga-detail-list dt { padding-top: var(--space-3); font-size: var(--text-xs); font-weight: 500; color: var(--text-muted); }
  .ga-detail-list dd { margin: 0; padding-bottom: var(--space-3); border-bottom: 1px solid var(--border-subtle); font-size: var(--text-base); overflow-wrap: anywhere; }
  .ga-detail-list dd:last-child { border-bottom: 0; padding-bottom: 0; }

  /* a real table again at 768 (the stacked-card rules run up to 768): four compact columns */
  .ga-split #gaScheduleTable { display: table; width: 100%; min-width: 0 !important; table-layout: auto; }
  .ga-split #gaScheduleTable thead { display: table-header-group; position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  .ga-split #gaScheduleTable tbody { display: table-row-group; }
  .ga-split #gaScheduleTable tbody tr { display: table-row; padding: 0; background: none; border: 0; border-radius: 0; cursor: pointer; }
  .ga-split #gaScheduleTable th, .ga-split #gaScheduleTable td { display: table-cell; padding: var(--space-2) var(--space-3); border: 0; border-bottom: 1px solid var(--border-subtle); font-size: var(--text-sm); font-weight: 400; text-align: left !important; vertical-align: top; }
  .ga-split #gaScheduleTable th { font-weight: 500; }
  .ga-split #gaScheduleTable td::before { content: none !important; }
  .ga-split #gaScheduleTable td[colspan] { text-align: center !important; }
  .ga-split #gaScheduleTable :is(th, td):not([colspan]):is(:nth-child(3), :nth-child(4), :nth-child(7), :nth-child(8)) { display: none; }
  .ga-split #gaScheduleTable tbody tr.is-selected td { background: var(--bg-surface-3); }
  .ga-split #gaScheduleTable tbody tr.is-selected td:nth-child(2) { font-weight: 600; }
  .ga-split #gaScheduleTable tbody tr:focus-visible { outline: 2px solid var(--clr-primary-500); outline-offset: -2px; }
}

/* sheet picker: the native select stays in the page, the sheet shows a radio list */
@media (max-width: 767px) {
  .m-sheet-form select.m-picker-native { display: none; }
  .m-picker { display: flex; flex-direction: column; max-height: 40vh; max-height: 40dvh; overflow: auto; border: var(--border-token); border-radius: var(--radius-md); background: var(--card-bg); }
  .m-picker-opt { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex: 0 0 auto; min-height: 48px; padding: 0 var(--space-4); background: none; border: 0; border-bottom: 1px solid var(--border-subtle); font: inherit; font-size: var(--text-base); color: var(--text-primary); text-align: left; cursor: pointer; }
  .m-picker-opt:last-child { border-bottom: 0; }
  .m-picker-opt[aria-checked="true"] { font-weight: 600; background: var(--bg-surface-2); }
  .m-picker-opt[aria-checked="true"]::after { content: ""; flex: 0 0 auto; width: 5px; height: 10px; border-right: 1.5px solid var(--clr-primary-500); border-bottom: 1.5px solid var(--clr-primary-500); transform: rotate(45deg); }
  .m-picker-opt:focus-visible { outline: 2px solid var(--clr-primary-500); outline-offset: -2px; }
}

/* ============================================================
   UI-9 STAGE B (part 4): headlines, checks, solver settings, modals as sheets
   ============================================================ */
.m-headline { display: none; }
@media (max-width: 767px) {
  .m-headline { display: block; margin: 0 0 var(--space-3); font-size: var(--text-md); font-weight: 600; line-height: 1.25; color: var(--text-primary); overflow-wrap: anywhere; }
  #reportsPanel .m-headline { margin-top: var(--space-3); }
  .workload-controls-card .ga-image { display: none; }
  .check-card.m-check-extra { display: none; }
  .m-checks-toggle { width: 100%; justify-content: flex-start; }
  .m-checks-toggle[hidden] { display: none; }
  /* advanced search settings: collapsed until the label is tapped */
  .workload-controls-card:not(.m-solver-open) .solver-summary,
  .workload-controls-card:not(.m-solver-open) .btn-advanced-settings { display: none; }
  .workload-controls-card .solver-label.m-collapse-head { margin: var(--space-3) 0 0; }

  /* every field is a full touch target */
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="hidden"]), select, textarea { min-height: var(--control-h); font-size: var(--text-md); }

  /* modal dialogs become bottom sheets with stacked buttons */
  .modal-overlay { align-items: flex-end; }
  .modal-card, .modal-overlay .modal-card { margin: 0; width: 100%; max-width: none; border-radius: var(--radius-sheet) var(--radius-sheet) 0 0; transform: translateY(100%); max-height: 92vh; max-height: 92dvh; }
  .modal-overlay.open .modal-card { transform: none; }
  .modal-body { overflow-y: auto; overscroll-behavior: contain; }
  .modal-footer { flex-direction: column; gap: var(--space-2); padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px)); }
  .modal-footer button { flex: none; width: 100%; min-height: var(--control-h); }
}
@media (max-width: 767px) and (prefers-reduced-motion: reduce) { .modal-card { transition: none; } }

/* saved runs: a locked run shows its note instead of an Actions button */
@media (max-width: 767px) {
  #savedRunsTable tr.m-no-actions .run-actions { display: block; }
  #savedRunsTable .run-none { display: block; padding: var(--space-2) 0; text-align: left; font-size: var(--text-sm); color: var(--text-muted); }
  #savedRunsTable .m-actions-btn[aria-expanded="true"] { background: var(--bg-surface-3); }
}

/* ============================================================
   UI-9 STAGE B (part 4): Details toggle on every stacked table, sort trigger
   ============================================================ */
.m-sheet-label { margin: 0 0 var(--space-2); font-size: var(--text-xs); font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); }
.m-sheet-form .m-picker + .m-sheet-label { margin-top: var(--space-4); }
@media (max-width: 767px) {
  .m-stack tbody tr:not(.m-open) td.m-extra { display: none; }
  .m-stack td.m-details-cell { display: block; grid-column: 1 / -1; padding-top: 0; }
  .m-stack td.m-details-cell::before { content: none; }
  .m-sort-btn { margin-bottom: var(--space-3); }
}

/* layout helpers that replace inline styles (tokens only) */
.u-mb-2 { margin-bottom: var(--space-2); } .u-mb-4 { margin-bottom: var(--space-4); }
.u-mb-5 { margin-bottom: var(--space-5); } .u-mb-6 { margin-bottom: var(--space-6); }
.u-mt-2 { margin-top: var(--space-2); } .u-mt-3 { margin-top: var(--space-3); } .u-mt-4 { margin-top: var(--space-4); }
.u-ml-3 { margin-left: var(--space-3); }
.u-row { display: flex; gap: var(--space-3); }
.u-scroll-x { overflow-x: auto; }
.u-maxw-280 { max-width: 280px; }
.sc-label { font-size: var(--text-sm); font-weight: 500; color: var(--text-primary); white-space: nowrap; }
.btn-compact { padding: var(--space-2) var(--space-4); font-size: var(--text-sm); }
.audit-table { width: 100%; border-collapse: collapse; font-size: var(--text-base); }
@media (max-width: 767px) {
  .u-row { flex-wrap: wrap; }
  .u-row > .btn { flex: 1 1 100%; min-height: var(--control-h); }
  .u-ml-3 { margin-left: 0; margin-top: var(--space-3); }
  .u-maxw-280 { max-width: none; width: 100%; }
}
.cs-block { max-width: 80px; } .cs-size { max-width: 100px; } .cs-key { max-width: 90px; }
.u-flex-1 { flex: 1; }
.u-hint { font-size: var(--text-xs); color: var(--text-muted); }
@media (max-width: 767px) { .cs-block, .cs-size, .cs-key { max-width: none; } }

/* tooltips: a 44 px tap area on phones, and they stay inside the screen */
@media (max-width: 767px) {
  .info-tip::before { content: ""; position: absolute; inset: -13px; }
  .info-tip::after { position: fixed; left: var(--space-4); right: var(--space-4); bottom: calc(72px + env(safe-area-inset-bottom, 0px)); width: auto; max-width: none; }
}

/* ===== UI-11 disclosure ===== */
.ent-group[data-disclosure] { margin-bottom: var(--ui-sp-3); }
.ent-group[data-disclosure] > .ent-group-body { padding-top: var(--ui-sp-3); padding-bottom: var(--ui-sp-3); }
.ent-group-count { flex: 0 0 auto; margin-left: auto; }
.ent-group-btn:has(.ent-group-count) .ent-group-name { flex: 0 1 auto; }
.ui-capped-empty td, .ui-capped-empty { color: var(--text-secondary, inherit); text-align: center; padding: var(--ui-sp-3); }

.ui-capped-toggle[hidden], .ui-capped-head[hidden], .ui-capped-head .ui-capped-filter[hidden], .ent-group-body[hidden] { display: none !important; }

/* ===== UI-11 schedule views ===== */
.sv-week .sv-gap, .sv-week .sv-gap-row .tt-time-label { opacity: .55; }
.sv-week .sv-gap { background: var(--bg-page); }
.sv-empty { margin: 0; padding: var(--space-4); color: var(--text-secondary); text-align: center; }
.sv-tl { min-width: 0; max-width: 100%; }
.sv-tl-scroll { max-width: 100%; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--bg-surface); }
.sv-tl-inner { width: 100%; }
.sv-tl-row { display: flex; align-items: stretch; min-height: 56px; border-top: 1px solid var(--border-subtle); }
.sv-tl-axisrow { min-height: 32px; border-top: 0; background: var(--bg-surface-2); }
.sv-tl-name { flex: 0 0 clamp(5.5rem, 22vw, 9rem); min-width: 0; overflow-wrap: anywhere; box-sizing: border-box; padding: var(--space-2) var(--space-3); display: flex; align-items: center; font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); background: var(--bg-surface); border-right: 1px solid var(--border-subtle); }
.sv-tl-axisrow .sv-tl-name { background: var(--bg-surface-2); color: var(--text-secondary); }
.sv-tl-track { position: relative; flex: 1 1 auto; min-width: 0; }
.sv-tl-axis { height: 32px; }
.sv-tl-tick { position: absolute; top: 8px; transform: translateX(-50%); font-size: var(--text-xs); color: var(--text-secondary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sv-tl-tick.first { transform: none; }
.sv-tl-tick.last { transform: translateX(-100%); }
.sv-tl-line { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--border-subtle); opacity: .6; }
.sv-block { position: absolute; top: 6px; bottom: 6px; box-sizing: border-box; display: flex; flex-direction: column; justify-content: center; gap: 2px; min-width: 0; padding: 2px var(--space-2); overflow: hidden; border-radius: var(--radius-sm); border: 1px solid var(--border-subtle); box-shadow: inset 0 -3px 0 var(--ok); background: var(--chip-bg); color: var(--text-primary); font-size: var(--text-xs); }
.sv-block.sv-lab { box-shadow: inset 0 -3px 0 var(--clr-primary-600); }
.sv-block-subject, .sv-block-meta { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sv-block-subject { font-weight: 600; }
.sv-block-meta { color: var(--text-secondary); }
.timetable-outer .week-tabs { padding: var(--ui-sp-2) var(--ui-sp-2) 0; }
.sv-tl-list { display: none; margin: 0; padding: 0 var(--space-3) var(--space-2); list-style: none; font-size: var(--text-sm); color: var(--text-primary); overflow-wrap: anywhere; }
.sv-tl-list li { padding: var(--space-1) 0; border-top: 1px solid var(--border-subtle); }
.sv-tl-list li:first-child { border-top: 0; }
@media (max-width: 599px) {
  .sv-tl-axisrow, .sv-tl-row .sv-tl-track { display: none; }
  .sv-tl-row { display: block; }
  .sv-tl-name { border-right: 0; }
  .sv-tl-list { display: block; }
}
.sv-daypage { position: fixed; inset: 0; z-index: 20010; display: flex; flex-direction: column; min-width: 0; background: var(--bg-page); color: var(--text-primary); overflow: hidden; }
.sv-day-bar { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2) var(--space-3); padding: calc(var(--space-2) + env(safe-area-inset-top, 0px)) max(var(--space-3), env(safe-area-inset-right)) var(--space-2) max(var(--space-3), env(safe-area-inset-left)); border-bottom: 1px solid var(--border-subtle); background: var(--bg-surface-2); }
.sv-day-title { margin: 0; font-size: var(--text-lg); flex: 1 1 auto; min-width: 0; }
.sv-fac-select { min-height: 40px; max-width: 100%; padding: 0 var(--space-2); font: inherit; color: var(--text-primary); background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); }
.sv-day-switch { display: flex; flex-wrap: wrap; gap: var(--space-2); padding: var(--space-2) max(var(--space-3), env(safe-area-inset-left)); border-bottom: 1px solid var(--border-subtle); background: var(--bg-surface); }
.sv-day-btn { min-width: 48px; min-height: 40px; padding: 0 var(--space-3); font: inherit; font-weight: 600; color: var(--text-secondary); background: transparent; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); cursor: pointer; }
.sv-day-btn[aria-pressed="true"] { color: var(--text-primary); background: var(--chip-bg); border-color: var(--clr-primary-600); }
.sv-day-btn:focus-visible, .sv-back:focus-visible, .sv-fac-select:focus-visible { outline: 2px solid var(--accent, currentColor); outline-offset: 2px; }
.sv-day-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: var(--space-3) max(var(--space-3), env(safe-area-inset-right)) calc(var(--space-4) + env(safe-area-inset-bottom, 0px)) max(var(--space-3), env(safe-area-inset-left)); }

/* ===== UI-11 text sizes ===== */
/* medium is the base html size (14px) and needs no rule; small and large rules are earlier in the file */
html[data-text="xlarge"] { font-size: 19px; }
@media (max-width: 900px) { html[data-text="xlarge"] { font-size: 20px; } }

/* four text sizes must wrap instead of overflowing at 360 px; app-style.css loads later, so the selectors are more specific */
.app-card .app-seg { flex-wrap: wrap; max-width: 100%; min-width: 0; box-sizing: border-box; }
.app-card .app-seg button { flex: 1 1 auto; min-width: 0; white-space: nowrap; }
.app-card .app-row:has(> .app-seg) { flex-wrap: wrap; row-gap: var(--space-2); }
.app-card .app-row > .app-seg { flex: 1 1 100%; }

/* ===== UI-11 user menu ===== */
.ic-settings { -webkit-mask-image: url("../images/icons/settings.svg"); mask-image: url("../images/icons/settings.svg"); }
.nav-user { position: relative; display: flex; align-items: center; flex-shrink: 0; }
.nav-menu-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; min-height: 0; padding: 0;
  background: transparent; color: var(--text-primary); border: 0; border-radius: 50%; box-shadow: none; cursor: pointer;
}
.nav-menu-btn:hover { background: var(--bg-surface-3); }
.nav-menu-btn:focus-visible, .user-menu [role="menuitem"]:focus-visible { outline: 2px solid var(--clr-primary-400); outline-offset: 2px; }
.nav-menu-btn .ic { width: 24px; height: 24px; }
.user-menu {
  position: absolute; top: calc(100% + 8px); right: 0; left: auto; min-width: 180px; padding: var(--space-2);
  background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop); z-index: 2000;
}
.user-menu[hidden] { display: none; }
.user-menu [role="menuitem"] {
  display: flex; align-items: center; gap: var(--space-2); width: 100%; min-height: 44px; padding: 0 var(--space-3);
  background: transparent; border: 0; border-radius: var(--radius-sm); box-shadow: none;
  font: inherit; font-size: var(--text-base); text-align: left; text-decoration: none; color: var(--text-secondary); cursor: pointer;
}
.user-menu [role="menuitem"]:hover { background: var(--bg-surface-3); color: var(--text-primary); }
.user-menu .ic { width: 20px; height: 20px; }
@media (min-width: 901px) {
  .nav-user { justify-self: end; }
}
@media (max-width: 900px) {
  .nav-back { grid-column: 1; grid-row: 1; }
  .nav-title { grid-column: 2; grid-row: 1; min-width: 0; }
  .nav-user { grid-column: 3; grid-row: 1; }
}


/* ===== UI-11 home professors ===== */
.dash-fac-picker { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.dash-fac-buttons { display: flex; flex-wrap: wrap; gap: var(--space-2); min-width: 0; }
.dash-fac-btn {
  min-height: 44px; max-width: 100%; padding: 0 var(--space-4); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: var(--bg-surface); color: var(--text-primary); border: 1px solid var(--border-default); border-radius: var(--radius-md);
  font: inherit; font-size: var(--text-base); cursor: pointer;
}
.dash-fac-btn:hover { background: var(--bg-surface-3); }
.dash-fac-btn[aria-pressed="true"] { background: var(--clr-primary-50); color: var(--clr-primary-600); border-color: var(--clr-primary-400); font-weight: 600; }
.dash-fac-btn:focus-visible, .dash-fac-select:focus-visible { outline: 2px solid var(--clr-primary-400); outline-offset: 2px; }
.dash-fac-select-wrap { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; max-width: 100%; }
.dash-fac-select-label { font-size: var(--text-sm); color: var(--text-muted); }
.dash-fac-select { min-height: 44px; max-width: 100%; }
.dash-fac-week { min-width: 0; max-width: 100%; }
@media (max-width: 767px) {
  .dash-fac-picker { flex-direction: column; align-items: stretch; }
  .dash-fac-select-wrap, .dash-fac-select { width: 100%; }
}


/* ===== UI-11 reports ===== */
.rep-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3); margin-bottom: var(--space-3); }
.rep-field { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; max-width: 100%; }
.rep-label { font-size: var(--text-sm); color: var(--text-muted); }
.rep-select { min-height: 44px; max-width: 100%; }
.rep-select:focus-visible, .rep-day-btn:focus-visible { outline: 2px solid var(--clr-primary-400); outline-offset: 2px; }
.rep-help { flex-basis: 100%; margin: 0; font-size: var(--text-sm); color: var(--text-muted); }
.rep-days { display: flex; flex-wrap: wrap; gap: var(--space-2); min-width: 0; }
.rep-day-btn {
  min-height: 44px; padding: 0 var(--space-3); background: var(--bg-surface); color: var(--text-primary);
  border: 1px solid var(--border-default); border-radius: var(--radius-md); font: inherit; font-size: var(--text-base); cursor: pointer;
}
.rep-day-btn:hover { background: var(--bg-surface-3); }
.reports-section.ent-group { margin-bottom: var(--space-4); }
@media (max-width: 767px) {
  .rep-controls { align-items: stretch; }
  .rep-field, .rep-select { width: 100%; }
  .rep-day-btn { flex: 1 1 30%; padding: 0 var(--space-2); }
}
/* ===== UI-11 chair sections ===== */
.ent-sec.ent-group { margin-bottom: var(--space-4); }
.ent-sec > .ent-group-body { padding-top: var(--space-3); padding-bottom: var(--space-4); }
.ent-sec .ent-head { justify-content: flex-end; }
.ent-sec .ent-head .save-status { margin-right: auto; }

/* ===== UI-11 profile and details ===== */
.ic-profile { -webkit-mask-image: url("../images/icons/profile.svg"); mask-image: url("../images/icons/profile.svg"); }
.fs-profile-head { display: flex; align-items: flex-start; gap: var(--space-5); }
.fs-profile-lines { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.fs-profile-lines .fs-field { margin-bottom: 0; }
.fs-label { font-size: var(--text-sm); font-weight: 600; color: var(--text-secondary); }
.fs-text, .fs-copytext, .fs-dept-list li { user-select: text; -webkit-user-select: text; overflow-wrap: anywhere; }
.fs-copyrow { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; min-height: 44px; }
.fs-copytext { flex: 1 1 auto; min-width: 0; padding: var(--space-2) 0; color: var(--text-primary); }
.fs-card .btn.fs-copy, .fs-card #fsDeptRetry { width: auto; min-height: 44px; flex: 0 0 auto; }
.fs-dept-gap { display: block; margin-top: var(--space-4); }
.fs-dept-list { margin: var(--space-2) 0 0; padding-left: var(--space-5); display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--space-1) var(--space-4); }
.fs-field select { min-height: 44px; }
.fs-avatar .av-host, .av-host.fs-avatar { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); flex-shrink: 0; }
.fs-avatar .app-avatar { display: flex; align-items: center; justify-content: center; width: 72px; height: 72px; border-radius: 50%; background: var(--clr-primary-50); color: var(--clr-primary-600); font-size: var(--text-xl); font-weight: 600; position: relative; overflow: hidden; }
.fs-avatar .av-img { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.fs-avatar .av-letter[hidden], .fs-avatar .av-input[hidden] { display: none; }
.fs-avatar .av-actions { display: flex; flex-direction: column; align-items: stretch; gap: var(--space-1); }
.fs-avatar .app-btn { min-height: 44px; padding: 0 var(--space-3); white-space: nowrap; background: var(--bg-surface); color: var(--text-primary); border: 1px solid var(--border-default); border-radius: var(--radius-md); font: inherit; font-size: var(--text-sm); cursor: pointer; }
.fs-avatar .app-btn:hover { background: var(--bg-surface-3); }
.fs-avatar .app-btn:focus-visible { outline: 2px solid var(--clr-primary-400); outline-offset: 2px; }
@media (max-width: 480px) {
  .fs-profile-head { flex-direction: column; align-items: stretch; }
  .fs-avatar { align-self: center; }
  .fs-dept-list { grid-template-columns: 1fr; }
}

/* ===== UI-11 faculty lists ===== */
.fs-filter-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3, 12px); margin: 0 0 var(--space-3, 12px); }
.fs-filter-row .fs-field { flex: 1 1 140px; min-width: 0; margin: 0; }
.fs-filter-row .fs-field select { width: 100%; min-height: 44px; }
.fs-filter-row .btn { min-height: 44px; flex: 0 0 auto; }
.fs-filter-row .btn[hidden] { display: none; }
@media (max-width: 480px) {
  .fs-filter-row .fs-field { flex: 1 1 100%; }
  .fs-filter-row .btn { flex: 1 1 100%; }
}
#facTestReminder { min-height: 44px; }

/* ===== UI-11B charts ===== */
.chart-scroll { width: 100%; height: 100%; max-width: 100%; overflow-x: auto; overflow-y: hidden; }
.chart-scroll-inner { position: relative; height: 100%; min-width: 100%; }
.mini-chart-wrapper { min-width: 0; max-width: 100%; overflow-x: auto; overflow-y: hidden; }
@media (max-width: 520px) {
  .mini-chart-wrapper canvas { max-width: none; }
}

/* ===== UI-11B topbar ===== */
.nav-logo-mobile { display: none; }
@media (max-width: 900px) {
  .nav-logo-mobile { display: block; grid-column: 1; grid-row: 1; width: 32px; height: 32px; justify-self: start; align-self: center; }
  .nav-back.is-hidden { display: none; }
}
/* ===== UI-11B section navigator ===== */
.nav-section-hidden { display: none !important; }
button.nav-item { line-height: inherit; text-align: left; }
button.nav-item:focus-visible, .nav-dd-item:focus-visible { outline: 2px solid var(--clr-primary-400); outline-offset: 2px; }
.nav-dd-menu {
  position: fixed; top: 0; left: 0; z-index: 1900; min-width: 260px; max-width: calc(100vw - 16px); padding: var(--space-2);
  background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop);
}
.nav-dd-menu[hidden] { display: none; }
/* NAVIN-01: invisible strip above the menu so the pointer can cross the gap from the top bar item without closing it */
.nav-dd-menu::before { content: ""; position: absolute; left: 0; right: 0; top: -10px; height: 10px; background: transparent; }
.nav-dd-sep { height: 1px; margin: var(--space-2) var(--space-3); background: var(--border-default); }
.nav-dd-item {
  white-space: nowrap;
  display: flex; align-items: center; width: 100%; min-height: 44px; padding: 0 var(--space-3); margin: 0;
  background: transparent; border: 0; border-radius: var(--radius-sm); box-shadow: none;
  font: inherit; font-size: var(--text-base); text-align: left; color: var(--text-secondary); cursor: pointer;
}
.nav-dd-item:hover { background: var(--bg-surface-3); color: var(--text-primary); }
.nav-dd-item[aria-current="true"] { background: var(--clr-primary-50); color: var(--clr-primary-600); font-weight: 700; }
.page-header .nav-section-now { flex: 0 0 100%; order: 5; margin: 0; max-width: none; font-size: var(--text-sm); color: var(--text-muted); }
.page-header .nav-section-now[hidden] { display: none; }

/* ===== UI-11B phone section cards ===== */
.section-hub, .section-back-bar { display: none; }
@keyframes ui11b-hub-fade { from { opacity: 0; } to { opacity: 1; } }
@media (max-width: 900px) {
  .section-hub:not([hidden]) { display: flex; flex-direction: column; gap: var(--space-3); margin: var(--space-3) 0 var(--space-4); animation: ui11b-hub-fade 0.18s var(--ease-ui, cubic-bezier(0.4, 0, 0.2, 1)); }
  .section-back-bar:not([hidden]) { display: block; position: sticky; top: 0; z-index: 5; margin: 0 0 var(--space-3); padding: var(--space-1) 0; background: var(--bg-page); }
  .section-card {
    display: flex; align-items: center; gap: var(--space-3); width: 100%; min-height: 72px; margin: 0; padding: var(--space-3) var(--space-4);
    background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-lg); box-shadow: none;
    font: inherit; text-align: left; color: var(--text-primary); cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  .section-card:active { background: var(--bg-surface-3); border-color: var(--border-strong); }
  .section-card:focus-visible, .section-back:focus-visible { outline: 2px solid var(--clr-primary-400); outline-offset: 2px; }
  .section-card-ic { flex: 0 0 auto; width: 28px; height: 28px; color: var(--clr-primary-600); background-color: currentColor; }
  .section-card-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
  .section-card-title { font-size: var(--text-md); font-weight: 700; color: var(--text-primary); overflow-wrap: anywhere; }
  .section-card-desc { font-size: var(--text-sm); color: var(--text-muted); overflow-wrap: anywhere; }
  .section-card-chev, .section-back-chev { flex: 0 0 auto; width: 9px; height: 9px; border-top: 2px solid var(--text-muted); border-right: 2px solid var(--text-muted); transform: rotate(45deg); }
  .section-back-chev { transform: rotate(-135deg); border-color: currentColor; }
  .section-back {
    display: inline-flex; align-items: center; gap: var(--space-2); min-height: 44px; margin: 0; padding: 0 var(--space-3) 0 var(--space-2);
    background: transparent; border: 0; box-shadow: none; font: inherit; font-size: var(--text-base); font-weight: 700; color: var(--clr-primary-600); cursor: pointer;
  }
  .section-back:active { background: var(--bg-surface-3); border-radius: var(--radius-sm); }
  .section-back-text { min-width: 0; overflow-wrap: anywhere; text-align: left; }
}
@media (min-width: 901px) { .section-hub, .section-back-bar { display: none !important; } }
@media (prefers-reduced-motion: reduce) { .section-hub:not([hidden]) { animation: none; } }

/* ===== UI-11B home week ===== */
.dash-fac-week .week-scroll { max-width: 100%; }

/* ===== UI-11B hub card wrap ===== */
@media (max-width: 900px) {
  .section-card { box-sizing: border-box; max-width: 100%; white-space: normal; overflow: hidden; }
  .section-card-text, .section-card-title, .section-card-desc { min-width: 0; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
}

/* ===== UI-11B live chart box ===== */
.mini-chart-wrapper .mini-chart-inner { position: relative; width: 200px; min-width: 200px; height: 140px; }
.mini-chart-wrapper .mini-chart-inner canvas { display: block; max-width: none; width: 100% !important; height: 100% !important; }

/* ===== UI-11B back card ===== */
@media (max-width: 900px) {
  .section-back-bar:not([hidden]) { padding: var(--space-1) 0; margin: 0 0 var(--space-3); background: var(--bg-page); }
  .section-back-bar .section-back {
    display: flex; align-items: center; gap: var(--space-3); box-sizing: border-box; width: 100%; max-width: 100%; min-height: 56px; margin: 0;
    padding: var(--space-2) var(--space-4); background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-lg);
    box-shadow: none; font: inherit; font-size: var(--text-md); font-weight: 700; line-height: 1.3; text-align: left; white-space: normal;
    color: var(--clr-primary-600); cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  .section-back-bar .section-back:active { background: var(--bg-surface-3); border-color: var(--border-strong); border-radius: var(--radius-lg); }
  .section-back-bar .section-back:focus-visible { outline: 2px solid var(--clr-primary-400); outline-offset: 2px; }
  .section-back-bar .section-back-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
}

/* ===== UI-11B back card flat ===== */
@media (max-width: 900px) {
  .section-back-bar:not([hidden]) { position: static; background: transparent; padding: 0; box-shadow: none; border: 0; }
  .section-back-bar .section-back, .section-back-bar .section-back:active, .section-back-bar .section-back:hover { box-shadow: none; filter: none; }
  .section-back-bar .section-back { background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-lg); }
}


/* ===== BF-01 layers ===== */
/* Layer order, bottom to top: bottom nav and top bar, menus, day page (.sv-daypage),
   sheets (.ui-sheet-ov, .ui-sheet), dialogs and move strips (.ad-ov, .mv-reason), toast. */
.toast-notif { z-index: 2147483600; }

/* ===== BF-01 scroll ===== */
.panel { overflow-anchor: none; }
.ui-sheet-body, .sv-daypage { overscroll-behavior: contain; }
/* ===== GRID-09: 30-minute week grid (fine mode only, legacy tables keep the rules above) ===== */
.week-table.is-fine { --wk-row-h: calc(var(--ui-fs-1) * 2.3); min-width: 0; }
.week-scroll.is-fine { overflow: visible; }
.week-table.is-fine thead th.wk-corner, .week-table.is-fine tbody th { width: 3.5rem; }
/* GF-03: a run of 60 minutes or more with no class collapses into one slim row; its label sits over the day columns */
.week-table tbody tr.wk-gap-row, .week-table tbody tr.wk-gap-row th, .week-table tbody tr.wk-gap-row td { height: 1.5rem; padding: 0; line-height: 1; vertical-align: middle; color: var(--text-secondary); background: var(--bg-page); font-size: var(--ui-fs-1); }
.week-table tbody tr.wk-gap-row th { position: relative; overflow: visible; white-space: nowrap; text-align: left; font-weight: 400; }
.wk-gap-label { position: absolute; z-index: 1; left: var(--ui-sp-2); top: 50%; transform: translateY(-50%); white-space: nowrap; }
.week-table.is-fine tbody tr { height: var(--wk-row-h); }
.week-table.is-fine tbody th { height: var(--wk-row-h); padding: 0 var(--ui-sp-2); line-height: 1; vertical-align: top; font-size: var(--ui-fs-1); }
.week-table.is-fine td { padding: 0; height: var(--wk-row-h); }
.week-table.is-fine td.wk-has { position: relative; }
.week-table.is-fine td.wk-has:not(.wk-stack) > .wk-class { position: absolute; top: 1px; right: 1px; bottom: 1px; left: 1px; width: auto; height: auto; margin: 0; padding: 2px var(--ui-sp-1); gap: 0; overflow: hidden; }
.week-table.is-fine td.wk-stack { padding: var(--ui-sp-1); }
.week-table.is-fine .wk-class > span { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.week-table.is-fine .wk-class .wk-tags { flex-wrap: nowrap; overflow: hidden; margin-top: 0; }
.wk-ok.wk-ok-start { align-items: center; padding-top: 0; border-width: 1px; opacity: .75; }
.wk-ok.wk-ok-start.is-over { opacity: 1; border-style: solid; }
.wk-span { position: absolute; z-index: 3; box-sizing: border-box; display: flex; align-items: flex-start; justify-content: center; padding-top: var(--ui-sp-1); border: 2px solid var(--clr-primary-600); border-radius: var(--radius-md); background: transparent; pointer-events: none; }
.wk-span[hidden] { display: none; }
.timetable-grid.is-fine { --wk-row-h: calc(var(--text-sm) * 2.3); }
.timetable-grid tbody tr.sv-gap-row, .timetable-grid tbody tr.sv-gap-row td, .timetable-grid tbody tr.tt-gap-row, .timetable-grid tbody tr.tt-gap-row td { height: 1.5rem; padding: 0; line-height: 1; vertical-align: middle; color: var(--text-secondary); font-size: var(--ui-fs-1); }
.timetable-grid tbody tr.sv-gap-row td.tt-time-label, .timetable-grid tbody tr.tt-gap-row td.tt-time-label { position: relative; overflow: visible; white-space: nowrap; text-align: left; }
.timetable-grid.is-fine tbody tr { height: var(--wk-row-h); }
.timetable-grid.is-fine .tt-time-label { padding: 0 var(--space-2); line-height: 1; vertical-align: top; }
.timetable-grid.is-fine td.tt-cell { padding: 0; height: var(--wk-row-h); }
.timetable-grid.is-fine td.tt-filled { position: relative; }
.timetable-grid.is-fine td.tt-filled:not(.wk-stack) > .tt-entry { position: absolute; top: 1px; right: 1px; bottom: 1px; left: 1px; overflow: hidden; padding: 2px var(--space-1, 4px); }
.timetable-grid.is-fine .tt-entry > * { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tt-when { color: var(--text-secondary); font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { .wk-span { transition: none; } }

/* ============================================================
   THEME-01: department accent colors
   app-core.js sets data-dept (IT, CS, MB, ES, MedB) on the html element after sign-in. Only the accent tokens,
   the focus ring, the period chip and the page tint change. Flat colors only. scripts/check_contrast.py
   loops the five departments in light and dark. IT neon green, CS forest green, MB sky blue, ES light green, MedB mint.
   The 500 and 600 steps stay dark enough for white button text (AA); the light tints carry the brighter look.
   ============================================================ */
/* IT: neon green */
[data-dept="IT"] {
  --clr-primary-50: #e7feee; --clr-primary-100: #cbfbdb; --clr-primary-200: #a3f5be; --clr-primary-300: #00c943; --clr-primary-400: #009e35;
  --clr-primary-500: #00802b; --clr-primary-600: #006321; --clr-primary-700: #004b19; --clr-primary-800: #003412;
  --accent-rgb: 0, 128, 43; --input-focus-ring: rgba(0, 128, 43, 0.15); --bg-page: #e5f5ea;
  --chip-p-bg: var(--clr-primary-50); --chip-p-fg: var(--clr-primary-700); --chip-p-link: var(--clr-primary-600); --rc-link: var(--clr-primary-600);
}
[data-dept="IT"][data-theme="dark"] {
  --clr-primary-50: #173621; --clr-primary-100: #1f472c; --clr-primary-200: #2b643e; --clr-primary-300: #398452;
  --clr-primary-600: #7bf4a3; --clr-primary-700: #b6f7cb; --clr-primary-800: #d6fae2;
  --btn-hover: #006321; --input-focus-ring: rgba(123, 244, 163, 0.28); --bg-page: #0d1610;
  --chip-p-bg: var(--clr-primary-50); --chip-p-fg: var(--clr-primary-800); --chip-p-link: var(--clr-primary-600); --rc-link: var(--clr-primary-600);
}
/* CS: forest green */
[data-dept="CS"] {
  --clr-primary-50: #e8fee7; --clr-primary-100: #cdfbcb; --clr-primary-200: #a6f5a3; --clr-primary-300: #72bf70; --clr-primary-400: #489a45;
  --clr-primary-500: #3a7c37; --clr-primary-600: #2d5f2b; --clr-primary-700: #214820; --clr-primary-800: #173116;
  --accent-rgb: 58, 124, 55; --input-focus-ring: rgba(58, 124, 55, 0.15); --bg-page: #e6f5e5;
  --chip-p-bg: var(--clr-primary-50); --chip-p-fg: var(--clr-primary-700); --chip-p-link: var(--clr-primary-600); --rc-link: var(--clr-primary-600);
}
[data-dept="CS"][data-theme="dark"] {
  --clr-primary-50: #183617; --clr-primary-100: #20471f; --clr-primary-200: #2d642b; --clr-primary-300: #3b8439;
  --clr-primary-600: #7ff47b; --clr-primary-700: #b8f7b6; --clr-primary-800: #d7fad6;
  --btn-hover: #2d5f2b; --input-focus-ring: rgba(127, 244, 123, 0.28); --bg-page: #0e160d;
  --chip-p-bg: var(--clr-primary-50); --chip-p-fg: var(--clr-primary-800); --chip-p-link: var(--clr-primary-600); --rc-link: var(--clr-primary-600);
}
/* MB: sky blue */
[data-dept="MB"] {
  --clr-primary-50: #e7f6fe; --clr-primary-100: #cbebfb; --clr-primary-200: #a3daf5; --clr-primary-300: #40b9f5; --clr-primary-400: #0b91d3;
  --clr-primary-500: #0975aa; --clr-primary-600: #075a84; --clr-primary-700: #054463; --clr-primary-800: #042f45;
  --accent-rgb: 9, 117, 170; --input-focus-ring: rgba(9, 117, 170, 0.15); --bg-page: #e5f0f5;
  --chip-p-bg: var(--clr-primary-50); --chip-p-fg: var(--clr-primary-700); --chip-p-link: var(--clr-primary-600); --rc-link: var(--clr-primary-600);
}
[data-dept="MB"][data-theme="dark"] {
  --clr-primary-50: #172b36; --clr-primary-100: #1f3a47; --clr-primary-200: #2b5164; --clr-primary-300: #396b84;
  --clr-primary-600: #7bccf4; --clr-primary-700: #b6e1f7; --clr-primary-800: #d6eefa;
  --btn-hover: #075a84; --input-focus-ring: rgba(123, 204, 244, 0.28); --bg-page: #0d1316;
  --chip-p-bg: var(--clr-primary-50); --chip-p-fg: var(--clr-primary-800); --chip-p-link: var(--clr-primary-600); --rc-link: var(--clr-primary-600);
}
/* ES: light green */
[data-dept="ES"] {
  --clr-primary-50: #f8fee7; --clr-primary-100: #eefbcb; --clr-primary-200: #dff5a3; --clr-primary-300: #8dbc0a; --clr-primary-400: #709508;
  --clr-primary-500: #597706; --clr-primary-600: #455c05; --clr-primary-700: #344504; --clr-primary-800: #243003;
  --accent-rgb: 89, 119, 6; --input-focus-ring: rgba(89, 119, 6, 0.15); --bg-page: #f1f5e5;
  --chip-p-bg: var(--clr-primary-50); --chip-p-fg: var(--clr-primary-700); --chip-p-link: var(--clr-primary-600); --rc-link: var(--clr-primary-600);
}
[data-dept="ES"][data-theme="dark"] {
  --clr-primary-50: #2d3617; --clr-primary-100: #3d471f; --clr-primary-200: #55642b; --clr-primary-300: #708439;
  --clr-primary-600: #d4f47b; --clr-primary-700: #e5f7b6; --clr-primary-800: #f1fad6;
  --btn-hover: #455c05; --input-focus-ring: rgba(212, 244, 123, 0.28); --bg-page: #14160d;
  --chip-p-bg: var(--clr-primary-50); --chip-p-fg: var(--clr-primary-800); --chip-p-link: var(--clr-primary-600); --rc-link: var(--clr-primary-600);
}
/* MedB: mint green */
[data-dept="MedB"] {
  --clr-primary-50: #e7fefb; --clr-primary-100: #cbfbf4; --clr-primary-200: #a3f5ea; --clr-primary-300: #10c2ab; --clr-primary-400: #0d9b88;
  --clr-primary-500: #0a7c6c; --clr-primary-600: #086054; --clr-primary-700: #06483f; --clr-primary-800: #04332c;
  --accent-rgb: 10, 124, 108; --input-focus-ring: rgba(10, 124, 108, 0.15); --bg-page: #e5f5f3;
  --chip-p-bg: var(--clr-primary-50); --chip-p-fg: var(--clr-primary-700); --chip-p-link: var(--clr-primary-600); --rc-link: var(--clr-primary-600);
}
[data-dept="MedB"][data-theme="dark"] {
  --clr-primary-50: #173631; --clr-primary-100: #1f4742; --clr-primary-200: #2b645c; --clr-primary-300: #39847a;
  --clr-primary-600: #7bf4e4; --clr-primary-700: #b6f7ee; --clr-primary-800: #d6faf6;
  --btn-hover: #086054; --input-focus-ring: rgba(123, 244, 228, 0.28); --bg-page: #0d1615;
  --chip-p-bg: var(--clr-primary-50); --chip-p-fg: var(--clr-primary-800); --chip-p-link: var(--clr-primary-600); --rc-link: var(--clr-primary-600);
}

/* THEME-01: the flat layout paints the light dashboard white; with a department set the page takes the department tint instead.
   Cards, tables and the top bar keep their own surface colors. */
html[data-dept], html[data-dept] body:has(.top-navbar), html[data-dept] .panels-wrapper { background: var(--bg-page); }

/* THEME-01: density. Comfortable is the default. Compact tightens the spacing scale and the desktop control height;
   phones keep 44 px controls in both (the phone value of --control-h is not touched). */
html[data-density="compact"] { --space-1: 0.1875rem; --space-2: 0.375rem; --space-3: 0.5625rem; --space-4: 0.75rem; --space-5: 1.125rem; --space-6: 1.5rem; --space-7: 2.25rem; }
@media (min-width: 768px) { html[data-density="compact"] { --control-h: 34px; } }

/* THEME-01 hardening: the period chip is a control, so it keeps the 44 px phone target in both densities. */
@media (max-width: 900px) { .page-header .period-chip { min-height: var(--control-h); } }
/* HELP-01: the department banner and the notice share one grid row, so the notice needs no row of its own */
.home-top { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; column-gap: var(--space-4); margin-bottom: var(--space-3); }
.home-top .dept-banner { grid-column: 1; margin-bottom: 0; }
.home-top .home-hint { grid-column: 2; grid-row: 1; margin: 0; }
@media (max-width: 900px) {
  .home-top { grid-template-columns: minmax(0, 1fr); row-gap: var(--space-3); }
  .home-top .home-hint { grid-column: 1; grid-row: auto; }
}
/* HELP-01: first-run notice on Home, a small bubble above the period chip. Warning tokens only (contrast pair is in scripts/check_contrast.py). */
.home-hint { display: flex; align-items: flex-start; gap: var(--space-2); max-width: 24rem; margin: 0 0 var(--space-3) auto; padding: var(--space-2) var(--space-3); background: var(--ui-warning-bg); color: var(--ui-warning-fg); border: 1px solid var(--ui-warning-fg); border-radius: var(--radius-lg); font-size: var(--text-sm); }
.home-hint[hidden] { display: none; }
.home-hint .ic { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }
.home-hint-body { flex: 1 1 auto; min-width: 0; }
.home-hint h3 { margin: 0; padding: 0; border: 0; font-size: var(--text-base); color: inherit; }
.home-hint p { margin: 0; color: inherit; }
.home-hint-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-2); }
.home-hint-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 32px; padding: 0 var(--space-3); border: 1px solid var(--ui-warning-fg); border-radius: var(--radius-md); background: transparent; color: var(--ui-warning-fg); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
/* the global button:hover and button:active rules would fill the button, so every state is pinned here */
.home-hint-btn:hover, .home-hint-btn:active, .home-hint-btn:focus { background: transparent; color: var(--ui-warning-fg); }
.home-hint-btn:hover { text-decoration: underline; }
.home-hint-btn:active { filter: none; transform: none; }
.home-hint-btn:focus-visible { outline: 2px solid var(--ui-warning-fg); outline-offset: 2px; }
@media (min-width: 901px) {
  .home-hint { max-width: 34rem; }
  .home-hint-body { display: flex; align-items: center; gap: var(--space-3); }
  .home-hint-text { flex: 1 1 auto; min-width: 0; }
  .home-hint-actions { margin-top: 0; flex-wrap: nowrap; flex-shrink: 0; }
}
@media (max-width: 900px) {
  .home-hint { max-width: none; margin-left: 0; }
  .home-hint-btn { min-height: 44px; flex: 1 1 auto; }
}
