/* ============================================
   HealthSec Stats - Estilos
   ============================================ */

:root {
  --bg-deep:    #0a0e1a;
  --bg-mid:     #111827;
  --bg-light:   #f8fafc;
  --bg-card:    #ffffff;
  --cyan:       #00d9ff;
  --green:      #10b981;
  --green-dark: #059669;
  --text:       #1f2937;
  --text-mid:   #4b5563;
  --text-light: #6b7280;
  --text-inv:   #f3f4f6;
  --text-inv-2: #9ca3af;
  --border:     #e5e7eb;
  --border-dark:#1f2937;
  --critical:   #dc2626;
  --shadow:     0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg:  0 10px 25px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-light);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
}

.wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ===== Header ===== */
.stats-header {
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border-dark);
  position: sticky;
  top: 0;
  z-index: 100;
}

.stats-header .wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1rem;
  padding-bottom: 1rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text-inv);
}

.brand-icon {
  font-size: 1.5rem;
}

.brand-name {
  background: linear-gradient(135deg, var(--cyan), var(--green));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  background: var(--critical);
  color: white;
  border-radius: 3px;
  letter-spacing: 0.1em;
  font-weight: 700;
}

.stats-header nav {
  display: flex;
  gap: 1.25rem;
}

.stats-header nav a {
  color: var(--text-inv-2);
  font-size: 0.95rem;
  text-decoration: none;
  transition: color 0.2s;
}

.stats-header nav a:hover {
  color: var(--cyan);
}

.stats-header nav a.logout {
  color: var(--critical);
}

/* ===== Main ===== */
main {
  padding: 2rem 0;
}

.page-title {
  font-size: 2rem;
  margin: 0 0 0.5rem 0;
  color: var(--text);
}

.page-subtitle {
  color: var(--text-light);
  margin: 0 0 2rem 0;
}

/* ===== KPI Cards ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 3rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--cyan), var(--green));
}

.kpi-label {
  font-size: 0.85rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.kpi-value {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 0.5rem;
  line-height: 1;
}

.kpi-detail {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.kpi-tag {
  font-size: 0.75rem;
  padding: 0.15rem 0.55rem;
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-mid);
}

.kpi-tag.kpi-free {
  background: rgba(0, 217, 255, 0.1);
  border-color: rgba(0, 217, 255, 0.3);
  color: #006680;
}

.kpi-tag.kpi-premium {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--green-dark);
  font-weight: 700;
}

/* ===== Charts ===== */
.charts-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.charts-section h2 {
  font-size: 1.1rem;
  margin: 0 0 1.25rem 0;
  color: var(--text);
  font-weight: 700;
}

.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 768px) {
  .charts-row { grid-template-columns: 1fr; }
}

.chart-container {
  position: relative;
  height: 280px;
}

.chart-container.chart-small {
  height: 220px;
}

/* ===== Tables ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.data-table th {
  background: var(--bg-light);
  padding: 0.65rem 0.85rem;
  text-align: left;
  font-weight: 700;
  color: var(--text);
  border-bottom: 2px solid var(--border);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.data-table td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-mid);
}

.data-table tr:hover td {
  background: var(--bg-light);
}

.data-table td code {
  background: rgba(0, 217, 255, 0.08);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  font-size: 0.88em;
  color: var(--cyan);
  border: 1px solid rgba(0, 217, 255, 0.2);
}

.data-table td.empty {
  text-align: center;
  color: var(--text-light);
  padding: 2rem;
  font-style: italic;
}

.truncate {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nowrap {
  white-space: nowrap;
}

.status {
  font-size: 0.75rem;
  padding: 0.15rem 0.55rem;
  border-radius: 3px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.status-confirmed {
  background: rgba(16, 185, 129, 0.15);
  color: var(--green-dark);
}

.status-pending {
  background: rgba(234, 179, 8, 0.15);
  color: #92400e;
}

.status-unsubscribed {
  background: rgba(220, 38, 38, 0.15);
  color: var(--critical);
}

/* ===== Login ===== */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 200px);
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

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

.login-card h1 {
  margin: 0 0 0.5rem 0;
  font-size: 1.5rem;
  color: var(--text);
}

.login-subtitle {
  color: var(--text-light);
  margin: 0 0 2rem 0;
}

.form-group {
  margin-bottom: 1rem;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-mid);
  margin-bottom: 0.4rem;
}

.form-group input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  background: var(--bg-light);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0, 217, 255, 0.15);
}

.btn-primary {
  display: inline-block;
  width: 100%;
  padding: 0.85rem 1.5rem;
  background: linear-gradient(135deg, var(--cyan), #0099bb);
  color: var(--bg-deep);
  border: none;
  border-radius: 6px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  margin-top: 0.5rem;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 217, 255, 0.3);
}

.login-foot {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-light);
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.alert-error {
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(220, 38, 38, 0.3);
  color: var(--critical);
}

/* ===== Error pages ===== */
.error-page {
  text-align: center;
  padding: 4rem 1rem;
}

.error-page h1 {
  font-size: 6rem;
  margin: 0;
  background: linear-gradient(135deg, var(--cyan), var(--green));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.error-page p {
  color: var(--text-light);
  margin: 1rem 0 2rem 0;
}

.error-page .btn-primary {
  width: auto;
  display: inline-block;
  padding: 0.75rem 2rem;
}

/* ===== Footer ===== */
.stats-footer {
  background: var(--bg-deep);
  color: var(--text-inv-2);
  padding: 1.5rem 0;
  text-align: center;
  font-size: 0.85rem;
  margin-top: 4rem;
}
