/* ==========================================================================
   FORMAL TABULATION DESIGN SYSTEM - SIQUIJOR STATE COLLEGE
   Clean, Modern, Accessible, Component-Driven Styling
   ========================================================================== */
/* Local Self-Hosted Plus Jakarta Sans Fonts (100% Offline Compatible) */
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 300 800;
  font-display: swap;
  src: url('../fonts/plus-jakarta-sans-latin.woff2') format('woff2-variations'),
       url('../fonts/plus-jakarta-sans-latin.woff2') format('woff2');
}

@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/plus-jakarta-sans-italic-latin.woff2') format('woff2-variations'),
       url('../fonts/plus-jakarta-sans-italic-latin.woff2') format('woff2');
}

/* Fallback discrete weight declarations for older devices/browsers */
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url('../fonts/plus-jakarta-sans-normal-300.ttf') format('truetype');
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/plus-jakarta-sans-normal-400.ttf') format('truetype');
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/plus-jakarta-sans-normal-500.ttf') format('truetype');
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/plus-jakarta-sans-normal-600.ttf') format('truetype');
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/plus-jakarta-sans-normal-700.ttf') format('truetype');
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('../fonts/plus-jakarta-sans-normal-800.ttf') format('truetype');
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/plus-jakarta-sans-italic-400.ttf') format('truetype');
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: italic;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/plus-jakarta-sans-italic-600.ttf') format('truetype');
}

:root {
  /* ==========================================================================
     SHADCN/UI DESIGN SYSTEM TOKENS — OFFLINE COMPATIBLE
     Neutral Zinc Palette + Clean 1px Borders + Elevated Focus Rings
     ========================================================================== */
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --card-foreground: 240 10% 3.9%;
  --popover: 0 0% 100%;
  --popover-foreground: 240 10% 3.9%;
  --primary: 240 5.9% 10%;
  --primary-foreground: 0 0% 98%;
  --secondary: 240 4.8% 95.9%;
  --secondary-foreground: 240 5.9% 10%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --accent: 240 4.8% 95.9%;
  --accent-foreground: 240 5.9% 10%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 0 0% 98%;
  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --ring: 240 5.9% 10%;
  --radius: 0.5rem;

  /* Mapped Variables (Maintains 100% backward compatibility with existing views) */
  --bg-main: #fafafa;
  --bg-card: #ffffff;
  --bg-subtle: #f4f4f5;
  
  --border-light: #e4e4e7;
  --border-medium: #d4d4d8;
  --border-focus: #18181b;
  
  --text-primary: #09090b;
  --text-secondary: #71717a;
  --text-muted: #a1a1aa;
  --text-inverse: #ffffff;
  
  --primary-navy: #18181b; /* Modern shadcn dark zinc */
  --primary-blue: #2563eb; /* Crisp pageant blue accent */
  --primary-hover: #27272a;
  --primary-light: #f4f4f5;
  
  --gold-500: #d97706;
  --gold-100: #fef3c7;
  --gold-text: #92400e;
  
  --silver-500: #64748b;
  --silver-100: #f1f5f9;
  
  --bronze-500: #b45309;
  --bronze-100: #ffedd5;
  
  --success-bg: #ecfdf5;
  --success-text: #047857;
  --success-border: #a7f3d0;
  
  --danger-bg: #fef2f2;
  --danger-text: #b91c1c;
  --danger-border: #fecaca;
  
  --warning-bg: #fffbeb;
  --warning-text: #b45309;
  --warning-border: #fde68a;

  /* shadcn/ui Crisp Elevation */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.07), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

  /* Radius (Standard shadcn 6px / 8px / 12px) */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;
  
  --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}


/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--primary-blue);
  text-decoration: none;
  transition: all 0.2s ease;
}
a:hover {
  color: var(--primary-hover);
}

/* ── Container Layouts ──────────────────────────────────────────────────────── */
.app-container {
  max-width: 96%;
  margin: 0 auto;
  padding: 0 20px 60px 20px;
  width: 100%;
  flex: 1;
}

.open-table-view {
  width: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px;
  align-items: start;
}

.open-table-view > div:first-child {
  grid-column: 1 / -1;
  grid-row: 1;
}

.open-table-view > .open-table-container {
  grid-column: 1;
  grid-row: 2;
  margin-bottom: 0;
}

.open-table-view > .ranking-panel {
  grid-column: 2;
  grid-row: 2;
}

.open-table-container {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 24px;
  width: 100%;
}

/* ── Header Component (shadcn sticky glassmorphism) ─────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  width: 100%;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
  padding: 12px 0;
  margin-bottom: 28px;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.header-logo {
  height: 44px;
  width: 44px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  padding: 3px;
  background: #ffffff;
}

.header-titles {
  display: flex;
  flex-direction: column;
}

.header-inst-name {
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  line-height: 1.2;
}

.header-sub-name {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.header-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--primary-navy);
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  margin-top: 3px;
  width: fit-content;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  text-decoration: none;
}

.nav-link:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.6);
}

.nav-link.active {
  background: #ffffff;
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.04);
}

/* ── Card Component (shadcn elevated card) ─────────────────────────────────── */
.app-card,
.ui-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 24px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.app-card.interactive:hover,
.ui-card.interactive:hover {
  border-color: var(--border-medium);
  box-shadow: var(--shadow-md);
}

.card-header,
.ui-card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
}

.card-title,
.ui-card-title {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-subtitle,
.ui-card-description {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 2px;
  font-weight: 400;
}

.card-body,
.ui-card-content {
  padding: 24px;
}

.card-footer,
.ui-card-footer {
  padding: 14px 24px;
  background: #fafafa;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Buttons (shadcn button variants & press effects) ───────────────────────── */
.btn,
.ui-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
  text-decoration: none;
  font-family: inherit;
  line-height: 1.25;
  user-select: none;
  white-space: nowrap;
}

.btn:active,
.ui-btn:active {
  transform: scale(0.98);
}

.btn:focus-visible,
.ui-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px var(--border-focus);
}

.btn-primary,
.ui-btn-default {
  background: #18181b;
  color: #fafafa;
  border-color: #27272a;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}
.btn-primary:hover,
.ui-btn-default:hover {
  background: #27272a;
  color: #ffffff;
}

.btn-secondary,
.ui-btn-secondary {
  background: #f4f4f5;
  color: #18181b;
  border-color: #e4e4e7;
}
.btn-secondary:hover,
.ui-btn-secondary:hover {
  background: #e4e4e7;
  color: #09090b;
}

.btn-outline,
.ui-btn-outline {
  background: transparent;
  color: #18181b;
  border-color: #e4e4e7;
}
.btn-outline:hover,
.ui-btn-outline:hover {
  background: #f4f4f5;
  color: #09090b;
}

.btn-ghost,
.ui-btn-ghost {
  background: transparent;
  color: #18181b;
  border-color: transparent;
}
.btn-ghost:hover,
.ui-btn-ghost:hover {
  background: #f4f4f5;
  color: #09090b;
}

.btn-danger,
.btn-destructive,
.ui-btn-destructive {
  background: #ef4444;
  color: #ffffff;
  border-color: #dc2626;
  box-shadow: 0 1px 2px 0 rgba(239, 68, 68, 0.2);
}
.btn-danger:hover,
.btn-destructive:hover,
.ui-btn-destructive:hover {
  background: #dc2626;
}

.btn-sm,
.ui-btn-sm {
  padding: 5px 10px;
  font-size: 0.8125rem;
  border-radius: calc(var(--radius-sm) - 1px);
}

.btn-lg,
.ui-btn-lg {
  padding: 12px 24px;
  font-size: 0.9375rem;
  border-radius: var(--radius-md);
}

/* ── Badges (shadcn pill badges) ───────────────────────────────────────────── */
.badge,
.ui-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  font-size: 0.6875rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  line-height: 1.2;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-success {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

.badge-warning {
  background: #fffbeb;
  color: #b45309;
  border-color: #fde68a;
}

.badge-danger {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.badge-neutral {
  background: #f4f4f5;
  color: #3f3f46;
  border-color: #e4e4e7;
}

.badge-gold {
  background: #fffbeb;
  color: #92400e;
  border-color: #fde68a;
  font-weight: 700;
}

.badge-rank-1 {
  background: #fef9c3;
  color: #854d0e;
  border-color: #facc15;
  font-weight: 700;
}

.badge-rank-2 {
  background: #f1f5f9;
  color: #334155;
  border-color: #cbd5e1;
  font-weight: 700;
}

.badge-rank-3 {
  background: #ffedd5;
  color: #9a3412;
  border-color: #fdba74;
  font-weight: 700;
}

.badge-rank-other {
  background: #f4f4f5;
  color: #71717a;
  border-color: #e4e4e7;
  font-weight: 600;
}


/* Rank number in-cell pill */
.rank-pill-1 {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fef08a;
  color: #713f12;
  border: 1px solid #eab308;
  border-radius: var(--radius-full);
  min-width: 28px;
  height: 24px;
  padding: 0 6px;
  font-weight: 800;
  font-size: 0.9375rem;
}

.rank-pill-2 {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e2e8f0;
  color: #1e293b;
  border: 1px solid #94a3b8;
  border-radius: var(--radius-full);
  min-width: 28px;
  height: 24px;
  padding: 0 6px;
  font-weight: 800;
  font-size: 0.9375rem;
}

.rank-pill-3 {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffedd5;
  color: #9a3412;
  border: 1px solid #fdba74;
  border-radius: var(--radius-full);
  min-width: 28px;
  height: 24px;
  padding: 0 6px;
  font-weight: 800;
  font-size: 0.9375rem;
}

/* ── Tables (shadcn data table styling) ────────────────────────────────────── */
.formal-table-wrap,
.ui-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
}

.formal-table,
.ui-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

.formal-table th,
.ui-table th {
  background: #fafafa;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

.formal-table td,
.ui-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}

.formal-table tr:last-child td,
.ui-table tr:last-child td {
  border-bottom: none;
}

.formal-table tr:hover td,
.ui-table tr:hover td {
  background-color: #f4f4f580;
}

.formal-table .section-header-row td,
.ui-table .section-header-row td {
  background: #f4f4f5;
  font-weight: 700;
  color: var(--text-primary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 8px 16px;
}

/* ── Score Textfields (shadcn tabular input) ───────────────────────────────── */
.score-input,
.ui-input {
  width: 90px;
  height: 36px;
  text-align: center;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
}

.score-input:focus,
.ui-input:focus {
  outline: none;
  border-color: #18181b;
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px var(--border-focus);
}

.score-input.saved {
  border-color: #a7f3d0;
  background-color: #ecfdf5;
  color: #047857;
}

/* ── Category Selection Grid ───────────────────────────────────────────────── */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 16px;
  width: 100%;
  grid-auto-flow: row;
}

.category-grid > .category-card {
  width: 100%;
  min-width: 0;
}

.category-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
  position: relative;
  overflow: hidden;
}

.category-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-medium);
}

.category-card-name {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  margin-bottom: 6px;
  line-height: 1.3;
}

.category-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ── Tab Navigation (shadcn segmented control) ─────────────────────────────── */
.tab-nav,
.ui-tabs-list {
  display: inline-flex;
  align-items: center;
  background: #f4f4f5;
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  gap: 3px;
  margin-bottom: 24px;
}

.tab-btn,
.ui-tabs-trigger {
  padding: 6px 14px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  text-decoration: none;
}

.tab-btn:hover,
.ui-tabs-trigger:hover {
  color: var(--text-primary);
}

.tab-btn.active,
.ui-tabs-trigger.active {
  background: #ffffff;
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.04);
}


/* ── Live Auto Refresh Indicator ───────────────────────────────────────────── */
.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #166534;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: #22c55e;
  border-radius: 50%;
  box-shadow: 0 0 0 rgba(34, 197, 94, 0.4);
  animation: pulse-dot-anim 1.5s infinite;
}

@keyframes pulse-dot-anim {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* ── Chat Widget (shadcn floating popover) ─────────────────────────────────── */
.chat-drawer-container {
  position: fixed;
  bottom: 20px;
  right: 24px;
  z-index: 1000;
}

.chat-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #18181b;
  color: #fafafa;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  border: 1px solid #27272a;
  font-weight: 500;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.chat-toggle-btn:hover {
  background: #27272a;
  transform: translateY(-1px);
}

.chat-toggle-btn:active {
  transform: scale(0.98);
}

.chat-window {
  position: absolute;
  bottom: 52px;
  right: 0;
  width: 350px;
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.chat-window.open {
  display: flex;
}

.chat-header {
  padding: 12px 16px;
  background: #ffffff;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 0.8125rem;
}

.chat-messages {
  height: 240px;
  overflow-y: auto;
  padding: 14px;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg-bubble {
  max-width: 82%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  line-height: 1.4;
  word-break: break-word;
}

.msg-me {
  align-self: flex-end;
  background: #18181b;
  color: #fafafa;
}

.msg-them {
  align-self: flex-start;
  background: #ffffff;
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}

.chat-input-area {
  padding: 10px 12px;
  border-top: 1px solid var(--border-light);
  background: #ffffff;
  display: flex;
  gap: 8px;
}

.chat-input {
  flex: 1;
  padding: 6px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.chat-input:focus {
  outline: none;
  border-color: #18181b;
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px var(--border-focus);
}


/* ════════════════════════════════════════════════════════════════════════════
   PROFESSIONAL DASHBOARD GRID SYSTEM — v2 Enhancements
   ════════════════════════════════════════════════════════════════════════════ */

/* ── Page Head ─────────────────────────────────────────────────────────────── */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.page-head-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--primary-navy);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.page-head-desc {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  margin-top: 6px;
}

.page-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.breadcrumb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

/* ── KPI / Stat Card Grid (shadcn metrics) ─────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

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

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle);
  color: var(--text-primary);
  flex-shrink: 0;
  border: 1px solid var(--border-light);
}

.stat-icon.gold { background: #fffbeb; color: #d97706; border-color: #fde68a; }
.stat-icon.green { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.stat-icon.slate { background: var(--bg-subtle); color: var(--text-secondary); }

.stat-body { min-width: 0; }

.stat-value {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0;
  margin-top: 2px;
}

/* ── Progress Bar ──────────────────────────────────────────────────────────── */
.progress-track {
  width: 100%;
  height: 6px;
  background: var(--bg-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: 8px;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: #18181b;
  transition: width 0.3s ease;
}

.progress-fill.green { background: #10b981; }

/* ── Segmented Filter Tabs (Stage / Type Selector) ─────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.filter-group {
  display: inline-flex;
  gap: 4px;
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}

.filter-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

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

.filter-tab.active {
  background: #ffffff;
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.04);
}

.filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-full);
  background: var(--border-light);
  color: var(--text-secondary);
  font-size: 0.6875rem;
  font-weight: 600;
}

.filter-tab.active .filter-count {
  background: #18181b;
  color: #fafafa;
}


/* ── Station Switcher Pills (shadcn segmented control) ───────────────────────── */
.station-switcher {
  display: inline-flex;
  gap: 4px;
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  align-items: center;
}

.station-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 600;
  transition: all 0.15s ease;
  text-decoration: none;
}

.station-pill:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.6);
}

.station-pill.active {
  background: #ffffff;
  color: var(--text-primary);
  font-weight: 700;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.04);
}


/* ── Generic Responsive Grids ──────────────────────────────────────────────── */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 24px;
  align-items: start;
}

.grid-2 > * { margin-bottom: 0; }

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

/* ── Form Field Pattern ────────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  align-items: end;
}

.form-field label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 800;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 5px;
}

.form-field .field-control {
  width: 100%;
  height: 40px;
  border: 1.5px solid var(--border-medium);
  border-radius: var(--radius-sm);
  background: #ffffff;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  padding: 0 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-field .field-control:focus {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

select.field-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

/* ── Sticky Action Bar ─────────────────────────────────────────────────────── */
.action-bar {
  position: sticky;
  bottom: 20px;
  z-index: 100;
  background: var(--bg-card);
  padding: 14px 22px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-medium);
  box-shadow: var(--shadow-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.action-bar-note {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* ── Table Header Chips ────────────────────────────────────────────────────── */
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 18px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-light);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary-navy);
  background: var(--primary-light);
  border: 1px solid #bfdbfe;
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.chip.gold { background: var(--gold-100); color: var(--gold-text); border-color: #fcd34d; }

.progress-fill.gold { background: linear-gradient(90deg, #fbbf24, #d97706); }

/* ── Print Styles for Official Tabulation Sheets ──────────────────────────── */
@media print {
  @page {
    size: auto;
    margin: 12mm 15mm;
  }

  html, body {
    background: #ffffff !important;
    color: #000000 !important;
    font-family: var(--font-sans) !important;
    font-size: 10pt !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Hide interactive / non-printable UI elements */
  .app-header, 
  .header-nav, 
  .chat-drawer-container, 
  .btn, 
  .no-print, 
  .live-indicator, 
  .pulse-dot, 
  #exit,
  .action-bar,
  .filter-bar,
  .table-toolbar {
    display: none !important;
  }

  .app-container {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .open-table-view, 
  .open-table-container,
  .app-card {
    border: none !important;
    box-shadow: none !important;
    background: #ffffff !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .formal-table-wrap {
    border: none !important;
    box-shadow: none !important;
    overflow: visible !important;
  }

  /* Formal Official Tabulation Table Print Formatting */
  .formal-table {
    width: 100% !important;
    max-width: 100% !important;
    table-layout: auto !important;
    border-collapse: collapse !important;
    border: 1.5px solid #0f172a !important;
    margin: 8px 0 !important;
  }

  .formal-table th, 
  .formal-table td {
    border: 1px solid #475569 !important;
    color: #000000 !important;
    padding: 5px 4px !important;
    font-size: 8.5pt !important;
    min-width: 0 !important;
    width: auto !important;
    white-space: normal !important;
  }

  .formal-table th {
    background: #f1f5f9 !important;
    font-weight: 800 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.01em !important;
    font-size: 8pt !important;
    line-height: 1.2 !important;
  }

  .formal-table td:first-child,
  .formal-table th:first-child {
    width: 40px !important;
    text-align: center !important;
  }

  .section-header-row td {
    background: #e2e8f0 !important;
    font-weight: 800 !important;
    font-size: 9pt !important;
    text-align: left !important;
    padding: 4px 8px !important;
    border-top: 2px solid #0f172a !important;
    border-bottom: 2px solid #0f172a !important;
  }

  tr {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  /* Badges in Print Mode */
  .badge {
    background: transparent !important;
    border: 1px solid #0f172a !important;
    color: #000000 !important;
    font-weight: 800 !important;
    padding: 1px 4px !important;
    font-size: 7.5pt !important;
    display: inline-block !important;
    white-space: nowrap !important;
  }

  .badge-rank-1 {
    border: 1.5px solid #ca8a04 !important;
    background: #fef08a !important;
    color: #713f12 !important;
    font-weight: 800 !important;
  }

  .badge-rank-2 {
    border: 1.5px solid #64748b !important;
    background: #e2e8f0 !important;
    color: #0f172a !important;
    font-weight: 800 !important;
  }

  .badge-rank-3 {
    border: 1.5px solid #f97316 !important;
    background: #fed7aa !important;
    color: #7c2d12 !important;
    font-weight: 800 !important;
  }

  .badge-rank-other {
    border: 1px solid #cbd5e1 !important;
    background: #f8fafc !important;
    color: #334155 !important;
    font-weight: 700 !important;
  }

    /* Print Header & Signatures Block */
  .print-header {
    display: block !important;
    margin-bottom: 16px !important;
  }

  .print-signatures-block {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    align-items: flex-end !important;
    gap: 32px 56px !important;
    margin-top: 36px !important;
    padding: 24px 0 0 !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    background: transparent !important;
    text-align: center !important;
  }

  .print-signatures-block > .print-sig-section {
    flex-basis: 100% !important;
  }

  .print-sig-section {
    font-size: 9pt !important;
    font-weight: 800 !important;
    letter-spacing: 0.08em !important;
    text-transform: uppercase !important;
    color: #000000 !important;
    text-align: center !important;
    padding-bottom: 6px !important;
    border-bottom: 1px solid #000000 !important;
  }

  .print-sig-slot {
    flex: 0 1 200px !important;
  }

  .print-sig-slot.tabulation {
    flex-basis: 220px !important;
  }

  .signature-line {
    border-bottom: 2.5px solid #000000 !important;
    width: 190px !important;
    max-width: 100% !important;
    height: 44px !important;
    margin: 0 auto !important;
  }

  .print-sig-slot.tabulation .signature-line {
    width: 230px !important;
    height: 48px !important;
  }

  .signature-label {
    font-weight: 800 !important;
    font-size: 8.5pt !important;
    color: #000000 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.03em !important;
    margin-top: 4px !important;
  }
}

/* ════════════════════════════════════════════════════════════════════════════
   UNIVERSAL TOAST NOTIFICATION SYSTEM
   ════════════════════════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
  max-width: 420px;
  width: calc(100vw - 48px);
}

.toast-item {
  pointer-events: auto;
  position: relative;
  background: #ffffff;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px -3px rgba(0, 0, 0, 0.12), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  border: 1px solid var(--border-medium);
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  animation: toast-slide-in 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: all 0.25s ease;
}

.toast-item.toast-closing {
  animation: toast-slide-out 0.25s ease forwards;
}

@keyframes toast-slide-in {
  from {
    opacity: 0;
    transform: translateX(60px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes toast-slide-out {
  from {
    opacity: 1;
    transform: translateX(0) scale(1);
    max-height: 120px;
    margin-bottom: 0;
  }
  to {
    opacity: 0;
    transform: translateX(60px) scale(0.9);
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-bottom: -12px;
  }
}

.toast-icon-wrap {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
}

.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-size: 0.875rem;
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 2px;
}

.toast-message {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.4;
  word-break: break-word;
}

.toast-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background 0.15s ease;
  line-height: 1;
}

.toast-close-btn:hover {
  color: var(--text-primary);
  background: var(--bg-subtle);
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  width: 100%;
  transform-origin: left;
  animation: toast-progress-deplete linear forwards;
}

@keyframes toast-progress-deplete {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

/* Toast Variants */
.toast-success {
  border-left: 4px solid #22c55e;
}
.toast-success .toast-icon-wrap {
  background: #dcfce7;
  color: #166534;
}
.toast-success .toast-title {
  color: #15803d;
}
.toast-success .toast-progress {
  background: #22c55e;
}

.toast-error, .toast-danger {
  border-left: 4px solid #ef4444;
}
.toast-error .toast-icon-wrap, .toast-danger .toast-icon-wrap {
  background: #fee2e2;
  color: #991b1b;
}
.toast-error .toast-title, .toast-danger .toast-title {
  color: #b91c1c;
}
.toast-error .toast-progress, .toast-danger .toast-progress {
  background: #ef4444;
}

.toast-warning {
  border-left: 4px solid #f59e0b;
}
.toast-warning .toast-icon-wrap {
  background: #fef3c7;
  color: #92400e;
}
.toast-warning .toast-title {
  color: #b45309;
}
.toast-warning .toast-progress {
  background: #f59e0b;
}

.toast-info {
  border-left: 4px solid #2563eb;
}
.toast-info .toast-icon-wrap {
  background: #eff6ff;
  color: #1d4ed8;
}
.toast-info .toast-title {
  color: #1e40af;
}
.toast-info .toast-progress {
  background: #2563eb;
}

/* ════════════════════════════════════════════════════════════════════════════
   ADMIN PANEL PREMIUM GRID & WORKSPACE SYSTEM
   ════════════════════════════════════════════════════════════════════════════ */

/* ── Mode Guide Grid ───────────────────────────────────────────────────────── */
.admin-mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 860px) {
  .admin-mode-grid {
    grid-template-columns: 1fr;
  }
}

.admin-mode-card {
  padding: 18px 20px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-light);
  background: var(--bg-card);
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.admin-mode-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.admin-mode-card.mode-1 {
  border-left: 4px solid var(--primary-navy);
  background: linear-gradient(to right, #f8fafc, #ffffff);
}

.admin-mode-card.mode-2 {
  border-left: 4px solid #d97706;
  background: linear-gradient(to right, #fffbeb, #ffffff);
}

.admin-mode-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.admin-mode-title {
  font-size: 0.9375rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mode-1 .admin-mode-title { color: var(--primary-navy); }
.mode-2 .admin-mode-title { color: #92400e; }

.admin-mode-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* ── KPI Summary Stats Grid ────────────────────────────────────────────────── */
.admin-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 1100px) {
  .admin-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 580px) {
  .admin-kpi-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Headcount & Parameters Grid ───────────────────────────────────────────── */
.admin-headcount-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

@media (max-width: 900px) {
  .admin-headcount-grid {
    grid-template-columns: 1fr;
  }
}

.admin-headcount-card {
  background: var(--bg-subtle);
  padding: 18px 20px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-light);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  transition: all 0.2s ease;
}

.admin-headcount-card:focus-within {
  border-color: var(--primary-blue);
  background: #ffffff;
  box-shadow: var(--shadow-sm);
}

.admin-headcount-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-headcount-label {
  font-size: 0.8125rem;
  font-weight: 800;
  color: var(--primary-navy);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.admin-headcount-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.admin-headcount-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-headcount-input-wrap .score-input {
  flex: 1;
  height: 44px;
  font-size: 1.25rem;
  font-weight: 800;
}

/* ── Add Category Component Grid ───────────────────────────────────────────── */
.admin-add-category-grid {
  display: grid;
  grid-template-columns: 2fr 1.3fr 0.9fr 0.8fr auto;
  gap: 14px;
  align-items: end;
}

@media (max-width: 1100px) {
  .admin-add-category-grid {
    grid-template-columns: 1fr 1fr;
  }
  .admin-add-category-grid .btn-submit-cell {
    grid-column: span 2;
  }
}

@media (max-width: 600px) {
  .admin-add-category-grid {
    grid-template-columns: 1fr;
  }
  .admin-add-category-grid .btn-submit-cell {
    grid-column: span 1;
  }
}

/* ── Categories Management Grid / Workstation ──────────────────────────────── */
.admin-categories-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 1100px) {
  .admin-categories-grid {
    grid-template-columns: 1fr;
  }
}

.admin-table-summary-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--bg-subtle);
  border-top: 1px solid var(--border-light);
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.admin-table-input {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  border: 1.5px solid var(--border-medium);
  border-radius: var(--radius-sm);
  background: #ffffff;
  transition: all 0.15s ease;
  font-family: inherit;
}

.admin-table-input:focus {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.admin-table-input-center {
  text-align: center;
  font-weight: 800;
  color: var(--primary-navy);
}

/* ════════════════════════════════════════════════════════════════════════════
   FLEXIBLE & INSTITUTIONAL PRINT ENGINE (@media print)
   ════════════════════════════════════════════════════════════════════════════ */

/* ── Screen Print Toolbar & Controller ─────────────────────────────────────── */
.print-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  border: 1.5px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-xs);
  flex-wrap: wrap;
  gap: 12px;
}

.print-toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.print-toolbar-label {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 4px;
}

.print-ctrl-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 0.8125rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-medium);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.print-ctrl-btn:hover {
  background: #ffffff;
  border-color: var(--primary-blue);
  color: var(--primary-blue);
}

.print-ctrl-btn.active {
  background: var(--primary-navy);
  border-color: var(--primary-navy);
  color: #ffffff;
}

/* ── Institutional Print Header (Screen & Print) ──────────────────────────── */
.print-header {
  display: block;
  padding: 20px 24px 12px 24px;
  background: #ffffff;
  border-bottom: 1px solid var(--border-light);
  text-align: center;
}

/* ── Institutional Signatures Block (Screen & Print) ───────────────────────── */
.print-signatures-block {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  gap: 32px 56px;
  padding: 36px 24px 28px;
  background: var(--bg-subtle);
  border-top: 1.5px solid var(--border-medium);
  text-align: center;
}

.print-signatures-block > .print-sig-section {
  flex-basis: 100%;
}

.print-sig-section {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #0f172a;
  text-align: center;
  padding-bottom: 8px;
  border-bottom: 1px solid #cbd5e1;
}

.print-sig-slot {
  flex: 0 1 200px;
}

.print-sig-slot.tabulation {
  flex-basis: 220px;
}

@media (max-width: 768px) {
  .print-signatures-block {
    gap: 28px;
  }

  .print-sig-slot,
  .print-sig-slot.tabulation {
    flex-basis: calc(50% - 14px);
  }
}

.signature-line {
  border-bottom: 2.5px solid #0f172a;
  width: 190px;
  max-width: 100%;
  height: 44px;
  margin: 0 auto;
}

.print-sig-slot.tabulation .signature-line {
  width: 230px;
  height: 48px;
}

.signature-label {
  font-size: 0.8125rem;
  font-weight: 800;
  color: var(--primary-navy);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 6px;
}

/* ── Mode Chooser (Judge Portal) ─────────────────────────────────────────── */
.mode-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-subtle);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: all 0.15s ease;
}

.mode-option:hover {
  background: #ffffff;
  border-color: var(--primary-blue);
  box-shadow: var(--shadow-sm);
}

.mode-option-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
}

.mode-option-icon.blue {
  background: var(--primary-light);
  color: var(--primary-blue);
}

.mode-option-icon.gold {
  background: #fef3c7;
  color: #d97706;
}

.mode-option-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--primary-navy);
}

.mode-option-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.mode-option-arrow {
  margin-left: auto;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.15s ease, color 0.15s ease;
}

.mode-option:hover .mode-option-arrow {
  transform: translateX(3px);
  color: var(--primary-blue);
}

/* ── Judge Live Personal Ranking Panel ───────────────────────────────────── */
.ranking-panel {
  position: sticky;
  top: 16px;
  background: #ffffff;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.ranking-panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-light);
}

.ranking-title {
  font-size: 0.9375rem;
  font-weight: 800;
  color: var(--primary-navy);
}

.ranking-sub {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ranking-list {
  max-height: calc(100vh - 280px);
  min-height: 120px;
  overflow-y: auto;
}

.rank-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
}

.rank-row:last-child {
  border-bottom: none;
}

.rank-pos {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-subtle);
  border: 1.5px solid var(--border-medium);
  font-size: 0.8125rem;
  font-weight: 800;
  color: var(--text-secondary);
}

.rank-row.top-1 .rank-pos {
  background: #f59e0b;
  border-color: #d97706;
  color: #ffffff;
}

.rank-row.top-2 .rank-pos {
  background: #94a3b8;
  border-color: #64748b;
  color: #ffffff;
}

.rank-row.top-3 .rank-pos {
  background: #b45309;
  border-color: #92400e;
  color: #ffffff;
}

.rank-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.rank-name {
  font-size: 0.875rem;
  font-weight: 800;
  color: var(--primary-navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-div {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
}

.rank-score {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 0.9375rem;
  font-weight: 800;
  color: var(--primary-blue);
  font-variant-numeric: tabular-nums;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ADMIN SIDEBAR LAYOUT (Dashboard)
   ═══════════════════════════════════════════════════════════════════════════ */

.admin-shell {
  display: flex;
  min-height: 100vh;
  background: var(--bg-main);
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.admin-sidebar {
  display: flex;
  flex-direction: column;
  width: 250px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  background: linear-gradient(180deg, #1e3a8a 0%, #172554 100%);
  color: var(--text-inverse);
}

.admin-side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  text-decoration: none;
}

.admin-side-brand img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-md);
  padding: 4px;
}

.admin-side-brand-name {
  font-size: 0.8125rem;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.2;
}

.admin-side-brand-sub {
  font-size: 0.6875rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.admin-side-label {
  padding: 18px 18px 8px;
  font-size: 0.6875rem;
  font-weight: 800;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.admin-side-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 10px;
}

.admin-side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: #cbd5e1;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.admin-side-link svg {
  flex-shrink: 0;
  opacity: 0.85;
}

.admin-side-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.admin-side-link.active {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  box-shadow: inset 3px 0 0 0 var(--gold-500);
}

.admin-side-spacer {
  flex: 1;
}

.admin-side-footer {
  padding: 14px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.admin-side-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #94a3b8;
}

/* ── Main Area ───────────────────────────────────────────────────────────── */
.admin-main {
  flex: 1;
  min-width: 0;
  padding: 28px 32px 48px;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.admin-topbar-title {
  font-size: 1.375rem;
  font-weight: 800;
  color: var(--primary-navy);
  line-height: 1.2;
}

.admin-topbar-sub {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.admin-mode-pill {
  display: flex;
  gap: 6px;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-medium);
}

.admin-mode-pill a {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 800;
  text-decoration: none;
  color: var(--text-secondary);
  white-space: nowrap;
}

.admin-mode-pill a.active-1 {
  background: var(--primary-blue);
  color: #ffffff;
}

.admin-mode-pill a.active-2 {
  background: var(--gold-500);
  color: #ffffff;
}

/* ── Overview quick cards ────────────────────────────────────────────────── */
.admin-quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.admin-quick-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px;
  background: var(--bg-card);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.admin-quick-card:hover {
  border-color: var(--primary-blue);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.admin-quick-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--primary-light);
  color: var(--primary-blue);
  flex-shrink: 0;
}

.admin-quick-title {
  font-size: 0.9375rem;
  font-weight: 800;
  color: var(--text-primary);
}

.admin-quick-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ── Mode selector cards (Overview) ──────────────────────────────────────── */
.admin-mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.admin-mode-card {
  display: block;
  padding: 20px;
  background: var(--bg-card);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-lg);
  text-decoration: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.admin-mode-card:hover {
  box-shadow: var(--shadow-md);
}

.admin-mode-card.mode-1.active {
  border-color: var(--primary-blue);
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
}

.admin-mode-card.mode-2.active {
  border-color: var(--gold-500);
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
}

.admin-mode-card-title {
  font-size: 0.9375rem;
  font-weight: 800;
  color: var(--text-primary);
}

.admin-mode-card-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ── Section cards ───────────────────────────────────────────────────────── */
.admin-section-gap > * + * {
  margin-top: 20px;
}

/* ── Responsive: sidebar collapses on small screens ─────────────────────── */
@media (max-width: 900px) {
  .admin-shell {
    flex-direction: column;
  }

  .admin-sidebar {
    width: 100%;
    height: auto;
    position: static;
  }

  .admin-side-nav {
    flex-direction: row;
    overflow-x: auto;
    padding: 10px;
  }

  .admin-side-link {
    white-space: nowrap;
  }

  .admin-side-link.active {
    box-shadow: inset 0 -3px 0 0 var(--gold-500);
  }

  .admin-side-label,
  .admin-side-spacer {
    display: none;
  }

  .admin-side-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .admin-main {
    padding: 20px 16px 40px;
  }
}

.rank-empty {
  padding: 24px 16px;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.ranking-note {
  padding: 10px 16px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border-top: 1px solid var(--border-light);
  text-align: center;
}

@media (max-width: 1024px) {
  .open-table-view {
    grid-template-columns: 1fr;
  }

  .open-table-view > div:first-child,
  .open-table-view > .open-table-container,
  .open-table-view > .ranking-panel {
    grid-column: auto;
    grid-row: auto;
  }

  .ranking-panel {
    position: static;
    margin-bottom: 24px;
  }
}

/* ── Print Media Rules ─────────────────────────────────────────────────────── */
@media print {
  /* Page Geometry — Landscape by default */
  @page {
    margin: 10mm 12mm 12mm 12mm;
    size: A4 landscape;
  }

  /* Universal Hide UI Chrome */
  .no-print,
  .app-header,
  .page-head,
  .page-head-actions,
  .action-bar,
  .btn,
  .filter-bar,
  .station-switcher,
  .chat-bubble,
  #chatPopup,
  #chatNotification,
  #toast-container,
  .live-indicator,
  .breadcrumb,
  .header-nav,
  .print-toolbar,
  .header-brand {
    display: none !important;
  }

  /* Zero container padding for maximum paper usage */
  body, html {
    background: #ffffff !important;
    color: #000000 !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif !important;
    margin: 0 !important;
    padding: 0 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .app-container,
  .open-table-container,
  .formal-table-wrap,
  .output {
    background: #ffffff !important;
    border: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Display Institutional Print Header */
  .print-header {
    display: block !important;
    margin-bottom: 14px !important;
    text-align: center !important;
  }

  .print-header img {
    width: 52px !important;
    height: 52px !important;
  }

  /* High-Contrast Print Tables */
  .formal-table {
    width: 100% !important;
    border-collapse: collapse !important;
    margin: 0 !important;
    font-size: 9.5pt !important;
    border: 1.5px solid #0f172a !important;
  }

  .formal-table th,
  .formal-table td {
    border: 1px solid #334155 !important;
    padding: 5px 6px !important;
    color: #000000 !important;
    text-align: center !important;
  }

  .formal-table th {
    background-color: #f1f5f9 !important;
    font-weight: 800 !important;
    color: #0f172a !important;
    text-transform: uppercase !important;
    font-size: 8.5pt !important;
    letter-spacing: 0.02em !important;
  }

  .formal-table thead {
    display: table-header-group !important;
  }

  .formal-table tr {
    page-break-inside: avoid !important;
  }

  .formal-table tbody tr:nth-child(even) {
    background-color: #f8fafc !important;
  }

  .formal-table .section-header-row td {
    background-color: #e2e8f0 !important;
    color: #0f172a !important;
    font-weight: 800 !important;
    text-align: left !important;
    padding: 6px 12px !important;
    font-size: 9pt !important;
    text-transform: uppercase !important;
  }

  .emcee-announcement-box {
    margin: 10px 0 !important;
    padding: 12px 16px !important;
    background: #fefce8 !important;
    border: 1.5px solid #d97706 !important;
    page-break-inside: avoid !important;
  }

  /* High-Contrast Badges for Print */
  .rank-pill-1, .badge-rank-1 {
    background: #fef08a !important;
    color: #713f12 !important;
    border: 1px solid #ca8a04 !important;
    font-weight: 800 !important;
    padding: 2px 8px !important;
    border-radius: 4px !important;
  }

  .rank-pill-2, .badge-rank-2 {
    background: #f1f5f9 !important;
    color: #1e293b !important;
    border: 1px solid #94a3b8 !important;
    font-weight: 800 !important;
    padding: 2px 8px !important;
    border-radius: 4px !important;
  }

  .rank-pill-3, .badge-rank-3 {
    background: #ffedd5 !important;
    color: #9a3412 !important;
    border: 1px solid #ea580c !important;
    font-weight: 800 !important;
    padding: 2px 8px !important;
    border-radius: 4px !important;
  }

  .badge-success {
    background: #dcfce7 !important;
    color: #14532d !important;
    border: 1px solid #22c55e !important;
  }

    /* Printable Signatures Block */
  .print-signatures-block {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    align-items: flex-end !important;
    gap: 32px 56px !important;
    margin-top: 24px !important;
    padding: 24px 0 0 !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    background: transparent !important;
    text-align: center !important;
  }

  .print-signatures-block > .print-sig-section {
    flex-basis: 100% !important;
  }

  .print-sig-section {
    font-size: 9pt !important;
    font-weight: 800 !important;
    letter-spacing: 0.08em !important;
    text-transform: uppercase !important;
    color: #000000 !important;
    text-align: center !important;
    padding-bottom: 6px !important;
    border-bottom: 1px solid #000000 !important;
  }

  .print-sig-slot {
    flex: 0 1 200px !important;
  }

  .print-sig-slot.tabulation {
    flex-basis: 220px !important;
  }

  .signature-line {
    border-bottom: 2.5px solid #000000 !important;
    width: 190px !important;
    max-width: 100% !important;
    height: 44px !important;
    margin: 0 auto !important;
  }

  .print-sig-slot.tabulation .signature-line {
    width: 230px !important;
    height: 48px !important;
  }

  .signature-label {
    font-weight: 800 !important;
    font-size: 8.5pt !important;
    color: #000000 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.03em !important;
    margin-top: 4px !important;
  }

  /* Density Scaling Modes */
  .density-compact .formal-table {
    font-size: 8pt !important;
  }
  .density-compact .formal-table th,
  .density-compact .formal-table td {
    padding: 3px 4px !important;
  }
  .density-compact .print-signatures-block {
    margin-top: 14px !important;
    padding-top: 10px !important;
  }
  .density-compact .signature-line {
    height: 36px !important;
  }

  .density-relaxed .formal-table {
    font-size: 11pt !important;
  }
  .density-relaxed .formal-table th,
  .density-relaxed .formal-table td {
    padding: 8px 10px !important;
  }

  /* Optional Hide Signatures */
  .hide-signatures .print-signatures-block {
    display: none !important;
  }
}

/* ── Mode Chooser (shadcn feature card) ─────────────────────────────────────── */
.mode-option {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
  user-select: none;
}

.mode-option:hover {
  border-color: var(--border-medium);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.mode-option:active {
  transform: scale(0.99);
}

.mode-option-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  border: 1px solid transparent;
}

.mode-option-icon.blue {
  background: #eff6ff;
  color: #2563eb;
  border-color: #dbeafe;
}

.mode-option-icon.gold {
  background: #fffbeb;
  color: #d97706;
  border-color: #fef3c7;
}

.mode-option-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}

.mode-option-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.mode-option-arrow {
  margin-left: auto;
  color: var(--text-muted);
  transition: transform 0.15s ease, color 0.15s ease;
}

.mode-option:hover .mode-option-arrow {
  transform: translateX(4px);
  color: var(--text-primary);
}
