/* Rumbo — estilos base, pensados primero para el celular. */
:root {
  --brand: #1f4e79;
  --brand-contrast: #ffffff;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5d6b7a;
  --border: #d9dee4;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --success: #067647;
  --success-bg: #e7f6ec;
  --warn-bg: #fff6e0;
  --radius: 10px;
  --gutter: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161c;
    --surface: #1a2129;
    --text: #e6ebf0;
    --muted: #9aa7b4;
    --border: #2c3641;
    --danger-bg: #3b1714;
    --success-bg: #12301f;
    --warn-bg: #3a2f12;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--brand); }
@media (prefers-color-scheme: dark) { a { color: #7fb3e6; } }

.topbar {
  background: var(--brand);
  color: var(--brand-contrast);
  padding: 10px var(--gutter);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.topbar .brand { font-weight: 700; font-size: 1.05rem; color: inherit; text-decoration: none; }
.topbar .spacer { flex: 1; }
.topbar a, .topbar button.link { color: var(--brand-contrast); }
.topbar form { margin: 0; }

.container { max-width: 960px; margin: 0 auto; padding: var(--gutter); }
.narrow { max-width: 420px; }

h1 { font-size: 1.4rem; margin: 8px 0 16px; }
h2 { font-size: 1.1rem; margin: 24px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--gutter);
  margin-bottom: var(--gutter);
}

.tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: var(--gutter); border-bottom: 1px solid var(--border); }
.tabs a { padding: 8px 12px; text-decoration: none; color: var(--muted); white-space: nowrap; border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--text); border-bottom-color: var(--brand); font-weight: 600; }

label { display: block; font-weight: 600; margin: 12px 0 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=search], input[type=tel], select, textarea {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.field-error { color: var(--danger); font-size: .875rem; margin-top: 4px; }
.has-error input, .has-error select { border-color: var(--danger); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 8px 0; }
.check input { width: 18px; height: 18px; }
.grid { display: grid; gap: 0 16px; }
@media (min-width: 640px) { .grid.two { grid-template-columns: 1fr 1fr; } }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px var(--gutter) var(--gutter); margin: 16px 0; }
legend { font-weight: 700; padding: 0 4px; }

.btn {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: var(--brand-contrast);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn.secondary { background: transparent; color: var(--brand); }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.block { width: 100%; text-align: center; }
button.link { background: none; border: 0; padding: 0; font: inherit; text-decoration: underline; cursor: pointer; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; align-items: center; }

.flash { padding: 12px 14px; border-radius: 8px; margin-bottom: 12px; }
.flash.error { background: var(--danger-bg); color: var(--danger); }
.flash.success { background: var(--success-bg); color: var(--success); }
.flash.warning { background: var(--warn-bg); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.badge { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: var(--bg); border: 1px solid var(--border); margin: 0 2px 2px 0; }
.badge.ok { background: var(--success-bg); color: var(--success); border-color: transparent; }
.badge.off { background: var(--danger-bg); color: var(--danger); border-color: transparent; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; }
.toolbar > * { flex: 1 1 180px; }
.toolbar .btn { flex: 0 0 auto; }

.secret { font: 700 1.4rem/1.2 ui-monospace, Menlo, monospace; letter-spacing: .12em; }
.credential { break-inside: avoid; }
@media print {
  .topbar, .no-print, .flash { display: none !important; }
  body { background: #fff; color: #000; }
  .card { border: 1px dashed #999; }
  .credentials-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
}

/* Cartelera */
a.card.post { display: block; color: inherit; text-decoration: none; }
a.card.post:hover { border-color: var(--brand); }
.post.unread { border-left: 4px solid var(--brand); }
.post-meta { display: flex; flex-wrap: wrap; gap: 4px; }
.post-title { margin: 8px 0 4px; font-size: 1.1rem; }
.post-image { display: block; width: 100%; max-height: 360px; object-fit: cover; border-radius: 8px; margin: 8px 0; }
.prose { overflow-wrap: anywhere; }
.prose img { max-width: 100%; }
.ack-box { border-color: var(--brand); }
.bell { position: relative; text-decoration: none; font-size: 1.1rem; }
.bell .count { position: absolute; top: -6px; right: -10px; background: var(--danger); color: #fff; border-radius: 99px; font-size: .7rem; padding: 0 5px; line-height: 1.4; }
.push-banner { border-color: var(--brand); }
textarea { width: 100%; padding: 10px 12px; font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; resize: vertical; }

/* Videos */
.video-row { display: grid; grid-template-columns: 120px 1fr; gap: 12px; align-items: center; }
.video-thumb { display: flex; align-items: center; justify-content: center; aspect-ratio: 16 / 9;
  background: var(--border); border-radius: 6px; overflow: hidden; text-decoration: none; font-size: 1.6rem; }
.video-thumb img { width: 100%; height: 100%; object-fit: cover; }
.video-player { display: block; width: 100%; max-height: 70vh; background: #000; border-radius: var(--radius); }
@media (max-width: 480px) { .video-row { grid-template-columns: 88px 1fr; } }

/* Capacitaciones */
.lesson-row { display: flex; gap: 12px; align-items: center; }
a.lesson-link { color: inherit; text-decoration: none; }
a.lesson-link:hover { border-color: var(--brand); }
.lesson-row.locked { opacity: .55; }
.lesson-num { flex: 0 0 32px; height: 32px; border-radius: 50%; background: var(--bg); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .9rem; }
.lesson-tools { display: flex; gap: 4px; }
.lesson-tools form { margin: 0; }
.btn.small { padding: 4px 10px; font-size: .9rem; }
.course-progress { width: 100%; height: 8px; margin-top: 8px; accent-color: var(--brand); }
.course-card.overdue { border-left: 4px solid var(--danger); }
.danger-text { color: var(--danger); }
.rule-row { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.rule-row:last-child { border-bottom: 0; }
.rule-row form { margin: 0; }
.mainnav { display: flex; gap: 4px; margin: 0 0 12px; border-bottom: 1px solid var(--border); }
.mainnav a { padding: 8px 12px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; }
.mainnav a.active { color: var(--text); border-bottom-color: var(--brand); font-weight: 600; }
.mainnav .count { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: var(--danger); color: #fff; font-size: .75rem; text-align: center; }
.control-option { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
.control-option input[type=radio] { width: 18px; height: 18px; flex: 0 0 auto; }

/* Exámenes */
.exam-facts { margin: 0 0 12px; padding-left: 20px; }
.exam-question legend { font-weight: 600; padding: 0 4px; }
.exam-question.right { border-left: 4px solid var(--success); }
.exam-question.wrong { border-left: 4px solid var(--danger); }
.exam-review { margin: 8px 0; padding-left: 20px; }
.exam-review li.correct { color: var(--success); font-weight: 600; }
.exam-timer { position: sticky; top: 8px; z-index: 5; font-weight: 700; text-align: center; }
.exam-timer.urgent { background: var(--danger-bg); color: var(--danger); }
#question-form .for-multiple, #question-form .only-tf { display: none; }
#question-form[data-type="multiple"] .for-single { display: none; }
#question-form[data-type="multiple"] .for-multiple { display: inline-block; }
#question-form[data-type="true_false"] .only-choice { display: none; }
#question-form[data-type="true_false"] .only-tf { display: block; }
.download-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.video-row.with-check { grid-template-columns: 24px 120px 1fr; }
.video-check { width: 18px; height: 18px; }
@media (max-width: 480px) { .video-row.with-check { grid-template-columns: 24px 88px 1fr; } }
.traceback { white-space: pre-wrap; word-break: break-word; font: .8rem/1.4 ui-monospace, Menlo, monospace; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; max-height: 420px; overflow: auto; }
.role-tag { display: inline-block; font-size: .7rem; padding: 1px 7px; margin-left: 4px; border-radius: 99px; border: 1px solid currentColor; opacity: .85; white-space: nowrap; }
