/* --- MODERN BLUE COLOR PALETTE & VARIABLES --- */
:root {
  --blue-900: #0f172a;
  --blue-800: #1e293b;
  --blue-600: #2563eb;
  --blue-500: #3b82f6;
  --blue-100: #dbeafe;
  --blue-50:  #eff6ff;

  --surface: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --danger: #ef4444;
  --danger-light: #fef2f2;

  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.05);

  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* --- GLOBAL RESETS --- */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-family);
  background-color: var(--blue-50);
  color: var(--text-main);
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* --- ANIMATIONS --- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn 0.4s ease-out forwards; }

/* --- SIDEBAR NAVIGATION --- */
.sidebar {
  width: 280px;
  background: linear-gradient(10deg, var(--blue-900), var(--blue-800));
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 100;
  box-shadow: var(--shadow-lg);
  transition: all 0.3s ease;
}

.sidebar-header {
  padding: 2rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 15px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo {
  min-width: 64px;
  height: 64px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.2rem;
}

/* Make the PBS logo link behave like the old logo container */
.pbs-logo-link {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-title{
  font-weight: 600;
  font-size: 1.1rem;
  line-height: 1.2;
}

.sidebar-nav {
  padding: 1.5rem 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 1rem 1.5rem;
  color: #cbd5e1;
  text-decoration: none;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  font-size: 1.05rem;
}

.nav-item:hover { background-color: rgba(255,255,255,0.05); color: white; }
.nav-item.active { background-color: var(--blue-600); color: white; box-shadow: var(--shadow-md); }
.nav-icon { font-size: 1.4rem; }

.sidebar-footer {
  padding: 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.85rem;
  color: #94a3b8;
}

/* --- MAIN CONTENT AREA --- */
.main-wrapper {
  flex: 1;
  margin-left: 280px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: calc(100% - 280px);
}

/* --- TOP HEADER & PROFILE --- */
.top-header {
  background-color: var(--surface);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
}

.dept-info { display: flex; align-items: center; gap: 15px; }

.dept-logo {
  min-width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: var(--blue-600);
}

.dept-name {
  font-size: clamp(1rem, 2vw, 1.25rem);
  font-weight: 700;
  color: var(--blue-900);
}

/* User Profile Styles */
.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0.5rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  position: relative;
  transition: background 0.2s;
}

.user-profile:hover { background-color: var(--blue-50); }

.user-details { display: flex; flex-direction: column; text-align: right; justify-content: center; }
.user-name { font-weight: 600; font-size: 1rem; color: var(--blue-900); }

.avatar {
  width: 40px;
  height: 40px;
  background-color: var(--blue-600);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1rem;
}

/* Profile Dropdown */
.profile-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  width: 200px;
  display: none;
  flex-direction: column;
  padding: 0.5rem 0;
  z-index: 100;
}

.profile-dropdown.show { display: flex; }

.profile-dropdown a {
  padding: 0.75rem 1.25rem;
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.95rem;
  transition: background 0.2s;
}

.profile-dropdown a:hover { background-color: var(--blue-50); }

.profile-divider{
  border: 0;
  border-top: 1px solid var(--border);
  margin: 0.5rem 0;
}

.sign-out { color: var(--danger); }

/* Content Sections */
.content-area { padding: 2rem; max-width: 1400px; margin: 0 auto; width: 100%; }
.page-section { display: none; }
.page-section.active { display: block; }

/* --- UI COMPONENTS --- */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: clamp(1.5rem, 3vw, 2rem);
  box-shadow: var(--shadow-md);
  margin-bottom: 2rem;
  border: 1px solid var(--border);
  width: 100%;
  overflow: hidden;
}

h2.section-title {
  color: var(--blue-900);
  font-size: clamp(1.25rem, 3vw, 1.5rem);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-subtext{
  color: var(--text-muted);
  margin-bottom: 2rem;
}

/* Hero Banner */
.hero-banner {
  background: linear-gradient(135deg, var(--blue-900), var(--blue-800));
  border-radius: var(--radius-lg);
  padding: clamp(1.5rem, 4vw, 3rem);
  color: white;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.hero-banner::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -10%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(59,130,246,0.3) 0%, transparent 70%);
  border-radius: 50%;
}

.hero-banner h1 {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  margin-bottom: 0.5rem;
  position: relative;
  z-index: 2;
  line-height: 1.2;
}

.hero-banner p {
  font-size: clamp(1rem, 2vw, 1.2rem);
  color: #cbd5e1;
  position: relative;
  z-index: 2;
}

/* Dashboard Grid */
.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.action-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-decoration: none;
  color: var(--text-main);
}

.action-card:hover { transform: translateY(-3px); border-color: var(--blue-600); box-shadow: var(--shadow-md); }

.action-icon {
  min-width: 60px;
  height: 60px;
  background-color: var(--blue-50);
  color: var(--blue-600);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.action-title { font-size: 1.25rem; font-weight: 700; color: var(--blue-900); }
.action-desc { font-size: 0.95rem; color: var(--text-muted); line-height: 1.4; }

.followup-alert{
  color: var(--danger);
  font-weight: 600;
}

/* Modern Tables */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
}

.modern-table { width: 100%; border-collapse: collapse; min-width: 600px; }

.modern-table th {
  background-color: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  text-align: left;
  padding: 1rem 1.25rem;
  border-bottom: 2px solid var(--border);
  font-size: 0.85rem;
  text-transform: uppercase;
}

.modern-table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 0.95rem;
}

.modern-table tr:hover td { background-color: var(--blue-50); }

.badge {
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  display: inline-block;
  white-space: nowrap;
}

.badge.danger { background-color: var(--danger-light); color: var(--danger); }

.btn-link {
  color: var(--blue-600);
  font-weight: 600;
  text-decoration: none;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  background: transparent;
  border: none;
  cursor: pointer;
}

.btn-link:hover{ text-decoration: underline; }

.semi-bold{ font-weight: 500; }

.text-right{ text-align: right; }

.file-name{
  font-weight: 600;
  color: var(--blue-900);
}

/* Forms */
.form-group { margin-bottom: 1.5rem; max-width: 100%; }

.form-label {
  display: block;
  font-weight: 600;
  color: var(--blue-900);
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

.form-control {
  width: 100%;
  padding: 0.85rem 1rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  background-color: #f8fafc;
}

.form-control:focus {
  outline: none;
  border-color: var(--blue-500);
  background-color: var(--surface);
}

textarea.form-control { min-height: 120px; resize: vertical; }

.upload-zone {
  border: 2px dashed var(--blue-600);
  background-color: var(--blue-50);
  padding: clamp(1.5rem, 4vw, 3rem);
  text-align: center;
  border-radius: var(--radius-md);
  cursor: pointer;
}

.upload-icon{ font-size: 2.5rem; margin-bottom: 1rem; }
.upload-title{ font-size: 1.1rem; font-weight: 600; color: var(--blue-900); }
.upload-subtitle{ color: var(--text-muted); margin-top: 0.5rem; font-size: 0.9rem; }

.btn-primary {
  background-color: var(--blue-600);
  color: white;
  border: none;
  padding: 1rem 2rem;
  font-size: 1.05rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  width: 100%;
  max-width: 300px;
  transition: all 0.2s;
}

.btn-primary:hover {
  background-color: var(--blue-500);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(37,99,235,0.2);
}

.btn-primary-dark{
  background-color: var(--blue-800);
}

/* Two-column layout for profile page */
.profile-grid { display: flex; gap: 2rem; flex-wrap: wrap; }
.profile-column { flex: 1; min-width: 300px; }

.profile-security-card{
  background-color: #f8fafc;
  border: 1px solid var(--border);
  box-shadow: none;
  padding: 1.5rem;
}

.security-title{
  color: var(--blue-900);
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
}

/* --- RESPONSIVE BREAKPOINTS --- */
@media (max-width: 1024px) {
  .sidebar { width: 240px; }
  .main-wrapper { margin-left: 240px; width: calc(100% - 240px); }
  .action-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
}

@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: 70px;
    flex-direction: row;
    bottom: 0;
    top: auto;
    box-shadow: 0 -4px 15px rgba(0,0,0,0.1);
    padding-bottom: env(safe-area-inset-bottom);
  }
  

  .sidebar-header, .sidebar-footer { display: none; }

  .sidebar-nav {
    flex-direction: row;
    justify-content: space-around;
    padding: 0;
    align-items: center;
    width: 100%;
    gap: 0;
  }

  .nav-item {
    flex-direction: column;
    gap: 4px;
    padding: 0.5rem;
    font-size: 0.7rem;
    border-radius: 0;
    flex: 1;
    text-align: center;
  }

  .nav-icon { font-size: 1.25rem; }


  .nav-item.active {
    background: none;
    color: white;
    border-top: 5px solid var(--blue-500); /* thicker */
    box-shadow: inset 0 10px 18px rgba(59,130,246,0.18);
  }

  .nav-item.active .nav-icon {
    filter: drop-shadow(0 2px 6px rgba(59,130,246,0.55));
  }


  .main-wrapper { margin-left: 0; width: 100%; padding-bottom: 80px; }

  .top-header {
    padding: 1rem;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .dept-info { gap: 10px; }
  .user-details { display: none; }
  .avatar { width: 35px; height: 35px; font-size: 0.9rem; }

  .content-area { padding: 1rem; }
  .action-grid { grid-template-columns: 1fr; gap: 1rem; }
  .action-card { flex-direction: row; text-align: left; padding: 1.25rem; align-items: center; }
  .action-icon { min-width: 50px; height: 50px; font-size: 1.5rem; }
  .action-title { font-size: 1.15rem; }
  .btn-primary { max-width: 100%; }
}

@media (max-width: 400px) {
  /* Hide ONLY the label text span, keep the icon span */
  .nav-item span:not(.nav-icon) { 
    display: none; 
  }

  .nav-icon { 
    font-size: 1.5rem; 
    margin-top: 8px; 
  }

  .dept-logo { 
    display: none; 
  }
}

/* Logo images scale to fit the existing logo containers */
.logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* If you want the FD/dept logo to stay circular, this helps */
.logo-img--dept {
  border-radius: 50%;
}

/* Hide app chrome until authenticated (front-end gate) */
body:not(.is-authenticated) .sidebar,
body:not(.is-authenticated) .top-header {
  display: none;
}

/* When logged out, main takes full width */
body:not(.is-authenticated) .main-wrapper {
  margin-left: 0;
  width: 100%;
}

/* --- Login page spacing polish --- */
#login .card {
  max-width: 560px;
  margin: 3rem auto;
}

#login .section-title {
  margin-bottom: 0.75rem; /* tighter under the title */
}

#login .section-subtext {
  margin-bottom: 1.25rem; /* consistent spacing for the first paragraph */
}

#login .login-lead {
  margin: 0 0 1rem;       /* consistent spacing before the button */
  color: var(--text-muted);
}

#login .login-actions {
  margin-top: 0.25rem;
}

#login .login-actions .btn-primary {
  width: 100%;
  max-width: 420px;
  display: block;
  margin: 0 auto;         /* center it */
  text-align: center;
  text-decoration: none;
}

#login .login-note {
  margin-top: 1rem;       /* breathing room after button */
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.4;
}

.followup-alert {
  font-weight: 600;
}

.followup-alert.alert-danger {
  color: var(--danger);
}

.followup-alert.alert-success {
  color: #16a34a; /* green */
}

/* ============================
   SUBMIT PAGE: center + wide like Image 2
   ============================ */

/* Do NOT set #submit to display:flex/grid (that can create the right-panel look).
   Instead, just control the card width and center it. */
#submit .card {
  max-width: 1100px;   /* adjust: 900–1200 based on taste */
  margin: 0 auto;      /* centers in the big canvas under the header */
}

/* Optional: keep the upload zone feeling "full width" inside the card */
#submit .upload-zone {
  width: 100%;
}


#contact .card {
  max-width: 1100px;
  margin: 0 auto;
}

/* =========================================================
   LOGIN (Version B) — Centered Secure Gateway + Gradient Wash
   Keep this as the ONLY login CSS block to avoid duplicates.
   ========================================================= */

/* Logged-out view: full-bleed background wash */
body:not(.is-authenticated) {
  background:
    radial-gradient(1100px 700px at 15% 12%, rgba(59,130,246,0.22), transparent 62%),
    radial-gradient(1000px 650px at 88% 18%, rgba(37,99,235,0.16), transparent 60%),
    radial-gradient(900px 600px at 50% 95%, rgba(59,130,246,0.10), transparent 60%),
    linear-gradient(180deg, #f6faff 0%, var(--blue-50) 55%, #eef5ff 100%);
}

/* Remove normal app padding when logged out */
body:not(.is-authenticated) .content-area {
  padding: 0;
  max-width: none;
  margin: 0;
}

/* Login section should fill the viewport */
#login {
  min-height: 100vh;
}

/* Center the gateway card */
#login .gateway-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(1.25rem, 3vw, 2.5rem);
  position: relative;
  overflow: hidden; /* prevents glow blobs from making scrollbars */
}

/* Soft glow blobs behind the card (Part A vibe) */
#login .gateway-wrap::before,
#login .gateway-wrap::after {
  content: "";
  position: absolute;
  width: 520px;
  height: 520px;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0.35;
  z-index: 0;
}

#login .gateway-wrap::before {
  top: -220px;
  right: -180px;
  background: radial-gradient(circle, rgba(59,130,246,0.60), transparent 65%);
}

#login .gateway-wrap::after {
  bottom: -240px;
  left: -200px;
  background: radial-gradient(circle, rgba(37,99,235,0.48), transparent 65%);
}

/* The main gateway card */
#login .gateway-card {
  width: min(640px, 100%);
  border-radius: 24px;
  background: rgba(255,255,255,0.90);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: clamp(1.5rem, 2.8vw, 2.4rem);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 1; /* sits above glow blobs */
}

/* Header row */
#login .gateway-header {
  display: flex;
  gap: 16px;
  align-items: center;
}

/* PBS logo container */
#login .gateway-logo {
  width: 62px;
  height: 62px;
  border-radius: 18px;
  background: #fff;
  border: 1px solid rgba(226,232,240,0.9);
  padding: 10px;
  object-fit: contain;
}

/* Small kicker text */
#login .gateway-kicker {
  color: var(--text-muted);
  font-weight: 650;
  letter-spacing: 0.2px;
  margin-bottom: 0.2rem;
}

/* Main title */
#login .gateway-title {
  font-size: clamp(1.5rem, 2.6vw, 2rem);
  letter-spacing: -0.3px;
  color: var(--blue-900);
  line-height: 1.15;
}

/* Subtitle */
#login .gateway-subtitle {
  color: var(--text-muted);
  margin-top: 0.35rem;
  line-height: 1.45;
}

/* Divider */
#login .gateway-divider {
  height: 1px;
  background: var(--border);
  margin: 1.25rem 0;
}

/* CTA "tile" */
#login .gateway-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: #fff;
  text-decoration: none;
  padding: 1rem 1.05rem;
  color: var(--text-main);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

#login .gateway-cta:hover {
  border-color: rgba(59,130,246,0.55);
  box-shadow: 0 10px 24px rgba(15,23,42,0.08);
  transform: translateY(-1px);
}

#login .gateway-cta:active {
  transform: translateY(0);
  box-shadow: 0 6px 14px rgba(15,23,42,0.06);
}

#login .gateway-cta:focus-visible {
  outline: 3px solid rgba(59,130,246,0.35);
  outline-offset: 2px;
}

/* Left side of CTA */
#login .gateway-cta__left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

/* Microsoft icon chip */
#login .gateway-ms {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: #f8fafc;
  display: grid;
  place-items: center;
  border: 1px solid rgba(226,232,240,0.9);
  flex: 0 0 auto;
}

/* CTA text */
#login .gateway-cta__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

#login .gateway-cta__title {
  font-weight: 750;
  color: var(--blue-900);
  letter-spacing: -0.1px;
}

#login .gateway-cta__meta {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Arrow */
#login .gateway-cta__arrow {
  color: var(--text-muted);
  font-size: 1.15rem;
}

/* Trust chips row */
#login .gateway-trust {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 1.1rem;
}

#login .gateway-chip {
  border: 1px solid rgba(59,130,246,0.22);
  background: rgba(59,130,246,0.08);
  color: var(--blue-800);
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  font-weight: 650;
  font-size: 0.9rem;
}

/* Fineprint */
#login .gateway-fineprint {
  margin-top: 1rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

/* Footer row */
#login .gateway-footer {
  margin-top: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.92rem;
}

#login .gateway-dot {
  opacity: 0.6;
}

/* Mobile tweaks */
@media (max-width: 520px) {
  #login .gateway-header {
    align-items: flex-start;
  }
  #login .gateway-logo {
    width: 54px;
    height: 54px;
    border-radius: 16px;
  }
}

/* Document inline comments */
.doc-comments-panel {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}

.doc-comments-log {
  max-height: 220px;
  overflow-y: auto;
  margin-bottom: 0.75rem;
}

.doc-comment {
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.doc-comment .author {
  font-weight: 600;
}

.doc-comment .timestamp {
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* =========================
   SUPPORT TICKETS (Contact PBS)
   ========================= */

.support-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
}

.support-sidebar {
  border-right: 1px solid var(--border);
  padding-right: 1rem;
}

.support-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.ticket-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.ticket-item {
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  background: white;
}

.ticket-item.active {
  border-color: var(--blue-600);
  background: var(--blue-50);
}

.ticket-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.ticket-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.support-thread {
  display: flex;
  flex-direction: column;
}

.ticket-thread-placeholder {
  color: var(--text-muted);
  text-align: center;
  margin-top: 3rem;
}

.chat-thread {
  flex: 1;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  background: #f8fafc;
  margin-bottom: 1rem;
}

@media (max-width: 900px) {
  .support-layout {
    grid-template-columns: 1fr;
  }

  .support-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
  }
}

/* =========================
 CONTACT PBS – Conversations
 ========================= */


.conversation-list {
  border-right: 1px solid var(--border);
  padding-right: 1rem;
}

.conversation-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.conversation-items {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.conversation-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  cursor: pointer;
  background: #fff;
}

.conversation-item.active {
  background: var(--blue-50);
  border-color: var(--blue-600);
}

.conversation-title-small {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.conversation-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.conversation-panel {
  display: flex;
  flex-direction: column;
}

.conversation-title {
  margin-bottom: 0.75rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--blue-900);
}

.message-thread {
  flex: 1;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  background: #f8fafc;
  margin-bottom: 1rem;
}

.message {
  margin-bottom: 0.75rem;
}

.message .author {
  font-weight: 600;
}

.message .timestamp {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.message-composer {
  display: flex;
  gap: 0.75rem;
}

.message-composer textarea {
  flex: 1;
}

/* =========================
 Contact PBS – Clean Messaging Layout
 ========================= */

#contact .card {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem;
}

.contact-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 2rem;
}

/* LEFT COLUMN */
.conversation-list {
  border-right: 1px solid var(--border);
  padding-right: 1.5rem;
}

.conversation-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.conversation-empty {
  color: var(--text-muted);
  font-size: 0.95rem;
  padding: 1.25rem 0;
}

/* Conversation items */
.conversation-item {
  padding: 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  transition: all 0.15s ease;
}

.conversation-item:hover {
  border-color: var(--blue-500);
  background: var(--blue-50);
}

.conversation-item.active {
  border-color: var(--blue-600);
  background: var(--blue-50);
}

/* RIGHT COLUMN */
.conversation-panel {
  display: flex;
  flex-direction: column;
  min-height: 420px;
}

.conversation-placeholder {
  flex: 1;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-size: 1rem;
  border: 1px dashed var(--border);
  border-radius: 16px;
  background: #f8fafc;
}

/* Thread */
.message-thread {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #f8fafc;
  margin-bottom: 1rem;
}

.message {
  margin-bottom: 0.75rem;
}

.message .author {
  font-weight: 600;
  margin-bottom: 2px;
}

.message .timestamp {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Composer */
.message-composer {
  display: flex;
  gap: 0.75rem;
}

/* Mobile */
@media (max-width: 900px) {
  .contact-layout {
    grid-template-columns: 1fr;
  }

  .conversation-list {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
  }
}

.new-message-panel {
  width: 100%;
  max-width: 480px;
}

.new-message-panel h3 {
  margin-bottom: 1rem;
  color: var(--blue-900);
}

/* Make Contact page less cramped */
.contact-layout {
  grid-template-columns: 340px 1fr;
  gap: 2.25rem;
}

/* Right panel header bar */
.conversation-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  border-radius: 14px;
  background: #fff;
}

.conversation-panel-title {
  font-weight: 750;
  color: var(--blue-900);
  letter-spacing: -0.2px;
}

/* Button: smaller + less ugly */
.btn-primary.small {
  padding: 0.55rem 0.9rem;
  font-size: 0.92rem;
  max-width: none;        /* your btn-primary defaults to max-width 300px */
  width: auto;            /* prevent weird stretching */
  border-radius: 12px;
}

.btn-new-message {
  white-space: nowrap;
}

/* =========================
 Contact PBS – spacing + layout de-cramp
 ========================= */

#contact .card {
  max-width: 1150px;
  margin: 0 auto;
  padding: 2.25rem; /* more breathing room inside the card */
}

/* Wider gap between left list and right panel */
#contact .contact-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 2.5rem;
  align-items: start;
}

/* LEFT column */
#contact .conversation-list {
  padding-right: 1.5rem;
  border-right: 1px solid var(--border);
}

/* RIGHT column */
#contact .conversation-panel {
  display: flex;
  flex-direction: column;
  min-height: 520px; /* gives the panel room to breathe */
}

/* Header bar above the thread/new-message area */
#contact .conversation-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;

  padding: 1rem 1.1rem;      /* <-- this fixes the “no padding” complaint */
  margin-bottom: 1.25rem;    /* <-- separates header from content below */
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
}

/* Add clean spacing BETWEEN title and button */
#contact .conversation-panel-header > * {
  /* ensures the button never touches the title visually */
  margin: 0;
}

#contact .conversation-panel-title {
  font-weight: 750;
  color: var(--blue-900);
  letter-spacing: -0.2px;
}

/* Button should NOT stretch weirdly */
#contact .btn-primary.small {
  width: auto;
  max-width: none;
  padding: 0.6rem 0.95rem;
  font-size: 0.92rem;
  border-radius: 12px;
}

/* New message container: make it feel like a focused panel */
#contact .conversation-placeholder {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  padding: 1.5rem;
}

/* Keep the new message panel from looking like it’s fighting the thread */
#contact .new-message-panel {
  max-width: 560px;
  margin: 0 auto;
}

#contact .new-message-panel h3 {
  margin-bottom: 1rem;
  color: var(--blue-900);
}

/* Thread spacing */
#contact .message-thread {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  max-height: 360px; /* prevents “everything is huge” feeling */
  overflow-y: auto;
}

/* Composer row: not gigantic */
#contact .message-composer {
  display: flex;
  gap: 0.9rem;
  align-items: flex-end;
}

#contact .message-composer textarea {
  min-height: 64px;
}

/* Mobile */
@media (max-width: 900px) {
  #contact .contact-layout {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  #contact .conversation-list {
    border-right: none;
    padding-right: 0;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
  }
}

body.auth-checking .page-section { display: none !important; }
body.auth-checking #login { display: block !important; }

body.is-authenticated #login { display: none !important; }

/* Force the HTML hidden attribute to actually hide elements */
[hidden] { display: none !important; }

/* =========================
 Contact PBS – FINAL CLEAN LAYOUT
 ========================= */

#contact .card.contact-layout {
  max-width: 1150px;
  margin: 0 auto;
  padding: 2.25rem;
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 2rem;
  align-items: start;
}

/* Left list */
#contact .conversation-list {
  border-right: 1px solid var(--border);
  padding-right: 1.25rem;
}

#contact .conversation-header {
  margin-bottom: 1rem;
}

#contact .conversation-items {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#contact .conversation-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem;
  background: #fff;
  cursor: pointer;
  transition: 0.15s ease;
}

#contact .conversation-item:hover {
  background: var(--blue-50);
  border-color: rgba(59,130,246,0.55);
}

#contact .conversation-item.active {
  background: var(--blue-50);
  border-color: var(--blue-600);
}

/* Right panel */
#contact .conversation-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#contact .conversation-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.95rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
}

#contact .conversation-panel-title {
  font-weight: 750;
  color: var(--blue-900);
}

#contact .btn-primary.small {
  width: auto;
  max-width: none;
  padding: 0.6rem 0.95rem;
  font-size: 0.92rem;
  border-radius: 12px;
}

/* Compose */
#contact .conversation-placeholder {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  padding: 1.25rem;
}

#contact .new-message-panel {
  max-width: 560px;
  margin: 0 auto;
}

#contact .new-message-panel h3 {
  margin-bottom: 0.85rem;
  color: var(--blue-900);
}

/* Thread */
#contact .message-thread {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  padding: 1.1rem;
  max-height: 380px;
  overflow-y: auto;
  margin-bottom: 1rem;
}

#contact .message-composer {
  display: flex;
  gap: 0.9rem;
  align-items: flex-end;
}

#contact .message-composer textarea {
  min-height: 64px;
}

/* Mobile */
@media (max-width: 900px) {
  #contact .card.contact-layout {
    grid-template-columns: 1fr;
  }

  #contact .conversation-list {
    border-right: none;
    padding-right: 0;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
  }
}

/* =========================
 Documents – Inline Comments
 ========================= */

.doc-comments-row td {
  padding: 0 !important;
  background: #f8fafc;
}

.doc-comments-panel {
  background: #f8fafc;
  border-top: 1px solid var(--border);
  padding: 1rem 1.25rem 1.25rem;
}

.doc-comments-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.doc-comments-title {
  font-weight: 700;
  color: var(--blue-900);
}

.doc-comments-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.doc-comments-log {
  max-height: 220px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem;
  margin-bottom: 0.9rem;
}

.doc-comment {
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  margin-bottom: 0.65rem;
}

.doc-comment:last-child {
  margin-bottom: 0;
}

.doc-comment .author {
  font-weight: 700;
  color: var(--blue-900);
  margin-bottom: 0.2rem;
}

.doc-comment .timestamp {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

.doc-comments-compose {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.doc-comments-compose textarea {
  flex: 1;
  min-height: 72px;
  resize: vertical;
}

.doc-comments-compose .btn-primary {
  width: auto;
  max-width: none;
  min-width: 150px;
}

.doc-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: nowrap;
}

.doc-actions-cell {
  text-align: center;
  vertical-align: middle;
}

.doc-action-btn {
  background: none;
  border: none;
  color: var(--blue-600);
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  font-size: 0.95rem;
}

.doc-action-btn:hover {
  text-decoration: underline;
}

.preview-modal[hidden] { display: none; }

.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
}

.preview-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.55);
}

.preview-modal__panel {
  position: relative;
  width: min(1100px, 92vw);
  height: min(80vh, 760px);
  margin: 6vh auto 0;
  background: #0f1115;
  color: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,.45);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.preview-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}

.preview-modal__title {
  font-size: 16px;
  font-weight: 600;
}

.preview-modal__close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 10px;
}

.preview-modal__close:hover {
  background: rgba(255,255,255,.08);
}

.preview-modal__body {
  flex: 1;
  background: #111827;
}

.preview-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #111827;
}

body.modal-open {
  overflow: hidden;
}

/* =========================
   Documents – tighter, cleaner action column
   ========================= */

#documents .modern-table th:last-child,
#documents .modern-table td:last-child {
  width: 300px;
  min-width: 300px;
  white-space: nowrap;
}

#documents .modern-table th:last-child {
  text-align: center;
}

.doc-actions-cell {
  text-align: center;
  vertical-align: middle;
}

.doc-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.doc-action-chip {
  appearance: none;
  border: 1px solid rgba(37, 99, 235, 0.18);
  background: #eff6ff;
  color: var(--blue-600);
  font-weight: 600;
  font-size: 0.84rem;
  line-height: 1;
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  flex: 0 0 auto;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    transform 0.15s ease;
}

.doc-action-chip:hover {
  background: #dbeafe;
  border-color: rgba(37, 99, 235, 0.32);
  transform: translateY(-1px);
}

.doc-action-chip:focus-visible {
  outline: 3px solid rgba(59, 130, 246, 0.22);
  outline-offset: 2px;
}

.doc-action-unavailable {
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  opacity: 0.75;
  white-space: nowrap;
}

/* Mobile: let actions wrap nicely under each other if needed */
@media (max-width: 768px) {
  .doc-actions-cell {
    text-align: left;
  }

  .doc-actions {
    justify-content: flex-start;
    gap: 0.5rem;
  }

  .doc-action-chip {
    font-size: 0.84rem;
    padding: 0.5rem 0.72rem;
  }
}

/* =========================
   Documents – Sort Header + Section Divider Polish
   Add this at the very bottom of style.css
   ========================= */

/* Make the sortable header buttons look like normal table headers */
.doc-sort-btn {
  all: unset;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  color: inherit;
  font: inherit;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1;
}

.doc-sort-btn:hover {
  color: var(--blue-600);
}

.doc-sort-btn:focus-visible {
  outline: 3px solid rgba(59, 130, 246, 0.22);
  outline-offset: 3px;
  border-radius: 6px;
}

.doc-sort-arrow {
  font-size: 0.8rem;
  color: var(--text-muted);
  transform: translateY(-1px);
}

/* Keep all header text aligned consistently */
#documents .modern-table th {
  vertical-align: middle;
}

#documents .modern-table th:last-child {
  text-align: center;
}

/* Make the documents section feel like one grouped block */
#documents .card {
  margin-bottom: 1rem;
}

#documents .table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  position: relative;
}

/* Soft divider line at the top of the table block */
#documents .table-wrapper::before {
  content: "";
  display: block;
  height: 4px;
  background: linear-gradient(
    90deg,
    rgba(37, 99, 235, 0.18),
    rgba(37, 99, 235, 0.06)
  );
}

/* Cleaner separation between header row and body row */
#documents .modern-table thead th {
  background: #f8fafc;
  border-bottom: 1px solid #dbe3ef;
}

/* Slightly stronger row dividers so each file feels distinct */
#documents .modern-table tbody td {
  border-bottom: 1px solid #e6edf5;
}

#documents .modern-table tbody tr:last-child td {
  border-bottom: none;
}

/* Optional: make the whole docs area breathe a little more */
#documents {
  position: relative;
}

#documents::after {
  content: "";
  display: block;
  height: 1px;
  margin-top: 2rem;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(148, 163, 184, 0.45),
    transparent
  );
}

/* =========================
   Preview Modal – Better File Preview Experience
   ========================= */

.preview-modal__panel {
  background: #ffffff;
  color: var(--text-main);
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.28);
}

.preview-modal__header {
  background: #ffffff;
  color: var(--blue-900);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
}

.preview-modal__title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--blue-900);
}

.preview-modal__close {
  color: var(--text-main);
}

.preview-modal__close:hover {
  background: var(--blue-50);
}

.preview-modal__body {
  flex: 1;
  background: #f8fafc;
  padding: 1rem;
  overflow: auto;
}

.preview-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #ffffff;
  border-radius: 12px;
}

/* Text preview */
.preview-text-wrap {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.preview-file-pill {
  align-self: flex-start;
  background: var(--blue-50);
  color: var(--blue-800);
  border: 1px solid rgba(37, 99, 235, 0.14);
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 700;
}

.preview-text-content {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.94rem;
  line-height: 1.6;
  color: var(--text-main);
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  min-height: 100%;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

/* Image preview */
.preview-image-wrap {
  height: 100%;
  display: grid;
  place-items: center;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
}

.preview-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 10px;
}

/* Fallback panel */
.preview-fallback {
  height: 100%;
  display: grid;
  place-items: center;
  text-align: center;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2rem;
}

.preview-fallback-icon {
  font-size: 2.25rem;
  margin-bottom: 0.75rem;
}

.preview-fallback h3 {
  color: var(--blue-900);
  margin-bottom: 0.5rem;
}

.preview-fallback p {
  max-width: 540px;
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 0.75rem;
}

.preview-fallback-note {
  font-size: 0.92rem;
}

.preview-fallback-actions {
  margin-top: 0.5rem;
}

.preview-fallback-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1rem;
  border-radius: 12px;
  background: var(--blue-600);
  color: #ffffff;
  text-decoration: none;
  font-weight: 700;
  transition: background 0.15s ease, transform 0.15s ease;
}

.preview-fallback-btn:hover {
  background: var(--blue-500);
  transform: translateY(-1px);
}

/* =========================
   Login – Ambient Background Motion
   Paste at very bottom of style.css
   ========================= */

@keyframes loginGlowFloatOne {
  0% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  25% {
    transform: translate3d(-14px, 10px, 0) scale(1.02);
  }
  50% {
    transform: translate3d(-6px, 22px, 0) scale(1.04);
  }
  75% {
    transform: translate3d(10px, 12px, 0) scale(1.015);
  }
  100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
}

@keyframes loginGlowFloatTwo {
  0% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  25% {
    transform: translate3d(16px, -8px, 0) scale(1.025);
  }
  50% {
    transform: translate3d(8px, -18px, 0) scale(1.045);
  }
  75% {
    transform: translate3d(-12px, -10px, 0) scale(1.02);
  }
  100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
}

/* Animate the two glow blobs that already exist behind the login card */
#login .gateway-wrap::before {
  animation: loginGlowFloatOne 18s ease-in-out infinite;
  will-change: transform;
}

#login .gateway-wrap::after {
  animation: loginGlowFloatTwo 22s ease-in-out infinite;
  will-change: transform;
}

/* Keep motion respectful for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  #login .gateway-wrap::before,
  #login .gateway-wrap::after {
    animation: none;
  }
}

/* =========================================
   CONTACT PBS — FINAL TIDY / OVERRIDE BLOCK
   Paste this at the VERY bottom of style.css
   ========================================= */

#contact .card.contact-layout {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.5rem;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
  background: transparent;
  border: none;
  box-shadow: none;
}

/* Left and right panels become their own clean cards */
#contact .conversation-list,
#contact .conversation-panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
}

/* LEFT PANEL */
#contact .conversation-list {
  padding: 1.1rem;
  min-height: 560px;
}

#contact .conversation-header {
  margin-bottom: 1rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--border);
}

#contact .conversation-header .section-title {
  margin-bottom: 0;
}

#contact .conversation-items {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#contact .conversation-empty {
  padding: 1rem;
  border: 1px dashed var(--border);
  border-radius: 14px;
  background: #f8fafc;
  color: var(--text-muted);
  font-size: 0.95rem;
}

#contact .conversation-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.95rem;
  background: #fff;
  cursor: pointer;
  transition: all 0.18s ease;
}

#contact .conversation-item:hover {
  border-color: rgba(37, 99, 235, 0.35);
  background: #f8fbff;
  transform: translateY(-1px);
}

#contact .conversation-item.active {
  border-color: var(--blue-600);
  background: var(--blue-50);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.08);
}

#contact .conversation-title-small {
  font-weight: 700;
  color: var(--blue-900);
  margin-bottom: 0.3rem;
}

#contact .conversation-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

#contact .conversation-ref-small {
  margin-top: 0.45rem;
  font-size: 0.78rem;
  color: var(--blue-800);
  background: #eff6ff;
  border: 1px solid rgba(37, 99, 235, 0.12);
  border-radius: 999px;
  padding: 0.3rem 0.55rem;
  display: inline-flex;
  max-width: 100%;
}

/* RIGHT PANEL */
#contact .conversation-panel {
  padding: 1.1rem;
  min-height: 560px;
  display: flex;
  flex-direction: column;
}

#contact .conversation-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  background: transparent;
  border-radius: 0;
}

#contact .conversation-panel-title {
  font-weight: 750;
  color: var(--blue-900);
  font-size: 1.05rem;
}

#contact .conversation-panel-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

#contact .btn-primary.small,
#contact .btn-ghost-danger.small {
  width: auto;
  max-width: none;
  padding: 0.6rem 0.95rem;
  font-size: 0.9rem;
  border-radius: 12px;
}

#contact .btn-ghost-danger {
  border: 1px solid rgba(239, 68, 68, 0.22);
  background: #fff5f5;
  color: #dc2626;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
}

#contact .btn-ghost-danger:hover {
  background: #fee2e2;
  border-color: rgba(239, 68, 68, 0.32);
  transform: translateY(-1px);
}

/* Compose panel */
#contact .conversation-placeholder {
  display: block;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #f8fafc;
  padding: 1.25rem;
  min-height: 420px;
}

#contact .new-message-panel {
  max-width: 640px;
  margin: 0 auto;
}

#contact .new-message-panel h3 {
  margin-bottom: 1rem;
  color: var(--blue-900);
}

#contact .form-help {
  margin-top: 0.45rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Thread mode */
#contact #conversationThread {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#contact .conversation-title {
  margin-bottom: 0.6rem;
  font-size: 1.25rem;
  font-weight: 750;
  color: var(--blue-900);
}

#contact .conversation-reference {
  margin-bottom: 0.9rem;
  display: inline-flex;
  align-self: flex-start;
  padding: 0.42rem 0.7rem;
  border-radius: 999px;
  background: #eff6ff;
  color: var(--blue-800);
  border: 1px solid rgba(37, 99, 235, 0.14);
  font-size: 0.84rem;
  font-weight: 700;
}

#contact .message-thread {
  flex: 1;
  min-height: 280px;
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #f8fafc;
  padding: 1rem;
  margin-bottom: 1rem;
}

#contact .message {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  padding: 0.8rem 0.9rem;
  margin-bottom: 0.75rem;
}

#contact .message:last-child {
  margin-bottom: 0;
}

#contact .message--user {
  border-left: 4px solid var(--blue-600);
}

#contact .message--pbs {
  border-left: 4px solid #cbd5e1;
}

#contact .message .author {
  font-weight: 700;
  color: var(--blue-900);
  margin-bottom: 0.2rem;
}

#contact .message .timestamp {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

#contact .message-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: end;
}

#contact .message-composer textarea {
  min-height: 72px;
}

#contact .message-composer .btn-primary {
  width: auto;
  max-width: none;
  min-width: 120px;
}

/* Mobile */
@media (max-width: 900px) {
  #contact .card.contact-layout {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 0;
  }

  #contact .conversation-list,
  #contact .conversation-panel {
    min-height: auto;
  }

  #contact .conversation-panel-header {
    flex-direction: column;
    align-items: stretch;
  }

  #contact .conversation-panel-actions {
    justify-content: flex-start;
  }

  #contact .message-composer {
    grid-template-columns: 1fr;
  }

  #contact .message-composer .btn-primary {
    width: 100%;
    max-width: 100%;
  }
}

/* =========================
Upload Files – File Preview
========================= */
.file-preview {
  margin-top: 1.25rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
}

.file-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  font-weight: 700;
  color: var(--blue-900);
}

.file-preview-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.file-preview-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
}

.file-preview-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.file-preview-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.file-preview-name {
  font-weight: 600;
  color: var(--blue-900);
  font-size: 0.92rem;
  word-break: break-word;
}

.file-preview-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

#submit .upload-zone.dragover {
  border-color: var(--blue-500);
  background: #dbeafe;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

#submit .upload-zone.dragover {
  border-color: var(--blue-500);
  background: #dbeafe;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}
/* =========================
Upload Success Toast
========================= */
.upload-toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10000;
  width: min(420px, calc(100vw - 32px));
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.9rem;
  align-items: start;
  padding: 1rem 1rem 1rem 0.95rem;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.18);
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.upload-toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.upload-toast__icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #dcfce7;
  color: #15803d;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1rem;
  flex-shrink: 0;
}

.upload-toast__content {
  min-width: 0;
}

.upload-toast__title {
  font-weight: 800;
  color: var(--blue-900);
  margin-bottom: 0.2rem;
}

.upload-toast__message {
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.upload-toast__close {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 10px;
  padding: 0.2rem 0.45rem;
  font-size: 1rem;
  line-height: 1;
}

.upload-toast__close:hover {
  background: var(--blue-50);
  color: var(--blue-900);
}

@media (max-width: 640px) {
  .upload-toast {
    right: 16px;
    left: 16px;
    bottom: 16px;
    width: auto;
  }
}


/* =========================
Documents – Filter Toolbar
========================= */
.docs-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: end;
  margin-top: 1.25rem;
}

.docs-filter-group {
  min-width: 220px;
  flex: 1 1 220px;
}

.docs-filter-group .form-label {
  margin-bottom: 0.45rem;
}

.docs-filter-select {
  background: #fff;
}

.docs-filter-actions {
  display: flex;
  align-items: center;
  padding-bottom: 0.2rem;
}

.docs-clear-filters {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 46px;
  padding: 0 0.75rem;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
  text-decoration: none;
}

.docs-clear-filters:hover {
  background: var(--blue-50);
  text-decoration: none;
}

.doc-filetype-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: #eff6ff;
  border: 1px solid rgba(37, 99, 235, 0.14);
  color: var(--blue-800);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

@media (max-width: 768px) {
  .docs-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .docs-filter-group,
  .docs-filter-actions {
    width: 100%;
  }

  .docs-clear-filters {
    width: 100%;
  }
}

.followup-icon-success {
  background: #dcfce7 !important;
  color: #16a34a !important;
  border: 1px solid #bbf7d0;
}

.followup-icon-danger {
  background: #fef3c7 !important;
  color: #d97706 !important;
  border: 1px solid #fde68a;
}

/* =========================
Terms & Conditions Gate
========================= */

body.terms-pending .sidebar,
body.terms-pending .top-header {
  display: none;
}

body.terms-pending .main-wrapper {
  margin-left: 0;
  width: 100%;
}

body.terms-pending .content-area {
  padding: 0;
  max-width: none;
  margin: 0;
}

#terms {
  min-height: 100vh;
}

#terms .terms-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(1.25rem, 3vw, 2.5rem);
  position: relative;
  overflow: hidden;
}

#terms .terms-wrap::before,
#terms .terms-wrap::after {
  content: "";
  position: absolute;
  width: 520px;
  height: 520px;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0.28;
  z-index: 0;
}

#terms .terms-wrap::before {
  top: -220px;
  right: -180px;
  background: radial-gradient(circle, rgba(59,130,246,0.55), transparent 65%);
}

#terms .terms-wrap::after {
  bottom: -240px;
  left: -200px;
  background: radial-gradient(circle, rgba(37,99,235,0.42), transparent 65%);
}

#terms .terms-card {
  width: min(980px, 100%);
  max-height: min(88vh, 980px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: 24px;
  background: rgba(255,255,255,0.94);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 1;
}

#terms .terms-header {
  padding: 1.75rem 1.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(239,246,255,0.9), rgba(255,255,255,0.95));
}

#terms .terms-kicker {
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 0.35rem;
}

#terms .terms-title {
  color: var(--blue-900);
  font-size: clamp(1.55rem, 2.8vw, 2.2rem);
  line-height: 1.15;
  margin-bottom: 0.5rem;
}

#terms .terms-subtitle {
  color: var(--text-muted);
  line-height: 1.5;
}

#terms .terms-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  padding: 1rem 1.75rem 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

#terms .terms-body {
  padding: 1.25rem 1.75rem 1.5rem;
  overflow-y: auto;
  line-height: 1.65;
  color: var(--text-main);
}

#terms .terms-body h3 {
  color: var(--blue-900);
  font-size: 1.05rem;
  margin: 1.35rem 0 0.55rem;
}

#terms .terms-body p {
  margin-bottom: 0.85rem;
}

#terms .terms-body ul {
  margin: 0 0 1rem 1.2rem;
}

#terms .terms-body li {
  margin-bottom: 0.45rem;
}

#terms .terms-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.85rem;
  padding: 1rem 1.75rem 1.5rem;
  border-top: 1px solid var(--border);
  background: #fff;
}

.btn-secondary {
  background: #ffffff;
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 1rem 1.4rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

#acceptTermsBtn,
#declineTermsBtn {
  width: auto;
  max-width: none;
  min-width: 140px;
}

@media (max-width: 768px) {
  #terms .terms-card {
    max-height: none;
    height: calc(100vh - 2rem);
  }

  #terms .terms-header,
  #terms .terms-meta,
  #terms .terms-body,
  #terms .terms-actions {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  #terms .terms-actions {
    flex-direction: column-reverse;
  }

  #acceptTermsBtn,
  #declineTermsBtn {
    width: 100%;
  }
}

/* =========================================
FRONT-END REFINEMENTS
- unread message badge
- centered upload success modal
- conversation unread indicators
- mobile/tablet contact layout improvements
Paste at VERY bottom of style.css
========================================= */

/* -------------------------
NAV: unread badge on Contact PBS
------------------------- */
.nav-icon--with-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-unread-badge {
  position: absolute;
  top: -6px;
  right: -10px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ef4444;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 20px;
  text-align: center;
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.85);
}

/* mobile nav badge tweak */
@media (max-width: 768px) {
  .nav-unread-badge {
    top: -2px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    font-size: 0.68rem;
  }
}

/* -------------------------
UPLOAD SUCCESS: centered modal
------------------------- */
.upload-toast {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.upload-toast__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.upload-toast__dialog {
  position: relative;
  z-index: 1;
  width: min(560px, calc(100vw - 2rem));
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
  padding: 2rem 1.5rem 1.35rem;
  display: grid;
  justify-items: center;
  text-align: center;
  transform: scale(0.96) translateY(10px);
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.upload-toast.show .upload-toast__dialog {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.upload-toast__icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #dcfce7;
  color: #15803d;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 2rem;
  margin-bottom: 1rem;
}

.upload-toast__content {
  min-width: 0;
}

.upload-toast__title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--blue-900);
  margin-bottom: 0.5rem;
}

.upload-toast__message {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.55;
  margin-bottom: 1.25rem;
}

.upload-toast__close {
  appearance: none;
  border: none;
  background: var(--blue-600);
  color: #ffffff;
  cursor: pointer;
  border-radius: 12px;
  padding: 0.8rem 1.15rem;
  font-size: 0.96rem;
  font-weight: 700;
  min-width: 140px;
  transition: background 0.18s ease, transform 0.18s ease;
}

.upload-toast__close:hover {
  background: var(--blue-500);
  transform: translateY(-1px);
}

@media (max-width: 640px) {
  .upload-toast__dialog {
    padding: 1.5rem 1rem 1rem;
    border-radius: 18px;
  }

  .upload-toast__title {
    font-size: 1.15rem;
  }

  .upload-toast__message {
    font-size: 0.95rem;
  }

  .upload-toast__icon {
    width: 62px;
    height: 62px;
    font-size: 1.6rem;
  }

  .upload-toast__close {
    width: 100%;
  }
}

/* -------------------------
CONTACT PBS: unread indicators
------------------------- */
#contact .conversation-item {
  position: relative;
}

#contact .conversation-item.unread {
  border-color: rgba(37, 99, 235, 0.38);
  background: #f8fbff;
}

#contact .conversation-item.unread .conversation-title-small {
  color: var(--blue-900);
}

#contact .conversation-unread-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
  flex: 0 0 auto;
  margin-left: auto;
  margin-top: 0.1rem;
  box-shadow: 0 0 0 2px #ffffff;
}

#contact .conversation-item-top {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

/* -------------------------
CONTACT PBS: better desktop spacing
------------------------- */
#contact .card.contact-layout {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.25rem;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
  background: transparent;
  border: none;
  box-shadow: none;
}

#contact .conversation-list,
#contact .conversation-panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
}

#contact .conversation-list {
  padding: 1rem;
  min-height: 560px;
}

#contact .conversation-panel {
  padding: 1rem;
  min-height: 560px;
}

#contact .conversation-items {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#contact .conversation-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  margin-bottom: 1rem;
}

#contact .conversation-panel-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

#contact .message-thread {
  max-height: 420px;
}

/* -------------------------
TABLET + MOBILE:
show compose/thread first,
previous conversations underneath
------------------------- */
@media (max-width: 900px) {
  #contact .card.contact-layout {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 0;
  }

  /* Put the active panel FIRST */
  #contact .conversation-panel {
    order: 1;
    min-height: auto;
  }

  /* Put previous conversations UNDERNEATH */
  #contact .conversation-list {
    order: 2;
    min-height: auto;
  }

  #contact .conversation-panel,
  #contact .conversation-list {
    padding: 1rem;
  }

  #contact .conversation-panel-header {
    flex-direction: column;
    align-items: stretch;
  }

  #contact .conversation-panel-actions {
    justify-content: stretch;
  }

  #contact .conversation-panel-actions .btn-primary {
    width: 100%;
    max-width: 100%;
  }

  #contact .message-thread {
    max-height: 320px;
  }

  #contact .message-composer {
    grid-template-columns: 1fr;
  }

  #contact .message-composer .btn-primary {
    width: 100%;
    max-width: 100%;
  }

  #contact .new-message-panel {
    max-width: 100%;
  }

  #contact .conversation-items {
    max-height: 320px;
    overflow-y: auto;
    padding-right: 0.15rem;
  }
}

@media (max-width: 640px) {
  #contact .conversation-title {
    font-size: 1.1rem;
  }

  #contact .conversation-panel-title {
    font-size: 1rem;
  }

  #contact .conversation-item {
    padding: 0.85rem;
  }

  #contact .conversation-meta,
  #contact .conversation-ref-small {
    font-size: 0.76rem;
  }
}

/* =========================================
UPLOAD SUCCESS MODAL — CENTERED IN MAIN AREA
Keeps sidebar/nav visible on desktop
========================================= */

.upload-toast {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 280px; /* keep desktop sidebar visible */
  width: auto;
  min-width: 0;
  max-width: none;
  height: 100vh;
  max-height: none;
  display: grid;
  grid-template-columns: 1fr;
  justify-items: center;
  align-items: center;
  gap: 0;
  padding: 1.5rem;
  z-index: 10000;
}

.upload-toast__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.50);
  backdrop-filter: blur(3px);
  border-left: 1px solid rgba(255, 255, 255, 0.06);
}

.upload-toast__dialog {
  position: relative;
  z-index: 1;
  width: min(760px, calc(100% - 2rem));
  min-height: 390px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.32);
  padding: 2.5rem 2.25rem 2rem;
  display: grid;
  justify-items: center;
  align-content: center;
  text-align: center;
  transform: scale(0.94) translateY(18px);
  opacity: 0;
  transition: transform 0.22s ease, opacity 0.22s ease;
}

.upload-toast.show .upload-toast__dialog {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.upload-toast__x {
  position: absolute;
  top: 16px;
  right: 16px;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 12px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  line-height: 1;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.upload-toast__x:hover {
  background: var(--blue-50);
  color: var(--blue-900);
  transform: translateY(-1px);
}

.upload-toast__icon {
  width: 94px;
  height: 94px;
  border-radius: 50%;
  background: #dcfce7;
  color: #15803d;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 2.5rem;
  margin-bottom: 1.25rem;
  box-shadow: inset 0 0 0 1px #bbf7d0;
}

.upload-toast__content {
  width: 100%;
  max-width: 560px;
}

.upload-toast__title {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--blue-900);
  line-height: 1.2;
  margin-bottom: 0.75rem;
}

.upload-toast__message {
  color: var(--text-muted);
  font-size: 1.08rem;
  line-height: 1.65;
  margin-bottom: 1.6rem;
}

.upload-toast__close {
  appearance: none;
  border: none;
  background: var(--blue-600);
  color: #ffffff;
  cursor: pointer;
  border-radius: 14px;
  padding: 1rem 1.4rem;
  font-size: 1.06rem;
  font-weight: 800;
  width: min(320px, 100%);
  min-height: 58px;
  transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.22);
}

.upload-toast__close:hover {
  background: var(--blue-500);
  transform: translateY(-1px);
}

/* Tablet desktop width where sidebar shrinks to 240px */
@media (max-width: 1024px) and (min-width: 769px) {
  .upload-toast {
    left: 240px;
  }
}

/* Mobile / bottom nav */
@media (max-width: 768px) {
  .upload-toast {
    left: 0;
    right: 0;
    top: 0;
    bottom: 70px; /* keep bottom nav visible */
    height: auto;
    padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom));
  }

  .upload-toast__dialog {
    width: min(100%, calc(100vw - 1.25rem));
    min-height: 330px;
    padding: 2rem 1rem 1.25rem;
    border-radius: 22px;
  }

  .upload-toast__title {
    font-size: 1.35rem;
  }

  .upload-toast__message {
    font-size: 0.98rem;
  }

  .upload-toast__icon {
    width: 78px;
    height: 78px;
    font-size: 2rem;
  }

  .upload-toast__close {
    width: 100%;
  }
}

/* -------------------------
CONTACT PBS
STACK SOONER
Conversations on top
Thread / New Message below
------------------------- */

/* Let the desktop layout breathe a little more before stacking */
#contact .card.contact-layout {
  grid-template-columns: 320px minmax(0, 1fr);
}

/* Stack earlier than the old 900px breakpoint */
@media (max-width: 1100px) {
  #contact .card.contact-layout {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 0;
  }

  /* Conversations list FIRST */
  #contact .conversation-list {
    order: 1;
    min-height: auto;
    padding: 1rem;
  }

  /* New message / active conversation SECOND */
  #contact .conversation-panel {
    order: 2;
    min-height: auto;
    padding: 1rem;
  }

  #contact .conversation-items {
    max-height: 300px;
    overflow-y: auto;
    padding-right: 0.1rem;
  }

  #contact .conversation-panel-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  #contact .conversation-panel-actions {
    width: 100%;
    justify-content: stretch;
  }

  #contact .conversation-panel-actions .btn-primary {
    width: 100%;
    max-width: 100%;
  }

  #contact .message-thread {
    max-height: 320px;
  }

  #contact .message-composer {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  #contact .message-composer .btn-primary {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  #contact .new-message-panel {
    max-width: 100%;
  }
}

/* Extra tightening for small phones */
@media (max-width: 640px) {
  #contact .conversation-title {
    font-size: 1.1rem;
  }

  #contact .conversation-panel-title {
    font-size: 1rem;
  }

  #contact .conversation-item {
    padding: 0.85rem;
  }
}

/* =========================
Contact PBS – Conversation Attachments
========================= */
#contact .conversation-attachments {
  margin-top: 0;
  margin-bottom: 1rem;
}

#contact .conversation-attachments .file-preview-header {
  margin-bottom: 0.75rem;
}

#contact .upload-zone.dragover {
  border-color: var(--blue-500);
  background: #dbeafe;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

/* =========================
Portal Admin Town Switcher
========================= */
.admin-town-banner {
  margin: 0 2rem 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(37, 99, 235, 0.16);
  border-radius: 14px;
  background: #eff6ff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.admin-town-banner__text {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--blue-900);
  font-weight: 600;
  flex-wrap: wrap;
}

.admin-town-banner__label {
  color: var(--blue-800);
}

.admin-town-banner__reset {
  white-space: nowrap;
}

.town-switch-modal {
  position: fixed;
  inset: 0;
  z-index: 10001;
}

.town-switch-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.town-switch-modal__dialog {
  position: relative;
  z-index: 1;
  width: min(720px, calc(100vw - 2rem));
  margin: 8vh auto 0;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.24);
  overflow: hidden;
}

.town-switch-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.2rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}

.town-switch-modal__eyebrow {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--blue-600);
  margin-bottom: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.town-switch-modal__title {
  margin: 0;
  color: var(--blue-900);
  font-size: 1.2rem;
}

.town-switch-modal__close {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  font-size: 1rem;
}

.town-switch-modal__close:hover {
  background: var(--blue-50);
  color: var(--blue-900);
}

.town-switch-modal__body {
  padding: 1rem 1.25rem;
}

.town-switch-modal__list {
  margin-top: 1rem;
  max-height: 420px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.town-switch-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: #ffffff;
  border-radius: 14px;
  padding: 0.9rem 1rem;
  cursor: pointer;
  transition: all 0.16s ease;
}

.town-switch-item:hover {
  background: var(--blue-50);
  border-color: rgba(37, 99, 235, 0.35);
}

.town-switch-item.active {
  background: var(--blue-50);
  border-color: var(--blue-600);
}

.town-switch-item__name {
  font-weight: 700;
  color: var(--blue-900);
  margin-bottom: 0.25rem;
}

.town-switch-item__meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.town-switch-empty {
  padding: 1rem;
  border: 1px dashed var(--border);
  border-radius: 14px;
  background: #f8fafc;
  color: var(--text-muted);
}

.town-switch-modal__footer {
  padding: 0 1.25rem 1.25rem;
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 768px) {
  .admin-town-banner {
    margin: 0 1rem 1rem;
    flex-direction: column;
    align-items: stretch;
  }

  .admin-town-banner__reset {
    width: 100%;
    text-align: left;
  }

  .town-switch-modal__dialog {
    width: min(100vw - 1rem, 720px);
    margin-top: 5vh;
  }
}

#contact .conversation-submitter {
  margin-bottom: 0.75rem;
  display: inline-flex;
  align-self: flex-start;
  padding: 0.42rem 0.7rem;
  border-radius: 999px;
  background: #f8fafc;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* =========================
Contact PBS – Open / Closed Tabs
========================= */

#contact .conversation-header {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

#contact .conversation-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem;
}

#contact .conversation-tab {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 750;
  font-size: 0.88rem;
  padding: 0.55rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

#contact .conversation-tab:hover {
  color: var(--blue-900);
  background: #ffffff;
}

#contact .conversation-tab.active {
  background: var(--blue-600);
  color: #ffffff;
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.18);
}

/* Force hidden to work even if display is set elsewhere */
[hidden] { display: none !important; }