:root {
  --bg: #1a3a5f; /* Deep CEIRD Blue */
  --surface: #244b7a;
  --surface-2: #2d5a92;
  --text: #ffffff;
  --muted: #cbd5e0;
  --primary: #ffd700; /* Gold/Yellow from CEIRD logo/accent */
  --primary-hover: #e6c200;
  --secondary: rgba(255, 255, 255, 0.1);
  --danger: #e05a5a;
  --success: #2fb980;
  --border: rgba(255, 255, 255, 0.15);
  --font-main: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-size: 14px;
}

body {
  margin: 0;
  font-family: var(--font-main);
  font-size: var(--font-size);
  background-color: var(--bg);
  background-image: 
    linear-gradient(rgba(26, 58, 95, 0.8), rgba(26, 58, 95, 0.9)),
    url("/static/research.jpg");
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.6;
}

/* Theme Overrides */
body.theme-light {
  --bg: #ffffff;
  --surface: #f8fafc;
  --surface-2: #f1f5f9;
  --text: #0f172a;
  --muted: #475569;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary: #f1f5f9;
  --border: #e2e8f0;
}
body.theme-light {
  background-image: none;
  background-color: #f8fafc;
}
body.theme-light .topbar {
  background: #ffffff;
  border-bottom: 2px solid var(--primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
body.theme-light .brand, body.theme-light .topbar .btn-secondary {
  color: #0f172a;
}
body.theme-light .sidebar {
  background: #ffffff;
  border-right: 1px solid #e2e8f0;
}
body.theme-light .sidebar-link {
  color: #475569;
}
body.theme-light .sidebar-link i {
  color: #2563eb;
}
body.theme-light .sidebar-link:hover {
  background: #f1f5f9;
  color: #2563eb;
}
body.theme-light .sidebar-link.active {
  background: #eff6ff;
  color: #2563eb;
  border-left-color: #2563eb;
}
body.theme-light .card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
body.theme-light h1, body.theme-light h2, body.theme-light h3 {
  color: #0f172a;
}
body.theme-light .muted {
  color: #64748b;
}
body.theme-light td {
  background: white;
  color: #0f172a;
  border-top-color: #f1f5f9;
}
body.theme-light tr:hover td {
  background: #f8fafc;
}
body.theme-light input, body.theme-light select, body.theme-light textarea {
  background: #ffffff;
  border: 1px solid #cbd5e0;
  color: #0f172a;
}
body.theme-light .btn-secondary {
  background: #f1f5f9;
  color: #0f172a;
  border: 1px solid #e2e8f0;
}

body.theme-dark {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --primary: #38bdf8;
  --primary-hover: #0ea5e9;
  --text: #f8fafc;
  --muted: #94a3b8;
}
body.theme-dark {
  background-image: none;
  background-color: #0f172a;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 2rem;
  background: #ffffff;
  border-bottom: 3px solid var(--primary);
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
  position: sticky;
  top: 0;
  z-index: 1000;
  min-height: 88px;
}

.brand {
  font-size: 1.5rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #1a3a5f;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid #e5e7eb;
  box-shadow: 0 2px 10px rgba(26, 58, 95, 0.18);
  overflow: hidden;
  flex-shrink: 0;
}

.brand-logo {
  width: 86px;
  height: 86px;
  object-fit: contain;
  display: block;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-title {
  color: #1a3a5f;
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: 2px;
}

.brand-sub {
  color: #64748b;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0.3px;
}

.nav {
  display: flex;
  gap: 12px;
}

/* Specific nav button styles for white background */
.topbar .btn-secondary {
  background: rgba(26, 58, 95, 0.05);
  color: #1a3a5f;
  border: 1px solid rgba(26, 58, 95, 0.1);
}

.topbar .btn-secondary:hover {
  background: rgba(26, 58, 95, 0.1);
  border-color: var(--primary);
  color: #1a3a5f;
}

.container {
  max-width: 1200px;
  margin: 40px auto;
  padding: 0 20px;
}

.card {
  background: rgba(36, 75, 122, 0.4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 30px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  position: relative;
  transform: translateZ(0);
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), transparent);
}

h1, h2, h3 {
  margin-top: 0;
  color: var(--primary);
  font-weight: 700;
}

.row {
  display: flex;
  gap: 15px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.row > .field {
  min-width: 0;
}

input,
select,
textarea {
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 12px 16px;
  font-size: 14px;
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  width: 100%;
  transition: border-color 0.3s, box-shadow 0.3s;
}

select {
  background-color: rgba(255, 255, 255, 0.9);
  color: #000000;
  font-weight: 500;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%231a3a5f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 40px;
}

select option {
  background-color: #ffffff !important;
  color: #000000 !important;
}

.approval-select {
  background-color: #ffffff !important;
  color: #1a3a5f !important;
  border: 2px solid var(--primary) !important;
  border-radius: 12px !important;
  padding: 12px 40px 12px 16px !important;
  font-weight: 700 !important;
  width: 100% !important;
  height: auto !important;
  display: block !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%231a3a5f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 15px center !important;
  background-size: 18px !important;
  position: relative;
  z-index: 5;
  cursor: pointer;
  transition: all 0.2s;
}

.approval-select:hover {
  border-color: var(--primary-hover) !important;
  background-color: #f8fafc !important;
}

.approval-select:focus {
  outline: none !important;
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 4px rgba(255, 215, 0, 0.2), 0 10px 25px rgba(0,0,0,0.2) !important;
  z-index: 200 !important;
  transform: translateY(-1px);
}

.approval-select option {
  background-color: #ffffff !important;
  color: #1a3a5f !important;
  padding: 12px !important;
  font-weight: 500 !important;
  font-family: var(--font-main);
}

/* Specific fix for scrollable areas containing dropdowns */
.scroll-glass-list {
  max-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Aesthetic Checkbox Styling */
.aesthetic-checkbox-container {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
  padding: 6px 10px;
  border-radius: 8px;
}

.aesthetic-checkbox-container:hover {
  background: rgba(255, 255, 255, 0.05);
}

.aesthetic-checkbox {
  position: relative;
  width: 22px;
  height: 22px;
  appearance: none;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid var(--primary);
  border-radius: 6px;
  cursor: pointer;
  outline: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.aesthetic-checkbox:checked {
  background: var(--primary);
  transform: scale(1.1);
}

.aesthetic-checkbox:checked::after {
  content: '\f00c';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  color: #1a3a5f;
  font-size: 14px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.aesthetic-checkbox:focus {
  box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.3);
}

.aesthetic-checkbox-label {
  color: var(--text);
  font-size: 0.95rem;
  margin-bottom: 0 !important;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(255, 215, 0, 0.2);
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.85rem;
}

.field {
  margin-bottom: 20px;
}

button,
.btn {
  cursor: pointer;
  background: var(--primary);
  color: #1a3a5f; /* Dark blue text on gold button */
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
  font-size: 0.95rem;
}

button:hover,
.btn:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 215, 0, 0.3);
}

.btn-secondary {
  background: var(--secondary);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: var(--primary);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-success {
  background: var(--success);
  color: white;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 20px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}

th,
td {
  padding: 16px;
  text-align: left;
}

th {
  color: var(--primary);
  background: rgba(0, 0, 0, 0.3);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.5px;
}

td {
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

tr:hover td {
  background: rgba(255, 255, 255, 0.05);
}

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

.alert {
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 20px;
  background: rgba(224, 90, 90, 0.15);
  border: 1px solid var(--danger);
  color: #ffadad;
}

/* Custom scrollbar to match theme */
::-webkit-scrollbar {
  width: 10px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--surface-2);
  border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* Sidebar Layout */
.app-content {
  display: flex;
  height: calc(100vh - 94px);
  overflow: hidden;
}

.sidebar {
  width: 260px;
  background: rgba(26, 58, 95, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  flex-shrink: 0;
  transition: all 0.3s ease;
  overflow-y: auto;
}

.main-body {
  flex: 1;
  width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  height: 100%;
}

.sidebar-link {
  padding: 14px 25px;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 15px;
  transition: all 0.2s;
  font-weight: 500;
  font-size: 0.95rem;
  border-left: 4px solid transparent;
}

.sidebar-link i {
  width: 24px;
  font-size: 1.1rem;
  color: var(--primary);
  transition: transform 0.2s;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--primary);
  border-left-color: rgba(255, 215, 0, 0.3);
}

.sidebar-link:hover i {
  transform: scale(1.1);
}

.sidebar-link.active {
  background: rgba(255, 215, 0, 0.1);
  border-left-color: var(--primary);
  color: var(--primary);
}

/* Theme Overrides */
body.theme-pink {
  --bg: #5f1a3a;
  --surface: #7a244b;
  --surface-2: #922d5a;
  --primary: #ff69b4;
  --primary-hover: #ff1493;
}
body.theme-pink h1, body.theme-pink h2, body.theme-pink h3 { color: #ff69b4; }
body.theme-pink .topbar { border-bottom-color: #ff69b4; }
body.theme-pink .sidebar-link i { color: #ff69b4; }
body.theme-pink .sidebar-link.active { background: rgba(255, 105, 180, 0.1); border-left-color: #ff69b4; color: #ff69b4; }

body.theme-green {
  --bg: #1a5f3a;
  --surface: #247a4b;
  --surface-2: #2d925a;
  --primary: #2fb980;
  --primary-hover: #27a36f;
}

body.theme-purple {
  --bg: #3a1a5f;
  --surface: #4b247a;
  --surface-2: #5a2d92;
  --primary: #bb86fc;
  --primary-hover: #9965f4;
}

body.theme-dark {
  --bg: #121212;
  --surface: #1e1e1e;
  --surface-2: #2c2c2c;
  --primary: #ffffff;
  --primary-hover: #e0e0e0;
}

.main-body {
  flex: 1;
  width: 100%;
  overflow-x: hidden;
  overflow-y: auto; /* Independent main content scroll */
}

@media (max-width: 992px) {
  .sidebar {
    width: 80px;
  }
  .sidebar-link span {
    display: none;
  }
  .sidebar-link {
    justify-content: center;
    padding: 20px 0;
  }
  .sidebar-link i {
    margin: 0;
    font-size: 1.4rem;
  }
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }
  .app-content {
    display: block;
    min-height: auto;
  }
}

/* Gmail-style notification bell — topbar is white, so use dark/gold contrast */
.notif-bell {
  position: relative;
  margin-right: 8px;
  z-index: 1100;
}
.notif-bell-btn {
  position: relative;
  background: #1a3a5f;
  border: 2px solid var(--primary);
  color: var(--primary);
  min-width: 44px;
  height: 42px;
  padding: 0 12px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 1.15rem;
  font-weight: 700;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
  box-shadow: 0 2px 8px rgba(26, 58, 95, 0.25);
}
.notif-bell-btn .notif-bell-label {
  font-size: 0.85rem;
  color: #fff;
  letter-spacing: 0.02em;
}
.notif-bell-btn:hover,
.notif-bell.open .notif-bell-btn {
  background: #244b7a;
  border-color: #ffd700;
  color: #ffd700;
  transform: translateY(-1px);
}
.notif-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ea4335;
  color: white;
  font-size: 0.72rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px #ffffff;
  line-height: 1;
}
.notif-badge[hidden] {
  display: none !important;
}
.notif-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: min(380px, calc(100vw - 24px));
  max-height: 420px;
  background: #12263f;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  z-index: 2000;
  display: none; /* closed by default — do NOT use display:flex here or [hidden] is ignored */
  flex-direction: column;
  overflow: hidden;
}
.notif-bell.open .notif-panel {
  display: flex;
}
.notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.2);
}
.notif-panel-header strong {
  color: white;
  font-size: 0.95rem;
  flex: 1;
}
.notif-panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.notif-mark-all {
  background: none;
  border: none;
  color: #8ec5ff;
  font-size: 0.8rem;
  cursor: pointer;
  font-weight: 600;
  padding: 4px 6px;
}
.notif-mark-all:hover {
  text-decoration: underline;
}
.notif-panel-close {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(224, 90, 90, 0.2);
  color: #ffb4b4;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
}
.notif-panel-close:hover {
  background: #e05a5a;
  color: white;
  border-color: #e05a5a;
}
.notif-panel-body {
  overflow-y: auto;
  max-height: 360px;
}
.notif-section-label {
  padding: 10px 16px 4px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  font-weight: 700;
}
.notif-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 16px;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background 0.15s;
  cursor: pointer;
  width: 100%;
  background: transparent;
  border-left: none;
  border-right: none;
  border-top: none;
  text-align: left;
}
.notif-item:hover {
  background: rgba(0, 122, 255, 0.12);
}
.notif-item.unread {
  background: rgba(0, 122, 255, 0.08);
}
.notif-item-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.95rem;
}
.notif-item-icon.approve {
  background: rgba(255, 193, 7, 0.18);
  color: #ffc107;
}
.notif-item-icon.view {
  background: rgba(0, 122, 255, 0.18);
  color: #5eb0ff;
}
.notif-item-text {
  flex: 1;
  min-width: 0;
}
.notif-item-title {
  color: white;
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.notif-item-msg {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 2px;
}
.notif-empty {
  padding: 36px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}
.notif-toast {
  position: fixed;
  top: 90px;
  right: 20px;
  z-index: 3000;
  background: #12263f;
  border: 1px solid rgba(0, 122, 255, 0.45);
  border-left: 4px solid var(--ios-accent);
  border-radius: 12px;
  padding: 14px 44px 14px 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  max-width: 360px;
  display: none;
  pointer-events: auto;
  animation: notifSlideIn 0.35s ease;
}
.notif-toast.show {
  display: block;
}
.notif-toast strong {
  color: white;
  display: block;
  margin-bottom: 4px;
  padding-right: 4px;
}
.notif-toast span {
  color: var(--muted);
  font-size: 0.85rem;
}
.notif-toast-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
  z-index: 3001;
  pointer-events: auto;
}
.notif-toast-close:hover {
  background: rgba(224, 90, 90, 0.35);
  color: #ffb4b4;
}
@keyframes notifSlideIn {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Global back navigation (previous tab / page) */
.page-back-nav {
  display: flex;
  align-items: center;
  margin: 0 0 14px;
}
.page-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  min-height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  box-shadow: none;
  transform: none;
}
.page-back-btn:hover {
  background: rgba(255, 215, 0, 0.12);
  border-color: var(--primary);
  color: var(--primary);
  transform: none;
  box-shadow: none;
}
.page-back-btn i {
  font-size: 0.95rem;
}
.page-back-btn.is-fallback {
  opacity: 0.85;
}
