/* Oportunidades — a dark ledger for a working tool that stays open all day.
   Source Serif for what is written about an opportunity, Plex Sans Condensed for the
   interface, DM Mono for every number so columns line up. */

@font-face { font-family: 'Plex Cond'; src: url(/assets/fonts/IBMPlexSansCondensed-Regular.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Plex Cond'; src: url(/assets/fonts/IBMPlexSansCondensed-Medium.woff2) format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Plex Cond'; src: url(/assets/fonts/IBMPlexSansCondensed-SemiBold.woff2) format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Source Serif'; src: url(/assets/fonts/SourceSerif4-Semibold.woff2) format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Source Serif'; src: url(/assets/fonts/SourceSerif4-Italic.woff2) format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: 'DM Mono'; src: url(/assets/fonts/DMMono-Regular.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'DM Mono'; src: url(/assets/fonts/DMMono-Medium.woff2) format('woff2'); font-weight: 500; font-display: swap; }

:root {
  color-scheme: dark;
  --bg: #16140f;
  --bg-2: #1b1914;
  --surface: #211e18;
  --surface-2: #2a2620;
  --line: #3a352d;
  --line-soft: #2b2822;
  --text: #ede6d6;
  --text-2: #bdb5a3;
  --muted: #8b8474;
  --accent: #ff6a3d;
  --accent-soft: rgba(255, 106, 61, .14);
  --accent-ink: #1b0e08;
  --danger: #ff6b6b;
  --ok: #6fd08c;
  --star: #ffc24a;
  --shadow: 0 18px 50px rgba(0, 0, 0, .55), 0 2px 8px rgba(0, 0, 0, .4);
  --scroll: rgba(255, 106, 61, .26);
  --scroll-hi: rgba(255, 106, 61, .5);

  --st-hipotesis: #b39dff;
  --st-con-evidencia: #3cc8d2;
  --st-en-experimento: #f2b134;
  --st-en-marcha: #63d26f;
  --st-dormida: #7096e6;
  --st-descartada: #8f8a82;
  --st-fusionada: #f07fb3;

  --e-complementa: #8ec5a4;
  --e-compite: #ff6b6b;
  --e-depende: #d9b46b;
  --e-variante: #a9a2ff;
  --e-nace-de: #ede6d6;
  --e-fusionada: #f07fb3;

  --f-ui: 'Plex Cond', 'IBM Plex Sans Condensed', 'Roboto Condensed', 'Arial Narrow', sans-serif;
  --f-serif: 'Source Serif', 'Source Serif 4', Georgia, serif;
  --f-mono: 'DM Mono', 'IBM Plex Mono', ui-monospace, monospace;

  --r: 6px;
  --r-lg: 10px;
  --top-h: 52px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f4efe3;
    --bg-2: #efe9db;
    --surface: #fffcf5;
    --surface-2: #ece5d6;
    --line: #d3cab8;
    --line-soft: #e2dacb;
    --text: #1f1c16;
    --text-2: #474238;
    --muted: #7a7262;
    --accent: #d4471c;
    --accent-soft: rgba(212, 71, 28, .1);
    --accent-ink: #fff8f2;
    --danger: #c62828;
    --ok: #23883a;
    --star: #d99000;
    --shadow: 0 18px 50px rgba(60, 45, 20, .18), 0 2px 8px rgba(60, 45, 20, .12);
    --scroll: rgba(212, 71, 28, .26);
    --scroll-hi: rgba(212, 71, 28, .48);

    --st-hipotesis: #6a4fd6;
    --st-con-evidencia: #0b8792;
    --st-en-experimento: #a86b00;
    --st-en-marcha: #23883a;
    --st-dormida: #2f5bb8;
    --st-descartada: #6e695f;
    --st-fusionada: #b83a78;

    --e-complementa: #3f8a5f;
    --e-compite: #c62828;
    --e-depende: #9a7420;
    --e-variante: #5b52d6;
    --e-nace-de: #1f1c16;
    --e-fusionada: #b83a78;
  }
}

/* ---- reset and base */

*, *::before, *::after { box-sizing: border-box; }
* { scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-hi); border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-corner { background: transparent; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.45 var(--f-ui);
  font-feature-settings: 'tnum' 1;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .7 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: light) { body::before { opacity: .09; filter: invert(1); } }

a { color: inherit; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }
[hidden] { display: none !important; }
.num, .mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- header */

.top {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: calc(var(--top-h) + var(--safe-t));
  padding: var(--safe-t) calc(16px + var(--safe-r)) 0 calc(16px + var(--safe-l));
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px) saturate(1.2);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  border-bottom: 1px solid var(--line-soft);
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  font: 600 19px/1 var(--f-serif);
  letter-spacing: -.01em;
  white-space: nowrap;
}
.brand img { width: 24px; height: 24px; border-radius: 6px; }
.nav { display: flex; gap: 2px; align-self: stretch; }
.nav a {
  display: flex;
  align-items: center;
  padding: 0 11px;
  text-decoration: none;
  color: var(--text-2);
  font-weight: 500;
  letter-spacing: .02em;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.nav a:hover { color: var(--text); }
.nav a[aria-current='page'] { color: var(--text); border-bottom-color: var(--accent); }
.top .spacer { flex: 1; }
.top-actions { display: flex; align-items: center; gap: 8px; }

.sync {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}
.sync .dot { width: 9px; height: 9px; border-radius: 50%; }
.sync.busy .dot { border: 2px solid var(--muted); border-top-color: transparent; animation: spin .8s linear infinite; }
.sync.alarm { color: var(--danger); }
.sync.alarm .dot { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent); }
@keyframes spin { to { transform: rotate(360deg); } }

.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 220px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  z-index: 40;
}
.menu-pop a, .menu-pop button {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--r);
  background: none;
  text-align: left;
  text-decoration: none;
  color: var(--text);
}
.menu-pop a:hover, .menu-pop button:hover { background: var(--surface-2); }
.menu-pop hr { border: 0; border-top: 1px solid var(--line-soft); margin: 5px 4px; }
.menu-pop .hint { display: block; font-size: 12px; color: var(--muted); }

/* ---- banners above everything */

.install-bar, .update-bar {
  position: relative;
  z-index: 31;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(8px + var(--safe-t)) calc(16px + var(--safe-r)) 8px calc(16px + var(--safe-l));
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 500;
}
.install-bar + .update-bar, .install-bar:not([hidden]) ~ .top { --safe-t: 0px; }
.update-bar:not([hidden]) ~ .top { --safe-t: 0px; }
.install-bar p, .update-bar p { margin: 0; flex: 1; }
.install-bar .btn, .update-bar .btn { border-color: color-mix(in srgb, var(--accent-ink) 40%, transparent); color: var(--accent-ink); background: transparent; }
.install-bar .btn.solid, .update-bar .btn.solid { background: var(--accent-ink); color: var(--accent); border-color: var(--accent-ink); }

/* ---- controls */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--text) 25%, var(--line)); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, white); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 28px; padding: 0 9px; font-size: 13px; }
.btn.icon { padding: 0; width: 34px; }
.btn.icon.small { width: 28px; }
.linkish { border: 0; background: none; padding: 0; color: var(--text-2); text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 3px; }
.linkish:hover { color: var(--text); }
.linkish.danger { color: var(--danger); }

input[type=text], input[type=search], input[type=url], input[type=number], input[type=date], input[type=password], select, textarea {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--bg-2);
  color: var(--text);
  font-size: 14.5px;
  min-width: 0;
}
textarea { resize: vertical; line-height: 1.5; min-height: 70px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=date]::-webkit-calendar-picker-indicator { filter: invert(.6); }
@media (prefers-color-scheme: light) { input[type=date]::-webkit-calendar-picker-indicator { filter: none; } }
select { padding-right: 26px; appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 52%, calc(100% - 9px) 52%;
  background-size: 5px 5px;
  background-repeat: no-repeat; }
label.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; color: var(--text-2); white-space: nowrap; }
label.check input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  white-space: nowrap;
  transition: background .12s, color .12s, border-color .12s;
}
.chip:hover { color: var(--text); border-color: color-mix(in srgb, var(--text) 30%, var(--line)); }
.chip[aria-pressed='true'] { background: color-mix(in srgb, var(--c, var(--accent)) 18%, transparent); border-color: var(--c, var(--accent)); color: var(--text); }
.chip:disabled { opacity: .45; cursor: default; }
.chip:disabled:hover { color: var(--text-2); border-color: var(--line); }
.chip[aria-pressed='true']:disabled { opacity: 1; }
.chip .sw { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--muted)); }
.chip .n { color: var(--muted); font-family: var(--f-mono); font-size: 11.5px; }
.chip.add { border-style: dashed; }

.pill {
  --c: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 9px 0 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--c) 15%, transparent);
  color: color-mix(in srgb, var(--c) 82%, var(--text));
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  line-height: 1;
}
.pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
[data-stage='hipotesis'] { --c: var(--st-hipotesis); }
[data-stage='con-evidencia'] { --c: var(--st-con-evidencia); }
[data-stage='en-experimento'] { --c: var(--st-en-experimento); }
[data-stage='en-marcha'] { --c: var(--st-en-marcha); }
[data-stage='dormida'] { --c: var(--st-dormida); }
[data-stage='descartada'] { --c: var(--st-descartada); }
[data-stage='fusionada'] { --c: var(--st-fusionada); }

.tag {
  display: inline-block;
  max-width: 17ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
  padding: 1px 7px;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  color: var(--text-2);
  font-size: 12px;
}

.stars { display: inline-flex; gap: 0; }
.stars button {
  width: 22px;
  height: 26px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--line);
  font-size: 15px;
  line-height: 1;
  transition: color .1s, transform .1s;
}
.stars button.on { color: var(--star); }
.stars:hover button { color: var(--line); }
.stars:hover button.hov { color: color-mix(in srgb, var(--star) 70%, transparent); }
.stars button:active { transform: scale(.85); }
.stars.big button { width: 34px; height: 38px; font-size: 24px; }
.stars.ro button { cursor: default; }

/* ---- view frame */

.view { position: relative; z-index: 1; display: block; padding: 18px calc(20px + var(--safe-r)) calc(56px + var(--safe-b)) calc(20px + var(--safe-l)); outline: none; }
.view.flush { padding: 0; }
.page { max-width: 1480px; margin: 0 auto; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
h1, h2, h3 { margin: 0; font-family: var(--f-serif); font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 19px; }
h3 { font-size: 15.5px; }

.stamp {
  position: fixed;
  right: calc(8px + var(--safe-r));
  bottom: calc(6px + var(--safe-b));
  z-index: 5;
  font: 10.5px/1 var(--f-mono);
  color: var(--muted);
  opacity: .55;
  pointer-events: none;
}

/* ---- resurgir */

.resurface { margin-bottom: 18px; }
.resurface-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.resurface-head h2 { font-size: 17px; }
.resurface-head .linkish { white-space: nowrap; }
.resurface-head h2 em { font-style: italic; font-weight: 400; color: var(--muted); font-size: 14px; margin-left: 6px; }
.resurface-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.rcard {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 13px 15px 13px 17px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  background: linear-gradient(135deg, color-mix(in srgb, var(--c) 9%, var(--surface)), var(--surface) 60%);
  overflow: hidden;
  animation: rise .45s cubic-bezier(.2, .7, .2, 1) both;
}
.rcard:nth-child(2) { animation-delay: .06s; }
.rcard:nth-child(3) { animation-delay: .12s; }
.rcard::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--c); }
.rcard a.t { font: 600 16px/1.25 var(--f-serif); text-decoration: none; }
.rcard a.t:hover { text-decoration: underline; }
.rcard .sig { font-size: 13px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rcard .sig b { color: var(--muted); font-weight: 500; }
.rcard .foot { display: flex; align-items: center; gap: 8px; margin-top: auto; font-size: 12.5px; color: var(--muted); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ---- filters */

.filters {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
}
.frow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.frow > .lbl { width: 62px; flex: none; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.frow .grow { flex: 1; min-width: 180px; }
.frow .field { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); }
.frow .field input[type=number] { width: 64px; }
.filters-toggle { display: none; }
.list-meta { display: flex; align-items: center; gap: 12px; margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.list-meta .count { font-family: var(--f-mono); color: var(--text-2); }
.list-meta .sort-narrow { display: none; }

/* ---- the table */

.tbl-wrap { border: 1px solid var(--line-soft); border-radius: var(--r-lg); overflow: auto; background: color-mix(in srgb, var(--surface) 55%, transparent); }
table.opps { width: 100%; border-collapse: collapse; font-size: 14px; }
table.opps th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 9px 10px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
table.opps th button { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
table.opps th button:hover { color: var(--text); }
table.opps th button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
table.opps th[aria-sort] { color: var(--text); }
table.opps th .arr { color: var(--accent); font-size: 10px; }
table.opps th.r, table.opps td.r { text-align: right; }
table.opps td { padding: 8px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.opps tbody tr { cursor: pointer; transition: background .1s; }
table.opps tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
table.opps tbody tr:last-child td { border-bottom: 0; }
td.c-id { color: var(--muted); font-family: var(--f-mono); font-size: 12.5px; padding-top: 10px; }
td.c-title { min-width: 280px; }
td.c-title a { font-weight: 500; text-decoration: none; font-size: 14.5px; }
td.c-title a:hover { text-decoration: underline; }
td.c-title .need { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--muted); font-size: 13px; margin-top: 2px; }
td.c-title .flags { display: inline-flex; gap: 6px; margin-left: 6px; vertical-align: 1px; }
.flag { font-size: 11px; padding: 0 6px; border-radius: 3px; border: 1px solid currentColor; color: var(--accent); white-space: nowrap; }
td.c-stage, td.c-stars { padding-top: 9px; white-space: nowrap; }
td.c-stars .stars button { width: 17px; height: 22px; font-size: 13px; }
td.c-terr .tag { margin: 0 3px 3px 0; max-width: 24ch; }
td.c-terr { max-width: 240px; }
td.c-score .muted { white-space: nowrap; }
.score { display: inline-grid; gap: 3px; min-width: 74px; }
.score .v { font-family: var(--f-mono); font-size: 13.5px; }
.score .v b { font-weight: 500; color: var(--text); }
.score .v span { color: var(--muted); }
.score .bar { height: 3px; border-radius: 2px; background: var(--line-soft); overflow: hidden; }
.score .bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.score .k { font-size: 11.5px; color: var(--muted); }
td.c-ev, td.c-rev, td.c-upd { font-family: var(--f-mono); font-size: 13px; white-space: nowrap; }
td.c-ev .paid { color: var(--ok); }
td.c-orig { color: var(--text-2); font-size: 13px; white-space: nowrap; }
td.c-upd { color: var(--text-2); }
.empty-state { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty-state h2 { color: var(--text); margin-bottom: 6px; }

/* ---- the ficha */

.ficha { max-width: 1220px; margin: 0 auto; }
.crumbs { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 13.5px; color: var(--muted); }
.crumbs a { text-decoration: none; color: var(--text-2); }
.crumbs a:hover { color: var(--text); }
.merged-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding: 12px 16px;
  margin-bottom: 18px;
  border: 1px solid var(--st-fusionada);
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--st-fusionada) 10%, transparent);
}
.merged-banner p { margin: 0; flex: 1; min-width: 240px; }
.deepen-banner { border-color: var(--accent); background: var(--accent-soft); }

.ficha-head { margin-bottom: 18px; }
.ficha-head .idline { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.ficha-head h1 { font-size: clamp(24px, 3.2vw, 34px); line-height: 1.15; }
.ficha-head .need { margin-top: 8px; font: italic 400 18px/1.45 var(--f-serif); color: var(--text-2); max-width: 70ch; }

.ficha-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }
.ficha-main { display: grid; gap: 26px; min-width: 0; }
.ficha-side { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; min-width: 0; }
.panel { min-width: 0; }
.terr-chips .chip, .stage-picker .chip { white-space: normal; text-align: left; line-height: 1.2; padding-top: 4px; padding-bottom: 4px; }

.panel { padding: 14px 15px; border: 1px solid var(--line-soft); border-radius: var(--r-lg); background: var(--surface); }
.panel > h3, .sec > h2 { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.panel > h3 .aside, .sec > h2 .aside { margin-left: auto; font: 400 12.5px var(--f-ui); color: var(--muted); }
.sec > h2 { padding-bottom: 7px; border-bottom: 1px solid var(--line-soft); }
.sec > h2 .count { font: 400 13px var(--f-mono); color: var(--muted); }

.stage-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.stage-ask { margin-top: 10px; display: grid; gap: 8px; padding: 10px; border-radius: var(--r); background: var(--bg-2); border: 1px dashed var(--line); }
.stage-ask label { font-size: 13px; color: var(--text-2); }
.stage-ask .row { display: flex; gap: 8px; justify-content: flex-end; }

dl.fields { display: grid; grid-template-columns: 150px minmax(0, 1fr); margin: 0; }
dl.fields dt { padding: 9px 12px 9px 0; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line-soft); }
dl.fields dd { margin: 0; padding: 5px 0; border-top: 1px solid var(--line-soft); min-width: 0; }
dl.fields dt:first-of-type, dl.fields dt:first-of-type + dd { border-top: 0; }
dl.fields dt .est { display: inline-block; margin-left: 4px; font-size: 10.5px; padding: 0 5px; border-radius: 3px; background: var(--surface-2); color: var(--text-2); letter-spacing: .03em; }

.ed {
  position: relative;
  display: block;
  min-height: 28px;
  padding: 4px 8px;
  margin: 0 -8px;
  border-radius: var(--r);
  cursor: text;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  transition: background .1s;
}
.ed:hover { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.ed:hover::after { content: '✎'; position: absolute; right: 6px; top: 5px; font-size: 12px; color: var(--muted); }
.ed.empty { color: var(--muted); font-style: italic; }
.ed.saving { opacity: .55; }
.ed-input { display: block; width: calc(100% + 16px); margin: 0 -8px; }
h1 .ed { margin: 0 -8px; }
h1 .ed-input { font: inherit; letter-spacing: inherit; padding: 2px 8px; }
.need .ed-input { font: inherit; }
.ed-hint { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.desc .ed { font: 400 15.5px/1.6 var(--f-ui); color: var(--text); max-width: 78ch; }

.crit { display: grid; gap: 10px; }
.crit-total { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.crit-total .big { font: 500 30px/1 var(--f-mono); }
.crit-total .of { color: var(--muted); font-family: var(--f-mono); }
.crit-item { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; }
.crit-item .name { font-size: 13.5px; font-weight: 500; }
.pips { display: inline-flex; gap: 3px; align-self: center; }
.pips i { width: 14px; height: 6px; border-radius: 2px; background: var(--line); }
.pips i.on { background: var(--accent); }
.crit-item .why { grid-column: 1 / -1; font-size: 12.5px; color: var(--text-2); }
.crit-item.none .name { color: var(--muted); }
.crit-by { font-size: 12px; color: var(--muted); margin-top: 6px; }

.terr-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.items { list-style: none; margin: 0; padding: 0; display: grid; }
.items > li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 10px 0; border-top: 1px solid var(--line-soft); }
.items > li:first-child { border-top: 0; }
.items .meta { font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.items .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.items .acts { display: flex; gap: 4px; align-items: start; }
.etype { display: inline-block; font-size: 11.5px; font-weight: 600; letter-spacing: .04em; padding: 1px 7px; border-radius: 3px; background: var(--surface-2); color: var(--text-2); }
.etype.pago, .etype.ingreso { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }

form.add { display: grid; gap: 8px; margin-top: 10px; padding: 12px; border: 1px dashed var(--line); border-radius: var(--r-lg); }
form.add .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
form.add .row > .grow { flex: 1; min-width: 160px; }
form.add .row.end { justify-content: flex-end; }

.rel-group { margin-top: 6px; }
.rel-group h4 { margin: 12px 0 2px; font-size: 12px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.rel-item { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line-soft); }
.rel-group h4 + .rel-item { border-top: 0; }
.rel-item a { text-decoration: none; flex: 1; min-width: 0; }
.rel-item a:hover .t { text-decoration: underline; }
.rel-item .t { font-weight: 500; }
.rel-item .id { color: var(--muted); font-family: var(--f-mono); font-size: 12.5px; margin-right: 6px; }
.rel-item .note { display: block; color: var(--muted); font-size: 12.5px; }

.picker { position: relative; }
.picker-results { display: grid; gap: 2px; margin-top: 6px; max-height: 260px; overflow: auto; }
.picker-results button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 9px; border: 0; border-radius: var(--r); background: none; text-align: left; }
.picker-results button:hover, .picker-results button:focus-visible { background: var(--surface-2); }
.picker-results .id { color: var(--muted); font-family: var(--f-mono); font-size: 12.5px; min-width: 38px; }
.picker-results .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picked { display: flex; flex-wrap: wrap; gap: 6px; }
.picked .chip { cursor: default; }
.picked .chip button { border: 0; background: none; padding: 0 0 0 2px; color: var(--muted); }

.actions-list { display: grid; gap: 6px; }
.actions-list .btn { justify-content: flex-start; width: 100%; }
.deepen-box { display: grid; gap: 8px; }
.share-row { display: flex; align-items: center; gap: 6px; padding: 6px 0; border-top: 1px solid var(--line-soft); font-size: 12.5px; }
.share-row:first-child { border-top: 0; }
.share-row code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--f-mono); color: var(--text-2); }
.copyline { display: flex; gap: 6px; align-items: center; }
.copyline code { flex: 1; min-width: 0; padding: 6px 8px; background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: var(--r); font: 12.5px var(--f-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.meta-list { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; margin: 0; }
.meta-list dt { color: var(--muted); }
.meta-list dd { margin: 0; color: var(--text-2); overflow-wrap: anywhere; }

table.hist { width: 100%; border-collapse: collapse; font-size: 13px; }
table.hist td { padding: 7px 8px 7px 0; border-top: 1px solid var(--line-soft); vertical-align: top; }
table.hist tr:first-child td { border-top: 0; }
table.hist .when { white-space: nowrap; color: var(--muted); font-family: var(--f-mono); font-size: 12px; }
table.hist .who { white-space: nowrap; color: var(--text-2); }
table.hist .what { font-weight: 500; white-space: nowrap; }
table.hist .chg { overflow-wrap: anywhere; }
table.hist .chg del { color: var(--muted); text-decoration-color: color-mix(in srgb, var(--danger) 60%, transparent); }
table.hist .chg ins { text-decoration: none; color: var(--text); }
table.hist .chg .arrow { color: var(--muted); margin: 0 5px; }
table.hist .why { display: block; color: var(--muted); font-style: italic; margin-top: 2px; }
table.hist .undo { text-align: right; white-space: nowrap; }
.hist-more { margin-top: 8px; }

/* ---- board */

.view.board-view { display: flex; flex-direction: column; height: calc(100vh - var(--top-h) - var(--safe-t)); height: calc(100dvh - var(--top-h) - var(--safe-t)); }
.board-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px calc(20px + var(--safe-r)) 10px calc(20px + var(--safe-l)); }
.bar-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.board-bar .grow { flex: 1; min-width: 160px; max-width: 320px; }
.board {
  display: flex;
  gap: 12px;
  align-items: stretch;
  padding: 4px calc(20px + var(--safe-r)) calc(24px + var(--safe-b)) calc(20px + var(--safe-l));
  overflow-x: auto;
  flex: 1;
  min-height: 0;
  scroll-snap-type: x proximity;
}
.col {
  flex: 0 0 286px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--line-soft);
  border-top: 3px solid var(--c);
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--c) 4%, var(--bg-2));
  scroll-snap-align: start;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.col.over { background: color-mix(in srgb, var(--c) 14%, var(--bg-2)); box-shadow: inset 0 0 0 1px var(--c); }
.col.folded { flex-basis: 52px; }
.col-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; }
.col-head h2 { font-size: 15px; flex: 1; }
.col-head .n { font: 12.5px var(--f-mono); color: var(--muted); }
.col.folded .col-head { flex-direction: column; padding: 10px 4px; gap: 10px; }
.col.folded .col-head h2 { writing-mode: vertical-rl; flex: none; }
.col-body { flex: 1; overflow-y: auto; padding: 2px 8px 10px; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.col.folded .col-body { display: none; }
.card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 8px;
  padding: 10px 10px 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  background: var(--surface);
  text-decoration: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: border-color .1s, box-shadow .1s, opacity .1s;
}
.card:hover { border-color: var(--line); box-shadow: 0 2px 10px rgba(0, 0, 0, .18); }
.card .t { font-weight: 500; font-size: 14px; line-height: 1.3; }
.card .grip {
  grid-row: 1 / span 2;
  grid-column: 2;
  align-self: start;
  width: 30px;
  height: 34px;
  margin: -4px -4px 0 0;
  display: grid;
  place-items: center;
  border-radius: var(--r);
  color: var(--muted);
  cursor: grab;
  touch-action: none;
}
.card .grip::before { content: ''; width: 8px; height: 14px; background: radial-gradient(circle, currentColor 1.3px, transparent 1.7px) 0 0 / 4px 4.7px; }
.card .grip:hover { background: var(--surface-2); color: var(--text); }
.card .info { grid-column: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 12px; color: var(--muted); }
.card .info .num { color: var(--text-2); }
.card .info .st { color: var(--star); letter-spacing: -1px; }
.card.lifted { opacity: .3; }
.card.ghost {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  box-shadow: var(--shadow);
  border-color: var(--accent);
  transform: rotate(-2deg);
  opacity: .96;
}
body.dragging, body.dragging * { cursor: grabbing !important; }
body.dragging .board { scroll-snap-type: none; }

/* ---- graph */

.graph-wrap { position: relative; height: calc(100vh - var(--top-h) - var(--safe-t)); height: calc(100dvh - var(--top-h) - var(--safe-t)); overflow: hidden; touch-action: none; }
.graph-wrap svg { width: 100%; height: 100%; display: block; cursor: grab; }
.graph-wrap svg.panning { cursor: grabbing; }
.graph-wrap .node { cursor: pointer; }
.graph-wrap .node circle { stroke: var(--bg); stroke-width: 2; transition: stroke .1s; }
.graph-wrap .node:hover circle, .graph-wrap .node.hl circle { stroke: var(--text); }
.graph-wrap .node text { font: 500 11px var(--f-ui); fill: var(--text-2); paint-order: stroke; stroke: var(--bg); stroke-width: 3px; pointer-events: none; }
.graph-wrap .node .nid { font: 9.5px var(--f-mono); fill: var(--bg); stroke: none; }
.graph-wrap .edge { fill: none; stroke-width: 1.4; opacity: .7; }
.graph-wrap .edge.dim, .graph-wrap .node.dim { opacity: .15; }
.graph-tools { position: absolute; top: 12px; right: calc(12px + var(--safe-r)); display: flex; gap: 8px; align-items: center; padding: 6px 8px; border: 1px solid var(--line-soft); border-radius: var(--r-lg); background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(6px); }
.legend { position: absolute; left: calc(12px + var(--safe-l)); bottom: calc(12px + var(--safe-b)); display: grid; gap: 8px; padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: var(--r-lg); background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(6px); font-size: 12px; color: var(--text-2); max-width: calc(100vw - 24px); }
.legend .row { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.legend .it { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend .it i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.legend svg { width: 26px; height: 10px; }
.legend summary { cursor: pointer; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; font-size: 11px; color: var(--muted); }
.gtip { position: absolute; pointer-events: none; z-index: 5; max-width: 300px; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow); font-size: 13px; }
.gtip .id { font-family: var(--f-mono); color: var(--muted); margin-right: 5px; }
.gtip .meta { display: flex; gap: 8px; align-items: center; margin-top: 4px; font-size: 12px; color: var(--muted); }

/* ---- login, missing */

.gate { min-height: calc(100vh - 120px); display: grid; place-items: center; padding: 20px; }
.gate-card { width: min(380px, 100%); padding: 30px 28px 26px; border: 1px solid var(--line-soft); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); animation: rise .4s both; }
.gate-card img { width: 52px; height: 52px; border-radius: 12px; margin-bottom: 14px; }
.gate-card h1 { font-size: 26px; margin-bottom: 4px; }
.gate-card p { margin: 0 0 18px; color: var(--muted); }
.gate-card form { display: grid; gap: 10px; }
.gate-card input { width: 100%; min-height: 42px; font-size: 16px; }
.gate-card .btn { min-height: 42px; }
.gate-card .err { color: var(--danger); font-size: 13.5px; min-height: 1.2em; margin: 0; }
.missing code { font-family: var(--f-mono); color: var(--accent); overflow-wrap: anywhere; }

/* ---- dialogs and toasts */

dialog.dlg {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 40px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
dialog.dlg::backdrop { background: rgba(8, 7, 5, .62); backdrop-filter: blur(2px); }
dialog.dlg[open] { animation: rise .2s both; }
.dlg form { display: grid; gap: 12px; padding: 20px 22px 18px; }
.dlg h2 { font-size: 21px; }
.dlg .lead { margin: -4px 0 0; color: var(--text-2); font-size: 14px; }
.dlg label.f { display: grid; gap: 5px; font-size: 13px; color: var(--text-2); }
.dlg label.f input, .dlg label.f select, .dlg label.f textarea { width: 100%; }
.dlg .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.dlg .err { color: var(--danger); font-size: 13.5px; margin: 0; }

.toasts { position: fixed; left: 50%; bottom: calc(22px + var(--safe-b)); transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; justify-items: center; width: min(520px, calc(100vw - 24px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow); font-size: 14px; animation: rise .2s both; }
.toast.err { border-color: var(--danger); }
.toast.err::before { content: '!'; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--danger); color: var(--bg); font-weight: 700; font-size: 13px; flex: none; }

/* ---- narrow screens */

@media (max-width: 1020px) {
  .ficha-grid { grid-template-columns: minmax(0, 1fr); }
  .ficha-side { order: -1; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
  .resurface-cards { grid-template-columns: 1fr; }
  .resurface-cards { grid-auto-flow: column; grid-auto-columns: minmax(260px, 82%); grid-template-columns: none; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 4px; }
  .rcard { scroll-snap-align: start; }
}

@media (max-width: 760px) {
  body { font-size: 15px; }
  .top { gap: 10px; padding-left: calc(10px + var(--safe-l)); padding-right: calc(10px + var(--safe-r)); }
  .brand span { display: none; }
  .nav a { padding: 0 8px; }
  .top .new-label { display: none; }
  .sync .txt { font-size: 11px; max-width: 84px; overflow: hidden; text-overflow: ellipsis; }
  .sync.alarm .txt { white-space: normal; line-height: 1.1; }
  .view { padding: 12px calc(12px + var(--safe-r)) calc(56px + var(--safe-b)) calc(12px + var(--safe-l)); }

  .resurface-head h2 em { display: none; }
  .filters-toggle { display: inline-flex; }
  .filters { display: none; }
  .filters.open { display: grid; }
  .frow > .lbl { width: 100%; }
  .list-meta .sort-narrow { display: inline-flex; margin-left: auto; gap: 6px; align-items: center; }

  .tbl-wrap { border: 0; background: none; overflow: visible; }
  table.opps, table.opps tbody { display: block; }
  table.opps thead { display: none; }
  table.opps tbody tr {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      'id stage stars'
      'title title title'
      'terr terr terr'
      'score ev rev'
      'orig orig upd';
    gap: 6px 10px;
    padding: 12px 13px;
    margin-bottom: 10px;
    border: 1px solid var(--line-soft);
    border-radius: var(--r-lg);
    background: var(--surface);
  }
  table.opps td { display: block; padding: 0; border: 0; min-width: 0; max-width: none; }
  td.c-id { grid-area: id; padding-top: 3px; }
  td.c-stage { grid-area: stage; padding-top: 0; }
  td.c-stars { grid-area: stars; padding-top: 0; }
  td.c-stars .stars button { width: 30px; height: 30px; font-size: 19px; }
  td.c-title { grid-area: title; min-width: 0; }
  td.c-title a { font-size: 16px; }
  td.c-terr { grid-area: terr; }
  td.c-terr:empty { display: none; }
  td.c-score { grid-area: score; }
  td.c-ev { grid-area: ev; align-self: center; }
  td.c-ev::before { content: 'Evidencias '; color: var(--muted); font-family: var(--f-ui); }
  td.c-rev { grid-area: rev; align-self: center; text-align: right; }
  td.c-orig { grid-area: orig; }
  td.c-upd { grid-area: upd; text-align: right; }

  .ficha-side { grid-template-columns: 1fr; }
  dl.fields { grid-template-columns: 1fr; }
  dl.fields dt { padding: 10px 0 0; border-top: 1px solid var(--line-soft); }
  dl.fields dd { border-top: 0; padding-top: 0; }
  dl.fields dt:first-of-type { border-top: 0; }
  .stars.big button { width: 42px; height: 44px; font-size: 28px; }
  table.hist, table.hist tbody, table.hist tr, table.hist td { display: block; }
  table.hist tr { padding: 8px 0; border-top: 1px solid var(--line-soft); display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; }
  table.hist td { border: 0; padding: 0; }
  table.hist .chg { grid-column: 1 / -1; }
  table.hist .undo { grid-row: 1; grid-column: 2; }

  .board { scroll-snap-type: x mandatory; padding-left: calc(12px + var(--safe-l)); }
  .col { flex-basis: 84vw; }
  .bar-chips { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding-bottom: 2px; }
  .board-bar .grow { max-width: none; }
  .board-bar { padding-left: calc(12px + var(--safe-l)); padding-right: calc(12px + var(--safe-r)); }
  .legend { font-size: 11.5px; }
  .install-bar, .update-bar { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
