* { box-sizing: border-box; }
body {
  font-family: -apple-system, Segoe UI, Roboto, sans-serif;
  background: #f4f5f7;
  color: #1c1e21;
  margin: 0;
}
.topnav {
  background: #ffffff;
  border-bottom: 1px solid #e1e4e8;
  padding: 12px 24px;
  display: flex;
  gap: 20px;
  align-items: center;
}
.topnav .brand { font-weight: 700; margin-right: auto; }
.topnav a { color: #1c1e21; text-decoration: none; }
.topnav a:hover { color: #4361ee; }

main { max-width: 1800px; margin: 24px auto; padding: 0 32px; }

.card {
  background: #fff;
  border: 1px solid #e1e4e8;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
}
.card h2 { margin-top: 0; font-size: 1.4rem; font-weight: 700; color: #111; }
h1 { font-size: 1.8rem; font-weight: 700; }

form label {
  display: block;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: #555;
}
form input[type=text], form input[type=url], form input[type=file],
form textarea, form input[type=datetime-local] {
  display: block;
  width: 100%;
  padding: 8px 10px;
  margin-top: 4px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.95rem;
}

.platforms { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid #ccc; border-radius: 20px;
  padding: 6px 14px; cursor: pointer; font-size: 0.85rem;
  text-transform: capitalize;
}
.chip input { margin: 0; }
.group-chip {
  background: #fff; color: #333; font-weight: 600; text-transform: none;
}
.group-chip.active { background: #4361ee; color: #fff; border-color: #4361ee; }

.thumb-choices { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.thumb-choices img.thumb-choice {
  width: 90px; height: 90px; object-fit: cover; border-radius: 6px;
  border: 3px solid transparent; cursor: pointer;
}
.thumb-choices img.thumb-choice.selected { border-color: #4361ee; }

button {
  background: #4361ee; color: #fff; border: none;
  border-radius: 6px; padding: 9px 18px; cursor: pointer; font-size: 0.9rem;
}
button:hover { background: #3651d4; }

#form-msg { display: block; margin-top: 8px; font-size: 0.85rem; }

.mini-picker { display: flex; gap: 14px; margin: -6px 0 12px; border: 1px solid #eee; border-radius: 8px; padding: 8px 10px; background: #fafafa; }
.mini-picker-cal { flex: 1.3; min-width: 0; }
.mini-picker-hours { flex: 1; min-width: 0; border-left: 1px solid #e5e5e5; padding-left: 12px; display: flex; flex-direction: column; }
.mini-picker-hours .hint { margin: 0 0 4px; }
.mini-hour-presets { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.mini-hour-preset { background: #eee; color: #333; padding: 5px 12px; font-size: 0.85rem; font-weight: 600; border-radius: 12px; }
.mini-hour-preset:hover { background: #dbe4ff; color: #34399a; }
.mini-picker-header { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 6px; font-size: 0.85rem; }
.mini-picker-header button { background: #eee; color: #333; padding: 3px 10px; font-size: 0.8rem; }
.mini-picker-header span { text-transform: capitalize; font-weight: 700; }
.mini-picker-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; margin-bottom: 4px; }
.mini-dow { text-align: center; font-size: 0.68rem; color: #999; }
.mini-day { background: #fff; border: 1px solid #ddd; color: #333; padding: 7px 0; border-radius: 4px; font-size: 0.9rem; font-weight: 600; line-height: 1; }
.mini-day:hover { background: #eef0ff; }
.mini-day.today { border-color: #4361ee; font-weight: 700; }
.mini-day.selected { background: #4361ee; color: #fff; border-color: #4361ee; }
#mini-picker-time { width: auto; display: block; margin-top: 4px; }

.thumb-scrub-row { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
#thumb-scrub-preview { width: 90px; height: 90px; object-fit: cover; border-radius: 6px; border: 3px solid transparent; }
#thumb-scrub-preview.selected { border-color: #4361ee; }
#thumb-scrub { flex: 1; }

.form-actions { display: flex; justify-content: space-between; align-items: center; }

.history-clear { display: flex; align-items: center; gap: 10px; }
#clear-history-form { display: flex; align-items: center; gap: 10px; }
#clear-history-form label { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 0.85rem; }
#clear-history-form input[type=date] {
  padding: 6px 8px; border: 1px solid #ccc; border-radius: 6px; font-size: 0.85rem;
}

.calendar-header { display: flex; align-items: center; justify-content: center; gap: 20px; margin-bottom: 12px; }
.calendar-header button { background: #eee; color: #333; }
.calendar-header h2 { text-transform: capitalize; }

.view-modes { display: flex; justify-content: center; gap: 8px; margin-bottom: 16px; }
.view-mode-chip { background: #fff; color: #333; font-weight: 600; }
.view-mode-chip.active { background: #4361ee; color: #fff; border-color: #4361ee; }

.calendar-grid.view-month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: 0.8rem; color: #888; padding-bottom: 4px; }
.cal-day {
  height: 140px; overflow-y: auto; border: 1px solid #eee; border-radius: 6px;
  padding: 6px; font-size: 0.8rem; background: #fafafa;
}
.cal-day.empty { background: transparent; border: none; }
.cal-day .num { font-weight: 600; color: #666; }
.cal-day .badge {
  display: flex; align-items: center; gap: 4px;
  margin-top: 4px; padding: 3px 5px; border-radius: 4px;
  background: #dbe4ff; color: #34399a; font-size: 0.75rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-day .badge.done { background: #d3f2e0; color: #1a7a4c; }
.cal-day .badge.error { background: #fbd7d7; color: #a12727; }
.cal-day .badge.cancelled { background: #eee; color: #999; }
.cal-day .badge.pending { background: #fdf1d6; color: #8a6300; }
.cal-day .group-pill { cursor: pointer; }
.cal-day .group-pill[draggable="true"] { cursor: grab; }
.cal-day.drag-over { background: #e8ecff; outline: 2px dashed #4361ee; }
.pill-thumb {
  width: 36px; height: 36px; object-fit: cover; border-radius: 4px;
  flex-shrink: 0;
}

.cal-hour-scroll { max-height: 640px; overflow-y: auto; border: 1px solid #eee; border-radius: 6px; }
.cal-hour-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal-hour-table th {
  position: sticky; top: 0; background: #fff; z-index: 1;
  font-size: 0.75rem; color: #666; padding: 6px 4px; border-bottom: 1px solid #eee; text-align: center;
}
.cal-hour-label {
  width: 60px; font-size: 0.7rem; color: #999; text-align: right;
  padding: 2px 8px; vertical-align: top; white-space: nowrap;
}
.cal-hour-cell {
  border: 1px solid #f0f0f0; height: 34px; vertical-align: top; padding: 1px;
}
.cal-hour-cell--day { height: 56px; }
.cal-hour-cell.drag-over { background: #e8ecff; outline: 2px dashed #4361ee; }
.cal-hour-cell .group-pill {
  display: flex; align-items: center; gap: 4px; padding: 2px 4px; margin-bottom: 2px;
  border-radius: 4px; font-size: 0.68rem; background: #dbe4ff; color: #34399a; cursor: pointer;
}
.cal-hour-cell .group-pill.done { background: #d3f2e0; color: #1a7a4c; }
.cal-hour-cell .group-pill.error { background: #fbd7d7; color: #a12727; }
.cal-hour-cell .group-pill.pending { background: #fdf1d6; color: #8a6300; }
.cal-hour-cell .pill-thumb { width: 16px; height: 16px; }
.cal-hour-cell--day .pill-thumb { width: 48px; height: 48px; }

.row-thumb {
  width: 56px; height: 56px; object-fit: cover; border-radius: 6px;
  vertical-align: middle; margin-right: 10px;
}

.group-detail-bulk {
  padding: 10px 0; font-size: 0.9rem;
}
.group-detail-bulk strong { display: block; margin-bottom: 6px; }

.group-detail-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 0; border-bottom: 1px solid #eee; font-size: 0.9rem;
}
.group-detail-info { flex: 1; }
.group-detail-controls { display: flex; align-items: center; gap: 6px; }
.group-detail-controls input[type=datetime-local] {
  padding: 5px 8px; border: 1px solid #ccc; border-radius: 6px; font-size: 0.85rem;
}

.list-header { display: flex; justify-content: space-between; align-items: center; }
table { width: 100%; border-collapse: collapse; margin-top: 10px; }
th, td { text-align: left; padding: 12px 8px; border-bottom: 1px solid #eee; font-size: 0.9rem; }

#posts-table { table-layout: fixed; }
#posts-table th:nth-child(1), #posts-table td:nth-child(1) { width: 3%; color: #999; font-size: 0.75rem; text-align: center; }
#posts-table th:nth-child(2), #posts-table td:nth-child(2) { width: 12%; }
#posts-table th:nth-child(3), #posts-table td:nth-child(3) { width: 10%; }
#posts-table th:nth-child(4), #posts-table td:nth-child(4) { width: 12%; }
#posts-table th:nth-child(5), #posts-table td:nth-child(5) { width: 48%; font-size: 1.05rem; white-space: normal; word-break: break-word; }
#posts-table th:nth-child(6), #posts-table td:nth-child(6) { width: 15%; text-align: right; }
.status-pending { color: #b8860b; }
.status-done { color: #1a7a4c; }
.status-error { color: #a12727; }
.status-cancelled { color: #999; }

.queue-date {
  background: #f4f5f7; font-weight: 600; font-size: 0.8rem; color: #555;
  text-transform: capitalize; padding-top: 10px;
}
.queue-section {
  background: #eef0f5; font-weight: 700; font-size: 0.85rem; color: #333;
  padding-top: 14px; border-top: 2px solid #ccc;
}

.hint { font-size: 0.8rem; color: #777; }
.pw-field { display: flex; align-items: center; gap: 6px; }
.pw-field input { flex: 1; }
.pw-toggle { background: none; border: 1px solid #ccc; border-radius: 4px; cursor: pointer; padding: 2px 8px; }
.flash-banner { padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; font-weight: 600; }
.flash-banner.success { background: #e3f6e8; color: #1a7a4c; border: 1px solid #1a7a4c; }
.flash-banner.error { background: #fbe9e7; color: #a12727; border: 1px solid #a12727; }
.hint a { color: #4361ee; }

.account-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid #eee; font-size: 0.9rem;
}
.account-row span { flex: 1; }
.account-row small { color: #888; }
button.danger { background: #c0392b; }
button.danger:hover { background: #a02f22; }
.add-form { margin-top: 14px; padding-top: 14px; border-top: 1px dashed #ddd; }

.rename-form { display: flex; align-items: center; gap: 6px; flex: 1; }
.rename-form input[type=text] {
  padding: 5px 8px; border: 1px solid #ccc; border-radius: 6px; font-size: 0.85rem; width: 100%;
}
button.secondary { background: #eee; color: #333; }
button.secondary:hover { background: #ddd; }

.nav-user { color: #666; font-size: 0.85rem; }
.tag-chip { background: #fff7e6; color: #8a6300; border-color: #f0d68a; font-weight: 600; }
.tag-chip:hover { background: #fdf1d6; }
[data-theme="dark"] .tag-chip { background: #2e2a1c; color: #f0d68a; border-color: #5a4d2a; }

.auth-page {
  min-height: calc(100vh - 60px); display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #4361ee 0%, #3a0ca3 100%);
  margin: -24px -32px; padding: 24px 32px;
}
[data-theme="dark"] .auth-page { background: linear-gradient(135deg, #1c1f26 0%, #0d0e12 100%); }
.auth-card {
  max-width: 380px; width: 100%; margin: 0; text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25); border-radius: 16px;
}
.auth-logo { width: 90px; height: 90px; border-radius: 50%; object-fit: cover; margin-bottom: 8px; border: 2px solid #ddd; }
.auth-card form { text-align: left; }
.auth-field {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid #ccc; border-radius: 8px; padding: 0 12px; margin-bottom: 14px;
}
.auth-field-icon { font-size: 1.1rem; }
.auth-field input {
  border: none !important; padding: 10px 0 !important; margin: 0 !important;
  background: transparent !important; flex: 1;
}
.auth-field input:focus { outline: none; }
.auth-remember { display: flex; align-items: center; gap: 6px; margin: -4px 0 14px; font-size: 0.85rem; }
.auth-remember input { margin: 0; }
.totp-qr { display: block; width: 200px; height: 200px; margin: 10px 0; }

.theme-toggle { display: flex; align-items: center; gap: 8px; }

/* --- Modo oscuro ----------------------------------------------------- */
[data-theme="dark"] body { background: #15171c; color: #e8e8ea; }
[data-theme="dark"] .topnav { background: #1c1f26; border-bottom-color: #2a2e37; }
[data-theme="dark"] .topnav a, [data-theme="dark"] .nav-user { color: #e8e8ea; }
[data-theme="dark"] .card { background: #1c1f26; border-color: #2a2e37; }
[data-theme="dark"] form label { color: #aaa; }
[data-theme="dark"] form input[type=text], [data-theme="dark"] form input[type=url],
[data-theme="dark"] form input[type=file], [data-theme="dark"] form input[type=date],
[data-theme="dark"] form input[type=time], [data-theme="dark"] form textarea,
[data-theme="dark"] form input[type=datetime-local] {
  background: #12141a; border-color: #3a3f4a; color: #e8e8ea;
}
[data-theme="dark"] .chip { border-color: #3a3f4a; color: #e8e8ea; }
[data-theme="dark"] .group-chip { background: #1c1f26; color: #ddd; }
[data-theme="dark"] button.secondary { background: #2a2e37; color: #ddd; }
[data-theme="dark"] button.secondary:hover { background: #353a45; }
[data-theme="dark"] .calendar-header button, [data-theme="dark"] .view-mode-chip { background: #2a2e37; color: #ddd; }
[data-theme="dark"] .mini-picker { background: #20242c; border-color: #2a2e37; }
[data-theme="dark"] .mini-picker-hours { border-left-color: #2a2e37; }
[data-theme="dark"] .mini-hour-preset { background: #2a2e37; color: #fff; }
[data-theme="dark"] .mini-day { background: #1c1f26; border-color: #3a3f4a; color: #fff; }
[data-theme="dark"] .mini-picker-header span { color: #fff; }
[data-theme="dark"] .card h2, [data-theme="dark"] h1, [data-theme="dark"] .calendar-header h2 { color: #fff; font-weight: 700; }
[data-theme="dark"] .cal-day { background: #20242c; border-color: #2a2e37; }
[data-theme="dark"] .cal-day .num { color: #ccc; }
[data-theme="dark"] .cal-hour-scroll { border-color: #2a2e37; }
[data-theme="dark"] .cal-hour-table th { background: #1c1f26; color: #ccc; border-bottom-color: #2a2e37; }
[data-theme="dark"] .cal-hour-cell { border-color: #262a33; }
[data-theme="dark"] table, [data-theme="dark"] th, [data-theme="dark"] td { border-color: #2a2e37; }
[data-theme="dark"] .queue-date { background: #20242c; color: #bbb; }
[data-theme="dark"] .queue-section { background: #262a33; color: #ddd; border-top-color: #3a3f4a; }
[data-theme="dark"] .hint { color: #999; }
[data-theme="dark"] .account-row { border-bottom-color: #2a2e37; }
[data-theme="dark"] .add-form { border-top-color: #3a3f4a; }
[data-theme="dark"] #clear-history-form input[type=date] { background: #12141a; border-color: #3a3f4a; color: #e8e8ea; }
