/* ═══════════════════════════════════════════════════════
   Audit Dashboard — Premium Dark Mode Design System
   ═══════════════════════════════════════════════════════ */

:root {
  /* Colors */
  --bg-base: #07070e;
  --bg-surface: #0d0d18;
  --bg-card: rgba(16, 16, 32, 0.65);
  --bg-card-hover: rgba(22, 22, 42, 0.75);
  --bg-input: rgba(12, 12, 26, 0.8);
  --border: rgba(99, 102, 241, 0.12);
  --border-focus: rgba(99, 102, 241, 0.4);
  --text-primary: #eaebf0;
  --text-secondary: #8b8fa3;
  --text-muted: #5a5e72;
  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.25);
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.15);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.15);
  --amber: #f59e0b;
  --amber-dim: rgba(245, 158, 11, 0.15);
  --cyan: #06b6d4;
  --purple: #a855f7;

  /* Typography */
  --font-sans: 'Inter', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;

  /* Spacing */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
}

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

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

body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Ambient background glow */
body::before {
  content: '';
  position: fixed;
  top: -30%;
  left: -10%;
  width: 60%;
  height: 60%;
  background: radial-gradient(ellipse, rgba(99, 102, 241, 0.06) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}
body::after {
  content: '';
  position: fixed;
  bottom: -20%;
  right: -10%;
  width: 50%;
  height: 50%;
  background: radial-gradient(ellipse, rgba(168, 85, 247, 0.04) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

.hidden { display: none !important; }
.mono { font-family: var(--font-mono); font-weight: 500; }

/* ═══ Login Screen ═══ */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.login-card {
  background: var(--bg-card);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  animation: fadeSlideUp 0.5s ease-out;
}

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

.login-icon {
  margin-bottom: 16px;
}

.login-header h1 {
  font-size: 1.7rem;
  font-weight: 700;
  background: linear-gradient(135deg, #eaebf0, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
}

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

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

.input-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.input-group input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-group input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-primary {
  width: 100%;
  padding: 13px 24px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity 0.2s, transform 0.15s;
  margin-top: 8px;
}

.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.login-error {
  color: var(--red);
  font-size: 0.85rem;
  text-align: center;
  margin-top: 16px;
  min-height: 20px;
}

/* ═══ Dashboard ═══ */
.dashboard {
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 7, 14, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.topbar-left h1 {
  font-size: 1.15rem;
  font-weight: 700;
  background: linear-gradient(135deg, #eaebf0, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

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

.topbar-user {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-ghost:hover {
  border-color: var(--red);
  color: var(--red);
  background: var(--red-dim);
}

/* ═══ Search ═══ */
.search-section {
  padding: 48px 32px 32px;
  display: flex;
  justify-content: center;
}

.search-container { width: 100%; max-width: 680px; }

.search-box {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 4px 4px 18px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow), 0 8px 32px rgba(0,0,0,0.3);
}

.search-icon { color: var(--text-muted); flex-shrink: 0; }

#email-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  padding: 14px 12px;
  outline: none;
  min-width: 0;
}

#email-input::placeholder { color: var(--text-muted); }

.btn-audit {
  padding: 12px 28px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-audit:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-audit:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ═══ Results ═══ */
.results {
  padding: 0 32px 64px;
  max-width: 1100px;
  margin: 0 auto;
  animation: fadeSlideUp 0.4s ease-out;
}

/* Verdict Banner */
.verdict-banner {
  text-align: center;
  padding: 32px 24px;
  margin-bottom: 32px;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
}

.verdict-badge-wrap { margin-bottom: 12px; }

.verdict-badge {
  display: inline-block;
  padding: 8px 24px;
  border-radius: 100px;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.verdict-badge.clean,
.verdict-badge.no_action_needed {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.verdict-badge.already_audited {
  background: rgba(6, 182, 212, 0.12);
  color: var(--cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.verdict-badge.needs_review,
.verdict-badge.phantom_credit {
  background: var(--amber-dim);
  color: var(--amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
  animation: pulse 2s ease-in-out infinite;
}

.verdict-badge.deficit_detected {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.3);
  animation: pulse 2s ease-in-out infinite;
}

.verdict-classification {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Cards Grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
}

.card:hover {
  border-color: rgba(99, 102, 241, 0.2);
  transform: translateY(-2px);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

.card-header h3 {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  flex: 1;
}

.card-body { padding: 20px; }

/* Info rows */
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

.info-row + .info-row { border-top: 1px solid rgba(99, 102, 241, 0.06); }

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

.info-value {
  font-size: 0.9rem;
  color: var(--text-primary);
  text-align: right;
  word-break: break-all;
  max-width: 60%;
}

/* Balance pair */
.balance-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.balance-item {
  text-align: center;
  padding: 16px;
  background: rgba(99, 102, 241, 0.04);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(99, 102, 241, 0.08);
}

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

.balance-value {
  display: block;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Data table */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 500;
  text-align: right;
  padding: 0 0 12px;
}

.data-table th:first-child { text-align: left; }

.data-table td {
  padding: 10px 0;
  font-size: 0.9rem;
  text-align: right;
  border-top: 1px solid rgba(99, 102, 241, 0.06);
}

.data-table td:first-child { text-align: left; }
.row-label { color: var(--text-secondary); font-weight: 500; }

.drift-row td { font-weight: 700; font-size: 1rem; }

.val-positive { color: var(--green); }
.val-negative { color: var(--red); }
.val-zero { color: var(--text-muted); }

/* Netting */
.netting-formula {
  background: rgba(99, 102, 241, 0.04);
  border: 1px solid rgba(99, 102, 241, 0.08);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.8;
}

.netting-result {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: rgba(99, 102, 241, 0.06);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(99, 102, 241, 0.12);
}

.netting-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.netting-value {
  font-size: 1.4rem;
  font-weight: 700;
}

/* Justification */
.card-justification {
  grid-column: 1 / -1;
}

.justification-text {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-secondary);
  padding: 16px 20px;
  border-left: 3px solid var(--accent);
  background: rgba(99, 102, 241, 0.04);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.btn-copy {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
}

.btn-copy:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.btn-copy.copied {
  border-color: var(--green);
  color: var(--green);
  background: var(--green-dim);
}

/* Prior audit content */
.prior-found {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  line-height: 1.6;
}

.prior-found.fixed {
  background: rgba(6, 182, 212, 0.08);
  border: 1px solid rgba(6, 182, 212, 0.2);
  color: var(--cyan);
}

.prior-found.no-action {
  background: var(--green-dim);
  border: 1px solid rgba(34, 197, 94, 0.2);
  color: var(--green);
}

.prior-not-found {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--amber-dim);
  border: 1px solid rgba(245, 158, 11, 0.2);
  color: var(--amber);
  font-size: 0.9rem;
}

/* ═══ Animations ═══ */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ═══ Responsive ═══ */
@media (max-width: 768px) {
  .topbar { padding: 12px 16px; }
  .search-section { padding: 24px 16px; }
  .results { padding: 0 16px 48px; }
  .cards-grid { grid-template-columns: 1fr; }
  .login-card { margin: 16px; padding: 32px 24px; }
  .balance-pair { grid-template-columns: 1fr; }
}
