/* Solicitors portal — the look of the Apps Script External Law Firm portal (its stylesheet, kept as it was), with the font served
   from this app (no Google Fonts) and a few additions at the end for what the Azure version adds (case details, correspondence,
   brief details, the sign-in code). */
@font-face { font-family: 'Plus Jakarta Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/plus-jakarta-sans-400.woff2) format('woff2'); }
@font-face { font-family: 'Plus Jakarta Sans'; font-style: normal; font-weight: 500; font-display: swap; src: url(/fonts/plus-jakarta-sans-500.woff2) format('woff2'); }
@font-face { font-family: 'Plus Jakarta Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url(/fonts/plus-jakarta-sans-600.woff2) format('woff2'); }
@font-face { font-family: 'Plus Jakarta Sans'; font-style: normal; font-weight: 700; font-display: swap; src: url(/fonts/plus-jakarta-sans-700.woff2) format('woff2'); }
@font-face { font-family: 'Plus Jakarta Sans'; font-style: normal; font-weight: 800; font-display: swap; src: url(/fonts/plus-jakarta-sans-800.woff2) format('woff2'); }
/* ==================== CSS VARIABLES ==================== */
:root {
  --primary-900: #0c1929;
  --primary-800: #132337;
  --primary-700: #1a365d;
  --primary-600: #234e82;
  --primary-500: #2c6faa;
  --primary-400: #4299e1;
  --primary-300: #63b3ed;
  --primary-200: #90cdf4;
  --primary-100: #bee3f8;
  --primary-50: #ebf8ff;
  
  --accent-500: #38b2ac;
  --accent-400: #4fd1c5;
  
  --success-500: #38a169;
  --success-100: #c6f6d5;
  --warning-500: #d69e2e;
  --warning-100: #fefcbf;
  --danger-500: #e53e3e;
  --danger-100: #fed7d7;
  
  --gray-900: #1a202c;
  --gray-800: #2d3748;
  --gray-700: #4a5568;
  --gray-600: #718096;
  --gray-500: #a0aec0;
  --gray-400: #cbd5e0;
  --gray-300: #e2e8f0;
  --gray-200: #edf2f7;
  --gray-100: #f7fafc;
  --gray-50: #fbfdff;
  
  --border-radius: 12px;
  --border-radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.15);
  --transition-speed: 0.3s;
  
  --font-primary: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ==================== RESET & BASE ==================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; height: 100%; }
body {
  font-family: var(--font-primary);
  background: linear-gradient(135deg, var(--gray-100) 0%, var(--gray-200) 100%);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==================== HEADER ==================== */
.app-header {
  background: linear-gradient(135deg, var(--primary-800) 0%, var(--primary-700) 100%);
  color: white;
  padding: 0;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 30;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.header-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.header-logo {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--primary-400) 0%, var(--accent-500) 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(66, 153, 225, 0.3);
}
.header-logo svg { width: 22px; height: 22px; }
.header-title { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Mobile header adjustments */
@media (max-width: 480px) {
  .header-inner { padding: 12px 16px; gap: 8px; }
  .header-logo { width: 36px; height: 36px; }
  .header-logo svg { width: 18px; height: 18px; }
  .header-title { font-size: 1rem; }
  .header-brand { gap: 8px; }
  .header-actions { gap: 6px; }
  .header-actions .btn { padding: 8px 10px; font-size: 0; gap: 0; min-width: 40px; }
  .header-actions .btn svg { width: 18px; height: 18px; }
}
@media (max-width: 360px) {
  .header-title { display: none; }
}

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-primary);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  text-decoration: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-600) 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(44, 111, 170, 0.3);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-700) 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(44, 111, 170, 0.4);
}
.btn-secondary { background: var(--gray-200); color: var(--gray-700); }
.btn-secondary:hover:not(:disabled) { background: var(--gray-300); }
.btn-danger {
  background: linear-gradient(135deg, var(--danger-500) 0%, #c53030 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(229, 62, 62, 0.3);
}
.btn-danger:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(229, 62, 62, 0.4);
}
.btn-ghost { background: rgba(255, 255, 255, 0.1); color: white; }
.btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.2); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none !important; }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-load-more {
  background: linear-gradient(135deg, var(--accent-500) 0%, var(--primary-500) 100%);
  color: white;
  padding: 14px 28px;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 4px 15px rgba(56, 178, 172, 0.4);
  border: 2px solid transparent;
}
.btn-load-more:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(56, 178, 172, 0.5);
}
@media (max-width: 480px) {
  .btn-load-more { padding: 12px 20px; font-size: 14px; }
}

/* ==================== MAIN CONTENT ==================== */
.main-content { flex: 1; max-width: 1200px; width: 100%; margin: 0 auto; padding: 24px; }
@media (max-width: 480px) {
  .main-content { padding: 16px 12px; }
}

/* ==================== CARDS ==================== */
.card { background: white; border-radius: var(--border-radius); box-shadow: var(--shadow-md); overflow: hidden; }
.card-header {
  background: linear-gradient(135deg, var(--primary-800) 0%, var(--primary-700) 100%);
  color: white;
  padding: 24px 32px;
}
.card-header h2 { font-size: 1.5rem; font-weight: 700; margin-bottom: 6px; }
.card-header p { opacity: 0.85; font-size: 14px; }
@media (max-width: 480px) {
  .card-header { padding: 20px 16px; }
  .card-header h2 { font-size: 1.25rem; }
}

/* ==================== ALERT BANNERS ==================== */
.alert-banner {
  padding: 16px 20px;
  border-radius: var(--border-radius-sm);
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.alert-banner svg { width: 20px; height: 20px; flex-shrink: 0; margin-top: 2px; }
.alert-banner-content { flex: 1; min-width: 0; }
.alert-banner-title { font-weight: 600; margin-bottom: 4px; }
.alert-banner-text { font-size: 14px; opacity: 0.9; }
.alert-warning {
  background: linear-gradient(135deg, var(--warning-100) 0%, #fef3c7 100%);
  border: 1px solid #f6e05e;
  color: #744210;
}
.alert-warning svg { color: var(--warning-500); }
.alert-info {
  background: linear-gradient(135deg, var(--primary-50) 0%, var(--primary-100) 100%);
  border: 1px solid var(--primary-200);
  color: var(--primary-800);
}
.alert-info svg { color: var(--primary-500); }
.alert-danger {
  background: linear-gradient(135deg, var(--danger-100) 0%, #fecaca 100%);
  border: 1px solid #fc8181;
  color: #742a2a;
}
.alert-danger svg { color: var(--danger-500); }
@media (max-width: 480px) {
  .alert-banner { padding: 12px 14px; gap: 10px; margin-bottom: 16px; }
  .alert-banner svg { width: 18px; height: 18px; }
  .alert-banner-title { font-size: 14px; }
  .alert-banner-text { font-size: 13px; }
}

/* ==================== FORM ELEMENTS ==================== */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
.form-control {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--border-radius-sm);
  font-size: 14px;
  font-family: var(--font-primary);
  transition: all 0.2s ease;
  background: white;
  color: var(--gray-800);
}
.form-control:focus {
  outline: none;
  border-color: var(--primary-400);
  box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.15);
}
.form-control::placeholder { color: var(--gray-500); }
textarea.form-control { resize: vertical; min-height: 100px; }
.form-hint { font-size: 12px; color: var(--gray-600); margin-top: 4px; }

/* Checkbox styling */
.form-checkbox-group {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--gray-50);
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--gray-200);
}
.form-checkbox {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--primary-500);
}
.form-checkbox-label {
  font-size: 14px;
  color: var(--gray-700);
  cursor: pointer;
  line-height: 1.4;
}
.form-checkbox-label strong { color: var(--gray-800); }
.form-checkbox-hint { font-size: 12px; color: var(--gray-500); margin-top: 4px; }
@media (max-width: 480px) {
  .form-checkbox-group { padding: 10px 12px; gap: 8px; margin-top: 12px; }
  .form-checkbox { width: 20px; height: 20px; }
  .form-checkbox-label { font-size: 13px; }
  .form-checkbox-hint { font-size: 11px; }
}

/* ==================== LOGIN SECTION ==================== */
.login-section { margin-bottom: 24px; }
.login-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.15);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 16px;
}
.login-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 768px) { 
  .login-grid { grid-template-columns: 1fr; gap: 20px; } 
}
.login-info h2 { font-size: 1.75rem; font-weight: 700; margin-bottom: 8px; color: white; }
.login-info p { color: rgba(255, 255, 255, 0.8); font-size: 14px; }
.login-form-wrapper { background: white; border-radius: var(--border-radius); padding: 24px; }
@media (max-width: 480px) {
  .login-info h2 { font-size: 1.35rem; }
  .login-info p { font-size: 13px; }
  .login-form-wrapper { padding: 16px; }
  .login-badge { font-size: 11px; padding: 5px 12px; }
}
.form-actions-login { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }
.form-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  font-size: 12px;
  color: var(--gray-600);
}
.form-footer a { color: var(--primary-500); text-decoration: none; font-weight: 500; }
.form-footer a:hover { text-decoration: underline; }

/* ==================== APP LAYOUT ==================== */
.app-layout { display: grid; grid-template-columns: 220px 1fr; gap: 24px; }
@media (max-width: 768px) { 
  .app-layout { grid-template-columns: 1fr; gap: 16px; } 
}

/* ==================== SIDEBAR ==================== */
.sidebar { background: white; border-radius: var(--border-radius); box-shadow: var(--shadow-sm); padding: 16px; height: fit-content; }
.sidebar-nav { display: flex; flex-direction: column; gap: 8px; }
@media (max-width: 768px) {
  .sidebar { padding: 8px; }
  .sidebar-nav { 
    flex-direction: row; 
    gap: 8px;
  }
  .sidebar-nav button { 
    flex: 1;
    justify-content: center;
    white-space: nowrap; 
  }
}
@media (max-width: 400px) {
  .sidebar { padding: 6px; }
  .sidebar-nav { gap: 6px; }
  .sidebar-nav button {
    padding: 10px 12px;
    font-size: 13px;
  }
  .sidebar-nav button svg {
    width: 16px;
    height: 16px;
  }
}
.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-primary);
  color: var(--gray-700);
  background: transparent;
  border: none;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}
.nav-btn:hover { background: var(--gray-100); color: var(--gray-900); }
.nav-btn.active {
  background: linear-gradient(135deg, var(--primary-50) 0%, var(--primary-100) 100%);
  color: var(--primary-700);
  font-weight: 600;
}
.nav-btn svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ==================== CONTENT AREA ==================== */
.content-area { display: flex; flex-direction: column; gap: 16px; }

/* ==================== SEARCH BAR & CASE COUNT ==================== */
.search-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.search-input-wrapper { position: relative; flex: 1; max-width: 400px; min-width: 200px; }
.search-input-wrapper svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--gray-500);
}
.search-input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--border-radius-sm);
  font-size: 14px;
  font-family: var(--font-primary);
  transition: all 0.2s ease;
  background: white;
}
.search-input:focus {
  outline: none;
  border-color: var(--primary-400);
  box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.15);
}
.case-count-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--primary-100) 0%, var(--primary-50) 100%);
  color: var(--primary-700);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--primary-200);
}
.case-count-badge svg { width: 16px; height: 16px; }
@media (max-width: 640px) {
  .search-bar { flex-direction: column; align-items: stretch; gap: 10px; }
  .search-input-wrapper { max-width: 100%; width: 100%; min-width: unset; }
  .case-count-badge { align-self: flex-start; }
}
@media (max-width: 480px) {
  .search-input { padding: 10px 12px 10px 38px; font-size: 14px; }
  .search-input-wrapper svg { left: 12px; width: 16px; height: 16px; }
  .case-count-badge { padding: 6px 12px; font-size: 12px; }
}

/* ==================== LOAD MORE BANNER ==================== */
.load-more-banner {
  background: linear-gradient(135deg, var(--primary-50) 0%, rgba(56, 178, 172, 0.1) 100%);
  border: 2px dashed var(--accent-500);
  border-radius: var(--border-radius);
  padding: 20px;
  text-align: center;
  margin-bottom: 16px;
}
.load-more-banner-text { font-size: 14px; color: var(--gray-700); margin-bottom: 12px; }
.load-more-banner-text strong { color: var(--primary-700); }

/* ==================== LEGEND ==================== */
.list-legend {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--gray-100);
  border-radius: var(--border-radius-sm);
}
.list-legend span:nth-child(1) { width: 32%; }
.list-legend span:nth-child(2) { width: 16%; }
.list-legend span:nth-child(3) { width: 12%; }
.list-legend span:nth-child(4) { width: 22%; }
.list-legend span:nth-child(5) { width: 18%; text-align: right; }
@media (max-width: 768px) { .list-legend { display: none; } }

/* ==================== CASE LIST ==================== */
.case-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.case-item {
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  padding: 16px 20px;
  transition: all 0.2s ease;
  cursor: pointer;
  border: 1.5px solid transparent;
}
.case-item:hover { box-shadow: var(--shadow-md); border-color: var(--primary-200); }
.case-item-inner { display: flex; align-items: center; gap: 16px; }
.case-col { min-width: 0; }
.case-col-name { width: 32%; }
.case-col-firm { width: 16%; }
.case-col-status { width: 12%; }
.case-col-date { width: 22%; }
.case-col-action { width: 18%; display: flex; justify-content: flex-end; }
.case-label {
  display: none;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.case-value {
  font-size: 14px;
  color: var(--gray-800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.case-col-name .case-value { font-weight: 600; }
.case-col-firm .case-value, .case-col-date .case-value { color: var(--gray-600); }
@media (max-width: 768px) {
  .case-item-inner { flex-direction: column; align-items: stretch; gap: 12px; }
  .case-col { width: 100% !important; }
  .case-col-action { justify-content: stretch; }
  .case-col-action .btn { width: 100%; }
  .case-label { display: block; }
}

/* ==================== STATUS BADGES ==================== */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1.4;
}
.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-active { background: var(--success-100); color: #22543d; }
.status-active::before { background: var(--success-500); }
.status-on-hold { background: var(--warning-100); color: #744210; }
.status-on-hold::before { background: var(--warning-500); }
.status-pending { background: var(--primary-50); color: var(--primary-700); }
.status-pending::before { background: var(--primary-400); }
.status-closed { background: var(--gray-200); color: var(--gray-700); }
.status-closed::before { background: var(--gray-500); }

/* ==================== CASE SECTIONS ==================== */
.case-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  margin-top: 4px;
}
.case-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-700);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.case-section-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
}
.case-section-line {
  flex: 1;
  height: 1px;
  background: var(--gray-300);
}

/* Closed Cases Collapsible */
.closed-section-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 16px;
  margin-top: 16px;
  background: var(--gray-100);
  border: 1.5px solid var(--gray-300);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-primary);
}
.closed-section-toggle:hover {
  background: var(--gray-200);
  border-color: var(--gray-400);
}
.closed-section-toggle svg {
  width: 18px;
  height: 18px;
  color: var(--gray-500);
  transition: transform 0.25s ease;
  flex-shrink: 0;
}
.closed-section-toggle.expanded svg {
  transform: rotate(90deg);
}
.closed-section-toggle-text {
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.closed-section-toggle-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  margin-left: auto;
}
.closed-cases-wrapper {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
}
.closed-cases-wrapper.expanded {
  max-height: 50000px;
}
.closed-cases-inner {
  padding-top: 12px;
}
.closed-case-item {
  opacity: 0.8;
}
.closed-case-item:hover {
  opacity: 1;
}

/* Case count badge adjustments for split counts */
.case-count-split {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.case-count-divider {
  width: 1px;
  height: 14px;
  background: var(--primary-300);
  opacity: 0.5;
}

/* ==================== EMPTY STATE ==================== */
.empty-state {
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  padding: 48px 24px;
  text-align: center;
  color: var(--gray-600);
}
.empty-state svg { width: 48px; height: 48px; color: var(--gray-400); margin-bottom: 16px; }

/* ==================== LOAD MORE (Bottom) ==================== */
.load-more-container {
  text-align: center;
  padding: 24px 16px;
  background: linear-gradient(135deg, var(--gray-50) 0%, var(--gray-100) 100%);
  border-radius: var(--border-radius);
  margin-top: 8px;
}

/* ==================== MODALS ==================== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: flex-start;
  justify-content: center;
  z-index: 50;
  padding: 24px;
  overflow-y: auto;
}
.modal-overlay.active { display: flex; }
.modal-content {
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  margin-top: 60px;
  animation: modalSlideIn 0.2s ease;
}
@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--gray-200); }
.modal-header h3 { font-size: 18px; font-weight: 700; color: var(--gray-900); }
.modal-body { padding: 24px; max-height: 65vh; overflow-y: auto; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}
@media (max-width: 640px) {
  .modal-overlay { padding: 12px; }
  .modal-content { margin: 8px; margin-top: 20px; max-width: calc(100% - 16px); border-radius: var(--border-radius-sm); }
  .modal-header { padding: 16px; }
  .modal-header h3 { font-size: 16px; }
  .modal-body { padding: 16px; max-height: 60vh; }
  .modal-footer { flex-direction: column-reverse; padding: 12px 16px; gap: 8px; }
  .modal-footer .btn { width: 100%; }
}

/* ==================== FILE UPLOAD ==================== */
.attachment-toggle { display: flex; gap: 8px; margin-bottom: 16px; }
.toggle-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  background: var(--gray-100);
  border: 2px solid transparent;
  border-radius: var(--border-radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-primary);
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.2s ease;
}
.toggle-btn:hover { background: var(--gray-200); color: var(--gray-700); }
.toggle-btn.active { background: var(--primary-50); border-color: var(--primary-400); color: var(--primary-700); }
.toggle-btn svg { width: 18px; height: 18px; }
.file-upload-area {
  border: 2px dashed var(--gray-300);
  border-radius: var(--border-radius-sm);
  padding: 32px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}
.file-upload-area:hover, .file-upload-area.dragover { border-color: var(--primary-400); background: var(--primary-50); }
.file-upload-icon { width: 40px; height: 40px; color: var(--gray-400); margin-bottom: 12px; }
.file-upload-text { font-size: 14px; color: var(--gray-700); font-weight: 500; margin-bottom: 4px; }
.file-upload-hint { font-size: 12px; color: var(--gray-500); }
.file-upload-input { position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
@media (max-width: 480px) {
  .file-upload-area { padding: 24px 16px; }
  .file-upload-icon { width: 32px; height: 32px; margin-bottom: 8px; }
  .file-upload-text { font-size: 13px; }
  .file-upload-hint { font-size: 11px; }
}
.file-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--gray-50);
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--gray-200);
}
.file-item-info { display: flex; align-items: center; gap: 10px; min-width: 0; }
.file-item-icon { width: 20px; height: 20px; color: var(--primary-500); flex-shrink: 0; }
.file-item-name { font-size: 13px; font-weight: 500; color: var(--gray-800); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-item-size { font-size: 12px; color: var(--gray-500); flex-shrink: 0; }
.file-item-remove {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--gray-400);
  transition: color 0.2s;
  flex-shrink: 0;
}
.file-item-remove:hover { color: var(--danger-500); }
.link-guidance {
  background: var(--primary-50);
  border-radius: var(--border-radius-sm);
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid var(--primary-100);
}
.link-guidance-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--primary-700); margin-bottom: 10px; }
.link-guidance-title svg { width: 16px; height: 16px; }
.link-guidance-list { list-style: none; font-size: 12px; color: var(--gray-600); display: flex; flex-direction: column; gap: 6px; }
.link-guidance-list li { padding-left: 16px; position: relative; }
.link-guidance-list li::before { content: "•"; position: absolute; left: 0; color: var(--primary-400); }

/* ==================== CONFIRM MODAL ==================== */
.confirm-icon { width: 64px; height: 64px; margin: 0 auto 16px; display: flex; align-items: center; justify-content: center; background: var(--warning-100); border-radius: 50%; }
.confirm-icon svg { width: 32px; height: 32px; color: var(--warning-500); }
.confirm-title { font-size: 18px; font-weight: 700; color: var(--gray-900); margin-bottom: 8px; }
.confirm-message { color: var(--gray-600); font-size: 14px; }

/* ==================== LOADING ==================== */
.loading-spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--gray-200);
  border-top-color: var(--primary-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==================== TOAST ==================== */
.toast-container { position: fixed; top: 24px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 12px; }
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: white;
  border-radius: var(--border-radius-sm);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 400px;
  opacity: 0;
  transform: translateX(100%);
  transition: all 0.3s ease;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.toast.success .toast-dot { background: var(--success-500); }
.toast.error .toast-dot { background: var(--danger-500); }
.toast.warn .toast-dot { background: var(--warning-500); }
.toast-message { font-size: 14px; color: var(--gray-700); }
@media (max-width: 480px) {
  .toast-container { top: 12px; right: 12px; left: 12px; }
  .toast { min-width: unset; max-width: unset; width: 100%; padding: 14px 16px; }
}

/* ==================== FOOTER ==================== */
.app-footer {
  background: white;
  border-top: 1px solid var(--gray-200);
  padding: 20px 24px;
  margin-top: auto;
}
.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.footer-logo { height: 24px; width: auto; opacity: 0.8; }
.footer-text { font-size: 12px; color: var(--gray-500); }
@media (max-width: 480px) {
  .app-footer { padding: 16px 12px; }
  .footer-inner { flex-direction: column; gap: 8px; }
  .footer-text { font-size: 11px; text-align: center; }
}

/* ==================== UTILITIES ==================== */
.hidden { display: none !important; }
.touch-target { min-height: 44px; }
@supports (padding-top: env(safe-area-inset-top)) {
  .app-header { padding-top: env(safe-area-inset-top); }
}
/* ==================== BRIEFS (NEW 4.1) ==================== */
.nav-badge { margin-left: auto; background: var(--danger-500); color: #fff; font-size: 11px; font-weight: 700; border-radius: 10px; padding: 1px 8px; line-height: 1.5; }
.nav-badge.hidden { display: none; }
.brief-banner { cursor: pointer; margin-bottom: 0; }
.brief-item { cursor: default; }
.brief-col-name .case-value { font-weight: 600; }
.brief-item.pending { border-color: var(--warning-500); border-left-width: 4px; }
.brief-col-name { width: 34%; } .brief-col-date { width: 16%; } .brief-col-status { width: 20%; } .brief-col-action { width: 30%; display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.brief-note { font-size: 12px; color: var(--gray-600); margin-top: 4px; white-space: normal; }
.status-accepted { background: var(--success-100); color: #22543d; } .status-accepted::before { background: var(--success-500); }
.status-declined { background: var(--danger-100); color: #742a2a; } .status-declined::before { background: var(--danger-500); }
.status-awaiting { background: var(--warning-100); color: #744210; } .status-awaiting::before { background: var(--warning-500); }
.btn-success { background: linear-gradient(135deg, var(--success-500) 0%, #2f855a 100%); color: #fff; }
.brief-choice { display: flex; gap: 8px; margin-bottom: 16px; }
.brief-choice .toggle-btn { flex: 1; justify-content: center; }
@media (max-width: 768px) { .brief-col-name, .brief-col-date, .brief-col-status, .brief-col-action { width: 100% !important; } .brief-col-action { justify-content: stretch; } .brief-col-action .btn { flex: 1; } }

/* ==================== AZURE ADDITIONS ==================== */
[hidden] { display: none !important; }
.modal-backdrop { position: fixed; inset: 0; }
.modal-content { position: relative; }
.modal-content.wide { max-width: 720px; }
.case-col-action, .brief-col-action { gap: 8px; }
.case-sub { font-size: 12px; color: var(--gray-500); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.case-value.soon { color: #b7791f; font-weight: 600; }
.code-input { font-size: 22px; letter-spacing: 0.45em; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.login-steps { display: flex; gap: 8px; flex-wrap: wrap; }
.details-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; margin-bottom: 20px; }
.details-grid .k { font-size: 11px; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.05em; }
.details-grid .v { font-size: 14px; color: var(--gray-800); font-weight: 500; overflow-wrap: anywhere; }
.details-grid .wide { grid-column: 1 / -1; }
.section-title { font-size: 13px; font-weight: 700; color: var(--gray-700); text-transform: uppercase; letter-spacing: 0.05em; margin: 4px 0 10px; display: flex; align-items: center; gap: 10px; }
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--gray-300); }
.instructions { white-space: pre-wrap; font-size: 14px; line-height: 1.6; background: var(--primary-50); border: 1px solid var(--primary-100); border-radius: var(--border-radius-sm); padding: 14px 16px; margin-bottom: 20px; overflow-wrap: anywhere; color: var(--gray-800); }
.thread { display: flex; flex-direction: column; gap: 10px; }
.thread-item { border: 1px solid var(--gray-200); border-radius: var(--border-radius-sm); padding: 12px 14px; background: var(--gray-50); }
.thread-item.mine { background: var(--primary-50); border-color: var(--primary-100); }
.thread-meta { font-size: 12px; color: var(--gray-600); margin-bottom: 4px; }
.thread-meta strong { color: var(--gray-800); }
.thread-text { font-size: 14px; color: var(--gray-800); white-space: pre-wrap; overflow-wrap: anywhere; }
.file-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.file-link { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--primary-600); background: white; border: 1px solid var(--primary-200); border-radius: 20px; padding: 5px 12px; text-decoration: none; cursor: pointer; font-family: var(--font-primary); }
.file-link:hover { background: var(--primary-50); }
.file-link svg { width: 14px; height: 14px; }
.file-item.uploading { opacity: .7; } .file-item.failed { border-color: var(--danger-500); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.empty-thread { font-size: 14px; color: var(--gray-500); }
@media (max-width: 640px) { .details-grid, .form-row { grid-template-columns: 1fr; } }

/* Loading without a blocking overlay (as the staff portal): a page loader only while the portal first opens, then spinners in the
   button, list or box being worked on. */
.page-loading { position: fixed; inset: 0; z-index: 300; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: linear-gradient(135deg, var(--primary-900) 0%, var(--primary-800) 100%); color: rgba(255,255,255,.65); font-size: 14px; font-weight: 500; transition: opacity .3s ease; }
.page-loading .loading-spinner { width: 40px; height: 40px; border-color: rgba(255,255,255,.15); border-top-color: var(--accent-400); }
.page-loading.fade-out { opacity: 0; pointer-events: none; }
.spin { width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .6s linear infinite; display: inline-block; flex-shrink: 0; }
.btn-secondary .spin, .btn-ghost .spin, .file-link .spin { border-color: var(--gray-300); border-top-color: var(--primary-500); }
.btn.is-busy { pointer-events: none; opacity: .85; }
.list-loading { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 40px 16px; color: var(--gray-500); font-size: 14px; list-style: none; }
.list-loading .loading-spinner, .box-loading .loading-spinner { width: 28px; height: 28px; border-width: 3px; }
.box-loading { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 48px 16px; color: var(--gray-500); font-size: 14px; }
.file-link.is-busy { pointer-events: none; opacity: .7; }
