* { box-sizing: border-box; }
body {
  margin: 0; background: #f2f4f8; color: #1c2430;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.35rem; margin: 0 0 .8rem; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
h3 { font-size: .95rem; margin: .8rem 0 .4rem; }

/* ---- Barra superior ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: #101828; color: #fff; padding: .6rem 1.2rem; flex-wrap: wrap; gap: .5rem;
}
.topbar .brand { font-weight: 700; }
.topbar nav { display: flex; gap: .9rem; align-items: center; flex-wrap: wrap; }
.topbar nav a { color: #cbd5e1; padding: .25rem .4rem; border-radius: 6px; }
.topbar nav a:hover { color: #fff; text-decoration: none; }
.topbar nav a.active { color: #fff; background: #1f2c44; }
.topbar .btn-new { background: #2563eb; color: #fff; padding: .35rem .7rem; border-radius: 8px; font-weight: 600; }
.topbar .logout { color: #94a3b8; }

main { max-width: 1360px; margin: 1.2rem auto; padding: 0 1rem; width: 100%; }
html, body { max-width: 100%; overflow-x: hidden; }
.foot { text-align: center; color: #94a3b8; font-size: .8rem; padding: 1.5rem 0; }

.card { background: #fff; border-radius: 12px; padding: 1.2rem 1.4rem; box-shadow: 0 1px 4px rgba(16,24,40,.08); }
.form-card { max-width: 720px; margin: 0 auto; }

/* ---- Mensajes ---- */
.flash { padding: .7rem 1rem; border-radius: 10px; margin-bottom: .9rem; }
.flash-ok    { background: #e7f6ec; color: #14532d; border: 1px solid #bbe5c8; }
.flash-error { background: #fdecec; color: #7f1d1d; border: 1px solid #f5c2c2; }
.flash-warn  { background: #fef7e0; color: #713f12; border: 1px solid #f3e0a0; }

/* ---- Formularios ---- */
label { display: block; margin: .8rem 0 .3rem; font-weight: 600; font-size: .9rem; }
input[type=text], input[type=password], input[type=datetime-local], textarea, select {
  width: 100%; padding: .55rem .7rem; margin-top: .25rem;
  border: 1px solid #d0d7e2; border-radius: 8px; font: inherit; background: #fff;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid #93c5fd; border-color: #60a5fa; }
fieldset { border: 1px solid #e2e8f0; border-radius: 10px; margin: 1rem 0; padding: .8rem 1rem; }
legend { font-weight: 700; font-size: .9rem; padding: 0 .4rem; }
details { margin: .8rem 0; }
details summary { cursor: pointer; font-weight: 600; color: #2563eb; }
button { font: inherit; cursor: pointer; }
.btn-row { display: flex; gap: .6rem; margin-top: 1.2rem; flex-wrap: wrap; align-items: center; }
.btn-primary, .btn-publish {
  border: 0; border-radius: 8px; padding: .55rem 1.1rem; font-weight: 700; color: #fff;
}
.btn-primary { background: #2563eb; }
.btn-publish { background: #16a34a; }
.btn-primary:hover { background: #1d4ed8; }
.btn-publish:hover { background: #15803d; }
.btn-sm {
  display: inline-block; border: 1px solid #d0d7e2; background: #fff; color: #1c2430;
  border-radius: 7px; padding: .3rem .6rem; font-size: .82rem;
}
.btn-sm:hover { background: #f1f5f9; text-decoration: none; }
.btn-danger { color: #b91c1c; border-color: #f1c5c5; }
.btn-danger:hover { background: #fdecec; }
.chk { font-weight: 400; display: flex; align-items: center; gap: .5rem; }
.chk input { width: auto; margin: 0; }
.acc-chk { padding: .35rem .2rem; border-radius: 6px; flex-wrap: wrap; }
.acc-chk:hover { background: #f8fafc; }
.target-error { margin: 0 0 .4rem 1.8rem; font-size: .8rem; color: #b91c1c; }
.counters { font-size: .82rem; color: #475569; margin-top: .3rem; }
.counters .over { color: #b91c1c; font-weight: 700; }
.img-preview img { max-width: 220px; max-height: 220px; border-radius: 8px; display: block; margin-bottom: .4rem; }
.img-gallery { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: .6rem; }
.img-gallery:empty { margin: 0; }
.thumb { position: relative; width: 96px; height: 96px; }
.thumb img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid #e2e8f0; cursor: zoom-in; display: block; }
.thumb-x {
  position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; padding: 0;
  border-radius: 50%; background: #dc2626; color: #fff; border: 2px solid #fff;
  font-size: 15px; line-height: 1; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.3);
  display: flex; align-items: center; justify-content: center;
}
.thumb-x:hover { background: #b91c1c; }
/* Modal / lightbox */
.img-modal { position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,.82); display: none; align-items: center; justify-content: center; }
.img-modal.open { display: flex; }
.img-modal img { max-width: 92vw; max-height: 90vh; border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.img-modal-close { position: absolute; top: 14px; right: 22px; color: #fff; font-size: 2.4rem; line-height: 1; cursor: pointer; font-weight: 300; }
.hashtag-bar { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; margin: .5rem 0; }
.hashtag-bar .btn-sm { background: #eef2ff; border-color: #c7d2fe; }

/* ---- Badges y estados ---- */
.badge {
  display: inline-block; color: #fff; font-size: .68rem; font-weight: 700;
  border-radius: 5px; padding: .1rem .35rem; margin-right: .15rem; vertical-align: middle;
}
.pill { border-radius: 999px; padding: .15rem .6rem; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.pill.st-draft     { background: #eef2f7; color: #475569; }
.pill.st-scheduled { background: #e0ecff; color: #1e40af; }
.pill.st-publishing{ background: #fef3c7; color: #92400e; }
.pill.st-published { background: #dcfce7; color: #166534; }
.pill.st-partial   { background: #fef3c7; color: #92400e; }
.pill.st-failed    { background: #fee2e2; color: #991b1b; }
.net-status { margin-right: .4rem; white-space: nowrap; }
.txt-warn { color: #b45309; } .txt-error { color: #b91c1c; font-weight: 700; }

/* ---- Tablas ---- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: .78rem; text-transform: uppercase; color: #64748b; padding: .5rem .6rem; border-bottom: 2px solid #e2e8f0; }
.tbl td { padding: .55rem .6rem; border-bottom: 1px solid #eef2f7; vertical-align: top; }
.tbl tr:hover td { background: #f8fafc; }
.row-muted td { opacity: .55; }
.nowrap { white-space: nowrap; }
.inline { display: inline; }
.actions .btn-sm { margin: 0 .1rem .2rem 0; }
.list-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .6rem; }
.muted { color: #64748b; }
.small { font-size: .82rem; }

/* ---- Calendario ---- */
.cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1rem; align-items: start; }
@media (max-width: 980px) { .cal-layout { grid-template-columns: 1fr; } }
.side { min-width: 0; }
.cal-head { display: flex; align-items: center; gap: .8rem; margin-bottom: .8rem; }
.cal-head h1 { margin: 0; flex: 0 0 auto; }
.cal-nav { font-size: 1.2rem; padding: .1rem .5rem; border-radius: 6px; background: #eef2f7; }
.cal-today { margin-left: auto; font-size: .85rem; }
/* Rejilla uniforme: todas las semanas y casillas del mismo tamaño */
.calendar {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-template-rows: auto;      /* fila de nombres de día: alto natural, no 158px */
  grid-auto-rows: 158px; gap: 4px;
}
.cal-dow { text-align: center; font-size: .75rem; font-weight: 700; color: #64748b; text-transform: uppercase; padding: .2rem 0; }
.cal-cell {
  background: #fbfcfe; border: 1px solid #e8edf4; border-radius: 8px;
  padding: .25rem; font-size: .78rem; overflow: hidden;
  display: flex; flex-direction: column; min-width: 0;
}
.cal-cell.out { opacity: .45; }
.cal-cell.today { border-color: #2563eb; box-shadow: inset 0 0 0 1px #2563eb; }
.cal-daynum { display: flex; justify-content: space-between; align-items: center; font-weight: 700; color: #475569; margin-bottom: .2rem; flex: 0 0 auto; }
.cal-add { visibility: hidden; color: #2563eb; font-weight: 700; padding: 0 .3rem; }
.cal-cell:hover .cal-add { visibility: visible; }
.cal-events { display: flex; flex-direction: column; gap: .25rem; overflow: hidden; min-height: 0; }
.cal-post {
  display: block; color: inherit; border-radius: 6px; padding: .2rem .35rem;
  background: #e0ecff; border-left: 3px solid #2563eb; overflow: hidden; flex: 0 0 auto;
}
.cal-post-head { display: flex; align-items: center; gap: .2rem; }
.cal-more { font-size: .72rem; color: #2563eb; font-weight: 600; padding: 0 .3rem; }

/* ---- Agenda (vista móvil, día a día hacia abajo) ---- */
.cal-agenda { display: none; }
.ag-day { border-top: 1px solid #eef2f7; padding: .5rem 0; }
.ag-day:first-child { border-top: 0; }
.ag-date { font-weight: 700; color: #1e40af; font-size: .85rem; margin-bottom: .35rem; text-transform: capitalize; }
.ag-date .ag-today { background: #2563eb; color: #fff; border-radius: 6px; padding: .05rem .4rem; }
.ag-post {
  display: block; color: inherit; border-radius: 8px; padding: .5rem .6rem; margin-bottom: .4rem;
  background: #e0ecff; border-left: 4px solid #2563eb;
}
.ag-post:hover { text-decoration: none; filter: brightness(.97); }
.ag-post.st-published { background: #dcfce7; border-left-color: #16a34a; }
.ag-post.st-partial, .ag-post.st-publishing { background: #fef3c7; border-left-color: #d97706; }
.ag-post.st-failed { background: #fee2e2; border-left-color: #dc2626; }
.ag-post.st-draft { background: #eef2f7; border-left-color: #94a3b8; }
.ag-head { display: flex; align-items: center; gap: .35rem; font-size: .85rem; margin-bottom: .15rem; }
.ag-head .ag-time { font-weight: 700; }
.ag-text { font-size: .85rem; color: #334155; }

@media (max-width: 620px) {
  .calendar { display: none; }
  .cal-agenda { display: block; }
  .cal-head h1 { font-size: 1.15rem; }
}
.cal-post:hover { text-decoration: none; filter: brightness(.96); }
.cal-post.st-published { background: #dcfce7; border-left-color: #16a34a; }
.cal-post.st-partial   { background: #fef3c7; border-left-color: #d97706; }
.cal-post.st-failed    { background: #fee2e2; border-left-color: #dc2626; }
.cal-post.st-draft     { background: #eef2f7; border-left-color: #94a3b8; }
.cal-post.st-publishing{ background: #fef3c7; border-left-color: #d97706; }
.cal-time { font-weight: 700; flex: 0 0 auto; }
.cal-post .badge { flex: 0 0 auto; }
.cal-snippet {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  color: #475569; overflow: hidden; line-height: 1.2; margin-top: .1rem;
}

/* ---- Panel lateral ---- */
.side .up-item { display: block; color: inherit; padding: .45rem .5rem; border-radius: 8px; border: 1px solid #eef2f7; margin-bottom: .45rem; }
.side .up-item:hover { background: #f8fafc; text-decoration: none; }
.up-date { font-weight: 700; font-size: .8rem; color: #1e40af; }
.up-text { font-size: .82rem; color: #475569; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.up-nets { margin: .1rem 0; }
.legend { margin-top: 1rem; font-size: .78rem; color: #475569; }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin: 0 .25rem 0 .6rem; }
.dot.st-scheduled { background: #2563eb; } .dot.st-published { background: #16a34a; }
.dot.st-partial { background: #d97706; } .dot.st-failed { background: #dc2626; } .dot.st-draft { background: #94a3b8; }

/* ---- Importador ---- */
.code-example {
  background: #0f172a; color: #e2e8f0; border-radius: 8px; padding: .8rem 1rem;
  font-size: .8rem; overflow-x: auto;
}

/* ---- Login / instalación ---- */
body.centered { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.login-card { width: 340px; }
.login-card h1 { text-align: center; }
.login-card button { width: 100%; margin-top: 1rem; background: #2563eb; color: #fff; border: 0; border-radius: 8px; padding: .6rem; font-weight: 700; }
