* { box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0f172a;
  color: #f8fafc;
  margin: 0;
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Auth Overlay Screen */
.auth-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #0f172a;
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}
.auth-card {
  background: #1e293b;
  border: 1px solid #334155;
  padding: 40px;
  border-radius: 12px;
  text-align: center;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.5);
}
.auth-card h1 { color: #38bdf8; margin-top: 0; margin-bottom: 8px; font-size: 1.8rem; }
.auth-card p { color: #94a3b8; font-size: 0.9rem; margin-bottom: 24px; }

/* Sidebar Navigation Layout */
aside {
  width: 250px;
  background: #1e293b;
  border-right: 1px solid #334155;
  display: flex;
  flex-direction: column;
  padding: 20px 0;
}
.brand {
  padding: 0 20px 20px 20px;
  border-bottom: 1px solid #334155;
  font-size: 1.2rem;
  font-weight: bold;
  color: #38bdf8;
}
.brand span { font-size: 0.8rem; color: #94a3b8; display: block; margin-top: 4px; }

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-bottom: 1px solid #334155;
  background: #0f172a;
}
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #0284c7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.85rem;
  color: white;
}
.user-info { overflow: hidden; }
.user-email { font-size: 0.8rem; color: #f8fafc; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }
.sign-out-link { font-size: 0.75rem; color: #ef4444; cursor: pointer; text-decoration: underline; margin-top: 2px; }

nav { margin-top: 20px; flex: 1; }
.nav-btn {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 12px 20px;
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 0.95rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.nav-btn:hover { background: #334155; color: white; }
.nav-btn.active { background: #0284c7; color: white; }

/* Main Workspace */
main {
  flex: 1;
  padding: 30px;
  overflow-y: auto;
}
.view-panel { display: none; }
.view-panel.active { display: block; }

/* Header Controls */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  max-width: 1000px;
}
.section-header h2 { margin: 0; border: none; padding: 0; }

/* Cards & Forms UI */
.card {
  background: #1e293b;
  padding: 24px;
  border-radius: 8px;
  border: 1px solid #334155;
  margin-bottom: 24px;
  max-width: 1000px;
}
h2 { margin-top: 0; color: #f8fafc; font-size: 1.4rem; border-bottom: 1px solid #334155; padding-bottom: 10px; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.full-width { grid-column: span 2; }
label { font-size: 0.85rem; font-weight: 600; color: #94a3b8; display: block; margin-bottom: 6px; }
input[type="text"], input[type="email"], input[type="datetime-local"], select, textarea {
  width: 100%;
  padding: 10px;
  border-radius: 6px;
  border: 1px solid #334155;
  background: #0f172a;
  color: white;
  font-size: 0.9rem;
}

.action-btn {
  background: #0284c7;
  color: white;
  border: none;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
}
.action-btn:hover { background: #0369a1; }

.secondary-btn {
  background: #475569;
  color: white;
  border: none;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
}
.secondary-btn:hover { background: #334155; }

.danger-btn {
  background: #991b1b;
  color: white;
  border: none;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
}
.danger-btn:hover { background: #7f1d1d; }

.conflict-btn {
  background: #d97706;
  color: white;
  border: none;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
}
.conflict-btn:hover { background: #b45309; }

.tickle-btn {
  background: #059669;
  color: white;
  border: none;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: bold;
  border-radius: 4px;
  cursor: pointer;
}
.tickle-btn:hover { background: #047857; }

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}
.data-table th, .data-table td {
  text-align: left;
  padding: 14px 12px;
  border-bottom: 1px solid #334155;
  font-size: 0.9rem;
}
.data-table th { color: #94a3b8; font-weight: 600; background: #0f172a; }
.clickable-row { cursor: pointer; transition: background 0.15s; }
.clickable-row:hover { background: #334155; }

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: bold;
}
.badge-pass { background: #065f46; color: #34d399; }

/* Status Badges */
.status-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: bold;
}
.status-open { background: #065f46; color: #34d399; }
.status-pending { background: #854d0e; color: #fde047; }
.status-on-hold { background: #7c2d12; color: #fdba74; }
.status-closed { background: #374151; color: #9ca3af; }

/* Role & Forum Badges */
.role-badge, .type-badge, .billable-badge {
  display: inline-block;
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 8px;
}
.role-client { background: #1e40af; color: #93c5fd; }
.role-opp-party { background: #991b1b; color: #fca5a5; }
.role-opp-counsel { background: #854d0e; color: #fde047; }
.role-other { background: #374151; color: #d1d5db; }
.type-badge { background: #312e81; color: #c7d2fe; margin-left: 0; margin-right: 6px; }
.billable-badge { background: #166534; color: #86efac; margin-left: 6px; }
.nonbillable-badge { background: #374151; color: #9ca3af; margin-left: 6px; }

.related-contact-pill, .task-item-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #0f172a;
  border: 1px solid #334155;
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 0.85rem;
}
.remove-pill-btn {
  color: #ef4444;
  cursor: pointer;
  font-weight: bold;
  margin-left: 8px;
}

/* Modal / Popups */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(4px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}
.modal-overlay.active { display: flex; }
.modal-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 24px;
  padding-bottom: 40px;
  width: 100%;
  max-width: 820px;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.5);
  max-height: 92vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  border-bottom: 1px solid #334155;
  padding-bottom: 12px;
}
.modal-header h3 { margin: 0; color: #38bdf8; }
.close-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 1.4rem;
  cursor: pointer;
}
.close-btn:hover { color: white; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.detail-item label { color: #94a3b8; font-size: 0.8rem; margin-bottom: 4px; }
.detail-item div { font-size: 1rem; color: #f8fafc; font-weight: 500; }
