/* ═══════════════════════════════════════════════════════════════
   RRA COMMAND CENTER — Apple × Restoration Hardware
   ═══════════════════════════════════════════════════════════════ */

:root {
  --cream: #f8f7f6;
  --primary: #130f0a;
  --accent: #793315;
  --accent-hover: #8a3d1c;
  --accent-light: rgba(121, 51, 21, 0.06);
  --accent-glow: rgba(121, 51, 21, 0.12);
  --border: #e8e4df;
  --border-light: #f0ece7;
  --muted: #9a9590;
  --muted-dark: #6b6560;
  --white: #ffffff;
  --surface: #faf9f8;
  --dark: #130f0a;
  --success: #2d6a4f;
  --success-light: rgba(45, 106, 79, 0.08);
  --warning: #b8860b;
  --warning-light: rgba(184, 134, 11, 0.08);
  --danger: #a0342e;
  --danger-light: rgba(160, 52, 46, 0.08);
  --info: #3a6ea5;
  --info-light: rgba(58, 110, 165, 0.08);

  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Work Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  --ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  --sidebar-width: 260px;
  --topbar-height: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(19, 15, 10, 0.04);
  --shadow: 0 2px 12px rgba(19, 15, 10, 0.06);
  --shadow-lg: 0 8px 30px rgba(19, 15, 10, 0.1);
  --shadow-hover: 0 6px 24px rgba(19, 15, 10, 0.08);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 15px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  font-family: var(--sans);
  background: var(--cream);
  color: var(--primary);
  line-height: 1.6;
  overflow-x: hidden;
}

::selection { background: var(--accent); color: white; }

.hidden { display: none !important; }

/* ═══ LOGIN ═══ */
.login-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--cream);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-light);
  animation: slideUp 0.6s var(--ease-out) both;
}

.login-logo {
  text-align: center;
  margin-bottom: 40px;
}

.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: var(--dark);
  color: var(--cream);
  font-family: var(--serif);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 20px;
}

.login-logo h1 {
  font-family: var(--serif);
  font-size: 1.8rem;
  font-weight: 300;
  letter-spacing: -0.01em;
  color: var(--primary);
}

.login-subtitle {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 4px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 500;
}

.input-group {
  margin-bottom: 20px;
}

.input-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-dark);
  margin-bottom: 8px;
}

.input-group input,
.input-group textarea,
.input-group select {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 0.95rem;
  color: var(--primary);
  background: var(--surface);
  transition: all 0.2s var(--ease);
  outline: none;
}

.input-group input:focus,
.input-group textarea:focus {
  border-color: var(--accent);
  background: var(--white);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.input-group input::placeholder { color: var(--muted); }

.login-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-bottom: 12px;
  min-height: 1.2em;
}

.login-footer {
  margin-top: 32px;
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ═══ BUTTONS ═══ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--dark);
  color: var(--cream);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.3s var(--ease);
}

.btn-primary:hover {
  background: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-full { width: 100%; }
.btn-sm { padding: 8px 18px; font-size: 0.8rem; }

.btn-signout {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  font-size: 1rem;
  transition: all 0.2s;
}
.btn-signout:hover { border-color: var(--danger); color: var(--danger); }

/* ═══ APP SHELL ═══ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ═══ SIDEBAR ═══ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--white);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.35s var(--ease-out);
}

.sidebar-header {
  padding: 24px 20px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-light);
}

.sidebar-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--dark);
  color: var(--cream);
  font-family: var(--serif);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-title {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--primary);
}

.sidebar-close {
  display: none;
  margin-left: auto;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--muted);
}

.nav-list {
  list-style: none;
  padding: 12px 10px;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--muted-dark);
  cursor: pointer;
  transition: all 0.2s var(--ease);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: var(--accent-light);
  color: var(--primary);
}

.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.nav-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  opacity: 0.7;
}

.nav-item.active .nav-icon { opacity: 1; }

.nav-divider {
  height: 1px;
  background: var(--border-light);
  margin: 8px 14px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-light);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.user-info { display: flex; flex-direction: column; }
.user-name { font-size: 0.85rem; font-weight: 600; color: var(--primary); }
.user-role { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }

/* ═══ MAIN CONTENT ═══ */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ═══ TOPBAR ═══ */
.topbar {
  height: var(--topbar-height);
  background: var(--white);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
}

.hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--primary);
  padding: 4px;
}

.search-box {
  flex: 1;
  max-width: 400px;
}

.search-box input {
  width: 100%;
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 100px;
  font-family: var(--sans);
  font-size: 0.85rem;
  background: var(--surface);
  outline: none;
  transition: all 0.2s;
}

.search-box input:focus {
  border-color: var(--accent);
  background: var(--white);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.notif-bell {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 6px;
}

.bell-icon { filter: grayscale(0.3); }

.notif-count {
  position: absolute;
  top: 0;
  right: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ═══ NOTIFICATION PANEL ═══ */
.notif-bell { position: relative; }

.notif-count.hidden { display: none; }

.notif-bell.flash .bell-icon {
  animation: bellShake 0.5s ease;
}

@keyframes bellShake {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(15deg); }
  40% { transform: rotate(-10deg); }
  60% { transform: rotate(8deg); }
  80% { transform: rotate(-5deg); }
}

.notif-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: -60px;
  width: 380px;
  max-height: 480px;
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 300;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.15s ease both;
}

.notif-panel.hidden { display: none; }

.notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border-light);
}

.notif-panel-header h4 {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
}

.notif-panel-list {
  overflow-y: auto;
  max-height: 400px;
  padding: 4px 0;
}

.notif-item {
  display: flex;
  gap: 12px;
  padding: 12px 18px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid var(--border-light);
  align-items: flex-start;
}

.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--accent-light); }
.notif-item.unread { background: rgba(121, 51, 21, 0.03); }
.notif-item.unread .notif-item-title { font-weight: 600; }

.notif-item-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
  background: var(--accent-light);
}

.notif-item-body { flex: 1; min-width: 0; }

.notif-item-title {
  font-size: 0.82rem;
  color: var(--primary);
  line-height: 1.3;
  margin-bottom: 2px;
}

.notif-item-time {
  font-size: 0.7rem;
  color: var(--muted);
}

.notif-item-mark {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  margin-top: 6px;
  opacity: 0;
}

.notif-item.unread .notif-item-mark { opacity: 1; }

/* Notification settings toggles */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  font-size: 0.88rem;
}

.toggle-row:last-child { border-bottom: none; }

.toggle-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

@media (max-width: 768px) {
  .notif-panel {
    width: calc(100vw - 32px);
    right: -16px;
  }
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-user-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--primary);
}

.topbar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
}

/* ═══ VIEW CONTAINER ═══ */
.view-container {
  flex: 1;
  padding: 28px;
  overflow-y: auto;
}

.view {
  display: none;
  animation: fadeIn 0.3s var(--ease-out) both;
}

.view.active { display: block; }

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.view-header h2 {
  font-family: var(--serif);
  font-size: 1.8rem;
  font-weight: 400;
  letter-spacing: -0.01em;
}

.view-subtitle {
  font-size: 0.85rem;
  color: var(--muted);
}

.placeholder-text {
  text-align: center;
  padding: 80px 20px;
  color: var(--muted);
  font-size: 1rem;
}

/* ═══ STATS GRID (Dashboard) ═══ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 24px;
  transition: all 0.3s var(--ease);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.stat-card.accent {
  background: var(--dark);
  border-color: var(--dark);
}
.stat-card.accent .stat-number { color: var(--cream); }
.stat-card.accent .stat-label { color: rgba(248, 247, 246, 0.6); }

.stat-number {
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 6px;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}

/* ═══ DASHBOARD PANELS ═══ */
.dashboard-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.panel {
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 24px;
}

.panel h3 {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--primary);
}

/* Tasks */
.task-list { display: flex; flex-direction: column; gap: 10px; }

.task-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.85rem;
  transition: all 0.2s;
}

.task-item:hover { background: var(--accent-light); }

.task-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.task-item.urgent .task-dot { background: var(--danger); }
.task-item.high .task-dot { background: var(--warning); }

.task-due {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
  flex-shrink: 0;
}

/* Activity */
.activity-feed { display: flex; flex-direction: column; gap: 10px; }

.activity-item {
  display: flex;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.85rem;
}

.activity-time {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
  min-width: 70px;
}

/* ═══ PIPELINE BOARD (Vertical Accordion) ═══ */
.pipeline-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.pipeline-tab {
  padding: 8px 18px;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: var(--white);
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--muted-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

.pipeline-tab:hover { border-color: var(--accent); color: var(--accent); }
.pipeline-tab.active { background: var(--accent); color: white; border-color: var(--accent); }

.pipeline-tab .tab-count {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  font-size: 0.7rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pipeline-tab:not(.active) .tab-count {
  background: var(--accent-light);
  color: var(--accent);
}

.pipeline-board {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: auto;
  overflow: visible;
}

.pipeline-stage-section { margin-bottom: 8px; }

.pipeline-stage-header {
  padding: 14px 18px;
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.pipeline-stage-header:hover { border-color: var(--accent); }

.pipeline-stage-header.open {
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom-color: transparent;
}

.stage-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stage-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.column-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-dark);
}

.column-count {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage-chevron {
  font-size: 0.8rem;
  color: var(--muted);
  transition: transform 0.2s;
}

.pipeline-stage-header.open .stage-chevron { transform: rotate(90deg); }

.column-cards {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 60px;
  transition: background 0.2s;
}

.column-cards.collapsed { display: none; }

.column-cards.drag-over {
  background: var(--accent-light);
  border-color: var(--accent);
}

/* ═══ PIPELINE CARDS ═══ */
.pipeline-card {
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 16px;
  cursor: grab;
  transition: all 0.25s var(--ease);
  position: relative;
}

.pipeline-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: var(--border);
}

.pipeline-card:active { cursor: grabbing; }

.pipeline-card.dragging {
  opacity: 0.5;
  transform: rotate(2deg) scale(1.02);
  box-shadow: var(--shadow-lg);
}

.card-address {
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 4px;
  line-height: 1.3;
}

.card-client {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 10px;
}

.card-price {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.card-badge {
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-date {
  background: var(--info-light);
  color: var(--info);
}

.badge-new-construction {
  background: var(--success-light);
  color: var(--success);
}

.badge-hot {
  background: var(--danger-light);
  color: var(--danger);
}

.badge-docs {
  background: var(--warning-light);
  color: var(--warning);
}

.card-date {
  font-size: 0.72rem;
  color: var(--muted);
}

/* ═══ APPOINTMENTS ═══ */
.appointments-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.appt-card {
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 24px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 20px;
  align-items: center;
  transition: all 0.25s var(--ease);
}

.appt-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.appt-date-block {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  background: var(--accent-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.appt-date-month {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
}

.appt-date-day {
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.appt-info h4 {
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.appt-info p {
  font-size: 0.85rem;
  color: var(--muted);
}

.appt-info .appt-time {
  font-weight: 600;
  color: var(--primary);
}

.appt-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}

.ally-todo {
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--warning-light);
  color: var(--warning);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.appt-status {
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.appt-status.scheduled { background: var(--info-light); color: var(--info); }
.appt-status.completed { background: var(--success-light); color: var(--success); }

/* ═══ MODAL ═══ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(19, 15, 10, 0.4);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.2s ease both;
}

.modal-content {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 700px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 36px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.35s var(--ease-out) both;
  position: relative;
}

.modal-sm { max-width: 480px; }

.modal-close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: none;
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
  color: var(--muted);
  transition: color 0.2s;
  line-height: 1;
}

.modal-close:hover { color: var(--primary); }

.modal-header { margin-bottom: 24px; }

.modal-header h2 {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 600;
}

.modal-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.modal-meta span:first-child {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
}

.modal-badge {
  padding: 4px 14px;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--accent-light);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Modal Tabs */
.modal-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 24px;
}

.modal-tab {
  padding: 10px 18px;
  background: none;
  border: none;
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.2s;
}

.modal-tab:hover { color: var(--primary); }
.modal-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.detail-section h4 {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 12px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.88rem;
}

.detail-row span:first-child { color: var(--muted-dark); }
.detail-row span:last-child { font-weight: 500; }

/* ═══ ANIMATIONS ═══ */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ═══ RESPONSIVE ═══ */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-panels { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .hamburger { display: block; }

  .main-content { margin-left: 0; }

  .topbar { padding: 0 16px; }
  .topbar-user-name { display: none; }
  .view-container { padding: 16px; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 16px; }
  .stat-number { font-size: 1.5rem; }

  .pipeline-column { min-width: 240px; width: 240px; }

  .appt-card { grid-template-columns: 1fr; gap: 12px; }
  .appt-date-block { width: auto; height: auto; flex-direction: row; gap: 8px; padding: 8px 16px; }

  .detail-grid { grid-template-columns: 1fr; }

  .modal-content { padding: 24px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .view-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .view-header h2 { font-size: 1.5rem; }
}

/* ═══ ROLE RESTRICTIONS ═══ */
.role-restricted {
  opacity: 0.5;
  pointer-events: none;
  position: relative;
}

.role-restricted::after {
  content: 'View Only';
  position: absolute;
  top: 4px;
  right: 8px;
  font-size: 0.65rem;
  background: var(--muted);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
}

/* ═══ CALENDAR ═══ */
.cal-month-label {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 600;
  min-width: 180px;
  text-align: center;
}

.cal-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  font-size: 0.78rem;
  color: var(--muted-dark);
}

.cal-leg-item { display: flex; align-items: center; gap: 5px; }

.cal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--white);
}

.cal-header-cell {
  padding: 10px 6px;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  background: var(--surface);
  border-bottom: 1px solid var(--border-light);
}

.cal-day {
  min-height: 100px;
  padding: 6px;
  border-right: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
}

.cal-day:nth-child(7n) { border-right: none; }
.cal-day:hover { background: var(--accent-light); }
.cal-day.outside { background: var(--surface); opacity: 0.5; }
.cal-day.today { background: rgba(121, 51, 21, 0.04); }
.cal-day.today .cal-day-num { background: var(--accent); color: white; border-radius: 50%; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; }

.cal-day-num {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 4px;
  display: inline-block;
}

.cal-event {
  display: block;
  padding: 2px 6px;
  margin-bottom: 2px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 500;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: opacity 0.15s;
}

.cal-event:hover { opacity: 0.85; }

.cal-event.type-dd { background: #a0342e; }
.cal-event.type-closing { background: #2d6a4f; }
.cal-event.type-inspection { background: #3a6ea5; }
.cal-event.type-appraisal { background: #6b4c9a; }
.cal-event.type-appointment { background: #b8860b; }
.cal-event.type-other { background: #9a9590; }

.cal-more {
  font-size: 0.68rem;
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
  padding: 0 6px;
}

/* Calendar list view */
.calendar-list { display: flex; flex-direction: column; gap: 8px; }

.cal-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

.cal-list-item:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.cal-list-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cal-list-date {
  min-width: 80px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary);
}

.cal-list-title {
  flex: 1;
  font-size: 0.88rem;
}

.cal-list-address {
  font-size: 0.78rem;
  color: var(--muted);
}

/* Dashboard mini calendar events */
.calendar-event-list { display: flex; flex-direction: column; gap: 8px; }

.cal-event-mini {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.85rem;
  transition: all 0.2s;
}

.cal-event-mini:hover { background: var(--accent-light); }

.cal-event-mini .cal-dot { flex-shrink: 0; }

.cal-event-mini-date {
  font-weight: 600;
  min-width: 60px;
  font-size: 0.78rem;
  color: var(--accent);
}

.panel-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-header-row h3 { margin-bottom: 0; }

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
}

.btn-link:hover { text-decoration: underline; }

.btn-outline {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-family: var(--sans);
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--primary);
  transition: all 0.2s;
}

.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

/* Week view adjustments */
.calendar-grid.week-view .cal-day { min-height: 200px; }

@media (max-width: 768px) {
  .cal-day { min-height: 60px; padding: 4px; }
  .cal-day-num { font-size: 0.72rem; }
  .cal-event { font-size: 0.6rem; padding: 1px 4px; }
  .cal-legend { font-size: 0.68rem; gap: 8px; }
  .cal-month-label { font-size: 1rem; min-width: 140px; }
  .calendar-grid.week-view .cal-day { min-height: 120px; }
  .pipeline-tabs { gap: 4px; }
  .pipeline-tab { padding: 6px 12px; font-size: 0.75rem; }
}

/* ═══ ACTIVITY FEED (FULL) ═══ */
.activity-feed-full { display: flex; flex-direction: column; gap: 10px; }

.activity-card {
  display: flex;
  gap: 14px;
  padding: 16px 20px;
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  align-items: flex-start;
}

.activity-card:hover { box-shadow: var(--shadow-sm); }

.activity-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  background: var(--accent-light);
}

.activity-body { flex: 1; }
.activity-body-title { font-size: 0.88rem; font-weight: 500; color: var(--primary); }
.activity-body-detail { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.activity-body-time { font-size: 0.72rem; color: var(--muted); margin-top: 4px; }
.activity-user-tag {
  padding: 2px 10px;
  border-radius: 100px;
  font-size: 0.68rem;
  font-weight: 600;
  background: var(--surface);
  color: var(--muted-dark);
  flex-shrink: 0;
}

/* ═══ REPORTS ═══ */
.report-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.report-charts .panel canvas { max-height: 300px; }

@media (max-width: 768px) {
  .report-charts { grid-template-columns: 1fr; }
  .view-header .view-actions { flex-wrap: wrap; }
}
