/* PushFlow — panel de administración */

:root {
  color-scheme: light;
  --plane:          #f9f9f7;
  --surface-1:      #fcfcfb;
  --surface-2:      #f2f2ef;
  --border:         #e3e3de;
  --border-strong:  #cfcfc8;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #86857e;

  --accent:         #2a78d6;
  --accent-hover:   #1c5cab;
  --accent-soft:    #e8f0fc;

  /* Paleta categórica validada (orden fijo, nunca ciclado) */
  --series-1: #2a78d6;   /* enviadas  */
  --series-2: #eb6834;   /* recibidas */
  --series-3: #1baf7a;   /* clics     */
  --series-4: #eda100;

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

  --grid:     #ebebe6;

  --radius:   10px;
  --radius-lg: 14px;
  --shadow:   0 1px 2px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --plane:          #0d0d0d;
    --surface-1:      #1a1a19;
    --surface-2:      #232322;
    --border:         #302f2d;
    --border-strong:  #45443f;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #8d8c84;
    --accent:         #3987e5;
    --accent-hover:   #5598e7;
    --accent-soft:    #17293f;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --grid:     #2a2a28;
    --shadow:   0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane: #0d0d0d; --surface-1: #1a1a19; --surface-2: #232322;
  --border: #302f2d; --border-strong: #45443f;
  --text-primary: #ffffff; --text-secondary: #c3c2b7; --text-muted: #8d8c84;
  --accent: #3987e5; --accent-hover: #5598e7; --accent-soft: #17293f;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --grid: #2a2a28;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--plane); color: var(--text-primary);
  font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }

/* --- Estructura ---------------------------------------------------------- */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface-1); border-right: 1px solid var(--border);
  padding: 18px 14px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 9px; padding: 4px 8px 18px; font-weight: 700; font-size: 16px; }
.brand span.logo { font-size: 20px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--text-secondary); cursor: pointer; font-weight: 500; border: 0;
  background: none; width: 100%; text-align: left; font-size: 13.5px; font-family: inherit;
}
.nav-item:hover { background: var(--surface-2); color: var(--text-primary); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); padding: 16px 10px 6px; font-weight: 600; }
.main { padding: 24px 28px 60px; max-width: 1280px; width: 100%; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--text-secondary); }

/* --- Tarjetas ------------------------------------------------------------ */
.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: 14px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* --- Cifras -------------------------------------------------------------- */
.stat { background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px 18px; }
.stat .label { color: var(--text-secondary); font-size: 12.5px; font-weight: 500; }
.stat .value { font-size: 30px; font-weight: 650; letter-spacing: -0.025em; margin-top: 6px; line-height: 1.1; }
.stat .sub { color: var(--text-muted); font-size: 12px; margin-top: 4px; }

/* --- Formularios --------------------------------------------------------- */
label { display: block; font-weight: 500; font-size: 13px; margin-bottom: 5px; color: var(--text-secondary); }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border-strong);
  border-radius: 8px; background: var(--surface-1); color: var(--text-primary);
  font: inherit; font-size: 13.5px;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent);
}
textarea { resize: vertical; min-height: 76px; }
.field { margin-bottom: 14px; }
.field .hint { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.check input { width: auto; }
.check label { margin: 0; color: var(--text-primary); font-weight: 400; }

button, .btn {
  padding: 9px 15px; border-radius: 8px; border: 1px solid transparent;
  background: var(--accent); color: #fff; font: inherit; font-size: 13.5px;
  font-weight: 600; cursor: pointer; white-space: nowrap;
}
button:hover, .btn:hover { background: var(--accent-hover); text-decoration: none; }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: var(--surface-1); color: var(--text-primary); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--critical); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

/* --- Tablas -------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--text-secondary); font-size: 12px;
  text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px;
  border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* --- Etiquetas de estado ------------------------------------------------- */
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px;
  border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--surface-2);
  color: var(--text-secondary); }
.tag.ok   { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); }
.tag.warn { background: color-mix(in srgb, var(--warning) 20%, transparent); color: #8a6100; }
.tag.err  { background: color-mix(in srgb, var(--critical) 14%, transparent); color: var(--critical); }
.tag.info { background: var(--accent-soft); color: var(--accent); }

/* --- Gráficos ------------------------------------------------------------ */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12.5px;
  color: var(--text-secondary); }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.tooltip {
  position: absolute; pointer-events: none; background: var(--surface-1);
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px;
  box-shadow: var(--shadow); font-size: 12.5px; z-index: 10; min-width: 130px;
  opacity: 0; transition: opacity .12s;
}
.tooltip.show { opacity: 1; }
.tooltip .tt-title { font-weight: 600; margin-bottom: 5px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tooltip .tt-row b { font-variant-numeric: tabular-nums; }
.tt-key { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); }

/* --- Utilidades ---------------------------------------------------------- */
.muted { color: var(--text-muted); }
.small { font-size: 12.5px; }
.mt { margin-top: 16px; } .mb { margin-bottom: 16px; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex-between { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.empty { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty .icon { font-size: 34px; display: block; margin-bottom: 10px; }
.snippet { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; overflow-x: auto; white-space: pre; font-family: var(--mono);
  font-size: 12.5px; line-height: 1.6; }
.toast { position: fixed; bottom: 22px; right: 22px; z-index: 100;
  background: var(--text-primary); color: var(--plane); padding: 12px 18px;
  border-radius: 10px; box-shadow: var(--shadow); font-weight: 500;
  animation: slide-up .22s ease; max-width: 380px; }
.toast.error { background: var(--critical); color: #fff; }
@keyframes slide-up { from { opacity: 0; transform: translateY(10px); } }

/* --- Acceso -------------------------------------------------------------- */
.login-wrap { display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { justify-content: center; font-size: 20px; }

/* --- Vista previa de notificación ---------------------------------------- */
.preview { background: var(--surface-2); border-radius: var(--radius-lg); padding: 20px; }
.preview-note {
  background: var(--surface-1); border-radius: 10px; box-shadow: var(--shadow);
  overflow: hidden; max-width: 380px; margin: 0 auto; border: 1px solid var(--border);
}
.preview-note .pn-head { display: flex; gap: 10px; padding: 12px 14px; align-items: flex-start; }
.preview-note .pn-icon { width: 40px; height: 40px; border-radius: 8px; background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center; font-size: 20px; flex: none;
  object-fit: cover; }
.preview-note .pn-title { font-weight: 600; font-size: 14px; word-break: break-word; }
.preview-note .pn-body { color: var(--text-secondary); font-size: 13px; margin-top: 2px;
  word-break: break-word; }
.preview-note .pn-site { color: var(--text-muted); font-size: 11.5px; margin-top: 5px; }
.preview-note .pn-image { width: 100%; display: block; max-height: 160px; object-fit: cover; }
.preview-note .pn-actions { display: flex; border-top: 1px solid var(--border); }
.preview-note .pn-actions button { flex: 1; background: none; color: var(--accent);
  border: 0; border-right: 1px solid var(--border); padding: 9px; font-size: 12.5px; }
.preview-note .pn-actions button:last-child { border-right: 0; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; overflow-x: auto;
    align-items: center; padding: 10px; }
  .brand { padding: 0 12px 0 4px; } .nav-section { display: none; }
  .nav-item { width: auto; white-space: nowrap; }
  .main { padding: 16px; }
}
