/* =============================================================================
   OBDM CRM — Stylesheet
   Mobile-first. Mirrors GuardArra design language.
   ============================================================================= */

:root {
  --color-navy: #1B3A5C;
  --color-navy-dark: #122842;
  --color-navy-light: #2A4F75;
  --color-bg: #F5F7FA;
  --color-bg-card: #FFFFFF;
  --color-text: #1F2937;
  --color-text-muted: #6B7280;
  --color-border: #E5E7EB;
  --color-border-light: #F3F4F6;
  --color-success: #059669;
  --color-success-bg: #D1FAE5;
  --color-warning: #D97706;
  --color-warning-bg: #FEF3C7;
  --color-danger: #DC2626;
  --color-danger-bg: #FEE2E2;
  --color-info: #2563EB;
  --color-info-bg: #DBEAFE;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 2px 4px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 8px 16px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --topbar-height: 60px;
  --sidebar-width: 240px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--color-info); text-decoration: none; }
a:hover { text-decoration: underline; }
hr { border: none; border-top: 1px solid var(--color-border); margin: 1rem 0; }
.muted { color: var(--color-text-muted); }
.small { font-size: 0.85em; }
.text-center { text-align: center; }

/* AUTH PAGES */
.auth-page {
  background: linear-gradient(135deg, var(--color-navy) 0%, var(--color-navy-dark) 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.auth-container { width: 100%; max-width: 440px; }
.auth-card {
  background: white;
  border-radius: var(--radius-xl);
  padding: 2rem;
  box-shadow: var(--shadow-lg);
}
.auth-brand { text-align: center; margin-bottom: 2rem; }
.auth-logo { font-size: 3rem; margin-bottom: 0.5rem; }
.auth-brand h1 { margin: 0 0 0.25rem; font-size: 1.5rem; color: var(--color-navy); }
.auth-subtitle { margin: 0; color: var(--color-text-muted); }
.auth-success { text-align: center; }
.auth-success-icon {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: var(--color-success-bg);
  color: var(--color-success);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin-bottom: 1rem;
}
.auth-footer {
  text-align: center;
  font-size: 0.85em;
  color: var(--color-text-muted);
  margin-top: 1.5rem;
}

/* FORMS */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.4rem;
  font-size: 0.9em;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-size: 1em;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: white;
  font-family: inherit;
  -webkit-appearance: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--color-navy);
  box-shadow: 0 0 0 3px rgba(27,58,92,0.1);
}
.form-hint { font-size: 0.8em; color: var(--color-text-muted); margin: 0.3rem 0 0; }
.form-row { display: grid; grid-template-columns: 1fr; gap: 0.75rem; }
@media (min-width: 640px) {
  .form-row { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .form-group-large { grid-column: span 2; }
}
.form-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border-light);
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  font-size: 0.95em;
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, transform 0.06s;
  white-space: nowrap;
  font-family: inherit;
}
.btn:active { transform: scale(0.98); }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--color-navy); color: white; border-color: var(--color-navy); }
.btn-primary:hover { background: var(--color-navy-dark); }
.btn-secondary { background: white; color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover { background: var(--color-bg); }
.btn-success { background: var(--color-success); color: white; border-color: var(--color-success); }
.btn-danger { background: var(--color-danger); color: white; border-color: var(--color-danger); }
.btn-block { width: 100%; }
.btn-link {
  background: none;
  border: none;
  color: var(--color-info);
  padding: 0.4rem;
  cursor: pointer;
  text-decoration: underline;
}

/* ALERTS */
.alert { padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: 0.95em; }
.alert-error { background: var(--color-danger-bg); color: var(--color-danger); border: 1px solid #FCA5A5; }
.alert-success { background: var(--color-success-bg); color: var(--color-success); border: 1px solid #6EE7B7; }
.alert-warning { background: var(--color-warning-bg); color: var(--color-warning); border: 1px solid #FCD34D; }
.alert-info { background: var(--color-info-bg); color: var(--color-info); border: 1px solid #93C5FD; }

/* =============================================================================
   TOPBAR (fixed at top, full width)
   ============================================================================= */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: var(--color-navy);
  color: white;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  gap: 0.75rem;
  z-index: 100;
  box-shadow: var(--shadow);
}
.topbar-mobile-toggle {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  line-height: 1;
}
.topbar-mobile-toggle:hover { background: rgba(255,255,255,0.1); }
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: white;
  font-weight: 600;
  font-size: 1.05rem;
  text-decoration: none;
}
.topbar-brand:hover { text-decoration: none; color: white; }
.topbar-brand-icon { font-size: 1.4rem; line-height: 1; }
.topbar-spacer { flex: 1; }
.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.9rem;
}
.topbar-user .user-name {
  font-weight: 500;
  color: rgba(255,255,255,0.95);
}
.topbar-user .role-badge {
  background: rgba(255,255,255,0.15);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.topbar-user .topbar-link {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}
.topbar-user .topbar-link:hover {
  background: rgba(255,255,255,0.1);
  color: white;
  text-decoration: none;
}

/* Hide some user info on small screens to save space */
@media (max-width: 540px) {
  .topbar-user .user-name { display: none; }
  .topbar-user .role-badge { display: none; }
}

/* =============================================================================
   SIDEBAR (fixed left on desktop, drawer on mobile)
   ============================================================================= */
.sidebar {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--topbar-height));
  background: white;
  border-right: 1px solid var(--color-border);
  padding: 1rem 0;
  overflow-y: auto;
  z-index: 90;
  transform: translateX(-100%);  /* hidden off-screen on mobile by default */
  transition: transform 0.25s ease;
  -webkit-overflow-scrolling: touch;
}
body.nav-open .sidebar { transform: translateX(0); }

.sidebar-section {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--color-text-muted);
  padding: 0.85rem 1.25rem 0.4rem;
  margin-top: 0.25rem;
}
.sidebar-section:first-child { margin-top: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 1.25rem;
  color: var(--color-text);
  text-decoration: none;
  font-size: 0.95rem;
  border-left: 3px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}
.nav-item:hover {
  background: var(--color-bg);
  color: var(--color-navy);
  text-decoration: none;
}
.nav-item.active {
  background: var(--color-bg);
  color: var(--color-navy);
  font-weight: 600;
  border-left-color: var(--color-navy);
}
.nav-icon {
  font-size: 1.1rem;
  width: 1.4rem;
  text-align: center;
  line-height: 1;
}

/* Sidebar overlay (mobile only - dimmed backdrop when drawer open) */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.35);
  z-index: 80;
  opacity: 0;
  transition: opacity 0.25s;
}
body.nav-open .sidebar-overlay {
  display: block;
  opacity: 1;
}

/* =============================================================================
   MAIN CONTENT AREA
   ============================================================================= */
.main {
  padding-top: var(--topbar-height);
  min-height: 100vh;
  background: var(--color-bg);
}
.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.25rem 1rem;
}

/* =============================================================================
   FLASH MESSAGES
   ============================================================================= */
.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.95em;
  border: 1px solid transparent;
}
.flash-error,
.flash-danger { background: var(--color-danger-bg); color: var(--color-danger); border-color: #FCA5A5; }
.flash-success { background: var(--color-success-bg); color: var(--color-success); border-color: #6EE7B7; }
.flash-warning { background: var(--color-warning-bg); color: var(--color-warning); border-color: #FCD34D; }
.flash-info { background: var(--color-info-bg); color: var(--color-info); border-color: #93C5FD; }

/* =============================================================================
   DESKTOP LAYOUT (>= 768px) - sidebar always visible, push main content right
   ============================================================================= */
@media (min-width: 768px) {
  .topbar-mobile-toggle { display: none; }
  .sidebar {
    transform: translateX(0);  /* always visible at desktop */
  }
  .sidebar-overlay { display: none !important; }
  .main {
    margin-left: var(--sidebar-width);
  }
  .page {
    padding: 1.5rem 2rem;
  }
}

/* PAGE HEADER */
.page-header {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
@media (min-width: 640px) {
  .page-header {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
  }
}
.page-header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
  color: var(--color-navy);
}
.page-subtitle { margin: 0; color: var(--color-text-muted); font-size: 0.95em; }
.page-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.back-link {
  display: inline-block;
  font-size: 0.9em;
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
}

/* CARDS */
.card {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border-light);
}
@media (min-width: 640px) { .card { padding: 1.5rem; } }
.card h2, .card h3 { margin: 0 0 1rem; color: var(--color-navy); font-size: 1.15rem; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.card-header h2, .card-header h3 { margin: 0; }
.card-danger { border: 1px solid #FCA5A5; }
.card-danger h3 { color: var(--color-danger); }

/* STATS GRID */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}
@media (min-width: 640px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); gap: 1rem; }
}
.stat-card {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border-light);
  text-decoration: none;
  color: var(--color-text);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: transform 0.12s, box-shadow 0.12s;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  text-decoration: none;
}
.stat-card-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-navy);
  line-height: 1;
}
.stat-card-label { font-size: 0.9em; font-weight: 500; margin-top: 0.5rem; }
.stat-card-sublabel { font-size: 0.8em; color: var(--color-text-muted); }
.stat-card-success .stat-card-value { color: var(--color-success); }
.stat-card-warning { border-color: var(--color-warning); }
.stat-card-warning .stat-card-value { color: var(--color-warning); }
.stat-card-highlight {
  background: linear-gradient(135deg, #F0F9FF 0%, #E0F2FE 100%);
  border-color: #BAE6FD;
}
.stat-card-highlight .stat-card-value { color: var(--color-info); }

/* STAGE PILL */
.stage-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8em;
  font-weight: 500;
  white-space: nowrap;
}
.stage-pill-large { padding: 0.4rem 0.85rem; font-size: 0.95em; }
.tag-pill {
  display: inline-flex;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78em;
  font-weight: 500;
}
.rating-pill { display: inline-flex; padding: 0.2rem 0.5rem; font-size: 0.85em; }
.badge {
  display: inline-flex;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78em;
  font-weight: 500;
  background: var(--color-bg);
  color: var(--color-text-muted);
}
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); }

/* EVENT ROW */
.event-row {
  display: flex;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-border-light);
}
.event-row:last-child { border-bottom: none; }
.event-time {
  flex: 0 0 70px;
  font-weight: 600;
  color: var(--color-navy);
  font-size: 0.9em;
}
.event-title { font-weight: 500; }
.event-meta { font-size: 0.85em; color: var(--color-text-muted); margin-top: 0.15rem; }
.section-divider {
  font-size: 0.85em;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}

/* EMPTY STATE */
.empty-state { text-align: center; padding: 3rem 1rem; }
.empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h3 { margin: 0 0 0.5rem; }
.empty-state p { color: var(--color-text-muted); margin-bottom: 1rem; }

/* LEAD MINI LIST */
.lead-mini-list { display: flex; flex-direction: column; gap: 0.25rem; }
.lead-mini {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--color-text);
  transition: background 0.12s;
}
.lead-mini:hover { background: var(--color-bg); text-decoration: none; }
.lead-mini-company { font-weight: 600; }
.lead-mini-meta { font-size: 0.85em; color: var(--color-text-muted); }

/* PIPELINE BOARD */
.pipeline-summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 1rem;
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
@media (min-width: 640px) {
  .pipeline-summary { grid-template-columns: repeat(4, 1fr); gap: 1rem; }
}
.pipeline-summary-item { text-align: center; }
.pipeline-summary-value { font-size: 1.5rem; font-weight: 700; color: var(--color-navy); }
.pipeline-summary-label { font-size: 0.85em; color: var(--color-text-muted); }

.kanban-scroll {
  overflow-x: auto;
  margin: 0 -1rem 1rem;
  padding: 0 1rem 0.5rem;
  -webkit-overflow-scrolling: touch;
}
.kanban-board {
  display: flex;
  gap: 0.75rem;
  min-width: min-content;
}
.kanban-column {
  flex: 0 0 280px;
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  padding: 0.75rem;
  border-top: 4px solid var(--color-navy);
}
.kanban-column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}
.kanban-column-title { font-weight: 600; }
.kanban-column-count {
  background: white;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.85em;
  font-weight: 600;
}
.kanban-column-value { font-size: 0.8em; color: var(--color-text-muted); margin-bottom: 0.75rem; }
.kanban-cards { display: flex; flex-direction: column; gap: 0.5rem; }
.kanban-empty {
  padding: 1.5rem 0.5rem;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.9em;
}
.kanban-more {
  display: block;
  padding: 0.5rem;
  text-align: center;
  background: white;
  border-radius: var(--radius);
  color: var(--color-info);
  font-size: 0.9em;
  font-weight: 500;
}

.lead-card {
  background: white;
  border-radius: var(--radius);
  padding: 0.75rem;
  display: block;
  text-decoration: none;
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border-light);
  transition: transform 0.1s, box-shadow 0.12s;
}
.lead-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
  text-decoration: none;
}
.lead-card-company { font-weight: 600; margin-bottom: 0.25rem; }
.lead-card-contact, .lead-card-location, .lead-card-meta {
  font-size: 0.82em;
  color: var(--color-text-muted);
  margin-bottom: 0.15rem;
}
.lead-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--color-border-light);
}
.lead-card-value { font-weight: 600; color: var(--color-success); font-size: 0.9em; }
.lead-card-overdue { color: var(--color-warning); font-size: 0.8em; font-weight: 600; }
.lead-card-due { color: var(--color-text-muted); font-size: 0.8em; }

.secondary-stages { margin-top: 1.5rem; }
.secondary-stages summary {
  cursor: pointer;
  padding: 0.75rem 1rem;
  background: white;
  border-radius: var(--radius);
  font-weight: 500;
  user-select: none;
}
.secondary-board { margin-top: 0.75rem; }

/* LEADS TABLE */
.filter-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.filter-search {
  flex: 1 1 200px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.95em;
}
.filter-select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: white;
  font-size: 0.95em;
}

.leads-table-wrap { overflow-x: auto; padding: 0; }
.leads-table { width: 100%; border-collapse: collapse; }
.leads-table thead th {
  text-align: left;
  padding: 0.75rem 1rem;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  font-size: 0.85em;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.leads-table tbody tr {
  cursor: pointer;
  transition: background 0.1s;
  border-bottom: 1px solid var(--color-border-light);
}
.leads-table tbody tr:hover { background: var(--color-bg); }
.leads-table td { padding: 0.85rem 1rem; vertical-align: top; }
.leads-table-company { font-weight: 600; }

@media (max-width: 639px) { .hide-mobile { display: none; } }
@media (min-width: 640px) { .show-mobile { display: none; } }

/* LEAD DETAIL */
.lead-header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.lead-detail-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
@media (min-width: 1024px) {
  .lead-detail-layout { grid-template-columns: 1fr 380px; }
}

.stage-advance-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}
.stage-advance-btn {
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--color-border);
  background: white;
  border-radius: var(--radius);
  font-size: 0.85em;
  cursor: pointer;
  font-family: inherit;
}
.stage-advance-btn:hover { background: var(--color-bg); }
.stage-advance-btn.active { font-weight: 600; }

.activity-form {
  background: var(--color-bg);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin-bottom: 1rem;
}
.activity-form-row {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
@media (max-width: 480px) {
  .activity-form-row { grid-template-columns: 1fr; }
}
.activity-form select,
.activity-form input[type="text"],
.activity-form textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95em;
}
.activity-form-actions { text-align: right; margin-top: 0.5rem; }

.activity-timeline { display: flex; flex-direction: column; gap: 0.85rem; }
.activity-item { display: flex; gap: 0.75rem; }
.activity-icon {
  flex: 0 0 36px;
  width: 36px; height: 36px;
  background: var(--color-bg);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1em;
}
.activity-body { flex: 1; }
.activity-text { font-size: 0.95em; margin-top: 0.25rem; }
.activity-meta { margin-top: 0.25rem; }

.followup-current {
  background: var(--color-info-bg);
  padding: 0.75rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.95em;
}
.followup-current strong { display: block; }

/* CALENDAR */
.cal-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.cal-view-toggle {
  display: flex;
  gap: 0.25rem;
  background: var(--color-bg);
  border-radius: var(--radius);
  padding: 0.2rem;
  margin-left: auto;
}
.cal-view-toggle a {
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  color: var(--color-text);
  text-decoration: none;
  font-size: 0.9em;
}
.cal-view-toggle a.active { background: white; box-shadow: var(--shadow-sm); font-weight: 500; }

.cal-list { display: flex; flex-direction: column; gap: 0.75rem; }
.cal-day-card { padding: 1rem; }
.cal-day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.5rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border-light);
}
.cal-day-header-today {
  background: var(--color-navy);
  color: white;
  margin: -1rem -1rem 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.cal-day-name { font-weight: 600; }
.cal-day-date { font-size: 0.85em; opacity: 0.85; }

.cal-event-row {
  display: flex;
  gap: 0.75rem;
  padding: 0.5rem 0;
  align-items: flex-start;
}
.cal-event-time {
  flex: 0 0 70px;
  font-size: 0.85em;
  font-weight: 600;
  color: var(--color-navy);
}
.cal-event-marker {
  flex: 0 0 4px;
  width: 4px;
  align-self: stretch;
  border-radius: 2px;
  background: var(--color-navy);
}
.cal-event-body { flex: 1; }
.cal-event-title { font-weight: 500; margin-bottom: 0.15rem; }
.cal-event-meta { font-size: 0.85em; color: var(--color-text-muted); }

.cal-month { padding: 0; overflow: hidden; }
.cal-month-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--color-bg);
}
.cal-month-dow {
  padding: 0.5rem;
  text-align: center;
  font-size: 0.8em;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
}
.cal-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.cal-month-cell {
  background: white;
  border-top: 1px solid var(--color-border-light);
  border-left: 1px solid var(--color-border-light);
  min-height: 90px;
  padding: 0.4rem;
  text-decoration: none;
  color: var(--color-text);
  display: flex;
  flex-direction: column;
  font-size: 0.8em;
}
.cal-month-cell-other { background: var(--color-bg); color: var(--color-text-muted); }
.cal-month-cell-today { background: #FEF3C7; }
.cal-month-cell:nth-child(7n) { border-right: 1px solid var(--color-border-light); }
.cal-month-cell-num { font-weight: 600; margin-bottom: 0.25rem; }
.cal-month-event {
  padding: 0.15rem 0.35rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.85em;
}
.cal-month-more { font-size: 0.75em; color: var(--color-text-muted); font-weight: 500; }