/* ==============================================================================
   Kelly Mortgage Specialist - Admin Dashboard Stylesheet
   Modern Executive Dark / Navy Slate Theme
   ============================================================================== */

:root {
  --bg-app: #0b0f19;
  --bg-card: #111827;
  --bg-subtle: #1e293b;
  --bg-input: #0f172a;
  
  --border-color: #1f2937;
  --border-subtle: #334155;
  --border-focus: #3b82f6;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-glow: rgba(37, 99, 235, 0.25);

  --emerald: #10b981;
  --emerald-subtle: rgba(16, 185, 129, 0.15);
  
  --blue: #38bdf8;
  --blue-subtle: rgba(56, 189, 248, 0.15);

  --amber: #f59e0b;
  --amber-subtle: rgba(245, 158, 11, 0.15);

  --red: #ef4444;
  --red-subtle: rgba(239, 68, 68, 0.15);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, Monaco, monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.5);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Login Page Styles
   ========================================================================== */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(circle at top, #1e293b 0%, #0b0f19 70%);
  padding: 20px;
}

.login-container {
  width: 100%;
  max-width: 480px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.login-header {
  text-align: center;
  margin-bottom: 30px;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(37, 99, 235, 0.12);
  border: 1px solid rgba(37, 99, 235, 0.3);
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #60a5fa;
  margin-bottom: 16px;
}

.brand-dot {
  width: 7px;
  height: 7px;
  background: #3b82f6;
  border-radius: 50%;
  box-shadow: 0 0 8px #3b82f6;
}

.login-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 14px 20px;
  background: #ffffff;
  color: #1f2937;
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.btn-google:hover {
  background: #f1f5f9;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

.btn-disabled {
  opacity: 0.5;
  pointer-events: none;
}

.login-footer-info {
  margin-top: 30px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
  font-size: 0.8rem;
}

.allowed-accounts-title {
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 500;
}

.allowed-accounts-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.allowed-accounts-list code {
  background: var(--bg-subtle);
  color: #38bdf8;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.auth-security-note {
  color: var(--text-dim);
  font-size: 0.75rem;
  line-height: 1.4;
}

/* ==========================================================================
   Admin Global Header & Navigation
   ========================================================================== */
.admin-body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  background: #0d1322;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 68px;
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.brand-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-accent {
  width: 10px;
  height: 24px;
  background: linear-gradient(180deg, #3b82f6 0%, #1d4ed8 100%);
  border-radius: 3px;
}

.brand-name {
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: 0.05em;
  color: #fff;
}

.brand-sub {
  font-size: 0.75rem;
  font-weight: 600;
  color: #38bdf8;
  margin-left: 4px;
}

.header-env-tag {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 4px;
}

.header-tabs {
  display: flex;
  gap: 8px;
  height: 100%;
  align-items: center;
}

.nav-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  height: 42px;
}

.nav-tab .tab-icon {
  width: 18px;
  height: 18px;
  opacity: 0.7;
}

.nav-tab:hover {
  color: #fff;
  background: var(--bg-subtle);
}

.nav-tab.active {
  color: #fff;
  background: rgba(37, 99, 235, 0.2);
  border: 1px solid rgba(37, 99, 235, 0.4);
}

.nav-tab.active .tab-icon {
  color: #60a5fa;
  opacity: 1;
}

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

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

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
}

.user-avatar-initial {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}

.user-details {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
}

.user-email {
  font-size: 0.72rem;
  color: var(--text-dim);
}

/* ==========================================================================
   Main App Container & Tab Panes
   ========================================================================== */
.app-main {
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 30px 24px 60px 24px;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: fadeIn 0.2s ease-in-out;
}

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

.page-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title-row h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

.section-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Buttons & Form Controls
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 0 14px var(--primary-glow);
}

.btn-secondary {
  background: var(--bg-subtle);
  color: #e2e8f0;
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  background: #283548;
  color: #fff;
}

.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border-subtle);
}

.btn-outline:hover {
  background: var(--bg-subtle);
  color: #fff;
}

.btn-outline-danger {
  background: transparent;
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-outline-danger:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 0.75rem;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 0.95rem;
}

/* ==========================================================================
   Tab 1: Collector & Action Cards & Terminal
   ========================================================================== */
.collector-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 0.82rem;
  font-weight: 600;
}

.status-indicator-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #64748b;
}

.status-indicator-dot.running {
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.6; }
  100% { transform: scale(1); opacity: 1; }
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.action-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-card);
}

.action-card-header {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}

.action-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.action-icon svg {
  width: 24px;
  height: 24px;
}

.action-icon.bg-blue {
  background: rgba(37, 99, 235, 0.2);
  color: #60a5fa;
  border: 1px solid rgba(37, 99, 235, 0.3);
}

.action-icon.bg-emerald {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.action-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
}

.action-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Terminal Console */
.terminal-container {
  background: #030712;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
}

.terminal-toolbar {
  background: #0f172a;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #1e293b;
}

.terminal-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.term-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
}

.dot-red { background: #ef4444; }
.dot-yellow { background: #f59e0b; }
.dot-green { background: #10b981; }

.terminal-title {
  margin-left: 8px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.terminal-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
}

.terminal-screen {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  padding: 18px;
  height: 480px;
  overflow-y: auto;
  color: #e2e8f0;
  white-space: pre-wrap;
  word-break: break-all;
}

.term-line.info { color: #38bdf8; }
.term-line.success { color: #34d399; }
.term-line.warning { color: #fbbf24; }
.term-line.error { color: #f87171; }

/* ==========================================================================
   Tab 2: Rates Viewer & KPIs
   ========================================================================== */
.rates-controls-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.control-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.input-date {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  padding: 7px 12px;
  border-radius: var(--radius-md);
  outline: none;
}

.input-date:focus {
  border-color: var(--border-focus);
}

.toggle-group {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}

.toggle-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.toggle-btn.active {
  background: var(--primary);
  color: #fff;
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
}

.kpi-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 4px;
}

.kpi-sub {
  font-size: 0.78rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.text-emerald { color: #10b981; }
.text-blue { color: #38bdf8; }

/* Table Toolbar */
.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 16px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  width: 320px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-dim);
}

.input-search {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 12px 8px 36px;
  color: #fff;
  font-size: 0.85rem;
  outline: none;
}

.input-search:focus {
  border-color: var(--border-focus);
}

.filter-pills {
  display: flex;
  gap: 6px;
}

.pill-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pill-btn:hover {
  background: var(--bg-subtle);
  color: #fff;
}

.pill-btn.active {
  background: rgba(37, 99, 235, 0.2);
  border-color: #3b82f6;
  color: #60a5fa;
}

/* Data Table */
.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.data-table th {
  background: #0d1424;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  color: #e2e8f0;
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.data-table .text-right { text-align: right; }
.data-table .text-center { text-align: center; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-owner {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-investment {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.best-rate-tag {
  color: #34d399;
  font-weight: 700;
}

/* ==========================================================================
   Tab 3: Spreadsheet Overwrite Editor
   ========================================================================== */
.editor-header-actions {
  display: flex;
  gap: 10px;
}

.spreadsheet-container {
  margin-top: 16px;
  margin-bottom: 24px;
}

.spreadsheet-table input.cell-input {
  width: 100%;
  background: #090d16;
  border: 1px solid #273549;
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 8px 10px;
  text-align: right;
  outline: none;
  transition: all 0.15s ease;
}

.spreadsheet-table input.cell-input:focus {
  border-color: #3b82f6;
  background: #0f172a;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.spreadsheet-table input.cell-input.dirty {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.08);
}

.btn-clear-row {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-dim);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.75rem;
}

.btn-clear-row:hover {
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.4);
}

.editor-bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 24px;
}

.changes-count-badge {
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 500;
}

.changes-count-badge.has-changes {
  color: #fbbf24;
  font-weight: 700;
}

/* ==========================================================================
   Alerts & Notifications
   ========================================================================== */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  font-size: 0.85rem;
  line-height: 1.4;
}

.alert-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}

.alert-danger {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.alert-warning {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fcd34d;
}

.alert-info {
  background: rgba(37, 99, 235, 0.12);
  border: 1px solid rgba(37, 99, 235, 0.3);
  color: #93c5fd;
}

.alert-content strong {
  display: block;
  font-weight: 700;
  margin-bottom: 2px;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: #1e293b;
  color: #fff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-size: 0.85rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.25s ease-out;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.toast-success {
  border-color: #10b981;
  background: #064e3b;
  color: #a7f3d0;
}

.toast.toast-error {
  border-color: #ef4444;
  background: #7f1d1d;
  color: #fecaca;
}

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