/* ═══════════════════════════════════════════════
   RoofIgnite Client Portal — Mobile-First CSS
   Base: 320px+ | Breakpoints: 480px, 640px, 768px
   ═══════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; background: #060b18; color: #e2e8f0; min-height: 100vh; -webkit-text-size-adjust: 100%; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

/* ═══ Layout ═══ */
.container { max-width: 960px; margin: 0 auto; padding: 16px 12px; }

/* ═══ Glass ═══ */
.glass { background: linear-gradient(135deg, rgba(15,23,42,0.8), rgba(30,41,59,0.6)); backdrop-filter: blur(20px) saturate(1.2); border: 1px solid rgba(148,163,184,0.08); border-radius: 14px; }

/* ═══ Header ═══ */
.header { display: flex; flex-direction: column; gap: 12px; padding: 16px; margin-bottom: 16px; }
.header-title { font-size: 18px; font-weight: 800; color: #fff; }
.header-sub { font-size: 12px; color: #64748b; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.header-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-email { font-size: 10px; color: #64748b; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.btn-signout { font-size: 11px; color: #94a3b8; background: rgba(100,116,139,0.15); border: 1px solid rgba(100,116,139,0.2); border-radius: 8px; padding: 6px 12px; cursor: pointer; transition: all 0.2s; white-space: nowrap; }
.btn-signout:hover { color: #fff; background: rgba(100,116,139,0.3); }

/* ═══ Account Picker ═══ */
.account-picker { padding: 8px 12px; border-radius: 10px; background: rgba(15,23,42,0.9); border: 1px solid rgba(148,163,184,0.15); color: #e2e8f0; font-size: 13px; outline: none; cursor: pointer; width: 100%; max-width: 280px; }
.account-picker option { background: #0f172a; color: #e2e8f0; }
.admin-badge { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 9999px; font-size: 9px; font-weight: 700; background: rgba(168,85,247,0.12); color: #c084fc; border: 1px solid rgba(168,85,247,0.15); letter-spacing: 0.03em; }

/* ═══ KPI Grid — 1 col mobile, 2 col tablet, auto desktop ═══ */
.kpi-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 16px; }
.kpi-card { padding: 14px 16px; border-radius: 12px; background: linear-gradient(135deg, rgba(15,23,42,0.9), rgba(30,41,59,0.7)); border: 1px solid rgba(148,163,184,0.08); }
.kpi-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: #64748b; font-weight: 600; margin-bottom: 4px; }
.kpi-value { font-size: 20px; font-weight: 800; color: #fff; line-height: 1.1; }
.kpi-sub { font-size: 11px; color: #64748b; margin-top: 3px; }

/* ═══ Projection Disclaimer ═══ */
.projection-disclaimer { font-size: 11px; color: #94a3b8; line-height: 1.6; margin-top: 14px; padding: 10px 14px; background: rgba(100,116,139,0.06); border: 1px solid rgba(100,116,139,0.1); border-radius: 10px; font-style: italic; }

/* ═══ Badges ═══ */
.badge { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 9999px; font-size: 10px; font-weight: 600; letter-spacing: 0.01em; white-space: nowrap; }
.badge-green { background: rgba(34,197,94,0.12); color: #34d399; border: 1px solid rgba(34,197,94,0.15); }
.badge-red { background: rgba(239,68,68,0.12); color: #f87171; border: 1px solid rgba(239,68,68,0.15); }
.badge-yellow { background: rgba(234,179,8,0.12); color: #fbbf24; border: 1px solid rgba(234,179,8,0.15); }
.badge-purple { background: rgba(168,85,247,0.12); color: #c084fc; border: 1px solid rgba(168,85,247,0.15); }
.badge-gray { background: rgba(148,163,184,0.1); color: #94a3b8; border: 1px solid rgba(148,163,184,0.1); }
.badge-blue { background: rgba(59,130,246,0.12); color: #60a5fa; border: 1px solid rgba(59,130,246,0.15); }

/* ═══ Cycle Bar ═══ */
.cycle-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ═══ Tables (shared) ═══ */
.history-table, .lead-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.history-table th, .lead-table th { text-align: left; padding: 8px 8px; color: #64748b; font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; border-bottom: 1px solid rgba(148,163,184,0.1); }
.history-table td, .lead-table td { padding: 7px 8px; border-bottom: 1px solid rgba(148,163,184,0.05); color: #cbd5e1; }
.history-table tr:hover td, .lead-table tr:hover td { background: rgba(148,163,184,0.04); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mobile-hide { display: none; }

/* ═══ Lead Statuses ═══ */
td.lead-booked { color: #34d399; }
td.lead-client { color: #fbbf24; }
td.lead-cancelled { color: #f87171; }
td.lead-open { color: #e2e8f0; }

/* ═══ Filter Badges ═══ */
.lead-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.filter-badge { display: inline-flex; align-items: center; padding: 5px 12px; border-radius: 9999px; font-size: 11px; font-weight: 600; cursor: pointer; transition: all 0.2s; border: 1.5px solid transparent; user-select: none; }
.filter-badge:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
.filter-badge.active { border-color: rgba(255,255,255,0.8); box-shadow: 0 0 16px rgba(255,255,255,0.15); }
.fb-green { background: rgba(34,197,94,0.15); color: #34d399; }
.fb-red { background: rgba(239,68,68,0.15); color: #f87171; }
.fb-white { background: rgba(226,232,240,0.1); color: #e2e8f0; }
.fb-yellow { background: rgba(251,191,36,0.15); color: #fbbf24; }
.fb-blue { background: rgba(59,130,246,0.15); color: #60a5fa; }

/* ═══ Modal ═══ */
.modal-overlay { position: fixed; inset: 0; z-index: 900; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); display: flex; align-items: flex-end; justify-content: center; padding: 0; }
.modal-box { background: #1e293b; border: 1px solid rgba(148,163,184,0.12); border-radius: 16px 16px 0 0; padding: 24px 20px 32px; width: 100%; max-width: 420px; }
.modal-title { font-size: 17px; font-weight: 700; color: #fff; margin-bottom: 4px; }
.modal-sub { font-size: 12px; color: #64748b; margin-bottom: 18px; }
.modal-input { width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid rgba(148,163,184,0.2); background: rgba(15,23,42,0.8); color: #e2e8f0; font-size: 16px; outline: none; -webkit-appearance: none; }
.modal-input:focus { border-color: #d4a843; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn-primary { flex: 1; }
.btn-primary { padding: 12px 20px; border-radius: 10px; border: none; font-size: 14px; font-weight: 700; cursor: pointer; background: #d4a843; color: #0f172a; transition: all 0.2s; min-height: 44px; }
.btn-primary:hover { background: #e0b850; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-cancel { padding: 12px 20px; border-radius: 10px; border: 1px solid rgba(148,163,184,0.2); background: transparent; color: #94a3b8; font-size: 14px; font-weight: 600; cursor: pointer; min-height: 44px; }
.btn-cancel:hover { color: #fff; border-color: rgba(148,163,184,0.4); }

/* ═══ Feedback Widget ═══ */
.fb-group { margin-bottom: 14px; border-radius: 12px; overflow: hidden; border: 1px solid rgba(148,163,184,0.06); }
.fb-group-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: linear-gradient(135deg, rgba(59,130,246,0.08), rgba(34,197,94,0.06)); cursor: pointer; user-select: none; border-bottom: 1px solid rgba(148,163,184,0.06); }
.fb-group-header:hover { background: linear-gradient(135deg, rgba(59,130,246,0.12), rgba(34,197,94,0.1)); }
.fb-group-title { font-size: 13px; font-weight: 700; color: #e2e8f0; }
.fb-group-arrow { color: #60a5fa; font-size: 12px; transition: transform 0.2s; }
.fb-group.collapsed .fb-group-arrow { transform: rotate(-90deg); }
.fb-group.collapsed .fb-group-body { display: none; }
.fb-group.collapsed .fb-group-header { border-bottom: none; }
.fb-lead { padding: 14px 16px; border-bottom: 1px solid rgba(148,163,184,0.06); background: rgba(15,23,42,0.3); transition: background 0.2s; }
.fb-lead:hover { background: rgba(15,23,42,0.5); }
.fb-lead:last-child { border-bottom: none; }
.fb-lead-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.fb-lead-name { font-size: 14px; font-weight: 700; color: #34d399; }
.fb-lead-date { font-size: 11px; color: #60a5fa; font-weight: 500; margin-left: 8px; }
.fb-lead-address { font-size: 11px; color: #fbbf24; margin-top: 2px; }
.fb-save-status { font-size: 10px; color: #34d399; opacity: 0; transition: opacity 0.3s; font-weight: 600; }
.fb-save-status.visible { opacity: 1; }
.fb-save-status.saving { color: #fbbf24; }
.fb-fields { display: flex; flex-direction: column; gap: 8px; }
.fb-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fb-notes { width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid rgba(148,163,184,0.12); background: rgba(15,23,42,0.8); color: #e2e8f0; font-size: 13px; font-family: inherit; resize: vertical; min-height: 38px; outline: none; transition: border-color 0.2s, box-shadow 0.2s; }
.fb-notes:focus { border-color: #d4a843; box-shadow: 0 0 0 2px rgba(212,168,67,0.15); }
.fb-checkbox-wrap { display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; white-space: nowrap; padding: 6px 12px; border-radius: 8px; background: rgba(34,197,94,0.06); border: 1px solid rgba(34,197,94,0.1); transition: all 0.2s; }
.fb-checkbox-wrap:hover { background: rgba(34,197,94,0.12); }
.fb-checkbox-wrap input[type="checkbox"] { width: 18px; height: 18px; accent-color: #22c55e; cursor: pointer; }
.fb-checkbox-label { font-size: 12px; color: #34d399; font-weight: 600; }
.fb-revenue { width: 110px; padding: 8px 10px; border-radius: 8px; border: 1px solid rgba(148,163,184,0.12); background: rgba(15,23,42,0.8); color: #e2e8f0; font-size: 13px; outline: none; transition: border-color 0.2s, box-shadow 0.2s; }
.fb-revenue:focus { border-color: #d4a843; box-shadow: 0 0 0 2px rgba(212,168,67,0.15); }
.fb-summary { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; padding: 14px 16px; background: linear-gradient(135deg, rgba(34,197,94,0.06), rgba(59,130,246,0.06)); border-radius: 12px; border: 1px solid rgba(34,197,94,0.1); }
.fb-stat { font-size: 13px; color: #94a3b8; display: flex; align-items: center; gap: 4px; }
.fb-stat strong { color: #fff; font-size: 15px; }
.fb-stat.closed strong { color: #34d399; }
.fb-stat.revenue strong { color: #d4a843; }

/* ═══ Toast ═══ */
.toast-container { position: fixed; bottom: 16px; left: 12px; right: 12px; z-index: 950; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 16px; border-radius: 12px; font-size: 12px; font-weight: 600; animation: fadeIn 0.3s ease-out; }
.toast-success { background: rgba(34,197,94,0.15); color: #34d399; border: 1px solid rgba(34,197,94,0.2); }
.toast-error { background: rgba(239,68,68,0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.2); }

/* ═══ Invite Button ═══ */
.btn-invite { display: inline-flex; align-items: center; gap: 4px; padding: 8px 14px; border-radius: 10px; border: 1px solid rgba(212,168,67,0.3); background: rgba(212,168,67,0.1); color: #d4a843; font-size: 11px; font-weight: 700; cursor: pointer; transition: all 0.2s; white-space: nowrap; min-height: 36px; }
.btn-invite:hover { background: rgba(212,168,67,0.2); border-color: rgba(212,168,67,0.5); }

/* ═══ Access List ═══ */
.access-list { margin-top: 10px; }
.access-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-radius: 8px; margin-bottom: 4px; gap: 8px; }
.access-row:hover { background: rgba(148,163,184,0.04); }
.access-email { font-size: 12px; color: #e2e8f0; word-break: break-all; }
.access-meta { font-size: 10px; color: #64748b; }
.btn-remove { font-size: 10px; color: #f87171; background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.15); border-radius: 8px; padding: 4px 10px; cursor: pointer; font-weight: 600; white-space: nowrap; min-height: 32px; }
.btn-remove:hover { background: rgba(239,68,68,0.2); }

/* ═══ Login Gate ═══ */
.login-gate { position: fixed; inset: 0; z-index: 999; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #020617, #0f172a, #020617); padding: 16px; }
.login-box { text-align: center; max-width: 360px; width: 100%; }
.login-logo { font-size: 24px; font-weight: 900; color: #fff; margin-bottom: 6px; }
.login-sub { font-size: 13px; color: #64748b; margin-bottom: 28px; }

/* ═══ Access Denied ═══ */
.denied-box { text-align: center; padding: 48px 20px; }
.denied-icon { font-size: 40px; margin-bottom: 12px; }
.denied-title { font-size: 18px; font-weight: 700; color: #fff; margin-bottom: 6px; }
.denied-msg { font-size: 13px; color: #64748b; line-height: 1.6; }

/* ═══ Loading ═══ */
.loading { text-align: center; padding: 60px 20px; color: #64748b; }
.spinner { width: 28px; height: 28px; border: 3px solid rgba(148,163,184,0.15); border-top-color: #d4a843; border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 14px; }
@keyframes spin { to { transform: rotate(360deg); } }
.fade-in { animation: fadeIn 0.3s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ═══════════════════════════════════════════════
   TABLET (480px+)
   ═══════════════════════════════════════════════ */
@media (min-width: 480px) {
  .container { padding: 20px 16px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-value { font-size: 22px; }
  .modal-overlay { align-items: center; padding: 16px; }
  .modal-box { border-radius: 16px; }
  .mobile-hide { display: table-cell; }
  .history-table, .lead-table { font-size: 13px; }
  .history-table th, .lead-table th { font-size: 10px; padding: 8px 10px; }
  .history-table td, .lead-table td { padding: 8px 10px; }
  .badge { font-size: 11px; padding: 3px 10px; }
  .header-sub { max-width: 320px; }
}

/* ═══════════════════════════════════════════════
   DESKTOP (768px+)
   ═══════════════════════════════════════════════ */
@media (min-width: 768px) {
  .container { padding: 24px; }
  .header { flex-direction: row; align-items: center; justify-content: space-between; padding: 20px 24px; margin-bottom: 24px; }
  .header-title { font-size: 20px; }
  .header-sub { max-width: none; }
  .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
  .kpi-card { padding: 16px 18px; border-radius: 14px; }
  .kpi-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.3); }
  .user-email { max-width: 240px; font-size: 11px; }
  .account-picker { width: auto; min-width: 220px; }
  .toast-container { left: auto; right: 24px; bottom: 24px; max-width: 360px; }
  .glass { border-radius: 16px; }
  .projection-disclaimer { font-size: 12px; }
}
