:root {
  --bg: #f5f6fa; --panel: #ffffff; --text: #1b1f2a; --muted: #6b7285; --line: #e6e8ef;
  --accent: #2f6bff; --accent-2: #e9f0ff; --ok: #12a150; --ok-bg: #e5f7ec; --bad: #d93a3a; --bad-bg: #fdeaea; --warn: #c98a00; --warn-bg: #fff6dc;
  --side: #10162a; --side-text: #c4cbe0; --side-active: #1f2a4a;
  --c1: #2f6bff; --c2: #14b8a6; --c3: #f59e0b; --c4: #a855f7;
  --radius: 12px; --shadow: 0 1px 2px rgba(16, 22, 42, .06), 0 4px 16px rgba(16, 22, 42, .04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1020; --panel: #151b2e; --text: #e7eaf3; --muted: #8d95ad; --line: #252d45;
    --accent: #5b8cff; --accent-2: #1c2747; --ok: #34d17b; --ok-bg: #12301f; --bad: #ff6b6b; --bad-bg: #3a1717; --warn: #f5b83d; --warn-bg: #3a2c0c;
    --side: #080b17; --side-active: #1a2240; --c1: #5b8cff; --c2: #2dd4bf; --c3: #fbbf24; --c4: #c084fc;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 Inter, system-ui, -apple-system, Segoe UI, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 4px 0; letter-spacing: -.02em; }
h2 { font-size: 16px; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
h3 { font-size: 14px; margin: 18px 0 8px; }
code { background: var(--accent-2); padding: 2px 6px; border-radius: 6px; font-size: 12px; word-break: break-all; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.muted { color: var(--muted); } .small, small { font-size: 12px; } .block { display: block; } .strong { font-weight: 600; }
.right { text-align: right; } .center { text-align: center; } .error { color: var(--bad); } .grow { flex: 1; } .inline { display: inline; }

/* Layout */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: var(--side); color: var(--side-text); display: flex; flex-direction: column; padding: 20px 14px; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
.brand { color: #fff; font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; padding: 0 8px 20px; }
.brand.big { font-size: 24px; color: var(--text); justify-content: center; padding: 0; }
.brand-mark { color: var(--c2); font-size: 22px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { color: var(--side-text); padding: 9px 12px; border-radius: 8px; font-weight: 500; }
.sidebar nav a:hover { background: var(--side-active); text-decoration: none; color: #fff; }
.sidebar nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 var(--c2); }
.sidebar-foot { margin-top: auto; border-top: 1px solid #ffffff14; padding-top: 14px; }
.who { display: block; color: #fff; padding: 0 8px; } .who small { display: block; color: var(--side-text); }
.link { background: none; border: 0; color: var(--side-text); cursor: pointer; padding: 6px 8px; font: inherit; }
.main { flex: 1; padding: 28px 32px 60px; min-width: 0; max-width: 1400px; }
.menu-btn { display: none; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 0; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions form { margin: 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.grid-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: 18px; }
.grid-1-1 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; min-width: 0; }
.card.narrow { max-width: 520px; }
.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Forms */
label { display: flex; flex-direction: column; gap: 5px; font-weight: 500; font-size: 13px; }
label.inline { flex-direction: row; align-items: center; gap: 8px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=checkbox] { width: auto; }
textarea { resize: vertical; }
select.sm { padding: 5px 8px; width: auto; font-size: 12px; }
.inline-form { display: flex; gap: 8px; align-items: center; margin: 0; }
.inline-form select { width: auto; }
.grow-input input { flex: 1; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 9px 14px; border-radius: 8px; font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); } .btn.danger:hover { border-color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .6; cursor: wait; }
.help { background: var(--accent-2); border-radius: 10px; padding: 4px 14px; margin-bottom: 14px; }

.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-weight: 500; }
.flash.ok { background: var(--ok-bg); color: var(--ok); } .flash.error { background: var(--bad-bg); color: var(--bad); }
.pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--accent-2); color: var(--accent); text-transform: capitalize; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.bad { background: var(--bad-bg); color: var(--bad); }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow); }
.kpi span:first-child { color: var(--muted); font-size: 12px; font-weight: 500; }
.kpi strong { font-size: 24px; letter-spacing: -.02em; }
.kpi.warn strong { color: var(--warn); }
.delta { font-size: 12px; font-weight: 600; } .delta.up { color: var(--ok); } .delta.down { color: var(--bad); } .delta.flat { color: var(--muted); }
.score { display: inline-block; min-width: 38px; text-align: center; padding: 2px 8px; border-radius: 6px; font-weight: 700; font-size: 12px; }
.score.s0 { background: var(--bad-bg); color: var(--bad); } .score.s1 { background: var(--warn-bg); color: var(--warn); } .score.s2 { background: var(--ok-bg); color: var(--ok); }

/* Tables */
.table-wrap { overflow-x: auto; }
.scroll-y { max-height: 360px; overflow-y: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table.compact td { padding: 7px 10px; }
.table.compact td:first-child { white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.w-check { width: 32px; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--accent); border-color: var(--accent); }
.filters { display: flex; gap: 6px; margin-bottom: 14px; }
.filters a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); background: var(--panel); }
.filters a.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Charts */
.chart { position: relative; height: 260px; } .chart.tall { height: 340px; } .chart.small { height: 160px; margin-top: 16px; }

/* Lists */
.list { list-style: none; padding: 0; margin: 0 0 16px; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 20px; display: flex; flex-direction: column; }
.timeline li::before { content: ''; position: absolute; left: 4px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.timeline li::after { content: ''; position: absolute; left: 7px; top: 16px; bottom: 0; width: 2px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline li.k-review::before { background: var(--c3); } .timeline li.k-post::before { background: var(--c2); }
.timeline li.k-llm::before, .timeline li.k-audit::before { background: var(--c4); } .timeline li.k-task::before { background: var(--ok); }
.timeline small { color: var(--muted); }
.tasks { list-style: none; margin: 0 0 12px; padding: 0; }
.tasks li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.tasks.big li { padding: 12px 0; }
.tasks .dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--muted); flex-shrink: 0; }
.tasks .t-doing .dot { border-color: var(--warn); background: var(--warn-bg); }
.tasks .t-done .dot { border-color: var(--ok); background: var(--ok); }
.tasks .t-done strong, .tasks li.t-done > :not(.dot):not(form):not(.pill) { color: var(--muted); }
.progress { height: 12px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--c1), var(--c2)); border-radius: 999px; }
.kw-list { list-style: none; padding: 0; margin: 0; }
.kw-list li { display: grid; grid-template-columns: minmax(0, 1.4fr) 1fr 60px; gap: 10px; align-items: center; padding: 5px 0; }
.kw-list li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kw-list b { text-align: right; font-size: 12px; }
.bar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; display: block; }
.bar i { display: block; height: 100%; background: var(--c1); border-radius: 999px; }

/* Cards de fichas */
.loc-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 14px; }
.loc-card { border: 1px solid var(--line); border-radius: 10px; padding: 14px; color: var(--text); display: flex; flex-direction: column; gap: 4px; }
.loc-card:hover { border-color: var(--accent); text-decoration: none; }
.mini-kpis { display: flex; gap: 12px; font-size: 12px; color: var(--muted); margin-top: 6px; }

/* Reseñas */
.reviews .review header { display: flex; align-items: center; gap: 12px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--accent-2); color: var(--accent); display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }
.rating { margin-left: auto; color: #f5a623; letter-spacing: 1px; white-space: nowrap; }
.rating.r1, .rating.r2 { color: var(--bad); }
.reply { background: var(--bg); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 6px; }
.reply p { margin: 4px 0 0; }
.star-row { display: grid; grid-template-columns: 26px 1fr 30px; align-items: center; gap: 8px; font-size: 12px; }
.kpi.stars { gap: 4px; }

/* Publicaciones e imágenes */
.posts { display: flex; flex-direction: column; gap: 14px; }
.post { display: flex; gap: 14px; border-bottom: 1px solid var(--line); padding-bottom: 14px; }
.post img { width: 110px; height: 110px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.post p { white-space: pre-wrap; margin: 6px 0; }
.thumbs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; cursor: pointer; border: 2px solid transparent; }
.thumbs img.picked { border-color: var(--accent); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.img-card { padding: 0; overflow: hidden; margin: 0; }
.img-card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.img-card figcaption { padding: 12px 14px; }
.img-placeholder { aspect-ratio: 1; display: grid; place-items: center; color: var(--muted); background: var(--bg); padding: 20px; text-align: center; }
.img-placeholder.bad { color: var(--bad); }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 4px 0 8px; }
.md-out { margin-top: 14px; }
.md-out li { margin-left: 18px; }

/* Auditoría y LLM */
.gauge { --v: 0; width: 160px; height: 160px; border-radius: 50%; margin: 10px auto 14px; display: grid; place-items: center; align-content: center;
  background: radial-gradient(closest-side, var(--panel) 78%, transparent 79%), conic-gradient(var(--c1) calc(var(--v) * 1%), var(--line) 0); }
.gauge span { font-size: 38px; font-weight: 700; letter-spacing: -.03em; line-height: 1; }
.checks { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; }
.checks li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.checks li small { margin-left: auto; white-space: nowrap; }
.ic { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.ok > .ic, .ok > summary .ic { background: var(--ok-bg); color: var(--ok); }
.bad > .ic, .bad > summary .ic { background: var(--bad-bg); color: var(--bad); }
.recs { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.rec { border: 1px solid var(--line); border-left: 4px solid var(--c1); border-radius: 8px; padding: 12px 14px; }
.rec.p-alta { border-left-color: var(--bad); } .rec.p-media { border-left-color: var(--warn); } .rec.p-baja { border-left-color: var(--ok); }
.rec strong { display: block; margin: 6px 0 2px; } .rec p { margin: 0; color: var(--muted); }
.code { font-family: ui-monospace, Consolas, monospace; font-size: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 14px; overflow-x: auto; white-space: pre; margin: 0 0 10px; }
textarea.code { white-space: pre-wrap; margin-top: 12px; }
.llm-q { border-bottom: 1px solid var(--line); padding: 10px 0; }
.llm-q summary { cursor: pointer; display: flex; align-items: center; gap: 10px; font-weight: 500; }
.llm-q ol { margin: 10px 0 0 32px; padding: 0; }
.sticky-bar { position: sticky; bottom: 12px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* Modales y utilidades */
.modal { border: 1px solid var(--line); border-radius: 14px; padding: 24px; width: min(560px, calc(100vw - 32px)); background: var(--panel); color: var(--text); }
.modal::backdrop { background: rgba(8, 11, 23, .55); }
.copy { cursor: pointer; }
.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Login */
body.auth { display: grid; place-items: center; min-height: 100vh; padding: 16px; background: radial-gradient(circle at 20% 10%, var(--accent-2), var(--bg) 60%); }
.auth-card { width: min(400px, 100%); display: flex; flex-direction: column; gap: 14px; text-align: center; padding: 32px; }
.auth-card label { text-align: left; }

/* Responsive */
@media (max-width: 1100px) {
  .grid-2-1, .grid-1-2, .grid-1-1 { grid-template-columns: 1fr; }
  .checks { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .grid-2, .row { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 20; left: -260px; transition: left .2s; }
  .sidebar.open { left: 0; }
  .main { padding: 16px 16px 60px; }
  .menu-btn { display: inline-block; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; font-size: 18px; margin-bottom: 12px; color: var(--text); cursor: pointer; }
  .post { flex-direction: column; } .post img { width: 100%; height: auto; aspect-ratio: 4/3; }
}

/* Pipeline (kanban) */
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.kcol { flex: 0 0 250px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 260px); }
.kcol.human { border-color: var(--c4); box-shadow: inset 0 3px 0 var(--c4); }
.kcol.over { outline: 2px dashed var(--accent); outline-offset: -4px; }
.kcol > header { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
.kcol > header small { margin-left: auto; }
.kdot { width: 10px; height: 10px; border-radius: 50%; background: var(--c1); flex-shrink: 0; }
.kdot.c2 { background: var(--c2); } .kdot.c3 { background: var(--c3); } .kdot.c4 { background: var(--c4); } .kdot.ok { background: var(--ok); } .kdot.bad { background: var(--bad); }
.kdrop { padding: 10px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 80px; }
.kcard { display: flex; flex-direction: column; gap: 3px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--text); background: var(--bg); cursor: grab; }
.kcard:hover { border-color: var(--accent); text-decoration: none; }
.kcard.dragging { opacity: .5; }
.kcard.needs { border-color: var(--bad); box-shadow: inset 3px 0 0 var(--bad); }
.kmeta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.kmeta small { margin-left: auto; }
.tool-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
