/* ─────────────────────────────────────────────────────────────
   PALETA — valores validados (ver skill de dataviz del proyecto)
───────────────────────────────────────────────────────────── */
:root {
  --page:           #0d0d0d;
  --surface:        #1a1a19;
  --surface-raised: #212120;
  --border:         rgba(255,255,255,0.10);
  --gridline:       #2c2c2a;

  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #898781;

  --accent:         #3987e5; /* categórico slot 1 — azul, oscuro */
  --accent-dim:     #1c5cab;

  --good:           #0ca30c;
  --warning:        #fab219;
  --serious:        #ec835a;
  --critical:       #d03b3b;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: var(--font);
  min-height: 100vh;
}

button, input {
  font-family: inherit;
}

[hidden] { display: none !important; }

/* ─────────────────────────────────────────────────────────────
   LOGIN
───────────────────────────────────────────────────────────── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background:
    radial-gradient(circle at 20% 20%, rgba(57,135,229,0.15), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(12,163,12,0.10), transparent 40%),
    var(--page);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.login-logo { font-size: 40px; }
.login-card h1 { margin: 0; font-size: 22px; }
.login-sub { margin: -8px 0 8px; color: var(--text-muted); font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; }

.login-card input {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  outline: none;
}
.login-card input:focus { border-color: var(--accent); }

.login-card button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.login-card button:hover { background: var(--accent-dim); }

.login-error { color: var(--critical); font-size: 13px; margin: 0; }

/* ─────────────────────────────────────────────────────────────
   LAYOUT GENERAL
───────────────────────────────────────────────────────────── */
.app { min-height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.brand-icon { font-size: 20px; }

.tabs { display: flex; gap: 4px; margin-left: 8px; }
.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}
.tab-btn:hover { background: var(--surface-raised); }
.tab-btn.active { background: var(--accent); color: #fff; }

.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.conn-indicator {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-muted);
}
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.conn-indicator.conn-connected .conn-dot { background: var(--good); box-shadow: 0 0 6px var(--good); }
.conn-indicator.conn-connected { color: var(--good); }
.conn-indicator.conn-connecting .conn-dot { background: var(--warning); }
.conn-indicator.conn-connecting { color: var(--warning); }

.icon-btn {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text-primary);
  width: 36px; height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { border-color: var(--accent); }
.icon-btn.muted { opacity: 0.5; }

.content {
  padding: 28px 32px;
  max-width: 1440px;
  margin: 0 auto;
  font-size: 15px;
}

.view { display: block; }

/* ─────────────────────────────────────────────────────────────
   STAT CARDS
───────────────────────────────────────────────────────────── */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 26px 24px;
}
.stat-card--accent { border-color: rgba(57,135,229,0.4); background: linear-gradient(180deg, rgba(57,135,229,0.10), var(--surface)); }

.stat-label { color: var(--text-muted); font-size: 14px; margin-bottom: 8px; }
.stat-value { font-size: 38px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-sub { color: var(--text-secondary); font-size: 14px; margin-top: 6px; }

/* ─────────────────────────────────────────────────────────────
   PANELS
───────────────────────────────────────────────────────────── */
.panel-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 16px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
}

.panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}
.panel-header h2 { margin: 0; font-size: 18px; font-weight: 700; }
.panel-header.standalone { margin-bottom: 18px; }
.panel-hint { color: var(--text-muted); font-size: 13px; }

.chart-wrap { height: 400px; position: relative; }

/* ─────────────────────────────────────────────────────────────
   FEED EN VIVO
───────────────────────────────────────────────────────────── */
.feed-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 420px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.feed-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  border: 1px solid var(--border);
}
.feed-item.is-new { animation: feed-flash 1.4s ease-out; }
@keyframes feed-flash {
  0%   { background: rgba(57,135,229,0.35); border-color: var(--accent); }
  100% { background: var(--surface-raised); }
}

.feed-badge {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0;
}
.feed-badge.matched { background: var(--good); }
.feed-badge.pending { background: var(--warning); }
.feed-badge.expired { background: var(--critical); }

.feed-status.matched { color: var(--good); }
.feed-status.pending { color: var(--warning); }
.feed-status.expired { color: var(--critical); }

.feed-main { flex: 1; min-width: 0; }
.feed-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-time { font-size: 12px; color: var(--text-muted); }
.feed-amount { font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }

.feed-empty { color: var(--text-muted); font-size: 13px; text-align: center; padding: 30px 0; }

.feed-search { display: flex; align-items: center; gap: 8px; }
.feed-search input {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  width: 170px;
  outline: none;
}
.feed-search input:focus { border-color: var(--accent); }
.icon-btn-sm {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 13px;
  flex-shrink: 0;
}
.icon-btn-sm:hover { border-color: var(--critical); color: var(--critical); }

/* ─────────────────────────────────────────────────────────────
   HISTORIAL
───────────────────────────────────────────────────────────── */
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}
.history-table th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--gridline);
}
.history-table td {
  padding: 15px 14px;
  border-bottom: 1px solid var(--gridline);
  font-variant-numeric: tabular-nums;
}
.history-table tr:last-child td { border-bottom: none; }
.history-table tr:hover td { background: var(--surface-raised); cursor: pointer; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge.auto   { background: rgba(12,163,12,0.15); color: var(--good); }
.badge.manual { background: rgba(250,178,25,0.15); color: var(--warning); }
.badge.none   { background: rgba(137,135,129,0.15); color: var(--text-muted); }

.row-delete-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
}
.row-delete-btn:hover { color: var(--critical); }

/* ─────────────────────────────────────────────────────────────
   MODALES
───────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-card--wide { max-width: 480px; max-height: 80vh; }

.modal-card h3 { margin: 0 0 4px; }

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.modal-head h3 { margin: 0; }

.modal-x {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  margin: -4px -4px 0 0;
  flex-shrink: 0;
}
.modal-x:hover { color: var(--text-primary); }

.modal-scroll-body {
  overflow-y: auto;
  max-height: calc(80vh - 90px);
  margin: 0 -8px;
  padding: 0 8px;
}

.modal-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}
.modal-card input {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
}
.modal-card input:focus { border-color: var(--accent); }

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

.btn-primary, .btn-secondary {
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dim); }
.btn-secondary { background: var(--surface-raised); color: var(--text-primary); border: 1px solid var(--border); }

.day-detail-row {
  display: flex; justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--gridline);
  font-size: 13px;
}
.day-detail-row small { color: var(--text-muted); font-size: 11px; }
.day-detail-row:last-child { border-bottom: none; }

/* ─────────────────────────────────────────────────────────────
   RESPONSIVE
───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .panel-grid { grid-template-columns: 1fr; }
  .stat-cards { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .content { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .tabs { order: 3; width: 100%; margin-left: 0; }
  .history-table { display: block; overflow-x: auto; white-space: nowrap; }
}
