/* ============================================================
   Tablero de proyectos de IA — BDBLC. Paleta anclada en el azul
   corporativo #002E65. Tema claro/oscuro por tokens.
   ============================================================ */
:root {
  --bg:#EBEEF4; --surface:#FFFFFF; --surface-2:#F4F6FA; --ink:#141B2B; --ink-2:#47526B; --ink-3:#6E7A90;
  --line:#DBE1EC; --line-2:#E9EDF4; --brand:#002E65; --brand-2:#234E86; --gold:#9C7C3A; --focus:#2E6BD6;
  --st-en-curso:#B0771B; --st-operativo:#1B8656; --st-bloqueado:#C1362A; --st-en-pausa:#6C7A93; --st-entregado:#3C6BA6; --st-idea:#8A93A6;
  --shadow:0 1px 2px rgba(16,28,54,.05),0 6px 18px rgba(16,28,54,.06);
  --shadow-lift:0 2px 6px rgba(16,28,54,.08),0 18px 40px rgba(16,28,54,.12);
  --shadow-modal:0 30px 80px rgba(10,18,40,.28);
  --radius:14px; --maxw:1180px;
  --serif:Georgia,"Iowan Old Style","Palatino Linotype","Times New Roman",serif;
  --sans:system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
  --mono:"SF Mono","JetBrains Mono","Cascadia Code",ui-monospace,Menlo,Consolas,monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg:#0A101C; --surface:#121B2C; --surface-2:#0E1626; --ink:#E7ECF5; --ink-2:#AAB5C9; --ink-3:#7C8AA2;
    --line:#253248; --line-2:#1B2637; --brand:#6FA0E0; --brand-2:#8FB6EC; --gold:#C7A868; --focus:#6FA0E0;
    --st-en-curso:#E0A542; --st-operativo:#38B57F; --st-bloqueado:#E86A55; --st-en-pausa:#8B98AE; --st-entregado:#6C9BD8; --st-idea:#9AA4B7;
    --shadow:0 1px 2px rgba(0,0,0,.3),0 6px 20px rgba(0,0,0,.35);
    --shadow-lift:0 2px 8px rgba(0,0,0,.35),0 22px 46px rgba(0,0,0,.5);
    --shadow-modal:0 30px 80px rgba(0,0,0,.6);
  }
}
:root[data-theme="light"] {
  --bg:#EBEEF4; --surface:#FFFFFF; --surface-2:#F4F6FA; --ink:#141B2B; --ink-2:#47526B; --ink-3:#6E7A90;
  --line:#DBE1EC; --line-2:#E9EDF4; --brand:#002E65; --brand-2:#234E86; --gold:#9C7C3A; --focus:#2E6BD6;
  --st-en-curso:#B0771B; --st-operativo:#1B8656; --st-bloqueado:#C1362A; --st-en-pausa:#6C7A93; --st-entregado:#3C6BA6; --st-idea:#8A93A6;
  --shadow:0 1px 2px rgba(16,28,54,.05),0 6px 18px rgba(16,28,54,.06);
  --shadow-lift:0 2px 6px rgba(16,28,54,.08),0 18px 40px rgba(16,28,54,.12);
  --shadow-modal:0 30px 80px rgba(10,18,40,.28);
}
:root[data-theme="dark"] {
  --bg:#0A101C; --surface:#121B2C; --surface-2:#0E1626; --ink:#E7ECF5; --ink-2:#AAB5C9; --ink-3:#7C8AA2;
  --line:#253248; --line-2:#1B2637; --brand:#6FA0E0; --brand-2:#8FB6EC; --gold:#C7A868; --focus:#6FA0E0;
  --st-en-curso:#E0A542; --st-operativo:#38B57F; --st-bloqueado:#E86A55; --st-en-pausa:#8B98AE; --st-entregado:#6C9BD8; --st-idea:#9AA4B7;
  --shadow:0 1px 2px rgba(0,0,0,.3),0 6px 20px rgba(0,0,0,.35);
  --shadow-lift:0 2px 8px rgba(0,0,0,.35),0 22px 46px rgba(0,0,0,.5);
  --shadow-modal:0 30px 80px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--sans); background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; line-height: 1.5; }

.eyebrow { margin: 0 0 8px; font-size: .72rem; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-3); }

/* ---------- Botones ---------- */
.btn { font: inherit; font-size: .86rem; font-weight: 600; cursor: pointer; border-radius: 10px; padding: 9px 15px;
  border: 1px solid transparent; display: inline-flex; align-items: center; gap: 8px; transition: background .13s, border-color .13s, color .13s, transform .1s; }
.btn svg { width: 15px; height: 15px; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn-ghost { background: var(--surface); color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover { color: var(--ink); border-color: var(--brand-2); }
.btn-danger { background: transparent; color: var(--st-bloqueado); border-color: color-mix(in srgb, var(--st-bloqueado) 40%, var(--line)); }
.btn-danger:hover { background: color-mix(in srgb, var(--st-bloqueado) 12%, transparent); }
.btn[disabled] { opacity: .55; cursor: default; }
.iconbtn { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink-2); cursor: pointer; box-shadow: var(--shadow); transition: color .13s, border-color .13s; }
.iconbtn svg { width: 17px; height: 17px; }
.iconbtn:hover { color: var(--brand); border-color: var(--brand-2); }
.linkbtn { background: none; border: 0; color: var(--brand); cursor: pointer; font: inherit; font-size: .8rem; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; padding: 0; }

/* On dark, brand becomes light — primary button needs dark ink for contrast */
@media (prefers-color-scheme: dark) { .btn-primary { color: #0A101C; } }
:root[data-theme="dark"] .btn-primary { color: #0A101C; }
:root[data-theme="light"] .btn-primary { color: #fff; }

/* ---------- Overlays (login + modal) ---------- */
.overlay { position: fixed; inset: 0; background: color-mix(in srgb, var(--bg) 70%, rgba(10,18,40,.6)); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.overlay[hidden] { display: none; }

.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-modal);
  padding: 34px 32px; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 4px; }
.login-logo { height: 34px; width: auto; align-self: flex-start; margin-bottom: 18px; }
.login-title { font-family: var(--serif); font-weight: 600; color: var(--brand); font-size: 2rem; margin: 0; letter-spacing: -.01em; }
.login-sub { margin: 4px 0 18px; color: var(--ink-3); font-size: .9rem; }
.login-error { margin: 4px 0 0; color: var(--st-bloqueado); font-size: .85rem; font-weight: 600; }
.login-error[hidden] { display: none; }
.login-card .btn-primary { margin-top: 14px; justify-content: center; padding: 11px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.field > span { font-size: .78rem; font-weight: 600; color: var(--ink-2); letter-spacing: .02em; }
.field > span em { color: var(--st-bloqueado); font-style: normal; }
.field > span em.muted { color: var(--ink-3); font-weight: 400; }
.field input, .field select, .field textarea {
  font: inherit; font-size: .92rem; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 9px; padding: 9px 11px; width: 100%; outline: none; transition: border-color .13s, box-shadow .13s; }
.field textarea { resize: vertical; line-height: 1.45; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.field.checkline { flex-direction: row; align-items: center; gap: 9px; margin-top: 20px; }
.field.checkline input { width: auto; }
.field.checkline span { font-size: .85rem; color: var(--ink-2); }

/* ---------- Modal editor ---------- */
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-modal);
  width: 100%; max-width: 640px; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 12px; }
.modal-head h2 { margin: 0; font-family: var(--serif); font-size: 1.4rem; color: var(--brand); font-weight: 600; }
.modal-body { padding: 8px 24px 20px; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; }
.modal-body .field { margin-top: 12px; }
.modal-body .span2 { grid-column: 1 / -1; }
.modal-foot { display: flex; align-items: center; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--line-2); background: var(--surface-2); }
.modal-foot .spacer { flex: 1; }

/* ---------- Page / masthead ---------- */
.page { padding: clamp(18px,4vw,44px) clamp(14px,4vw,40px) 60px; min-height: 100vh; }
.page[hidden] { display: none; }
.wrap { max-width: var(--maxw); margin: 0 auto; }
.masthead { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding-bottom: 22px; margin-bottom: 26px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.masthead h1 { font-family: var(--serif); font-weight: 600; color: var(--brand); font-size: clamp(1.9rem,4.6vw,3rem); line-height: 1.02; margin: 0; letter-spacing: -.01em; text-wrap: balance; display: flex; align-items: center; gap: 18px; }
.mast-rule { flex: 1; height: 2px; min-width: 30px; background: linear-gradient(90deg, var(--gold), transparent); border-radius: 2px; opacity: .8; }
.mast-sub { margin: 12px 0 0; color: var(--ink-2); font-size: .95rem; }
.mast-sub b { color: var(--ink); font-weight: 600; }
.mast-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.user { display: flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px 6px 14px; box-shadow: var(--shadow); }
.user #user-name { font-weight: 600; color: var(--ink); }

/* ---------- KPIs + distro ---------- */
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 16px 14px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--kc, var(--brand)); }
.kpi-n { font-family: var(--serif); font-size: 2.1rem; line-height: 1; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi-l { margin-top: 8px; font-size: .78rem; font-weight: 600; letter-spacing: .04em; color: var(--ink-2); text-transform: uppercase; display: flex; align-items: center; gap: 7px; }
.kpi-l .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--kc, var(--brand)); flex: none; }
.distro { display: flex; height: 12px; border-radius: 999px; overflow: hidden; margin: 6px 0 30px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.distro span { display: block; min-width: 2px; }
.distro.empty { display: none; }

/* ---------- section heading ---------- */
.section-h { font-size: .82rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 14px; display: flex; align-items: center; gap: 10px; }
.section-h .badge { font-family: var(--mono); font-size: .72rem; letter-spacing: 0; font-weight: 600; color: var(--st-bloqueado); background: color-mix(in srgb, var(--st-bloqueado) 12%, transparent); border: 1px solid color-mix(in srgb, var(--st-bloqueado) 30%, transparent); padding: 1px 8px; border-radius: 999px; text-transform: none; }

/* ---------- attention lane ---------- */
.attention { margin-bottom: 26px; }
.attention[hidden] { display: none; }
.att-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; }
.att-card { background: var(--surface); border: 1px solid color-mix(in srgb, var(--st) 34%, var(--line)); border-left: 4px solid var(--st); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); cursor: pointer; transition: box-shadow .14s, transform .14s; }
.att-card:hover { box-shadow: var(--shadow-lift); transform: translateY(-2px); }
.att-card .att-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.att-card h3 { margin: 0; font-size: 1.02rem; font-weight: 650; color: var(--ink); }
.att-card .why { margin: 8px 0 0; font-size: .9rem; color: var(--ink-2); }
.att-card .why b { color: var(--st); font-weight: 600; }
.att-card .next { margin: 10px 0 0; font-size: .92rem; color: var(--ink); }
.att-card .next span { display: block; font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 3px; font-weight: 700; }

/* ---------- controls ---------- */
.controls { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.controls-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.search { flex: 1 1 220px; min-width: 180px; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; box-shadow: var(--shadow); }
.search svg { width: 16px; height: 16px; color: var(--ink-3); flex: none; }
.search input { border: 0; background: transparent; font: inherit; color: var(--ink); width: 100%; outline: none; }
.search input::placeholder { color: var(--ink-3); }
.sortsel { display: inline-flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; box-shadow: var(--shadow); }
.sortsel label { font-size: .78rem; color: var(--ink-3); font-weight: 600; letter-spacing: .04em; }
.sortsel select { border: 0; background: transparent; font: inherit; color: var(--ink); padding: 9px 4px; outline: none; cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; background: var(--surface); color: var(--ink-2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; display: inline-flex; align-items: center; gap: 7px; transition: color .12s, border-color .12s, background .12s; }
.chip .cdot { width: 8px; height: 8px; border-radius: 50%; background: var(--cc, var(--ink-3)); flex: none; }
.chip .cn { font-family: var(--mono); font-size: .72rem; color: var(--ink-3); }
.chip:hover { border-color: var(--brand-2); color: var(--ink); }
.chip[aria-pressed="true"] { background: color-mix(in srgb, var(--cc, var(--brand)) 14%, var(--surface)); border-color: color-mix(in srgb, var(--cc, var(--brand)) 45%, var(--line)); color: var(--ink); }
.chip[aria-pressed="true"] .cn { color: color-mix(in srgb, var(--cc, var(--brand)) 70%, var(--ink-3)); }
.chips-label { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); font-weight: 700; margin-right: 4px; align-self: center; }
.clearbtn { font: inherit; font-size: .78rem; font-weight: 600; background: none; border: 0; color: var(--brand); cursor: pointer; padding: 6px 4px; text-decoration: underline; text-underline-offset: 3px; }
.clearbtn[hidden] { display: none; }

/* ---------- board / cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; align-items: start; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; position: relative; transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease; }
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); border-color: color-mix(in srgb, var(--st) 40%, var(--line)); }
.card-stripe { height: 3px; background: var(--st); }
.card-body { padding: 15px 17px 16px; }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card h3 { margin: 0; font-size: 1.02rem; font-weight: 650; color: var(--ink); line-height: 1.25; text-wrap: balance; }
.card-actions { display: flex; gap: 4px; flex: none; opacity: 0; transition: opacity .13s; }
.card:hover .card-actions, .card:focus-within .card-actions { opacity: 1; }
.minibtn { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-3); cursor: pointer; }
.minibtn svg { width: 14px; height: 14px; }
.minibtn:hover { color: var(--brand); border-color: var(--brand-2); }
.pri { flex: none; display: inline-flex; gap: 3px; align-items: flex-end; height: 15px; padding-top: 3px; }
.pri i { width: 4px; border-radius: 1px; background: var(--line); display: block; }
.pri i:nth-child(1){height:7px;} .pri i:nth-child(2){height:11px;} .pri i:nth-child(3){height:15px;}
.pri[data-p="alta"] i { background: var(--st-bloqueado); }
.pri[data-p="media"] i:nth-child(-n+2) { background: var(--st-en-curso); }
.pri[data-p="baja"] i:nth-child(1) { background: var(--ink-3); }
.meta { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; margin: 11px 0 0; }
.pill { font-size: .73rem; font-weight: 650; letter-spacing: .02em; padding: 3px 9px; border-radius: 999px; color: var(--st); background: color-mix(in srgb, var(--st) 13%, transparent); border: 1px solid color-mix(in srgb, var(--st) 32%, transparent); display: inline-flex; align-items: center; gap: 6px; }
.pill .pdot { width: 7px; height: 7px; border-radius: 50%; background: var(--st); }
.tag { font-size: .73rem; font-weight: 600; color: var(--ink-3); padding: 3px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.resp { font-size: .78rem; color: var(--ink-3); margin-left: auto; }
.next { margin: 13px 0 0; }
.next-l { font-size: .67rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); font-weight: 700; margin-bottom: 4px; }
.next-t { font-size: .9rem; color: var(--ink); }
.next-t.done { color: var(--ink-3); font-style: italic; }
.block { margin: 11px 0 0; font-size: .84rem; padding: 9px 11px; border-radius: 9px; color: var(--st-bloqueado); background: color-mix(in srgb, var(--st-bloqueado) 9%, transparent); border: 1px solid color-mix(in srgb, var(--st-bloqueado) 24%, transparent); }
.block b { font-weight: 700; letter-spacing: .04em; text-transform: uppercase; font-size: .72rem; }
.card.pauseblock .block { color: var(--st-en-pausa); background: color-mix(in srgb, var(--st-en-pausa) 11%, transparent); border-color: color-mix(in srgb, var(--st-en-pausa) 26%, transparent); }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-2); }
.signal { display: inline-flex; align-items: center; gap: 7px; font-family: var(--mono); font-size: .74rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.signal .fdot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.fresh { background: var(--st-operativo); } .warm { background: var(--st-en-curso); } .stale { background: var(--ink-3); }
.rel { color: var(--ink-2); }
.detail { font-family: var(--mono); font-size: .74rem; color: var(--ink-3); max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.detail { color: var(--brand); text-decoration: none; }
a.detail:hover { text-decoration: underline; }
details.notes { margin-top: 11px; }
details.notes summary { font-size: .78rem; color: var(--brand); cursor: pointer; font-weight: 600; list-style: none; display: inline-flex; align-items: center; gap: 5px; }
details.notes summary::-webkit-details-marker { display: none; }
details.notes summary::after { content: "+"; font-family: var(--mono); }
details.notes[open] summary::after { content: "\2212"; }
details.notes p { margin: 8px 0 0; font-size: .84rem; color: var(--ink-2); white-space: pre-wrap; }
.empty { text-align: center; color: var(--ink-3); padding: 50px 20px; font-size: .95rem; }
.empty[hidden] { display: none; }

/* ---------- footer ---------- */
.foot { margin-top: 40px; padding-top: 22px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: .82rem; }
.legend { display: flex; flex-wrap: wrap; gap: 14px 20px; margin-bottom: 16px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-2); }
.legend .ld { width: 9px; height: 9px; border-radius: 50%; }
.foot .note { margin: 6px 0 0; max-width: 80ch; }
.foot .note b { color: var(--ink-2); }

/* ---------- toasts ---------- */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: var(--surface); padding: 11px 18px; border-radius: 10px; font-size: .88rem; font-weight: 500; box-shadow: var(--shadow-lift); animation: toastin .2s ease; max-width: 90vw; }
.toast.err { background: var(--st-bloqueado); color: #fff; }
.toast.ok { background: var(--st-operativo); color: #fff; }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

:where(a,button,select,input,textarea,summary):focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media (max-width: 860px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid, .att-grid { grid-template-columns: 1fr; }
  .resp { margin-left: 0; width: 100%; }
  .modal-body { grid-template-columns: 1fr; }
  .mast-right { width: 100%; }
}
