/* ═══════════════════════════════════════════════════════════════════
   Stripe ↔ iFirma Dashboard — Dark Mode Design System
   ═══════════════════════════════════════════════════════════════════ */

:root {
  /* Colors */
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.8);
  --bg-card-hover: rgba(31, 41, 55, 0.9);
  --bg-glass: rgba(17, 24, 39, 0.6);

  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  --accent-blue: #3b82f6;
  --accent-blue-glow: rgba(59, 130, 246, 0.3);
  --accent-green: #10b981;
  --accent-green-glow: rgba(16, 185, 129, 0.3);
  --accent-red: #ef4444;
  --accent-red-glow: rgba(239, 68, 68, 0.3);
  --accent-yellow: #f59e0b;
  --accent-yellow-glow: rgba(245, 158, 11, 0.3);
  --accent-purple: #8b5cf6;
  --accent-purple-glow: rgba(139, 92, 246, 0.3);
  --accent-stripe: #635bff;
  --accent-ifirma: #22c55e;

  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Spacing */
  --radius: 12px;
  --radius-sm: 8px;

  /* Shadows */
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-glow: 0 0 40px rgba(59, 130, 246, 0.08);
}

/* ─── Reset ─────────────────────────────────────────────────────── */

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

[hidden] {
  display: none !important;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ─── Login Overlay ─────────────────────────────────────────────── */

.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3rem 2.5rem;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-card), var(--shadow-glow);
  backdrop-filter: blur(20px);
}

.login-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.login-card h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.login-card p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

.login-card input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 1rem;
}

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

.login-card button {
  width: 100%;
  padding: 0.75rem;
  background: var(--accent-blue);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.login-card button:hover {
  background: #2563eb;
}

.login-card button:active {
  transform: scale(0.98);
}

.login-error {
  color: var(--accent-red);
  font-size: 0.85rem;
  margin-top: 0.75rem;
}

/* ─── Dashboard Container ──────────────────────────────────────── */

.dashboard {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem 2rem;
  animation: fadeIn 0.4s ease;
}

/* ─── Header ────────────────────────────────────────────────────── */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.logo-stripe { color: var(--accent-stripe); }
.logo-arrow { color: var(--text-muted); margin: 0 0.15rem; }
.logo-ifirma { color: var(--accent-ifirma); }
.logo-brand { color: var(--text-primary); }

.header-badge {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.btn-logout:hover {
  color: var(--accent-red);
  border-color: var(--accent-red-glow);
}

.btn-icon.spinning svg {
  animation: spin 0.6s ease;
}

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

/* ─── Refresh Ring ──────────────────────────────────────────────── */

.refresh-indicator {
  position: relative;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.refresh-ring {
  position: absolute;
  width: 36px;
  height: 36px;
  transform: rotate(-90deg);
}

.refresh-ring-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 2;
}

.refresh-ring-fg {
  fill: none;
  stroke: var(--accent-blue);
  stroke-width: 2;
  stroke-dasharray: 100.53;
  stroke-dashoffset: 0;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear;
}

.refresh-timer {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  z-index: 1;
}

/* ─── Company Bar ───────────────────────────────────────────────── */

.company-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* ─── Cards ─────────────────────────────────────────────────────── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(12px);
  transition: border-color 0.3s, box-shadow 0.3s;
}

.card:hover {
  border-color: var(--border-hover);
}

/* Status Cards */
.status-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.status-card {
  padding: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.card-icon {
  font-size: 1.75rem;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
}

.card-content h3 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.card-content span {
  font-size: 0.95rem;
  font-weight: 500;
}

/* Status Dot */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.35rem;
  vertical-align: middle;
}

.status-dot.active {
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green-glow);
  animation: pulse 2s infinite;
}

.status-dot.inactive {
  background: var(--text-muted);
}

/* Stats Row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  padding: 1.25rem;
  text-align: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.25rem;
}

.stat-sub {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.35rem;
}

/* ─── Tables ────────────────────────────────────────────────────── */

.tables-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.table-card {
  padding: 1.25rem;
  overflow: hidden;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.table-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.table-counts {
  display: flex;
  gap: 0.5rem;
}

.count-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead th {
  text-align: left;
  padding: 0.65rem 0.75rem;
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  white-space: nowrap;
}

tbody tr {
  transition: background 0.15s;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

tbody tr:last-child td {
  border-bottom: none;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 0;
}

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
}

.badge-failed {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
}

.badge-progress {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
}

.badge-pending {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-yellow);
}

.badge-retry {
  background: rgba(139, 92, 246, 0.15);
  color: var(--accent-purple);
}

.mono {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ─── Footer ────────────────────────────────────────────────────── */

.footer {
  text-align: center;
  padding: 1rem 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

/* ─── Animations ────────────────────────────────────────────────── */

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

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

.fade-in {
  animation: fadeIn 0.35s ease;
}

/* ─── Loading Skeleton ──────────────────────────────────────────── */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-secondary) 25%,
    rgba(255, 255, 255, 0.04) 50%,
    var(--bg-secondary) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
  height: 1em;
  display: inline-block;
  width: 60px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── Responsive ────────────────────────────────────────────────── */

@media (max-width: 1024px) {
  .status-cards { grid-template-columns: repeat(2, 1fr); }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .tables-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .status-cards { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .header { flex-direction: column; gap: 0.75rem; }
  .dashboard { padding: 0 1rem 1.5rem; }
}
