@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@500;700;800&display=swap');
* { margin: 0; padding: 0; box-sizing: border-box; }
html { overflow-x: hidden; }
body { max-width: 100vw; overflow-x: hidden; overscroll-behavior-x: none; }
:root {
  --bg: #f8f9fa; --bg-alt: #eef1f5; --bg-card: #ffffff; --bg-sidebar: rgba(255,255,255,0.88);
  --border: #e9ecef; --text: #212529; --text-muted: #6c757d;
  --accent: #CC0000; --accent-soft: rgba(204,0,0,0.08); --accent-glow: rgba(204,0,0,0.16);
  --green: #059669; --blue: #2563eb; --yellow: #d97706; --red: #CC0000; --gray: #6c757d;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 12px 28px rgba(15, 23, 42, 0.08), 0 4px 10px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 18px 42px rgba(15, 23, 42, 0.12), 0 8px 18px rgba(15, 23, 42, 0.08);
  --radius-sm: 10px; --radius-md: 12px; --radius-lg: 16px;
}
body { font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: linear-gradient(135deg, #f4f6f8 0%, #edf0f4 52%, #e7ebf0 100%); color: var(--text); display: flex; min-height: 100vh; max-width: 100vw; overflow-x: hidden; position: relative; }
body::before { content: ''; position: fixed; inset: 0; pointer-events: none; background-image: radial-gradient(rgba(33,37,41,0.05) 0.7px, transparent 0.7px); background-size: 22px 22px; opacity: 0.4; }
button { font: inherit; cursor: pointer; }

/* Sidebar */
.sidebar { width: 240px; min-width: 240px; background: var(--bg-sidebar); border-right: 1px solid rgba(233,236,239,0.92); padding: 28px 0 22px; display: flex; flex-direction: column; height: 100vh; position: fixed; top: 0; left: 0; z-index: 100; backdrop-filter: blur(18px); box-shadow: 12px 0 40px rgba(15, 23, 42, 0.04); }
.sidebar-brand { padding: 12px 22px 22px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.sidebar-logo-pill { background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,249,250,0.94)); border: 1px solid var(--border); border-radius: 14px; padding: 12px 16px; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-sm); }
.sidebar-logo { width: 120px; height: auto; display: block; }
.sidebar-subtitle { font-size: 10px; font-weight: 800; letter-spacing: 2.8px; text-transform: uppercase; color: var(--text-muted); }
.sidebar-brand p { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.sidebar-nav { padding: 18px 10px 8px; flex: 1; }
.sidebar-nav a { display: flex; align-items: center; gap: 12px; padding: 11px 16px; margin: 2px 8px; color: var(--text-muted); text-decoration: none; font-size: 14px; font-weight: 500; border-radius: 12px; transition: all 0.18s ease; position: relative; }
.sidebar-nav a:hover, .sidebar-nav a.active { color: var(--accent); background: rgba(204,0,0,0.07); transform: translateX(2px); }
.sidebar-nav a.active { box-shadow: inset 3px 0 0 var(--accent); color: var(--accent); font-weight: 700; }
.sidebar-nav .icon { width: 18px; text-align: center; }

/* Main */
.main { flex: 1; min-width: 0; margin-left: 240px; padding: 28px 34px; min-height: 100vh; overflow-x: hidden; position: relative; z-index: 1; }
.ghost-btn {
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.82);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 600;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.ghost-btn:hover {
  border-color: rgba(204,0,0,0.24);
  color: var(--accent);
  background: rgba(255,255,255,0.96);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.dashboard-sign-out {
  position: fixed;
  top: 18px;
  right: 24px;
  z-index: 230;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(17,24,39,0.08);
}

/* Command Table Visual */
.command-table {
  background: radial-gradient(circle at top, rgba(204,0,0,0.12), transparent 34%), #111111;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  padding: 24px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
  max-width: 100%;
  box-shadow: 0 18px 40px rgba(0,0,0,0.28);
}
.command-table::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, rgba(204,0,0,0), rgba(204,0,0,0.95), rgba(255,82,82,0.95), rgba(204,0,0,0.95), rgba(204,0,0,0));
  box-shadow: 0 0 18px rgba(204,0,0,0.55);
}
.command-table-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #ffffff;
  margin-bottom: 16px;
  text-align: center;
}
.agents-seats {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}
.agent-seat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 13px 16px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 14px;
  min-width: 96px;
  backdrop-filter: blur(10px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
  transition: all 0.2s;
}
.agent-seat:hover {
  border-color: rgba(204,0,0,0.4);
  background: rgba(255,255,255,0.12);
  transform: translateY(-2px);
}
.agent-seat-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  position: relative;
}
.agent-seat-avatar .status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--bg-card);
}
.status-dot.online { background: var(--green); animation: statusPulse 1.8s ease-in-out infinite; }
.status-dot.built { background: var(--blue); }
.status-dot.offline { background: var(--gray); }
.agent-seat-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}
.agent-seat-role {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.3;
}
.agent-seat-nametag {
  font-size: 9px;
  background: rgba(204,0,0,0.10);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* Stats */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat-card { background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(255,255,255,0.94)); border: 1px solid rgba(233,236,239,0.92); border-radius: 12px; padding: 16px 18px; min-width: 0; overflow: hidden; box-shadow: var(--shadow-sm); position: relative; transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease; }
.stat-card .label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1.1px; font-weight: 700; }
.stat-card .value { font-size: 25px; font-weight: 800; margin-top: 6px; font-family: 'JetBrains Mono', 'SF Mono', Monaco, monospace; letter-spacing: -0.03em; }
.stat-card .sub { font-size: 11px; color: var(--text-muted); }

/* Cards grid */
.panel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 16px; margin-bottom: 20px; }
.panel { background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(255,255,255,0.94)); border: 1px solid rgba(233,236,239,0.92); border-radius: 12px; padding: 16px 18px; box-shadow: var(--shadow-sm); transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease; }
.panel h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; font-weight: 800; padding-left: 12px; border-left: 3px solid rgba(204,0,0,0.78); }
.panel h2 .count { background: var(--accent); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 10px; }
/* Operations row: side-by-side on desktop, stacked on mobile */
.ops-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.ops-row .panel { margin-bottom: 0; }


/* Agent cards */
.agent-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.agent-item:last-child { border-bottom: none; }
.agent-avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.agent-info { flex: 1; min-width: 0; }
.agent-info .name { font-weight: 600; font-size: 14px; }
.agent-info .role { font-size: 12px; color: var(--text-muted); }

/* Status badges */
.badge { font-size: 10px; padding: 5px 10px; border-radius: 999px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.45px; white-space: nowrap; border: 1px solid transparent; }
.badge-active { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-complete { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-built { background: rgba(59,130,246,0.15); color: var(--blue); }
.badge-blocked { background: rgba(234,179,8,0.15); color: var(--yellow); }
.badge-planned { background: rgba(107,114,128,0.15); color: var(--gray); }
.badge-paused { background: rgba(107,114,128,0.15); color: var(--gray); }
.badge-pending { background: rgba(234,179,8,0.15); color: var(--yellow); }
.badge-approved { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-denied { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-in-progress { background: rgba(59,130,246,0.15); color: var(--blue); }

/* Project cards */
.project-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.project-item:last-child { border-bottom: none; }
.project-item .proj-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.project-item .proj-name { font-weight: 600; font-size: 14px; }
.project-item .proj-status { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Activity */
.activity-item { padding: 10px 0; border-bottom: 1px solid var(--border); display: flex; gap: 12px; align-items: flex-start; }
.activity-item:last-child { border-bottom: none; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.activity-dot.build { background: var(--blue); }
.activity-dot.system { background: var(--accent); }
.activity-dot.decision { background: var(--green); }
.activity-dot.policy { background: var(--yellow); }
.activity-dot.milestone { background: var(--green); }
.activity-text { font-size: 13px; flex: 1; }
.activity-time { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.activity-agent { font-size: 11px; color: var(--accent); font-weight: 600; }

/* Blocker */
.blocker-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.blocker-item:last-child { border-bottom: none; }
.blocker-item .blocker-title { font-weight: 600; font-size: 13px; color: var(--yellow); }
.blocker-item .blocker-project { font-size: 12px; color: var(--text-muted); }

/* Approval actions */
.approval-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.approval-item:last-child { border-bottom: none; }
.approval-actions { display: flex; gap: 8px; margin-top: 8px; }
.btn { padding: 5px 14px; border-radius: 6px; border: none; font-size: 12px; font-weight: 600; cursor: pointer; transition: opacity 0.15s; }
.btn:hover { opacity: 0.85; }
.btn-approve { background: var(--green); color: #fff; }
.btn-deny { background: var(--red); color: #fff; }

/* Scrollable panels */
.panel-scroll { max-height: 400px; overflow-y: auto; }
.panel-scroll::-webkit-scrollbar { width: 7px; }
.panel-scroll::-webkit-scrollbar-track { background: transparent; }
.panel-scroll::-webkit-scrollbar-thumb { background: linear-gradient(180deg, rgba(108,117,125,0.35), rgba(108,117,125,0.6)); border-radius: 999px; }

/* Memory view */
.memory-content { background: #f9fafb; border: 1px solid var(--border); border-radius: 12px; padding: 16px; font-family: 'JetBrains Mono', 'SF Mono', Monaco, monospace; font-size: 13px; white-space: pre-wrap; max-height: 500px; overflow-y: auto; color: var(--text-muted); box-shadow: inset 0 1px 2px rgba(15,23,42,0.04); }

/* Page sections */
.page { display: none; }
.page.active { display: block; }

/* Mobile hamburger */
.mobile-header { display: none; }

/* Mobile Office (replaces canvas on small screens) */
.mobile-office { display: none; margin-bottom: 16px; }
.mobile-office-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.mo-agent {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 6px;
  text-align: center;
  position: relative;
}
.mo-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  margin-bottom: 6px;
  position: relative;
}
.mo-dot {
  position: absolute;
  bottom: -1px; right: -1px;
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 2px solid var(--bg-card);
}
.mo-name { font-size: 11px; font-weight: 700; color: var(--text); }
.mo-tag {
  font-size: 8px;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 600;
  display: inline-block;
  margin-top: 4px;
}

.mission-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.mission-select {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font: inherit;
  color: var(--text);
}
.mission-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.mission-table {
  width: 100%;
  border-collapse: collapse;
}
.mission-table th,
.mission-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 13px;
  vertical-align: top;
}
.mission-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: #fafafa;
}
.mission-table tr:last-child td { border-bottom: none; }

.mission-btn {
  border: 1px solid rgba(204,0,0,0.22);
  background: #CC0000;
  color: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.mission-btn.secondary {
  background: #fff;
  color: #CC0000;
}

.mission-btn.danger {
  background: #fff;
  color: #CC0000;
  border-color: rgba(204,0,0,0.45);
}

.referral-section {
  margin-bottom: 18px;
}

.referral-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.referral-section-title h3 {
  margin: 0;
  font-size: 15px;
}

.referral-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 4px rgba(15,23,42,0.05);
}

.referral-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.referral-card-title {
  font-weight: 800;
  color: var(--text);
}

.referral-card-meta {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
}

.referral-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.referral-detail {
  border: 1px solid rgba(233,236,239,0.88);
  border-radius: 8px;
  padding: 8px;
  background: rgba(248,249,250,0.7);
}

.referral-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.referral-value {
  font-size: 13px;
  color: var(--text);
  font-weight: 650;
  overflow-wrap: anywhere;
}

.referral-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.mission-row-new { background: rgba(204, 0, 0, 0.05); }
.mission-row-worked { opacity: 0.72; }
.mission-row-clickable { cursor: pointer; }
.mission-action-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.mission-action-btn.secondary {
  background: var(--green);
}
.mission-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.mission-status-pill.new { background: rgba(204,0,0,0.12); color: var(--accent); }
.mission-status-pill.worked,
.mission-status-pill.approved { background: rgba(22,163,74,0.12); color: var(--green); }
.mission-status-pill.pending { background: rgba(217,119,6,0.12); color: var(--yellow); }
.mission-empty {
  padding: 18px 14px;
  color: var(--text-muted);
  font-size: 13px;
}
.mission-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.mission-detail-item {
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.mission-detail-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.mission-detail-value {
  font-size: 13px;
  color: var(--text);
  word-break: break-word;
}

/* ============ PWA SAFE AREAS (notch, home indicator) ============ */
@media (max-width: 1280px) {
  @supports (padding: env(safe-area-inset-top)) {
    .mobile-header {
      padding-top: calc(14px + env(safe-area-inset-top));
    }
    .main {
      padding-bottom: calc(16px + env(safe-area-inset-bottom)) !important;
    }
    .chat-input-area {
      padding-bottom: calc(14px + env(safe-area-inset-bottom));
    }
  }
}

/* ============ IPAD / TABLET (portrait 768-1280px) ============ */
@media (min-width: 768px) and (max-width: 1280px) {
  .ops-row { grid-template-columns: 1fr 1fr; gap: 12px; }
  .main { padding: 16px 24px !important; }
  .panel-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .stats-row { grid-template-columns: repeat(4, 1fr); gap: 12px; }
  .stat-card .value { font-size: 22px; }
  .agents-seats { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .agent-seat { padding: 12px 10px; }
  .agent-seat-avatar { width: 40px; height: 40px; font-size: 15px; }
  .agent-seat-name { font-size: 12px; }
  .agent-seat-role { font-size: 9px; }
  .chat-drawer {
  border-top-left-radius: 18px; width: 480px; height: 60vh; max-height: 700px; }
}

/* ============ MOBILE / TABLET ============ */
@media (max-width: 1280px) {
  .sidebar {
    display: none !important;
  }
  .sidebar.open {
    display: flex !important;
    position: fixed;
    left: 0;
    top: 0;
    width: 240px;
    z-index: 200;
  }
  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 99;
  }
  .sidebar-overlay.show { display: block; }

  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    padding-top: max(14px, env(safe-area-inset-top, 14px));
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
  }
  .mobile-header-brand { display: flex; flex-direction: row; align-items: center; gap: 8px; }
  .mobile-logo-pill { background: #fff; border: 1px solid var(--border); border-radius: 5px; padding: 3px 7px; display: flex; align-items: center; }
  .mobile-logo { height: 26px; width: auto; display: block; }
  .mobile-header-dyad { font-size: 18px; font-weight: 900; color: #fff; letter-spacing: 2px; line-height: 1; }
  .mobile-header-title { font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted); }
  .mobile-header h1 { font-size: 14px; color: var(--accent); font-weight: 700; }
  .hamburger { background: none; border: none; color: var(--text); font-size: 24px; cursor: pointer; padding: 8px; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; position: relative; z-index: 51; }

  .main { margin-left: 0 !important; padding: 8px 10px 16px !important; width: 100vw !important; max-width: 100vw !important; overflow-x: hidden !important; }
  
  .command-table { display: block; padding: 10px; margin-bottom: 12px; }
  .mobile-office { display: none !important; }
  .panel-grid { grid-template-columns: 1fr; gap: 12px; }
  .stats-row { grid-template-columns: repeat(4, 1fr); gap: 10px; }
  .ops-row { grid-template-columns: 1fr; gap: 12px; }
  .stat-card { padding: 12px 14px; }
  .stat-card .value { font-size: 20px; }
  .panel { padding: 14px; }

  .agents-seats { gap: 6px; display: grid; grid-template-columns: repeat(3, 1fr); }
  .agent-seat { padding: 8px 6px; min-width: unset; }
  .agent-seat-avatar { width: 32px; height: 32px; font-size: 13px; }
  .agent-seat-avatar .status-dot { width: 10px; height: 10px; }
  .agent-seat-name { font-size: 10px; }
  .agent-seat-nametag { font-size: 8px; padding: 1px 6px; }
  .agent-seat-role { font-size: 8px; }
  .command-table-title { font-size: 10px; margin-bottom: 10px; }

  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-card { padding: 10px 12px; }
  .stat-card .value { font-size: 18px; }
  .stat-card .label { font-size: 10px; }
  .stat-card .sub { font-size: 10px; }

  .panel { padding: 12px; margin-bottom: 0; }
  .panel h2 { font-size: 12px; margin-bottom: 10px; }
  .panel-grid { grid-template-columns: 1fr; gap: 10px; }

  .agent-item { padding: 8px 0; gap: 10px; }
  .agent-avatar { width: 32px; height: 32px; font-size: 12px; }
  .agent-info .name { font-size: 13px; }
  .agent-info .role { font-size: 11px; }

  .project-item { padding: 10px 0; }
  .project-item .proj-name { font-size: 13px; }
  .project-item .proj-status { font-size: 11px; }

  .badge { font-size: 9px; padding: 2px 6px; }
}

/* CRM Left Sidebar - show on desktop */
@media (min-width: 900px) {
  .crm-left-sidebar { display: block !important; }
}

/* ============================================================
   AGENT CHAT DRAWER
   ============================================================ */

.chat-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 900;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.chat-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.chat-drawer {
  border-top-left-radius: 18px;
  position: fixed;
  bottom: 0;
  right: 0;
  width: 420px;
  max-width: 100vw;
  height: 52vh;
  min-height: 420px;
  max-height: 620px;
  background: linear-gradient(180deg, rgba(12,18,30,0.98), rgba(17,24,39,0.98));
  border-left: 1px solid #1f2937;
  border-top: 1px solid #1f2937;
  border-top-left-radius: 14px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
  box-shadow: -4px -4px 24px rgba(0,0,0,0.4);
  pointer-events: none;
}
.chat-drawer.open {
  transform: translateY(0);
  pointer-events: auto;
}

.chat-drawer-header {
  display: flex;
  background: linear-gradient(180deg, rgba(15,23,42,0.96), rgba(15,23,42,0.88));
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #1f2937;
  background: #0f172a;
  flex-shrink: 0;
}

.chat-agent-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  border: 2px solid transparent;
  flex-shrink: 0;
}

.chat-icon-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.7);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.chat-icon-btn:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: #374151; border-radius: 2px; }

.chat-message-row {
  display: flex;
  max-width: 88%;
}
.user-row {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.agent-row {
  align-self: flex-start;
}

.chat-bubble {
  padding: 11px 15px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.55;
  max-width: 100%;
}
.user-bubble {
  background: #CC0000;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.agent-bubble {
  background: rgba(31,41,55,0.92);
  color: #e5e7eb;
  border: 1px solid transparent;
  border-bottom-left-radius: 4px;
}

.chat-bubble-text {
  word-break: break-word;
}
.chat-bubble-time {
  font-size: 10px;
  color: rgba(255,255,255,0.35);
  margin-top: 4px;
  text-align: right;
}
.user-bubble .chat-bubble-time { color: rgba(255,255,255,0.5); }

/* Typing indicator */
.chat-thinking {
  padding: 0 20px 8px;
  flex-shrink: 0;
}
.typing-dots {
  display: flex;
  gap: 4px;
  padding: 4px 0 2px;
}
.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6b7280;
  animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Input area */
.chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid #1f2937;
  background: #0f172a;
  flex-shrink: 0;
}

.chat-mic-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.7);
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
.chat-mic-btn:hover { background: rgba(255,255,255,0.12); }
.chat-mic-btn.mic-active {
  background: rgba(239,68,68,0.2);
  border-color: #ef4444;
  color: #ef4444;
  animation: micPulse 1s infinite;
}
@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}

.chat-input {
  flex: 1;
  background: rgba(31,41,55,0.9);
  border: 1px solid #374151;
  border-radius: 10px;
  color: #f3f4f6 !important;
  font-size: 14px;
  padding: 10px 14px;
  resize: none;
  min-height: 40px;
  max-height: 120px;
  line-height: 1.5;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  -webkit-text-fill-color: #f3f4f6;
  caret-color: #f3f4f6;
}
.chat-input:focus {
  border-color: rgba(204,0,0,0.55);
  box-shadow: 0 0 0 4px rgba(204,0,0,0.12);
}

.chat-input::placeholder { color: #6b7280; }

.chat-send-btn {
  background: #CC0000;
  border: none;
  color: #fff;
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.chat-send-btn:hover { background: #aa0000; }

/* Voice mode pulse dot */
.voice-pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
  flex-shrink: 0;
  animation: voicePulse 1.2s infinite ease-in-out;
}
@keyframes voicePulse {
  0%, 100% { opacity: 1; transform: scale(1); box-shadow: 0 0 0 0 rgba(239,68,68,0.5); }
  50% { opacity: 0.8; transform: scale(1.2); box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}

/* Agent card clickable */
.agent-card-clickable {
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.agent-card-clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

/* Mobile adjustments */
@media (max-width: 640px) {
  .chat-drawer {
  border-top-left-radius: 18px;
    width: 100vw;
    height: 60vh;
    min-height: 380px;
    border-top-left-radius: 14px;
    border-left: none;
  }
}

/* ============================================================
   PHONE — HARD OVERRIDE (max 767px)
   Desktop and iPad (768px+) are UNTOUCHED above.
   All phone-specific layout lives here.
   ============================================================ */
@media (max-width: 767px) {
  .dashboard-sign-out {
    top: 12px;
    right: 14px;
    padding: 7px 10px;
    font-size: 11px;
  }

  /* Root layout — prevent any horizontal overflow */
  html, body {
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  body {
    display: block !important; /* kill flex — sidebar is fixed, not in flow */
  }

  /* Sidebar — hidden off-screen, slide in on open */
  .sidebar {
    display: none !important;
    width: 240px !important;
    z-index: 200 !important;
  }
  .sidebar.open {
    display: flex !important;
  }

  /* Mobile header — always full width */
  .mobile-header {
    display: flex !important;
    width: 100% !important;
    box-sizing: border-box !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 50 !important;
  }

  /* Main content — full width, no left margin */
  .main {
    display: block !important;
    width: 100% !important;
    max-width: 100vw !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding: 8px 10px 24px !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
    min-width: 0 !important;
  }

  /* PWA safe area for notch/home indicator */
  @supports (padding: env(safe-area-inset-top)) {
    .mobile-header {
      padding-top: calc(14px + env(safe-area-inset-top)) !important;
    }
    .main {
      padding-bottom: calc(24px + env(safe-area-inset-bottom)) !important;
    }
    .chat-input-area {
      padding-bottom: calc(14px + env(safe-area-inset-bottom)) !important;
    }
  }

  /* Office canvas — show on phone, hide the simple grid */
  .command-table {
    display: block !important;
    padding: 8px !important;
    margin-bottom: 12px !important;
    overflow: hidden !important;
  }
  .command-table-title {
    font-size: 9px !important;
    margin-bottom: 6px !important;
  }
  #office-canvas {
    width: 100% !important;
    height: auto !important;
    border-radius: 8px !important;
  }
  .mobile-office {
    display: none !important;
  }

  /* Stats row — single column stack on phone so token burn card has full width */
  .stats-row {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    margin-bottom: 12px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .stat-card {
    padding: 10px 12px !important;
    min-width: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }
  /* Token burn row items — shrink to fit on mobile */
  .stat-card [style*="min-width:90px"] {
    min-width: 0 !important;
    flex: 1 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
  .stat-card [style*="min-width:50px"],
  .stat-card [style*="min-width:52px"] {
    min-width: 0 !important;
    flex-shrink: 0 !important;
  }
  .stat-card .value {
    font-size: 20px !important;
  }
  .stat-card .label {
    font-size: 10px !important;
  }
  .stat-card .sub {
    font-size: 10px !important;
  }

  .ops-row { grid-template-columns: 1fr !important; gap: 10px !important; }
  .ops-row .panel { margin-bottom: 0 !important; }
    /* Panel grid — single column */
  .panel-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .panel {
    padding: 12px !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    width: 100% !important;
  }
  .panel h2 {
    font-size: 12px !important;
    margin-bottom: 10px !important;
  }

  /* Transactions panel */
  #transactions-dashboard-panel {
    width: 100% !important;
    box-sizing: border-box !important;
    min-width: 0 !important;
    margin-bottom: 12px !important;
  }
  #txn-stats-row {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  /* Agent command table seats — replaced by mobile-office, but style just in case */
  .agents-seats {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 6px !important;
  }
  .agent-seat {
    padding: 8px 6px !important;
    min-width: 0 !important;
  }
  .agent-seat-avatar {
    width: 32px !important;
    height: 32px !important;
    font-size: 13px !important;
  }
  .agent-seat-name { font-size: 10px !important; }
  .agent-seat-nametag { font-size: 8px !important; padding: 1px 6px !important; }
  .agent-seat-role { font-size: 8px !important; }

  /* List items */
  .agent-item { padding: 8px 0 !important; gap: 10px !important; }
  .agent-avatar { width: 32px !important; height: 32px !important; font-size: 12px !important; }
  .agent-info .name { font-size: 13px !important; }
  .agent-info .role { font-size: 11px !important; }
  .project-item { padding: 10px 0 !important; }
  .project-item .proj-name { font-size: 13px !important; }
  .project-item .proj-status { font-size: 11px !important; }
  .badge { font-size: 9px !important; padding: 2px 6px !important; }
  .blocker-item .blocker-title { font-size: 12px !important; }
  .blocker-item .blocker-project { font-size: 11px !important; }
  .activity-text { font-size: 12px !important; }

  /* Chat drawer — full width on phone */
  .chat-drawer {
  border-top-left-radius: 18px;
    width: 100vw !important;
    height: 65vh !important;
    min-height: 380px !important;
    border-top-left-radius: 14px !important;
    border-left: none !important;
    right: 0 !important;
    left: 0 !important;
  }

  /* Trading page grid */
  /* Cleaning page cards */
  #cleaning-cards {
    grid-template-columns: 1fr !important;
  }
  #cleaning-summary {
    grid-template-columns: repeat(2, 1fr) !important;
  }

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

/* Mobile: restore original white card backgrounds */
@media (max-width: 767px) {
  .panel, .stat-card { background: var(--bg-card) !important; }
}

/* ── Responsive 3-column grid (used by Buildium stats/ops rows) ── */
.stats-3col {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

/* ── Cleaning snapshot responsive layout ── */
.cleaning-snapshot-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.cleaning-stats-flex {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.cleaning-stats-flex > div {
  min-width: 0;
}

@media (max-width: 767px) {
  .cleaning-snapshot-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  .cleaning-stats-flex {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 8px !important;
  }
  .cleaning-stats-flex > div {
    text-align: center;
  }
  /* Tighten transaction list items on mobile */
  .txn-list-item-right {
    gap: 4px !important;
  }
  .txn-list-item-right .txn-days-col {
    min-width: 28px !important;
  }
  .txn-progress-ring {
    width: 28px !important;
    height: 28px !important;
    font-size: 9px !important;
  }
  /* Buildium stats/ops rows — keep 3-col but tighter */
  .stats-3col {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 6px !important;
  }
}

/* ── Streaming chat bubble ── */
.stream-cursor {
  display: inline-block;
  animation: blink 0.7s step-end infinite;
  color: rgba(255,255,255,0.6);
  font-weight: 300;
  margin-left: 1px;
}
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }


/* Nexus sidebar submenu */
.sidebar-section-header { display:flex; align-items:center; justify-content:space-between; }
.sidebar-expand-arrow { font-size:12px; transition:transform 0.2s; color:var(--text-muted); margin-left:auto; }
.sidebar-expand-arrow.open { transform:rotate(90deg); }
.sidebar-submenu { padding-left:20px; }
.sidebar-submenu a { display:block; padding:6px 12px; font-size:13px; color:var(--text-muted); text-decoration:none; border-radius:6px; transition:all 0.15s; }
.sidebar-submenu a:hover { background:rgba(255,255,255,0.06); color:var(--text-primary); }

/* Nexus feature cards */
.nexus-feature-card { background:white; border:1px solid #f3f4f6; border-radius:10px; padding:14px; text-align:center; transition:all 0.2s; cursor:pointer; display:block; }
.nexus-feature-card:hover { border-color:#fca5a5; transform:translateY(-2px); box-shadow:0 4px 12px rgba(220,38,38,0.08); }

/* ── PWA Standalone Mode — keep hamburger nav, just adjust safe areas ── */
@media (display-mode: standalone) {
  .mobile-header {
    padding-top: calc(14px + env(safe-area-inset-top)) !important;
  }
  .main { 
    padding-bottom: calc(16px + env(safe-area-inset-bottom)) !important; 
  }
}

/* SEO stats cards — 3x2 on mobile, 6x1 on desktop */
.seo-stats-grid { grid-template-columns: repeat(3, 1fr); }
@media (min-width: 768px) { .seo-stats-grid { grid-template-columns: repeat(6, 1fr); } }

/* ── Page & card animations ── */
@keyframes page-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.page-enter { animation: page-fade-in 0.2s ease-out forwards; }

@keyframes card-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.card-stagger > * {
  opacity: 0;
  animation: card-in 0.22s ease-out forwards;
}
.card-stagger > *:nth-child(1) { animation-delay: 0ms; }
.card-stagger > *:nth-child(2) { animation-delay: 50ms; }
.card-stagger > *:nth-child(3) { animation-delay: 100ms; }
.card-stagger > *:nth-child(4) { animation-delay: 150ms; }
.card-stagger > *:nth-child(5) { animation-delay: 200ms; }
.card-stagger > *:nth-child(6) { animation-delay: 250ms; }

.owner-funnel-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}
.owner-funnel-step {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 12px;
  text-align: center;
}
.owner-funnel-step .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.owner-funnel-step .value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
}
.owner-source-row, .owner-lead-row {
  display: grid;
  grid-template-columns: 1.3fr 0.9fr 0.8fr 0.8fr;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.owner-source-row.header, .owner-lead-row.header {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 700;
}
.owner-lead-row {
  grid-template-columns: 1.2fr 1fr 0.8fr 1fr;
}
.owner-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
@media (max-width: 900px) {
  .owner-funnel-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .owner-source-row, .owner-lead-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .owner-source-row.header, .owner-lead-row.header {
    display: none;
  }
}

#mowing-cards {
  grid-template-columns: 1fr !important;
}
#mowing-summary {
  grid-template-columns: repeat(2, 1fr) !important;
}

.mowing-snapshot-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 767px) {
  .mowing-snapshot-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
}

@keyframes statusPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(5,150,105,0.38); } 50% { box-shadow: 0 0 0 7px rgba(5,150,105,0); } }

.panel:hover, .stat-card:hover, .agent-card-clickable:hover { box-shadow: var(--shadow-md); border-color: rgba(204,0,0,0.14); }
.stat-card:hover { transform: translateY(-2px); }
.panel:hover { transform: translateY(-1px); }
.stat-card::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, rgba(204,0,0,0.8), rgba(204,0,0,0.1)); opacity: 0.88; }
.stats-row .stat-card:nth-child(2)::before { background: linear-gradient(90deg, rgba(5,150,105,0.9), rgba(5,150,105,0.1)); }
.stats-row .stat-card:nth-child(3)::before { background: linear-gradient(90deg, rgba(37,99,235,0.9), rgba(37,99,235,0.1)); }
.stats-row .stat-card:nth-child(4)::before { background: linear-gradient(90deg, rgba(217,119,6,0.9), rgba(217,119,6,0.1)); }

.mission-table tbody tr:nth-child(even), .mission-table tr:nth-child(even) td { background: rgba(248,249,250,0.65); }
.mission-empty::before { content: '◎'; display: inline-block; margin-right: 8px; color: rgba(108,117,125,0.7); }

.agent-item, .project-item, .activity-item, .approval-item, .blocker-item { transition: background 0.16s ease; }
.agent-item:hover, .project-item:hover, .activity-item:hover, .approval-item:hover, .blocker-item:hover { background: rgba(248,249,250,0.75); }

/* ── S.E.O.N Client Dashboard ─────────────────────────────────── */
.seon-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
@media (max-width: 768px) {
  .seon-grid { grid-template-columns: 1fr; }
}
.seon-card {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.seon-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.seon-stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.seon-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  min-width: 80px;
  flex: 1;
}
.seon-stat-val {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  display: flex;
  align-items: center;
}
.seon-stat-lbl {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-top: 2px;
  white-space: nowrap;
}
.seon-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.seon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
}
.seon-btn:hover { background: var(--bg-hover, rgba(99,102,241,.12)); color: #6366f1; }

/* ── SEON Full Report View ── */
.seon-report-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
  margin-bottom: 20px;
}
.seon-report-back:hover { background: var(--bg-hover, rgba(99,102,241,.12)); color: #6366f1; }

.seon-report-header {
  margin-bottom: 28px;
}
.seon-report-title {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 8px;
}
.seon-report-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
}
.seon-report-domain {
  color: #6366f1;
  text-decoration: none;
  font-weight: 500;
}
.seon-report-domain:hover { text-decoration: underline; }

.seon-section {
  margin-bottom: 28px;
}
.seon-section-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin: 0 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.seon-report-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.seon-report-stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  text-align: center;
}
.seon-report-stat-val {
  font-size: 22px;
  font-weight: 700;
  display: block;
  margin-bottom: 4px;
}
.seon-report-stat-lbl {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.seon-chart-wrap {
  position: relative;
  height: 160px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 8px;
}
.seon-chart-legend {
  display: flex;
  gap: 16px;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.seon-chart-legend-dot {
  display: inline-block;
  width: 10px;
  height: 3px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: middle;
}

.seon-audit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.seon-audit-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
.seon-audit-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.seon-audit-table tr:last-child td { border-bottom: none; }
.seon-audit-table tr:hover td { background: var(--bg-hover, rgba(255,255,255,.03)); }

.seon-badge {
  display: inline-block;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.seon-badge-pass  { background: #22c55e22; color: #22c55e; }
.seon-badge-warn  { background: #f59e0b22; color: #f59e0b; }
.seon-badge-fail  { background: #ef444422; color: #ef4444; }
.seon-badge-high  { background: #ef444422; color: #ef4444; }
.seon-badge-med   { background: #f59e0b22; color: #f59e0b; }
.seon-badge-low   { background: #6b728022; color: #6b7280; }
.seon-badge-crit  { background: #ef444422; color: #ef4444; }
.seon-badge-info  { background: #6366f122; color: #6366f1; }

.seon-kw-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.seon-kw-tab {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
}
.seon-kw-tab.active {
  background: #6366f1;
  border-color: #6366f1;
  color: #fff;
}
.seon-kw-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.seon-kw-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  padding: 7px 10px;
  background: var(--bg-card);
  border-radius: 6px;
  border: 1px solid var(--border);
}
.seon-kw-text { flex: 1; font-weight: 500; }
.seon-kw-note { font-size: 11px; color: var(--text-muted); }

.seon-nap-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 16px;
  font-size: 13px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.seon-nap-field label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.seon-nap-field span { font-weight: 500; }

.seon-content-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.seon-content-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}
.seon-content-title { flex: 1; font-weight: 500; }
.seon-content-meta { font-size: 11px; color: var(--text-muted); }
.seon-content-link { color: #6366f1; text-decoration: none; font-size: 11px; }
.seon-content-link:hover { text-decoration: underline; }

.seon-summary-fixes {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.seon-summary-fix {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  padding: 6px 10px;
  background: var(--bg-card);
  border-radius: 6px;
}
.seon-summary-fix-check { color: #22c55e; font-size: 15px; flex-shrink: 0; }

.seon-next-steps {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.seon-next-col { }
.seon-next-col-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 8px;
  padding: 4px 8px;
  border-radius: 4px;
}
.seon-next-col-blocker  { background: #ef444415; color: #ef4444; }
.seon-next-col-auto     { background: #6366f115; color: #6366f1; }
.seon-next-col-bryan    { background: #f59e0b15; color: #f59e0b; }
.seon-next-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.seon-next-item:last-child { border-bottom: none; }

.seon-empty-state {
  padding: 16px;
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

/* ── SEO MATURITY METER ───────────────────────────────────────────────────── */
.seo-maturity-panel { margin-bottom: 20px; }
.seo-maturity-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
  margin-bottom: 8px;
}
.sm-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.sm-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}
.sm-card-title { font-size: 15px; font-weight: 600; color: var(--text); }
.sm-card-domain { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.sm-grade-badge {
  width: 52px; height: 52px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800;
  flex-shrink: 0;
  border: 3px solid currentColor;
}
.sm-score-row {
  display: flex; align-items: flex-end; gap: 10px; margin-bottom: 8px;
}
.sm-score-big { font-size: 40px; font-weight: 800; line-height: 1; }
.sm-score-max { font-size: 16px; color: var(--text-muted); margin-bottom: 6px; }
.sm-delta {
  font-size: 13px; font-weight: 600;
  padding: 2px 8px; border-radius: 20px;
  margin-bottom: 6px;
}
.sm-delta-up   { background: #22c55e20; color: #22c55e; }
.sm-delta-down { background: #ef444420; color: #ef4444; }
.sm-delta-flat { background: #6b728020; color: #6b7280; }
.sm-gauge {
  width: 100%; height: 10px;
  background: var(--border);
  border-radius: 5px;
  margin-bottom: 14px;
  overflow: hidden;
}
.sm-gauge-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.8s ease;
}
.sm-grade-label { font-size: 11px; color: var(--text-muted); margin-bottom: 14px; }
.sm-milestone {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 12px;
}
.sm-milestone-title { font-weight: 600; color: var(--text); margin-bottom: 6px; }
.sm-milestone-item { color: var(--text-muted); padding: 2px 0; display: flex; align-items: center; gap: 6px; }
.sm-milestone-item strong { color: var(--text); }
.sm-categories { margin-bottom: 14px; }
.sm-cat-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 0; border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.sm-cat-row:last-child { border-bottom: none; }
.sm-cat-icon { font-size: 14px; width: 20px; flex-shrink: 0; }
.sm-cat-name { font-size: 12px; color: var(--text); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sm-cat-bar-wrap { width: 80px; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; flex-shrink: 0; }
.sm-cat-bar-fill { height: 100%; border-radius: 3px; transition: width 0.6s ease; }
.sm-cat-pct { font-size: 11px; color: var(--text-muted); width: 32px; text-align: right; flex-shrink: 0; }
.sm-cat-chevron { font-size: 10px; color: var(--text-muted); flex-shrink: 0; transition: transform 0.2s; }
.sm-cat-chevron.open { transform: rotate(90deg); }
/* Category accordion items */
.sm-cat-items { display: none; background: var(--bg); border-radius: 8px; padding: 8px; margin: 4px 0 8px; }
.sm-cat-items.open { display: block; }
.sm-item-row {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 12px;
}
.sm-item-row:last-child { border-bottom: none; }
.sm-item-status { flex-shrink: 0; margin-top: 1px; }
.sm-item-label { flex: 1; color: var(--text); min-width: 0; }
.sm-item-evidence { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.sm-item-btn {
  font-size: 11px; padding: 3px 8px; border-radius: 5px; border: none; cursor: pointer;
  font-weight: 600; flex-shrink: 0; white-space: nowrap;
}
.sm-item-btn-close  { background: #3b82f620; color: #3b82f6; }
.sm-item-btn-close:hover { background: #3b82f640; }
.sm-item-btn-manual { background: #6b728020; color: #6b7280; }
.sm-item-btn-manual:hover { background: #6b728040; }
.sm-item-btn-done   { background: #22c55e20; color: #22c55e; }
.sm-item-btn-done:hover { background: #22c55e40; }
/* History trend chart */
.sm-trend { margin-top: 14px; }
.sm-trend-title { font-size: 11px; color: var(--text-muted); margin-bottom: 6px; }
.sm-trend-placeholder { font-size: 11px; color: var(--text-muted); font-style: italic; text-align: center; padding: 16px 0; }
.sm-trend svg { width: 100%; height: 80px; display: block; overflow: visible; }
.sm-probe-date { font-size: 10px; color: var(--text-muted); margin-top: 6px; text-align: right; }
/* Status icons */
.sm-status-complete { color: #22c55e; }
.sm-status-partial  { color: #f59e0b; }
.sm-status-missing  { color: #ef4444; }
.sm-status-unknown  { color: #6b7280; }
/* Loading */
.sm-loading {
  text-align: center; color: var(--text-muted); font-size: 13px;
  padding: 30px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px;
}
/* Action result toast */
.sm-toast {
  position: fixed; bottom: 20px; right: 20px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 16px;
  font-size: 13px; z-index: 9999;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  max-width: 320px;
  animation: smFadeIn 0.2s ease;
}
@keyframes smFadeIn { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }
/* ── START BUTTON VARIANTS ──────────────────────────────────────────────── */
.sm-start-btn {
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: background 0.15s, transform 0.1s;
}
.sm-start-btn:active { transform: scale(0.97); }
.sm-start-auto   { background: #1e40af30; color: #60a5fa; border: 1px solid #1e40af60; }
.sm-start-auto:hover   { background: #1e40af55; }
.sm-start-guided { background: #78350f30; color: #fbbf24; border: 1px solid #78350f60; }
.sm-start-guided:hover { background: #78350f55; }
.sm-start-manual { background: #1f293730; color: #94a3b8; border: 1px solid #33415560; }
.sm-start-manual:hover { background: #1f293750; }
/* ── WIZARD MODAL ──────────────────────────────────────────────── */
.sm-wizard-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.sm-wizard-modal {
  background: var(--bg-card, #1e293b);
  border: 1px solid var(--border, #334155);
  border-radius: 14px;
  width: 100%; max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  outline: none;
}
.sm-wizard-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 20px 20px 12px;
  border-bottom: 1px solid var(--border);
}
.sm-wizard-title {
  font-size: 16px; font-weight: 700; color: var(--text, #f1f5f9);
}
.sm-wizard-meta {
  font-size: 11px; color: var(--text-muted, #94a3b8); margin-top: 3px;
}
.sm-wizard-close {
  background: transparent; border: none; cursor: pointer;
  color: var(--text-muted, #94a3b8); font-size: 22px; line-height: 1;
  padding: 0 0 0 12px; flex-shrink: 0;
}
.sm-wizard-close:hover { color: #f1f5f9; }
.sm-wizard-progress {
  height: 3px; background: var(--border, #334155);
}
.sm-wizard-progress-fill {
  height: 100%; background: #3b82f6;
  transition: width 0.3s ease;
  border-radius: 0 2px 2px 0;
}
.sm-wizard-body {
  padding: 20px;
  flex: 1;
}
.sm-wizard-step-title {
  font-size: 14px; font-weight: 600; color: var(--text, #f1f5f9);
  margin-bottom: 10px;
}
.sm-wizard-instruction {
  font-size: 13px; color: var(--text-muted, #94a3b8);
  line-height: 1.6;
}
.sm-wizard-instruction code {
  background: #0f172a; border: 1px solid #334155;
  border-radius: 4px; padding: 1px 5px; font-size: 11px; color: #7dd3fc;
}
.sm-wizard-instruction strong { color: var(--text, #f1f5f9); }
.sm-wizard-action { margin-top: 14px; }
.sm-wizard-action-btn {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 7px; border: none; cursor: pointer;
  font-size: 12px; font-weight: 600;
  text-decoration: none;
  transition: background 0.15s;
}
.sm-wizard-ext  { background: #1e40af; color: #fff; }
.sm-wizard-ext:hover { background: #1d4ed8; }
.sm-wizard-check { background: #064e3b; color: #34d399; }
.sm-wizard-check:hover { background: #065f46; }
.sm-wizard-save { background: #1e40af; color: #fff; margin-left: 8px; }
.sm-wizard-save:hover { background: #1d4ed8; }
.sm-wizard-copy-row {
  display: flex; align-items: center; gap: 8px; margin-top: 8px;
}
.sm-wizard-code {
  flex: 1; background: #0f172a; border: 1px solid #334155;
  border-radius: 6px; padding: 6px 10px;
  font-size: 11px; color: #7dd3fc; word-break: break-all;
}
.sm-wizard-input-row {
  display: flex; align-items: center; gap: 8px; margin-top: 8px;
}
.sm-wizard-input {
  flex: 1; background: #0f172a; border: 1px solid #334155;
  border-radius: 6px; padding: 7px 10px;
  font-size: 13px; color: var(--text, #f1f5f9);
  outline: none;
}
.sm-wizard-input:focus { border-color: #3b82f6; }
.sm-wizard-confirm {
  margin-top: 12px; font-size: 11px; color: #64748b;
  font-style: italic;
}
.sm-wizard-result {
  margin: 0 20px 10px;
  font-size: 13px;
  padding: 8px 12px;
  background: #0f172a;
  border-radius: 6px;
  border: 1px solid #334155;
}
.sm-wizard-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  gap: 8px;
}
.sm-wizard-nav-btn {
  padding: 8px 14px; border-radius: 7px;
  border: 1px solid var(--border, #334155);
  background: transparent; color: var(--text-muted, #94a3b8);
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: background 0.15s;
}
.sm-wizard-nav-btn:hover:not([disabled]) { background: #1e293b; color: #f1f5f9; }
.sm-wizard-nav-btn[disabled] { cursor: not-allowed; }
.sm-wizard-next-btn { background: #1e40af; color: #fff; border-color: #1e40af; }
.sm-wizard-next-btn:hover { background: #1d4ed8 !important; color: #fff !important; }
.sm-wizard-done-btn { background: #065f46; color: #34d399; border-color: #065f46; }
.sm-wizard-done-btn:hover { background: #047857 !important; color: #fff !important; }
.sm-wizard-step-dots { display: flex; gap: 4px; align-items: center; }
.sm-wizard-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--border, #334155);
  transition: background 0.2s;
}
.sm-wizard-dot.active { background: #3b82f6; width: 10px; border-radius: 3px; }
/* ── END SEO MATURITY METER ────────────────────────────────────────────────── */

/* ── EMAIL AUDIT ─────────────────────────────────────────────────────────── */
.ea-pill { background: var(--panel-bg); border: 1px solid var(--border); color: var(--text-muted); padding: 5px 14px; border-radius: 999px; font-size: 12px; font-weight: 600; cursor: pointer; transition: all 0.15s; }
.ea-pill:hover { border-color: var(--accent); color: var(--text); }
.ea-pill.ea-pill-active { background: rgba(99,102,241,0.15); border-color: #6366f1; color: #818cf8; }
.ea-badge { font-size: 11px; padding: 3px 9px; border-radius: 999px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; white-space: nowrap; }
.ea-badge-sent { background: rgba(34,197,94,0.15); color: #22c55e; }
.ea-badge-blocked { background: rgba(239,68,68,0.15); color: #ef4444; }
.ea-badge-dryrun { background: rgba(59,130,246,0.15); color: #60a5fa; }
.ea-badge-error { background: rgba(249,115,22,0.15); color: #fb923c; }
#email-audit-table tr:hover td { background: rgba(255,255,255,0.02); }
#email-audit-table tbody tr { cursor: pointer; }
#email-audit-table tbody tr:hover td { background: rgba(99,102,241,0.06); }
#email-audit-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
#email-audit-table td.ea-context-blocked { color: #ef4444; }

/* ── EMAIL AUDIT DETAIL DRAWER ───────────────────────────────────────────── */
.ea-detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 1100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.ea-detail-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.ea-detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 520px;
  max-width: 100vw;
  background: linear-gradient(180deg, rgba(12,18,30,0.99), rgba(17,24,39,0.99));
  border-left: 1px solid #1f2937;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
  pointer-events: none;
  box-shadow: -6px 0 32px rgba(0,0,0,0.5);
}
.ea-detail-drawer.open {
  transform: translateX(0);
  pointer-events: auto;
}
.ea-detail-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid #1f2937;
  background: rgba(15,23,42,0.95);
  flex-shrink: 0;
}
.ea-detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}
.ea-detail-meta {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 6px 12px;
  font-size: 13px;
}
.ea-detail-meta .em-label {
  color: rgba(255,255,255,0.4);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-top: 2px;
}
.ea-detail-meta .em-value {
  color: #e5e7eb;
  word-break: break-all;
}
.ea-detail-body-pre {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 14px 16px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12.5px;
  line-height: 1.6;
  color: #d1d5db;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 420px;
  overflow-y: auto;
  margin: 0;
}
.ea-detail-footer {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid #1f2937;
  background: rgba(15,23,42,0.9);
  flex-shrink: 0;
  flex-wrap: wrap;
}
@media (max-width: 600px) {
  .ea-detail-drawer { width: 100vw; }
}
/* ── END EMAIL AUDIT DETAIL DRAWER ───────────────────────────────────────── */
/* ── END EMAIL AUDIT ─────────────────────────────────────────────────────── */
