/* ==========================================================================
   PUCIT Class CMS - Unified Design System Stylesheet
   Faithfully inspired by Google Stitch PUCIT Class Management System References
   Light Mode (Collegiate Clean) & Dark Mode (Modern Deep Charcoal / Zinc)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CSS Custom Properties / Design Tokens
   -------------------------------------------------------------------------- */
:root,
html.light,
[data-theme="light"],
[data-bs-theme="light"] {
  --theme: 'light';

  /* Canvas & Surfaces */
  --bg-canvas: #f5f5f5;
  --bg-surface: #ffffff;
  --bg-elevated: #fafafa;
  --bg-elevated-hover: #f4f4f5;
  --bg-hover: #f4f4f5;
  --bg-active: #e5e5e5;

  /* Borders */
  --border: #e5e5e5;
  --border-light: #f4f4f5;
  --border-strong: #d4d4d8;
  --border-focus: #0f172a;

  /* Typography Colors */
  --text: #0f172a;
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-faint: #94a3b8;

  /* Primary Button / Highlight */
  --primary: #0f2744;
  --primary-hover: #1e3a8a;
  --primary-fg: #ffffff;

  /* Semantic Status: Emerald (Success / Present / Active) */
  --emerald: #059669;
  --emerald-fg: #065f46;
  --emerald-bg: #ecfdf5;
  --emerald-border: #a7f3d0;

  /* Semantic Status: Amber (Warning / Pending / Due Soon) */
  --amber: #d97706;
  --amber-fg: #92400e;
  --amber-bg: #fffbeb;
  --amber-border: #fde68a;

  /* Semantic Status: Rose / Red (Danger / Absent / Overdue) */
  --rose: #dc2626;
  --rose-fg: #991b1b;
  --rose-bg: #fef2f2;
  --rose-border: #fecaca;

  /* Semantic Status: Blue / Info */
  --blue: #2563eb;
  --blue-fg: #1e40af;
  --blue-bg: #eff6ff;
  --blue-border: #bfdbfe;

  /* Elevation Shadows: Architectural, crisp, low-contrast */
  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.06), 0 1px 2px -1px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.03);

  /* Radius */
  --radius-xs: 3px;
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 8px;
  --radius-full: 9999px;

  /* Fonts */
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Tabler / Bootstrap token integration */
  --tblr-body-bg: var(--bg-canvas);
  --tblr-body-color: var(--text);
  --tblr-border-color: var(--border);
  --tblr-card-bg: var(--bg-surface);
  --tblr-primary: var(--primary);
}

html.dark,
[data-theme="dark"],
[data-bs-theme="dark"] {
  --theme: 'dark';

  /* Canvas & Surfaces */
  --bg-canvas: #09090b;
  --bg-surface: #121214;
  --bg-elevated: #18181b;
  --bg-elevated-hover: #222226;
  --bg-hover: #1f1f23;
  --bg-active: #27272a;

  /* Borders */
  --border: #27272a;
  --border-light: #1f1f23;
  --border-strong: #3f3f46;
  --border-focus: #f4f4f5;

  /* Typography Colors */
  --text: #f4f4f5;
  --text-primary: #f4f4f5;
  --text-secondary: #d4d4d8;
  --text-muted: #a1a1aa;
  --text-faint: #71717a;

  /* Primary Button / Highlight */
  --primary: #f4f4f5;
  --primary-hover: #ffffff;
  --primary-fg: #09090b;

  /* Semantic Status: Emerald */
  --emerald: #34d399;
  --emerald-fg: #6ee7b7;
  --emerald-bg: rgba(6, 78, 59, 0.4);
  --emerald-border: rgba(5, 150, 105, 0.5);

  /* Semantic Status: Amber */
  --amber: #fbbf24;
  --amber-fg: #fde68a;
  --amber-bg: rgba(120, 53, 15, 0.4);
  --amber-border: rgba(217, 119, 6, 0.5);

  /* Semantic Status: Rose */
  --rose: #f87171;
  --rose-fg: #fca5a5;
  --rose-bg: rgba(127, 29, 29, 0.4);
  --rose-border: rgba(220, 38, 38, 0.5);

  /* Semantic Status: Blue */
  --blue: #60a5fa;
  --blue-fg: #93c5fd;
  --blue-bg: rgba(30, 58, 138, 0.4);
  --blue-border: rgba(37, 99, 235, 0.5);

  /* Elevation Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.4), 0 1px 2px -1px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6), 0 4px 6px -4px rgba(0, 0, 0, 0.5);

  /* Tabler / Bootstrap token integration */
  --tblr-body-bg: var(--bg-canvas);
  --tblr-body-color: var(--text);
  --tblr-border-color: var(--border);
  --tblr-card-bg: var(--bg-surface);
  --tblr-primary: var(--primary);
}

/* --------------------------------------------------------------------------
   2. Reset & Typography
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 14px;
  background-color: var(--bg-canvas);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans) !important;
  font-size: 13.5px !important;
  line-height: 1.5 !important;
  color: var(--text) !important;
  background-color: var(--bg-canvas) !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--text) !important;
  font-family: var(--font-sans);
  font-weight: 600;
  line-height: 1.25;
  margin: 0;
}

h1, .h1 { font-size: 20px !important; font-weight: 700 !important; letter-spacing: -0.015em; }
h2, .h2 { font-size: 16px !important; font-weight: 600 !important; letter-spacing: -0.01em; }
h3, .h3 { font-size: 15px !important; font-weight: 600 !important; }
h4, .h4 { font-size: 14px !important; font-weight: 600 !important; }
h5, .h5 { font-size: 13px !important; font-weight: 600 !important; }

p {
  margin-top: 0;
  margin-bottom: 0.75rem;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  color: inherit;
}

/* Tabular figures for numbers, IDs, timestamps */
.font-mono,
.font-monospace,
.tabular-nums,
.tabular-stat {
  font-family: var(--font-mono) !important;
  font-feature-settings: "tnum" 1, "cv05" 1;
  font-variant-numeric: tabular-nums;
}

/* Material symbols outlined standard sizing */
.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
  font-size: 18px;
  line-height: 1;
  vertical-align: middle;
  display: inline-block;
  user-select: none;
}

/* --------------------------------------------------------------------------
   3. Shell, Sidebar & Header Layout
   -------------------------------------------------------------------------- */
.app-shell {
  display: flex;
  min-height: 100vh;
  background-color: var(--bg-canvas);
  position: relative;
}

/* Fixed 256px Sidebar */
.app-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 256px;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border);
  z-index: 50;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  user-select: none;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.15s ease, border-color 0.15s ease;
  overflow-y: auto;
}

.sidebar-header {
  height: 64px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background-color: var(--bg-elevated);
  flex-shrink: 0;
}

.brand-crest {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background-color: var(--primary);
  color: var(--primary-fg);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: var(--font-sans);
}

.brand-text-block {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-subtitle {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-section-title {
  padding: 16px 16px 6px 16px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}

.sidebar-nav {
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all 0.15s ease;
  text-decoration: none;
}

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

.sidebar-nav .nav-link.active,
.sidebar-nav .nav-link[aria-current="page"] {
  background-color: var(--primary);
  color: var(--primary-fg);
  font-weight: 600;
}

.sidebar-nav .nav-link.active .material-symbols-outlined,
.sidebar-nav .nav-link.active svg {
  color: var(--primary-fg);
}

.sidebar-nav .nav-link .nav-link-icon,
.sidebar-nav .nav-link .material-symbols-outlined {
  font-size: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.sidebar-nav .nav-link .sidebar-badge {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 600;
  font-family: var(--font-mono);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-active);
  color: var(--text-secondary);
}

.sidebar-nav .nav-link.active .sidebar-badge {
  background-color: rgba(255, 255, 255, 0.2);
  color: var(--primary-fg);
}

/* Sidebar Footer / Pipeline card */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  background-color: var(--bg-elevated);
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.sidebar-pipeline-card {
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background-color: var(--bg-surface);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Main Content Wrapper */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin-left: 256px;
  width: calc(100% - 256px);
  background-color: var(--bg-canvas);
  transition: margin-left 0.2s ease, width 0.2s ease;
}

@media (max-width: 1023.98px) {
  .app-sidebar {
    transform: translateX(-100%);
    max-width: 85vw;
    width: 270px;
    box-shadow: none;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    -webkit-overflow-scrolling: touch;
  }
  .app-sidebar.show {
    transform: translateX(0);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  }
  .app-main {
    margin-left: 0;
    width: 100%;
  }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(9, 9, 11, 0.6);
    backdrop-filter: blur(2px);
    z-index: 45;
  }
  .sidebar-backdrop.show {
    display: block;
  }
}

/* Top Fixed Header */
.app-header {
  position: fixed;
  top: 0;
  right: 0;
  left: 256px;
  height: 64px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  padding-top: env(safe-area-inset-top, 0px);
  transition: left 0.2s ease, background-color 0.15s ease, border-color 0.15s ease;
}

@media (max-width: 1023.98px) {
  .app-header {
    left: 0;
    padding: 0 12px;
  }
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Breadcrumb in Header */
.breadcrumb-container {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.breadcrumb-container a {
  color: var(--text-muted);
  transition: color 0.15s;
}

.breadcrumb-container a:hover {
  color: var(--text);
}

.breadcrumb-separator {
  color: var(--text-faint);
  font-size: 11px;
}

.breadcrumb-current {
  color: var(--text);
  font-weight: 600;
}

/* Term chip in header */
.term-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Page Content Area */
.content-wrapper {
  padding-top: 84px; /* 64px header + 20px gap */
  padding-bottom: 48px;
  padding-left: 24px;
  padding-right: 24px;
  flex: 1;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

@media (max-width: 767.98px) {
  .content-wrapper {
    padding-left: max(14px, env(safe-area-inset-left, 0px));
    padding-right: max(14px, env(safe-area-inset-right, 0px));
    padding-top: calc(64px + 14px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
    gap: 16px;
  }
}

/* --------------------------------------------------------------------------
   4. Cards, Containers & Visual Depth
   -------------------------------------------------------------------------- */
.card {
  background-color: var(--bg-surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-xs) !important;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
  overflow: hidden;
}

.card:hover {
  border-color: var(--border-strong);
}

.card-header {
  background-color: var(--bg-elevated) !important;
  border-bottom: 1px solid var(--border) !important;
  padding: 12px 18px !important;
  color: var(--text) !important;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  color: var(--text) !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  margin: 0;
}

.card-body {
  padding: 18px !important;
  color: var(--text) !important;
  background-color: var(--bg-surface) !important;
}

.card-footer {
  background-color: var(--bg-elevated) !important;
  border-top: 1px solid var(--border) !important;
  padding: 12px 18px !important;
  color: var(--text-muted) !important;
  font-size: 12px !important;
}

/* Page Header Banner (Inspired by Stitch Top Academic Identity Banner) */
.page-banner {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (min-width: 992px) {
  .page-banner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.page-title {
  font-size: 20px !important;
  font-weight: 700 !important;
  letter-spacing: -0.015em;
  color: var(--text) !important;
  margin-bottom: 2px;
}

.page-subtitle {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 0;
}

/* Stat Cards (Key Metrics 4-Card Row) */
.stat-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
}

.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.stat-value {
  font-size: 26px !important;
  font-weight: 700 !important;
  color: var(--text);
  font-family: var(--font-mono);
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 4px 0;
}

.stat-subtext {
  font-size: 11px;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   5. Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  font-family: var(--font-sans) !important;
  font-size: 12.5px !important;
  font-weight: 500 !important;
  min-height: 34px !important;
  height: auto !important;
  padding: 6px 12px !important;
  border-radius: var(--radius-sm) !important;
  border: 1px solid transparent !important;
  cursor: pointer !important;
  user-select: none !important;
  text-decoration: none !important;
  transition: all 0.15s ease !important;
  white-space: normal !important;
  text-align: center !important;
  line-height: 1.25 !important;
  box-sizing: border-box !important;
  max-width: 100% !important;
  word-break: break-word !important;
}

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

.btn-sm {
  min-height: 28px !important;
  height: auto !important;
  padding: 4px 8px !important;
  font-size: 11.5px !important;
  line-height: 1.2 !important;
}

.btn-lg {
  min-height: 40px !important;
  height: auto !important;
  padding: 8px 16px !important;
  font-size: 13.5px !important;
}

/* Primary Button: Solid Dark in Light Mode, Solid Light in Dark Mode */
.btn-primary {
  background-color: var(--primary) !important;
  color: var(--primary-fg) !important;
  border-color: var(--primary) !important;
  box-shadow: var(--shadow-xs);
}

.btn-primary:hover {
  background-color: var(--primary-hover) !important;
  border-color: var(--primary-hover) !important;
  color: var(--primary-fg) !important;
}

/* Secondary / Outline Button */
.btn-secondary,
.btn-outline-secondary,
.btn-default {
  background-color: var(--bg-surface) !important;
  color: var(--text) !important;
  border-color: var(--border-strong) !important;
}

.btn-secondary:hover,
.btn-outline-secondary:hover,
.btn-default:hover {
  background-color: var(--bg-hover) !important;
  border-color: var(--text-muted) !important;
  color: var(--text) !important;
}

/* Ghost / Icon Button */
.btn-ghost,
.btn-icon {
  background-color: transparent !important;
  color: var(--text-secondary) !important;
  border-color: transparent !important;
}

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

.btn-icon {
  width: 32px !important;
  height: 32px !important;
  padding: 0 !important;
}

/* Destructive / Danger Button */
.btn-danger,
.btn-outline-danger {
  background-color: var(--bg-surface) !important;
  color: var(--rose) !important;
  border-color: var(--rose-border) !important;
}

.btn-danger:hover,
.btn-outline-danger:hover {
  background-color: var(--rose-bg) !important;
  border-color: var(--rose) !important;
  color: var(--rose-fg) !important;
}

.btn-success,
.btn-outline-success {
  background-color: var(--bg-surface) !important;
  color: var(--emerald) !important;
  border-color: var(--emerald-border) !important;
}

.btn-success:hover,
.btn-outline-success:hover {
  background-color: var(--emerald-bg) !important;
  border-color: var(--emerald) !important;
  color: var(--emerald-fg) !important;
}

/* Full Width */
.w-100 { width: 100% !important; }

/* --------------------------------------------------------------------------
   6. Badges & Status Chips
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex !important;
  align-items: center !important;
  gap: 4px !important;
  padding: 2px 7px !important;
  font-size: 11px !important;
  font-weight: 500 !important;
  border-radius: var(--radius-sm) !important;
  border: 1px solid var(--border) !important;
  background-color: var(--bg-elevated) !important;
  color: var(--text-secondary) !important;
  line-height: 1.2 !important;
  white-space: nowrap !important;
}

.badge-pill,
.rounded-pill {
  border-radius: var(--radius-full) !important;
  padding: 2px 9px !important;
}

.badge-success,
.bg-success,
.bg-success-subtle,
.badge-emerald {
  background-color: var(--emerald-bg) !important;
  color: var(--emerald-fg) !important;
  border-color: var(--emerald-border) !important;
}

.badge-warning,
.bg-warning,
.bg-warning-subtle,
.badge-amber {
  background-color: var(--amber-bg) !important;
  color: var(--amber-fg) !important;
  border-color: var(--amber-border) !important;
}

.badge-danger,
.bg-danger,
.bg-danger-subtle,
.badge-rose {
  background-color: var(--rose-bg) !important;
  color: var(--rose-fg) !important;
  border-color: var(--rose-border) !important;
}

.badge-info,
.bg-info,
.bg-info-subtle,
.badge-blue {
  background-color: var(--blue-bg) !important;
  color: var(--blue-fg) !important;
  border-color: var(--blue-border) !important;
}

.badge-dark,
.bg-dark {
  background-color: var(--primary) !important;
  color: var(--primary-fg) !important;
  border-color: var(--primary) !important;
}

.badge-secondary,
.bg-secondary,
.bg-secondary-subtle {
  background-color: var(--bg-elevated) !important;
  color: var(--text-secondary) !important;
  border-color: var(--border) !important;
}

/* --------------------------------------------------------------------------
   7. Data Tables & Data Grids
   -------------------------------------------------------------------------- */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100% !important;
  border-collapse: collapse !important;
  margin-bottom: 0 !important;
  color: var(--text) !important;
  font-size: 12.5px !important;
}

.table thead th {
  background-color: var(--bg-elevated) !important;
  color: var(--text-muted) !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.04em !important;
  padding: 9px 14px !important;
  border-bottom: 1px solid var(--border) !important;
  border-top: none !important;
  white-space: nowrap !important;
  text-align: left;
}

.table tbody td {
  padding: 11px 14px !important;
  border-bottom: 1px solid var(--border-light) !important;
  border-top: none !important;
  color: var(--text) !important;
  vertical-align: middle !important;
  background-color: transparent !important;
}

.table tbody tr {
  transition: background-color 0.1s ease;
}

.table tbody tr:hover td,
.table-hover tbody tr:hover {
  background-color: var(--bg-hover) !important;
}

.table tbody tr:last-child td {
  border-bottom: none !important;
}

.table-footer {
  padding: 10px 16px;
  background-color: var(--bg-elevated);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   8. Form Controls & Inputs
   -------------------------------------------------------------------------- */
.form-label {
  display: block;
  font-size: 12px !important;
  font-weight: 600 !important;
  color: var(--text-secondary) !important;
  margin-bottom: 5px !important;
}

.form-control,
.form-select,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="file"],
input[type="number"],
textarea,
select {
  display: block;
  width: 100%;
  height: 36px;
  padding: 6px 12px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text) !important;
  background-color: var(--bg-surface) !important;
  border: 1px solid var(--border-strong) !important;
  border-radius: var(--radius-sm) !important;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
  outline: none;
}

textarea.form-control,
textarea {
  height: auto;
  min-height: 80px;
}

.form-control:focus,
.form-select:focus,
input:focus,
textarea:focus,
select:focus {
  border-color: var(--border-focus) !important;
  box-shadow: 0 0 0 1px var(--border-focus) !important;
}

.form-control::placeholder,
input::placeholder,
textarea::placeholder {
  color: var(--text-faint);
}

.form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2371717a' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px 10px;
  padding-right: 32px;
  appearance: none;
}

.form-check-input {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  background-color: var(--bg-surface);
  cursor: pointer;
}

.form-check-input:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}

.form-text,
.form-help {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* --------------------------------------------------------------------------
   9. Alerts & Flash Messages
   -------------------------------------------------------------------------- */
.messages-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.alert {
  padding: 10px 14px !important;
  border-radius: var(--radius) !important;
  border: 1px solid var(--border) !important;
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  font-size: 12.5px !important;
  line-height: 1.4 !important;
  margin-bottom: 0 !important;
  box-shadow: var(--shadow-xs);
}

.alert-success {
  background-color: var(--emerald-bg) !important;
  color: var(--emerald-fg) !important;
  border-color: var(--emerald-border) !important;
}

.alert-danger,
.alert-error {
  background-color: var(--rose-bg) !important;
  color: var(--rose-fg) !important;
  border-color: var(--rose-border) !important;
}

.alert-warning {
  background-color: var(--amber-bg) !important;
  color: var(--amber-fg) !important;
  border-color: var(--amber-border) !important;
}

.alert-info {
  background-color: var(--blue-bg) !important;
  color: var(--blue-fg) !important;
  border-color: var(--blue-border) !important;
}

.btn-close {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  color: inherit !important;
  opacity: 0.6 !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  margin-left: auto !important;
}

.btn-close:hover {
  opacity: 1 !important;
}

/* --------------------------------------------------------------------------
   10. Dropdowns & Modals
   -------------------------------------------------------------------------- */
.user-menu-wrapper {
  position: relative;
}

.user-profile-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 4px;
  border-radius: var(--radius-sm);
  background-color: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--text);
}

.user-profile-trigger:hover {
  background-color: var(--bg-hover);
  border-color: var(--border);
}

.user-avatar-initials {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background-color: var(--primary);
  color: var(--primary-fg);
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-profile-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.1;
  text-align: left;
}

.user-profile-meta .user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.user-profile-meta .user-role-label {
  font-size: 10px;
  color: var(--text-muted);
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 6px;
  min-width: 200px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 100;
}

.dropdown-menu.show {
  display: block;
  animation: dropdownFadeIn 0.12s ease-out;
}

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

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-xs);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.1s ease;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
}

.dropdown-item:hover {
  background-color: var(--bg-hover);
  color: var(--text);
}

.dropdown-divider {
  height: 1px;
  background-color: var(--border-light);
  margin: 4px 0;
}

/* --------------------------------------------------------------------------
   11. Standalone / Auth Layout (Login, Password Reset)
   -------------------------------------------------------------------------- */
.standalone-canvas {
  min-height: calc(100vh - 64px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background-color: var(--bg-canvas);
}

.standalone-card {
  width: 100%;
  max-width: 420px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.password-input-wrapper {
  position: relative;
}

.password-input-wrapper .password-toggle-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.password-input-wrapper .password-toggle-btn:hover {
  color: var(--text);
}

/* --------------------------------------------------------------------------
   12. Progress Bars & Custom Controls
   -------------------------------------------------------------------------- */
.progress {
  height: 6px;
  border-radius: var(--radius-full);
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-light);
  overflow: hidden;
  position: relative;
}

.progress-bar {
  height: 100%;
  border-radius: var(--radius-full);
  background-color: var(--primary);
  transition: width 0.3s ease;
}

.progress-bar-success { background-color: var(--emerald); }
.progress-bar-warning { background-color: var(--amber); }
.progress-bar-danger  { background-color: var(--rose); }

/* Pill Tabs (Mobile-Friendly Horizontal Scrolling) */
.pill-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: nowrap;
}

.pill-tabs::-webkit-scrollbar,
.no-scrollbar::-webkit-scrollbar {
  display: none;
}

.pill-tabs,
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.pill-tab {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-xs);
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.pill-tab:hover {
  color: var(--text);
}

.pill-tab.active {
  background-color: var(--primary);
  color: var(--primary-fg);
  font-weight: 600;
}

/* Mobile Input Sizing: Prevent iOS Zoom & Enhance Touch Targets */
@media (max-width: 767.98px) {
  .form-control,
  .form-select,
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="date"],
  input[type="file"],
  input[type="number"],
  textarea,
  select {
    font-size: 16px !important;
    min-height: 42px;
  }

  textarea {
    min-height: 80px;
  }

  .btn {
    min-height: 38px !important;
    height: auto !important;
    padding: 6px 12px !important;
    white-space: normal !important;
    text-align: center !important;
    word-break: break-word !important;
    max-width: 100% !important;
  }

  .btn-sm {
    min-height: 32px !important;
    height: auto !important;
    padding: 4px 8px !important;
    font-size: 11.5px !important;
    white-space: normal !important;
    text-align: center !important;
    word-break: break-word !important;
    max-width: 100% !important;
  }
}

/* Institutional Footer */
.institutional-footer {
  width: 100%;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border);
  padding: 16px 24px;
  font-size: 11.5px;
  color: var(--text-muted);
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1600px;
  margin: 0 auto;
}

@media (min-width: 768px) {
  .footer-inner {
    flex-direction: row;
  }
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 16px;
}

.footer-links a:hover {
  color: var(--text);
}
