:root {
  --bg: #f4f7fe;
  --panel: #ffffff;
  --panel-2: #f7faff;
  --line: #e4e7ef;
  --accent: #2657fe;
  --accent-2: #1b3fd6;
  --accent-3: #5b8cff;
  --gold: var(--accent);
  --gold-2: var(--accent-2);
  --ink: #182038;
  --muted: #5c6478;
  --ok: #1f8a4c;
  --warn: #c47a1a;
  --err: #d64545;
  --shadow: 0 16px 40px rgba(24, 32, 56, 0.08);
  --grad: linear-gradient(135deg, #1b3fd6 0%, #2657fe 55%, #4d7efe 100%);
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 84% 8%, rgba(91, 140, 255, 0.18), transparent 28%),
    linear-gradient(180deg, #ffffff 0%, #f4f7fe 42%, #f7faff 100%);
  color: var(--ink);
  font-family: Manrope, system-ui, sans-serif;
}

.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background-image: radial-gradient(rgba(24, 32, 56, 0.06) 1.2px, transparent 1.3px);
  background-size: 26px 26px;
  -webkit-mask-image: radial-gradient(55% 55% at 84% 12%, #000, transparent 76%);
  mask-image: radial-gradient(55% 55% at 84% 12%, #000, transparent 76%);
}

.top,
.view {
  position: relative;
  z-index: 1;
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
}

.top {
  padding: 16px 0 18px;
}
.top-bar {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 72px;
  padding: 8px 10px 8px 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 12px 28px rgba(24, 32, 56, 0.06);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  color: inherit;
  text-decoration: none;
}
.brand img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}
.brand-name {
  display: block;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.brand-name span { color: var(--accent); }
.brand-sub {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.tabs {
  display: flex;
  flex: 0 1 auto;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  margin: 0 0 0 8px;
  padding: 0;
  min-width: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}
.tabs a,
.tabs button {
  flex: 0 0 auto;
  background: transparent;
  color: var(--ink);
  border: 0;
  border-radius: 999px;
  font-weight: 700;
  padding: 10px 16px;
  white-space: nowrap;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  box-shadow: none;
}
.tabs a[hidden] { display: none !important; }
.tabs a.active,
.tabs button.active {
  background: var(--grad);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(38, 87, 254, 0.28);
}
.tab-dot {
  display: none;
  width: 8px;
  height: 8px;
  margin-left: 6px;
  border-radius: 50%;
  background: #fff;
  vertical-align: middle;
}
.tab-dot:not([hidden]) { display: inline-block; }
.tabs a.active .tab-dot,
.tabs button.active .tab-dot { background: #fff; }
.tabs a:not(.active) .tab-dot,
.tabs button:not(.active) .tab-dot { background: var(--accent); }

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}
.session {
  display: flex;
  align-items: center;
  gap: 8px;
}
#user-name {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
#logout {
  padding: 8px 12px;
  font-size: 13px;
}

.coleta-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 18px;
  align-items: start;
  padding-bottom: 40px;
}

.view[hidden] { display: none !important; }

.eyebrow {
  margin: 0 0 6px;
  color: var(--gold);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 11px;
}

h1, h2, h3 {
  font-family: Manrope, system-ui, sans-serif;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0;
}

h1 { font-size: clamp(26px, 3.4vw, 38px); }
h2 { font-size: 20px; margin-bottom: 12px; }
h3 { font-size: 22px; margin: 8px 0 12px; }

.status-pill {
  width: max-content;
  flex-shrink: 0;
  margin-left: 0;
  border: 1px solid var(--line);
  background: #f7faff;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  box-shadow: none;
}

.status-pill[data-state="running"] { color: var(--gold-2); }
.status-pill[data-state="done"] { color: var(--ok); }
.status-pill[data-state="error"] { color: var(--err); }
.status-pill[data-state="cancelled"] { color: var(--warn); }

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  padding-bottom: 40px;
  align-items: start;
}

.browse {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 18px;
}

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.list-card,
.reader {
  margin-bottom: 0;
  min-height: 72vh;
}

.hint, .ghost, label, dt, .logs, .history, #progress-label, #page-info, .empty, .item-meta {
  color: var(--muted);
}

.hint, label { display: block; font-size: 14px; line-height: 1.45; }
label { margin: 14px 0 8px; color: var(--gold-2); }

.row, .actions, .progress-head, .table-head, .pager, .filters {
  display: flex;
  gap: 8px;
  align-items: center;
}

.filters { flex-wrap: wrap; margin-bottom: 12px; }

.row input, #search, #tag, .field input, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
}

select { min-width: 160px; }

button {
  border: 0;
  border-radius: 999px;
  background: var(--grad);
  color: #fff;
  font: inherit;
  font-weight: 800;
  padding: 11px 16px;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(38, 87, 254, 0.22);
}

button:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.ghost-btn {
  background: #fff;
  color: var(--ink);
  border: 1.5px solid var(--line);
  box-shadow: none;
}
.actions { margin-top: 14px; flex-wrap: wrap; }

.next-copy {
  margin: 0 0 14px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}
.text-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 0;
  background: none;
  border: 0;
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  box-shadow: none;
}
.text-btn:disabled { opacity: 0.45; }
.more {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.more summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}
.more .hint { margin: 10px 0; }
.more .ghost-btn { margin-top: 8px; }

.stats dl { display: grid; gap: 10px; margin: 0; }
.stats div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}
dd { margin: 0; font-weight: 800; font-size: 22px; color: var(--ink); }

.history, .logs, .item-list {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow: auto;
}

.history { max-height: 180px; }
.logs { max-height: 260px; }
.progress-wide .logs { max-height: calc(100vh - 280px); min-height: 420px; }
.now-item {
  min-height: 1.4em;
  margin: 4px 0 8px;
  font-weight: 800;
  font-size: 22px;
  color: var(--accent-2);
}
.catalog-wide { min-height: 72vh; }
.catalog-wide .item-list, .catalog-wide .item-grid { max-height: none; }
.item-list { max-height: calc(72vh - 230px); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.catalog-card { padding: 22px; }
.catalog-head { margin-bottom: 16px; }
.catalog-head h2 { margin-bottom: 6px; }
.catalog-head .hint { margin: 0; max-width: 46rem; }
.catalog-card #search {
  font-size: 16px;
  padding: 14px 16px;
  margin-bottom: 16px;
  border-radius: 16px;
  box-shadow: 0 8px 20px rgba(24, 32, 56, 0.05);
}
.catalog-toolbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.field {
  display: flex;
  flex-direction: column;
  margin: 0;
  color: var(--ink);
}
.field span {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold-2);
}
.field select { width: 100%; min-width: 0; }
.filter-group { margin-bottom: 14px; }
.filter-label {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold-2);
}
.catalog-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin: 4px 0 16px;
  color: var(--muted);
  font-size: 14px;
}
.summary-clear {
  width: auto;
  margin: 0;
  padding: 6px 10px;
  text-align: right;
}
.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 14px;
  margin: 0 0 16px;
  overflow: visible;
}
.item-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-height: 188px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 10px 22px rgba(24, 32, 56, 0.06);
}
.item-card:hover, .item-card.active {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 14px 28px rgba(24, 32, 56, 0.1);
}
.item-card .item-title {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.03em;
  line-height: 1.25;
  margin-bottom: 8px;
}
.item-card .open-hint {
  margin-top: auto;
  padding-top: 12px;
  color: var(--gold-2);
  font-size: 13px;
  font-weight: 650;
}
.item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  max-width: 100%;
}
.item-tags .chip,
.tag-chips .chip {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.item-tags .chip:hover,
.tag-chips .chip:hover {
  border-color: var(--accent);
  color: var(--accent-2);
}
.muted-chip {
  color: var(--muted);
  cursor: default;
}
.badge.muted {
  background: rgba(111, 106, 94, 0.1);
  color: var(--muted);
}
.oa-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}
.filter-chip {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  box-shadow: none;
}
.filter-chip small {
  margin-left: 4px;
  color: var(--muted);
  font-weight: 400;
}
.filter-chip.active {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 18px rgba(38, 87, 254, 0.22);
}
.filter-chip.active small { color: rgba(255, 255, 255, 0.82); }
.filter-chip[data-filter="alerta"].active {
  background: rgba(213, 122, 114, 0.16);
  border-color: var(--err);
  color: var(--err);
}
.item-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  align-items: center;
}
.chip.mini {
  cursor: pointer;
  padding: 2px 8px;
  font-size: 11px;
}
.history li, .logs li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.logs time { color: var(--gold); margin-right: 8px; }

.bar {
  height: 8px;
  border-radius: 999px;
  background: #e9eefb;
  overflow: hidden;
  margin: 10px 0 12px;
}

#bar-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--grad);
  transition: width 0.25s ease;
}

.check {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0;
  color: var(--ink);
  font-size: 13px;
}

.item {
  width: 100%;
  text-align: left;
  background: transparent;
  color: inherit;
  border: 1px solid transparent;
  border-bottom: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 10px;
  font-weight: 500;
  box-shadow: none;
}

.item:hover, .item.active { border-color: var(--line); background: #eaf0ff; }
.item.item-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-height: 188px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 10px 22px rgba(24, 32, 56, 0.06);
}
.item.item-card:hover, .item.item-card.active {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 14px 28px rgba(24, 32, 56, 0.1);
}
.item-title { display: block; }
.item-meta { display: block; margin-top: 4px; font-size: 12px; font-weight: 400; }
.badge {
  display: inline-block;
  margin-top: 0;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(143, 191, 122, 0.16);
  color: var(--ok);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge.warn {
  background: rgba(213, 122, 114, 0.16);
  color: var(--err);
  cursor: pointer;
}

.reader { overflow: auto; }
.empty { padding: 48px 12px; text-align: center; }
.cover { width: 100%; max-height: 240px; object-fit: cover; border-radius: 16px; margin-bottom: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 18px; }
.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--gold-2);
}

.block { margin: 22px 0; padding-top: 8px; border-top: 1px solid var(--line); }
.block h2 { color: var(--gold-2); font-size: 15px; letter-spacing: 0.08em; text-transform: uppercase; }

.prose, .prose p, .option { line-height: 1.65; }
.prose a { color: var(--gold); }
.prose table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.prose td, .prose th { border: 1px solid var(--line); padding: 8px; }
.prose img, .media-img { max-width: 100%; border-radius: 12px; }
.prose ul { padding-left: 18px; }

.topic { margin: 18px 0; }
.section {
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f7faff;
}

.kind {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
}

.callout { border-color: #c9d6ff; background: #eaf0ff; }
.iframe-alert {
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(213, 122, 114, 0.55);
  background: rgba(213, 122, 114, 0.12);
}
.iframe-alert strong { display: block; color: var(--err); margin-bottom: 6px; }
.iframe-alert p { margin: 0 0 10px; color: var(--ink); font-size: 14px; }
.caption { margin-top: 8px; font-size: 13px; color: var(--muted); }
.video, .frame { width: 100%; min-height: 360px; border: 0; border-radius: 12px; background: #000; }
.podcast-frame { min-height: 300px; background: #111; }
.audio { width: 100%; margin: 8px 0; }
.option { margin: 8px 0; padding: 10px; border-radius: 10px; border: 1px solid var(--line); }
.option.correct { border-color: rgba(143, 191, 122, 0.7); }
.objectives { margin: 0; padding-left: 18px; }

.figure {
  margin: 0;
  padding: 8px;
  background: #eef2fb;
  border-radius: 16px;
}
.figure img {
  display: block;
  width: 100%;
  max-height: 520px;
  object-fit: contain;
  background: #eef2fb;
  border-radius: 12px;
}
.figure figcaption {
  margin-top: 10px;
  padding: 0 6px 4px;
}
.figure figcaption strong {
  display: block;
  color: var(--ink);
}
.figure figcaption span {
  display: block;
  margin-top: 4px;
  font-size: 12px;
}
.reader-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 8px;
}
a.ghost-btn {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  border: 1.5px solid var(--line);
  font-weight: 800;
  padding: 11px 16px;
  text-decoration: none;
}
.quote {
  margin: 0;
  padding: 2px 0 2px 14px;
  border-left: 3px solid var(--accent);
}
.fold-list { display: grid; gap: 10px; }
.fold {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.fold h4 { margin: 0 0 6px; font-size: 15px; }
.live-feed {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid #d7e1ff;
  border-radius: 14px;
  background: #eaf0ff;
}
.live-feed[hidden] { display: none; }
.live-feed-title {
  margin: 0 0 4px;
  color: var(--gold-2);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.live-feed-step {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 14px;
}
.live-feed ol {
  margin: 0;
  padding: 0;
  list-style: none;
}
.live-feed li {
  font-size: 13px;
  color: var(--muted);
  padding: 4px 0;
  border-top: 1px solid var(--line);
}
.live-feed li:last-child { color: var(--ink); }
.katex-display {
  margin: 12px 0;
  overflow-x: auto;
}
.latex {
  color: var(--gold-2);
}
.pdf-frame {
  width: 100%;
  min-height: 640px;
  border: 0;
  border-radius: 12px;
  background: #fff;
}
.pdf-figure figcaption {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

@media (max-width: 1100px) {
  .layout, .browse, .view, .coleta-layout { display: block; width: min(100% - 20px, 1440px); }
  .item-list, .list-card, .reader, .progress-wide .logs { max-height: none; min-height: 0; }
  .catalog-toolbar { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .top-bar {
    flex-wrap: wrap;
    border-radius: 24px;
    padding: 12px 14px;
    gap: 10px;
  }
  .brand { min-width: 0; }
  .top-actions { margin-left: auto; }
  .tabs {
    order: 3;
    width: 100%;
    flex: 1 1 100%;
    margin: 0;
    justify-content: stretch;
  }
  .tabs a,
  .tabs button { flex: 1; }
}

.login-body { min-height: 100vh; }
.login-wrap {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  padding: 28px 24px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}
.login-card .brand { margin-bottom: 22px; }
.login-card h1 { margin-bottom: 8px; }
.login-card .hint { margin: 0 0 18px; }
.login-card .field { margin-bottom: 12px; }
.login-card .field span { color: var(--ink); text-transform: none; letter-spacing: 0; font-size: 13px; }
.login-card input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
}
.login-card button[type="submit"] { width: 100%; margin-top: 8px; }
.login-error {
  margin: 0 0 8px;
  color: var(--err);
  font-size: 14px;
  font-weight: 700;
}
