/* Sistema visual de app.realtyfy.com (Brand Book v3): claro por defecto (Ivory Stone), oscuro navy solo si el usuario lo elige.
   Midnight Navy #0F172A · Ivory Stone #F6F3EE · Deep Forest #2F4F46 · Copper Gold #C9975B. Manrope (titulares) + Inter (interfaz). */
:root, :root[data-theme="light"] {
  --bg: #F6F3EE;
  --surface: #FFFFFF;
  --surface-2: #F1EDE4;
  --field: #F6F3EE;
  --ink: #0F172A;
  --muted: #64748B;
  --line: #E7E1D6;
  --line-strong: #DDD5C7;
  --accent: #2F4F46;
  --accent-solid: #2F4F46;
  --accent-ink: #F6F3EE;
  --accent-soft: #DEE9E3;
  --ok: #3D6E54;
  --ok-soft: #DFECE4;
  --warn: #966832;
  --warn-soft: #F5E7CF;
  --bad: #A34B39;
  --bad-soft: #F5E1DA;
  --info: #46688C;
  --info-soft: #DDE6EF;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 10px 30px rgba(15, 23, 42, .06);
  --font-display: "Manrope", "Inter", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Inter", system-ui, sans-serif;
  --font-code: ui-monospace, "SFMono-Regular", Menlo, monospace;
  --r: 14px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0B1120;
  --surface: #0F172A;
  --surface-2: #1E293B;
  --field: #0B1120;
  --ink: #F6F3EE;
  --muted: #94A3B8;
  --line: rgba(246, 243, 238, .10);
  --line-strong: rgba(246, 243, 238, .16);
  --accent: #A4C0B3;
  --accent-solid: #3D6156;
  --accent-ink: #F6F3EE;
  --accent-soft: #1D362E;
  --ok: #7CAE8E;
  --ok-soft: #1B3A2C;
  --warn: #D4A96F;
  --warn-soft: #332816;
  --bad: #D08A76;
  --bad-soft: #341A15;
  --info: #A3B9CF;
  --info-soft: #1C2C40;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 14px; line-height: 1.5; font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
.wrap { max-width: 1320px; margin: 0 auto; padding-inline: 20px; padding-block: 24px 64px; display: grid; gap: 28px; }
.wrap > * { min-width: 0; }
@media (max-width: 520px) { .wrap { padding-inline: 16px; } }
h1, h2, h3 { font-family: var(--font-display); margin: 0; text-wrap: balance; }
h2 { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
p { margin: 0; }
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.sec-head .note { font-size: 12.5px; color: var(--muted); }

/* Header */
.top { display: grid; gap: 14px; }
.eyebrow { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; font-size: 12px; color: var(--muted); letter-spacing: .04em; }
.eyebrow b { font-family: var(--font-display); font-weight: 800; letter-spacing: .14em; color: var(--ink); }
.title-row { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: end; justify-content: space-between; }
h1 { font-size: clamp(28px, 4.4vw, 42px); font-weight: 800; line-height: 1.05; letter-spacing: -.02em; }
.status-line { max-width: 72ch; font-size: 15px; color: var(--ink); }
.clocks { display: flex; gap: 18px; font-size: 12px; color: var(--muted); }
.clocks span b { display: block; font-family: var(--font-mono); font-size: 18px; color: var(--ink); font-weight: 500; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--ink); white-space: nowrap; }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.info { background: var(--info-soft); color: var(--info); }

/* Phases */
.phases { display: grid; grid-template-columns: repeat(var(--n, 6), minmax(0, 1fr)); gap: 4px; }
.phase { display: grid; gap: 6px; }
.phase .bar { height: 6px; border-radius: 3px; background: var(--surface-2); }
.phase.done .bar { background: var(--accent-solid); opacity: .45; }
.phase.current .bar { background: var(--accent-solid); }
.phase .lbl { font-size: 12px; font-weight: 600; line-height: 1.25; }
.phase .dt { font-size: 11.5px; color: var(--muted); font-family: var(--font-mono); }
.phase.next .lbl, .phase.later .lbl { color: var(--muted); font-weight: 500; }
@media (max-width: 720px) { .phases { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 14px; } }

/* Summary tiles */
.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 900px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 520px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: grid; gap: 2px; text-align: left; }
button.tile:hover { border-color: var(--accent); }
.tile .k { font-size: 12px; color: var(--muted); }
.tile .v { font-family: var(--font-display); font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.tile .s { font-size: 12px; color: var(--muted); }
.tile.bad .v { color: var(--bad); }
.tile.warn .v { color: var(--warn); }

/* Round meter */
.round { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; display: grid; gap: 12px; }
.round-top { display: flex; flex-wrap: wrap; gap: 8px 28px; align-items: baseline; justify-content: space-between; }
.round-big { font-family: var(--font-display); font-weight: 800; letter-spacing: -.02em; font-size: 28px; font-variant-numeric: tabular-nums; }
.round-big small { font-size: 16px; color: var(--muted); font-weight: 600; }
.tickets { display: grid; grid-template-columns: repeat(var(--t, 18), minmax(0, 1fr)); gap: 3px; }
.ticket { height: 22px; border-radius: 3px; background: var(--surface-2); }
.ticket.on { background: var(--accent-solid); }
.round-facts { display: flex; flex-wrap: wrap; gap: 6px 22px; font-size: 12.5px; color: var(--muted); }
.round-facts b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

/* Two-col */
.two { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 28px; }
@media (max-width: 960px) { .two { grid-template-columns: minmax(0, 1fr); } }

/* Gates */
.gates { display: grid; gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.gate { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; padding: 11px 14px; align-items: start; border-top: 1px solid var(--line); }
.gate:first-child { border-top: 0; }
.gate .n { font-family: var(--font-mono); font-size: 12px; color: var(--muted); padding-top: 2px; }
.gate .t { font-weight: 600; }
.gate .d { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.gsel { border: 1px solid var(--line-strong); background: var(--field); border-radius: 8px; padding: 2px 4px; font-size: 12px; }

/* Decisions */
.decs { display: grid; gap: 10px; }
.dec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: grid; gap: 6px; }
.dec .t { font-weight: 600; font-size: 14.5px; }
.dec .ctx { font-size: 13px; color: var(--muted); }
.dec .rec { font-size: 13px; }
.dec .rec b { font-weight: 600; }
.dec .meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 12px; color: var(--muted); }
.dec .resolve { display: flex; gap: 8px; flex-wrap: wrap; }
.dec .resolve input { flex: 1 1 220px; min-width: 0; }
details.past { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px; }
details.past summary { cursor: pointer; font-weight: 600; font-size: 13px; }
.past-list { display: grid; gap: 8px; margin-top: 10px; }
.past-item { display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 10px; font-size: 13px; }
.past-item .dt { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.field { border: 1px solid var(--line-strong); background: var(--field); border-radius: 10px; padding: 8px 11px; font-size: 13px; min-width: 0; }
.toolbar .grow { flex: 1 1 180px; }
.btn { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 10px; padding: 7px 12px; font-weight: 600; font-size: 13px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent-solid); color: var(--accent-ink); border-color: var(--accent-solid); }
.btn.primary:hover { filter: brightness(1.12); border-color: var(--accent-solid); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 4px 9px; font-size: 12px; }

/* Board */
.board-scroll { overflow-x: auto; padding-bottom: 6px; }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; min-width: min-content; }
.col { background: var(--surface-2); border-radius: var(--r); padding: 10px; display: grid; gap: 8px; align-content: start; }
.col-head { display: flex; justify-content: space-between; align-items: center; padding: 2px 4px 4px; font-weight: 700; font-size: 13px; }
.col-head .count { font-family: var(--font-mono); font-size: 12px; color: var(--muted); font-weight: 500; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; vertical-align: 1px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px; display: grid; gap: 7px; text-align: left; width: 100%; }
.card:hover { border-color: var(--accent); }
.card .t { font-weight: 600; font-size: 13.5px; line-height: 1.3; }
.card .row { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 4px; background: var(--surface-2); color: var(--muted); font-weight: 500; }
.tag.area { background: transparent; border: 1px solid var(--line); }
.tag.prio-alta { background: var(--bad-soft); color: var(--bad); font-weight: 700; letter-spacing: .04em; }
.who { font-size: 11.5px; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.who.client { background: var(--warn-soft); color: var(--warn); }
.who.ext { background: var(--info-soft); color: var(--info); }
.who.ai { background: var(--surface-2); color: var(--muted); }
.card .blk { font-size: 12px; color: var(--bad); }
.card .due { font-size: 11.5px; font-family: var(--font-mono); color: var(--muted); }
.card .due.late { color: var(--bad); }
.more { border: 0; background: transparent; color: var(--accent); font-weight: 600; font-size: 12.5px; padding: 4px; text-align: left; }

/* People */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.person { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; display: grid; gap: 8px; align-content: start; }
.person-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.person-head h3 { font-size: 18px; font-weight: 700; }
.person-head .c { font-size: 12px; color: var(--muted); }
.mini { display: grid; grid-template-columns: 10px minmax(0, 1fr); gap: 8px; align-items: start; padding: 6px 4px; border-radius: 6px; border: 0; background: transparent; text-align: left; width: 100%; }
.mini:hover { background: var(--surface-2); }
.mini .dot { margin: 5px 0 0; }
.mini .t { font-size: 13px; }
.mini .s { font-size: 11.5px; color: var(--muted); }

/* Contract */
.tbl-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
table { border-collapse: collapse; width: 100%; min-width: 640px; }
th, td { text-align: left; padding: 10px 12px; border-top: 1px solid var(--line); vertical-align: top; font-size: 13px; }
th { border-top: 0; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
td.n { font-family: var(--font-mono); color: var(--muted); width: 36px; }
td.cl { font-family: var(--font-mono); font-size: 12px; white-space: nowrap; }
tr.is-done td:not(.chk) { color: var(--muted); }
tr.is-done td.ch { text-decoration: line-through; text-decoration-color: var(--line); }
td.chk { width: 44px; }
td.chk input { width: 18px; height: 18px; accent-color: var(--accent); }

/* Activity */
.log { display: grid; gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.log-item { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 12px; padding: 9px 14px; border-top: 1px solid var(--line); font-size: 13px; }
.log-item:first-child { border-top: 0; }
.log-item .dt { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.log-item .by { color: var(--muted); font-size: 12px; }
@media (max-width: 520px) { .log-item { grid-template-columns: minmax(0, 1fr); gap: 2px; } }

/* Drawer */
.scrim { position: fixed; inset: 0; background: rgba(10, 16, 14, .38); z-index: 20; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 100%); background: var(--surface); z-index: 21; box-shadow: var(--shadow); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
.drawer header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.drawer header h3 { font-size: 18px; }
.drawer .body { overflow-y: auto; padding: 16px 18px; display: grid; gap: 14px; align-content: start; }
.drawer footer { display: flex; gap: 8px; justify-content: space-between; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.f { display: grid; gap: 5px; }
.f label, .f .lab { font-size: 12px; font-weight: 600; color: var(--muted); }
.f textarea { min-height: 84px; resize: vertical; }
.f2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; }
.chip[aria-pressed="true"] { background: var(--accent-solid); border-color: var(--accent-solid); color: var(--accent-ink); }
.src { font-family: var(--font-code); font-size: 12px; color: var(--muted); word-break: break-all; }

.notice { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r); padding: 18px; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 8px; font-size: 13px; z-index: 30; }
@media (prefers-reduced-motion: no-preference) { .card, .tile, .btn { transition: border-color .15s ease; } }

[hidden] { display: none !important; }
a { color: var(--accent); }
.small { font-size: 12.5px; }

/* Barra de la app */
.appbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 20px; background: var(--bg); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.appbar .brand { font-family: var(--font-display); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; font-size: 12.5px; color: var(--ink); text-decoration: none; }
.appbar .brand span { color: var(--muted); font-weight: 600; letter-spacing: .04em; text-transform: none; margin-left: 6px; }
.appbar-links { display: flex; gap: 16px; align-items: center; font-size: 13px; }
.appbar-links a { color: var(--muted); text-decoration: none; font-weight: 500; }
.appbar-links a:hover, .appbar-links a[aria-current="page"] { color: var(--ink); }
.linklike { border: 0; background: none; padding: 0; color: var(--muted); font-weight: 500; font-size: 13px; }
.linklike:hover { color: var(--bad); }
@media (max-width: 520px) { .appbar { padding-inline: 16px; } }

.page-h1 { font-size: clamp(26px, 3.6vw, 34px); font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }

/* Lista de proyectos */
.proj-list { display: grid; gap: 10px; max-width: 640px; }
.proj { display: flex; justify-content: space-between; gap: 12px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); text-decoration: none; color: var(--ink); }
.proj:hover { border-color: var(--accent); }
.proj-name { font-weight: 600; font-size: 15px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(340px, 100%); display: grid; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 24px; box-shadow: var(--shadow); }
.login-head { display: grid; gap: 4px; justify-items: center; text-align: center; margin-bottom: 18px; }
.login-head .page-h1 { font-size: 30px; }
.login-wrap { display: grid; justify-items: center; }
.login-card .btn { padding-block: 10px; }
.form-error { color: var(--bad); font-size: 13px; }
.form-ok { color: var(--ok); font-size: 13px; }

/* Admin y cuenta */
.narrow { max-width: 760px; }
.panel-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; display: grid; gap: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; align-items: end; }
.secret { font-family: var(--font-code); background: var(--warn-soft); color: var(--ink); padding: 10px 12px; border-radius: 8px; display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between; }
.secret code { font-size: 15px; user-select: all; word-break: break-all; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }

.theme-toggle { border: 1px solid var(--line-strong); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; font-weight: 500; }
.theme-toggle:hover { color: var(--ink); }
.appbar .brand { letter-spacing: .02em; text-transform: none; font-size: 15px; }
.appbar .brand span { margin-left: 4px; }
.card .t, .dec .t, .gate .t { font-family: var(--font-display); }
