:root {
  --rosa: #FF98E1;
  --rosa-int: #DF2BBB;
  --amarillo: #FFE948;
  --bg: #0A0A0A;
  --panel: #1A1A1A;
  --panel-2: #242424;
  --text: #F5F5F5;
  --muted: #9a9a9a;
  --border: #2e2e2e;
  --error: #ff5d7a;
  --ok: #6bffb3;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.87, 0, 0.13, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: radial-gradient(ellipse at 50% 0%, rgba(255,152,225,0.07) 0%, transparent 60%), var(--bg); color: var(--text); font-family: 'Lexend', system-ui, sans-serif; min-height: 100vh; }

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--error); min-height: 1.2em; margin: 0.5rem 0 0; font-size: 0.9rem; }

.brand { font-family: 'Anton', sans-serif; letter-spacing: 0.04em; text-transform: uppercase; color: var(--rosa); margin: 0; animation: logoPulse 3s ease-in-out infinite; }

button { cursor: pointer; font-family: inherit; }
.btn-primary {
  background: var(--rosa); color: #111; border: none; padding: 0.7rem 1.1rem;
  font-family: 'Anton', sans-serif; letter-spacing: 0.05em; text-transform: uppercase;
  border-radius: 6px; font-size: 0.95rem; transition: background 0.15s;
}
.btn-primary:hover { background: var(--rosa-int); color: #fff; }
.btn-ghost {
  background: transparent; color: var(--text); border: 1px solid var(--border);
  padding: 0.4rem 0.8rem; border-radius: 6px; font-size: 0.85rem;
}
.btn-ghost:hover { border-color: var(--rosa); color: var(--rosa); }
.btn-danger { background: transparent; color: var(--error); border: none; font-size: 0.85rem; }

input, select {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  padding: 0.6rem 0.8rem; border-radius: 6px; font-family: inherit; font-size: 0.95rem;
}
input:focus, select:focus { outline: none; border-color: var(--rosa); }

/* LOGIN */
#view-login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-card { background: var(--panel); padding: 2.5rem; border-radius: 10px; width: 100%; max-width: 380px; border: 1px solid var(--border); }
.login-card h1 { font-size: 2rem; margin-bottom: 0.3rem; }
.login-card form { display: flex; flex-direction: column; gap: 0.8rem; margin-top: 1.5rem; }

/* APP */
.topbar {
  display: flex; align-items: center; gap: 2rem; padding: 1rem 2rem;
  background: var(--panel); border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.topbar .brand { font-size: 1.5rem; }
.tabs { display: flex; gap: 0.3rem; flex: 1; flex-wrap: wrap; }
.tab {
  background: transparent; color: var(--muted); border: none; padding: 0.6rem 1rem;
  font-family: 'Anton', sans-serif; letter-spacing: 0.05em; text-transform: uppercase;
  font-size: 0.95rem; border-radius: 6px; transition: all 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--panel-2); color: var(--rosa); }
.user-box { display: flex; align-items: center; gap: 0.8rem; font-size: 0.9rem; color: var(--muted); }

.content { padding: 2rem; max-width: 1400px; margin: 0 auto; }
.panel { animation: fade 0.2s; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  margin: 1.5rem 0 1rem; flex-wrap: wrap; gap: 1rem;
}
.panel-head h2 { font-family: 'Anton', sans-serif; letter-spacing: 0.04em; text-transform: uppercase; margin: 0; font-size: 1.4rem; }
.row-gap { display: flex; gap: 0.6rem; flex-wrap: wrap; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 1rem 1.2rem; }
.kpi span { display: block; color: var(--muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; }
.kpi strong { display: block; font-family: 'Anton', sans-serif; font-size: 1.8rem; margin-top: 0.3rem; }
.kpi-hi { background: linear-gradient(135deg, var(--rosa) 0%, var(--rosa-int) 100%); color: #111; border-color: transparent; }
.kpi-hi span { color: #111; opacity: 0.7; }

/* Charts */
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }
.chart-card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; min-height: 280px; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 0.7rem 0.9rem; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: var(--panel-2); color: var(--muted); font-weight: 500; text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.05em; }
tbody tr:hover { background: rgba(255, 152, 225, 0.05); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Forms inline */
.form-inline { display: flex; gap: 0.6rem; flex-wrap: wrap; background: var(--panel); padding: 1rem; border-radius: 8px; border: 1px solid var(--border); margin-bottom: 1rem; }
.form-inline input, .form-inline select { flex: 1; min-width: 140px; }

/* ── OJO CONTRASEÑA ── */
.pass-wrap { position: relative; }
.pass-wrap input { padding-right: 44px; width: 100%; }
.btn-ojo { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: #666; padding: 4px; display: flex; align-items: center; }
.btn-ojo:hover { color: #FF98E1; }
.link-olvide { display: block; width: 100%; text-align: center; margin-top: 14px; font-size: 13px; color: #666; cursor: pointer; background: none; border: none; font-family: inherit; text-decoration: underline; }
.link-olvide:hover { color: #FF98E1; }

/* ── EMIL KOWALSKI UI POLISH ── */
@keyframes logoPulse {
  0%, 100% { text-shadow: 0 0 8px rgba(255,152,225,0.3); }
  50% { text-shadow: 0 0 20px rgba(255,152,225,0.6), 0 0 40px rgba(255,152,225,0.2); }
}

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

.btn-primary {
  transition: background 0.15s, transform 0.15s var(--ease-out), box-shadow 0.15s;
}
.btn-primary:active { transform: scale(0.97); }

.btn-ghost {
  transition: border-color 0.15s, color 0.15s, transform 0.15s var(--ease-out);
}
.btn-ghost:active { transform: scale(0.97); }

.kpi { animation: fadeUp 0.5s var(--ease-out) both; }
.kpi:nth-child(2) { animation-delay: 0.06s; }
.kpi:nth-child(3) { animation-delay: 0.12s; }
.kpi:nth-child(4) { animation-delay: 0.18s; }
.kpi:nth-child(5) { animation-delay: 0.24s; }
.kpi:nth-child(6) { animation-delay: 0.30s; }
.chart-card { animation: fadeUp 0.5s var(--ease-out) 0.2s both; }

@media (hover: none) {
  .btn-primary:hover { background: var(--rosa); color: #111; }
  .btn-ghost:hover { border-color: var(--border); color: var(--text); }
  .tab:hover { color: var(--muted); }
  tbody tr:hover { background: transparent; }
  .btn-ojo:hover { color: #666; }
  .link-olvide:hover { color: #666; }
}

@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { background: var(--rosa-int); color: #fff; }
  .btn-ghost:hover { border-color: var(--rosa); color: var(--rosa); }
  .tab:hover { color: var(--text); }
  tbody tr:hover { background: rgba(255, 152, 225, 0.05); }
  .btn-ojo:hover { color: #FF98E1; }
  .link-olvide:hover { color: #FF98E1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── CALENDARIO + MODAL (sesión 2) ─── */
.filter { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); padding: 0.5rem 0.7rem; border-radius: 6px; font-family: inherit; font-size: 0.9rem; }
.filter:focus { outline: none; border-color: var(--rosa); }

.badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.75rem; font-weight: 500; letter-spacing: 0.03em; text-transform: uppercase; }
.badge-idea       { background: rgba(154,154,154,0.2); color: #c5c5c5; }
.badge-redactando { background: rgba(255,217,87,0.15); color: #ffd957; }
.badge-aprobado   { background: rgba(107,255,179,0.15); color: var(--ok); }
.badge-programado { background: rgba(85,170,255,0.18); color: #6db8ff; }
.badge-publicado  { background: rgba(255,152,225,0.18); color: var(--rosa); }
.badge-cancelado  { background: rgba(255,93,122,0.15); color: var(--error); }

.cal-row-btn { background: transparent; border: 1px solid var(--border); color: var(--muted); padding: 0.3rem 0.7rem; border-radius: 5px; font-size: 0.8rem; cursor: pointer; }
.cal-row-btn:hover { color: var(--rosa); border-color: var(--rosa); }
.cal-caption-cell { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center; z-index: 100; animation: fade 0.15s; padding: 1rem; }
.modal-content { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; max-width: 640px; width: 100%; max-height: 92vh; overflow-y: auto; animation: fadeUp 0.25s var(--ease-out); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 1.2rem 1.5rem; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-family: 'Anton', sans-serif; letter-spacing: 0.04em; text-transform: uppercase; font-size: 1.2rem; }
#form-post { padding: 1.2rem 1.5rem; display: flex; flex-direction: column; gap: 0.9rem; }
#form-post label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--muted); }
#form-post input, #form-post select, #form-post textarea { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); padding: 0.6rem 0.8rem; border-radius: 6px; font-family: inherit; font-size: 0.95rem; }
#form-post input:focus, #form-post select:focus, #form-post textarea:focus { outline: none; border-color: var(--rosa); }
#form-post textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
@media (max-width: 540px) { .form-row { grid-template-columns: 1fr; } }
.modal-actions { display: flex; gap: 0.6rem; align-items: center; margin-top: 0.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }

.toast { position: fixed; bottom: 2rem; right: 2rem; background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--ok); padding: 0.8rem 1.2rem; border-radius: 6px; font-size: 0.9rem; z-index: 200; animation: fadeUp 0.25s var(--ease-out); }
.toast-error { border-left-color: var(--error); }

/* === Sesión 3: dashboard datos reales + biblioteca === */
#dash-proximos ul, #dash-top ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.5rem; }
#dash-proximos li, #dash-top li { display: flex; gap: 0.7rem; align-items: center; padding: 0.5rem 0; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
#dash-proximos li:last-child, #dash-top li:last-child { border-bottom: none; }
#dash-proximos .pp-fecha { color: var(--rosa); font-family: 'Anton', sans-serif; letter-spacing: .04em; min-width: 90px; }
#dash-proximos .pp-titulo { flex: 1; }
#dash-proximos .pp-plat { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: .05em; }
#dash-top li img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; background: var(--panel-2); }
#dash-top .tp-meta { flex: 1; }
#dash-top .tp-meta strong { display: block; color: var(--rosa); font-size: 0.95rem; }
#dash-top .tp-meta span { color: var(--muted); font-size: 0.78rem; }
#dash-top a { color: var(--text); text-decoration: none; }
#dash-top a:hover { color: var(--rosa); }

#ig-stamp { font-size: 0.85rem; }

.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0.8rem; padding: 0.4rem 0; }
.asset-card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; cursor: pointer; transition: border-color 0.15s, transform 0.15s; display: flex; flex-direction: column; }
.asset-card:hover { border-color: var(--rosa); transform: translateY(-2px); }
.asset-thumb { aspect-ratio: 1; background: var(--panel-2); display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 0.7rem; }
.asset-thumb img, .asset-thumb video { width: 100%; height: 100%; object-fit: cover; }
.asset-meta { padding: 0.55rem 0.7rem; font-size: 0.78rem; }
.asset-meta strong { display: block; color: var(--text); margin-bottom: 0.2rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-meta .at-tags { color: var(--muted); display: flex; gap: 0.25rem; flex-wrap: wrap; }
.asset-meta .at-tag { background: var(--panel-2); padding: 0.1rem 0.45rem; border-radius: 3px; font-size: 0.7rem; }
.asset-card .at-estado-pendiente { color: var(--amarillo); }
.asset-card .at-estado-listo { color: var(--ok); }

#form-upload { padding: 1.2rem 1.5rem; display: flex; flex-direction: column; gap: 0.9rem; }
#form-upload label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--muted); }
#form-upload input, #form-upload select { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); padding: 0.6rem 0.8rem; border-radius: 6px; font-family: inherit; font-size: 0.95rem; }
.progress-wrap { display: flex; align-items: center; gap: 0.6rem; }
.progress-bar { flex: 1; height: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.progress-bar span { display: block; height: 100%; width: 0; background: var(--rosa); transition: width 0.2s; }

.filter { padding: 0.5rem 0.8rem; }

/* === Captions IA === */
.caption-form { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 1.2rem 1.5rem; display: flex; flex-direction: column; gap: 0.9rem; max-width: 820px; }
.caption-form label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--muted); }
.caption-form textarea, .caption-form input, .caption-form select { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); padding: 0.6rem 0.8rem; border-radius: 6px; font-family: inherit; font-size: 0.95rem; }
.caption-form textarea { resize: vertical; min-height: 70px; }
.cap-results { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; margin-top: 1.2rem; }
.cap-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 1.1rem 1.2rem; display: flex; flex-direction: column; gap: 0.6rem; }
.cap-card .cap-tono { font-family: 'Anton', sans-serif; letter-spacing: .04em; font-size: 0.78rem; color: var(--rosa); text-transform: uppercase; }
.cap-card .cap-text { color: var(--text); font-size: 0.95rem; line-height: 1.55; white-space: pre-wrap; }
.cap-card .cap-hashtags { color: var(--muted); font-size: 0.82rem; }
.cap-card .cap-cta { color: var(--muted); font-size: 0.78rem; }
.cap-card .cap-actions { display: flex; gap: 0.5rem; margin-top: auto; padding-top: 0.5rem; border-top: 1px solid var(--border); }
.cap-card .cap-len { color: var(--muted); font-size: 0.72rem; }
.cap-historial-item { padding: 0.7rem 1rem; border-bottom: 1px solid var(--border); display: flex; gap: 0.7rem; align-items: center; font-size: 0.85rem; }
.cap-historial-item:last-child { border-bottom: none; }
.cap-historial-item .ch-fecha { color: var(--rosa); font-family: 'Anton', sans-serif; min-width: 90px; font-size: 0.78rem; letter-spacing: .04em; }
.cap-historial-item .ch-brief { flex: 1; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cap-historial-item .ch-plat { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: .05em; }
.cap-historial-item .ch-btn { background: transparent; border: 1px solid var(--border); color: var(--muted); padding: 0.3rem 0.6rem; border-radius: 5px; font-size: 0.78rem; }
.cap-historial-item .ch-btn:hover { color: var(--rosa); border-color: var(--rosa); }
