:root {
  color-scheme: light;
  --navy: #172238;
  --blue: #345d9b;
  --pale: #eaf0fa;
  --paper: #f1f0ea;
  --line: #e5e9f0;
  --muted: #586780;
  font: 14px/1.5 Inter, system-ui, sans-serif;
  color: var(--navy);
  background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0; }
h1, h2, h3, p { margin: 0; }
h1, h2 { font-weight: 680; line-height: 1.12; }
h1 { font-size: clamp(1.7rem, 3.8vw, 2.1rem); letter-spacing: -.045em; }
h2 { font-size: 1.13rem; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, .button { cursor: pointer; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--navy); padding: .55rem .85rem; }
button:hover { border-color: var(--blue); }
:focus-visible { outline: 3px solid #527eb8; outline-offset: 3px; }
.primary { background: var(--navy); color: white; border-color: var(--navy); }
.header { background: var(--navy); color: white; padding: .6rem max(1.25rem, calc((100vw - 1220px)/2)); }
.brand { display: inline-flex; align-items: center; gap: .85rem; text-decoration: none; }
.brand img { object-fit: contain; }
.header-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.account-menu { position: relative; }
.account-menu summary { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid #ffffff50; border-radius: 8px; color: white; font-size: 1.5rem; cursor: pointer; list-style: none; }
.account-menu summary::-webkit-details-marker { display: none; }
.account-menu summary:hover, .account-menu[open] summary { background: #ffffff1a; }
.account-options { position: absolute; z-index: 2; right: 0; top: calc(100% + .4rem); display: grid; gap: .25rem; min-width: 13rem; padding: .4rem; border-radius: 10px; border: 1px solid var(--line); background: white; box-shadow: 0 8px 24px #17223833; }
.account-options button { border-color: transparent; text-align: left; }
.account-options button:hover { background: var(--paper); }
nav { display: flex; gap: .45rem; overflow: auto; padding: .3rem 0 .55rem; }
nav a { padding: .45rem .7rem; text-decoration: none; border-radius: 6px; white-space: nowrap; font-size: .88rem; }
nav a[aria-current="page"] { background: var(--pale); color: var(--navy); }
main { max-width: 1260px; padding: 2rem 1.25rem 3.5rem; margin: auto; }
.demo { display: inline-block; background: #efe6d4; padding: .35rem .7rem; border-radius: 5px; margin-bottom: 1.2rem; font-size: .82rem; }
.page-heading { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.6rem; }
.page-heading p { color: var(--muted); margin-top: .55rem; }
.metrics, .columns, .kanban { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .85rem; }
.columns { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 1rem; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 1.15rem; margin-bottom: .8rem; }
.metrics strong { font: 650 2.1rem Inter, system-ui, sans-serif; display: block; margin-top: .45rem; }
small, .muted { color: var(--muted); }
.scroll { overflow: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .9rem; }
th, td { padding: .65rem .55rem; border-bottom: 1px solid var(--line); }
th { white-space: nowrap; }
.contact-phone { white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
.link { background: transparent; border: 0; padding: .1rem 0; text-align: left; text-decoration: underline; text-underline-offset: .2em; }
.actions, .filters { display: flex; gap: .65rem; flex-wrap: wrap; align-items: end; }
.filters { padding-bottom: .8rem; }
.stack { display: grid; gap: .65rem; margin-top: .8rem; }
.row { display: flex; gap: .65rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.kanban h2 { font: inherit; font-weight: 700; }
.kanban button { text-align: left; width: 100%; }
.kanban button small { display: block; }
label { display: grid; gap: .3rem; font-size: .88rem; }
input:not([type=checkbox]), select, textarea { width: 100%; border: 1px solid #c1ccdd; border-radius: 7px; padding: .45rem .6rem; color: var(--navy); background: white; }
dialog { width: min(92vw, 520px); border: 1px solid var(--line); border-radius: 14px; color: inherit; padding: 1.4rem; }
dialog::backdrop { background: #0f1a2e99; }
dialog .actions { justify-content: space-between; margin-top: .65rem; }
.message { color: #7b3e19; }
@media (max-width: 730px) {
  .metrics, .kanban { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .columns { grid-template-columns: 1fr; }
}
@media (max-width: 390px) { .kanban { grid-template-columns: 1fr; } }
[hidden] { display: none; }
#notice:not(:empty) { position: fixed; bottom: 1rem; left: 1rem; right: 1rem; width: fit-content; max-width: calc(100vw - 2rem); margin: auto; background: #fff3da; padding: .7rem 1rem; border: 1px solid var(--line); border-radius: 8px; z-index: 1; }
.access { max-width: 450px; margin: 5vh auto; }
.permission-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: .7rem; }
fieldset { border: 1px solid var(--line); border-radius: 8px; }
.inline-check { display: flex; align-items: center; }
dialog { max-height: 90vh; }
dd { margin: 0 0 .65rem; }
dt { font-weight: 600; }
main > .actions { margin-bottom: .8rem; }

.password-field { display: grid; gap: .3rem; }
.password-input { position: relative; }
.password-input input { padding-right: 6.3rem; }
.password-input button { position: absolute; top: 50%; right: .25rem; transform: translateY(-50%); padding: .3rem .6rem; font-size: .88rem; }
.login-help { margin-top: 1.3rem; }
.login-help summary { cursor: pointer; text-decoration: underline; }

/* Commercial workspace */
.header { background: linear-gradient(115deg,#172238,#172238); box-shadow: 0 5px 18px #14213c1b; }
nav a { transition: background-color .15s ease, color .15s ease; }
nav a:not([aria-current]):hover { background: #ffffff1a; }
.page-heading { border-bottom: 1px solid #e5e9f0; padding-bottom: 1.2rem; }
.card { box-shadow: 0 4px 18px #1722380c; }
.metrics .card { border-top: 3px solid #527eb8; }
.status-chip { display: inline-block; background: #edf3fc; border: 1px solid #dce7f8; border-radius: 999px; padding: .15rem .55rem; white-space: nowrap; }
.status-chip[data-status="Cualificado"] { background: #d7e6fb; color: #244b80; }
.status-chip[data-status="Descartado"] { background: #f2e9e5; color: #704235; border-color: #ead9d1; }
.duplicate-note { display: block; padding-top: .25rem; }
.notes-cell { min-width: 15rem; }
.inline-note { display: grid; grid-template-columns: 1fr auto; align-items: start; gap: .3rem .45rem; }
.inline-note textarea { resize: vertical; min-width: 9rem; font-size: .85rem; }
.inline-note button { padding: .25rem .5rem; font-size: .8rem; }
.inline-note button:disabled { opacity: .55; cursor: default; }
.inline-note small { grid-column: 1 / -1; }
.inline-note small:empty { display: none; }
.channel-card > p { color: var(--muted); margin-top: .45rem; }
.channel-metrics { display: grid; grid-template-columns: repeat(auto-fit,minmax(7rem,1fr)); gap: .5rem; margin: 1rem 0; }
.channel-metrics > div { background: #f3f6fc; border-radius: 9px; padding: .65rem; }
.channel-metrics dt { font-size: .8rem; }
.channel-metrics dd { font: 650 1.6rem Inter, system-ui, sans-serif; margin: .25rem 0 0; }

/* Seguridad: códigos largos visibles sin desbordar pantallas pequeñas */
.mfa-secret {overflow-wrap:anywhere;word-break:break-all;background:#f1f0ea;padding:1rem;border-radius:8px;user-select:all;}
.recovery-list {white-space:pre-wrap;overflow-wrap:anywhere;font-size:1rem;line-height:1.8;background:#f1f0ea;padding:1rem;border-radius:8px;}

body.workspace { --rail: 15.4rem; }
body.workspace.nav-compact { --rail: 4.8rem; }
.workspace .header { position: sticky; top: 0; z-index: 3; padding: 0; height: 4.65rem; }
.workspace .header-top { height: 100%; padding: 0 1.4rem 0 1rem; justify-content: start; }
.workspace .brand { order: -1; width: calc(var(--rail) - 1rem); flex-shrink: 0; padding-left: .65rem; }
.brand img { filter: brightness(0) invert(1); }
#section-title { font-weight: 650; }
#account { margin-left: auto; }
.nav-toggle { background: #ffffff12; color: #fff; border-color: #ffffff22; padding: .3rem .7rem; }
.workspace nav { position: fixed; left: 0; top: 4.65rem; bottom: 0; width: var(--rail); display: flex; flex-direction: column; gap: .18rem; padding: 1rem .65rem; background: var(--navy); }
.workspace nav a { display: flex; align-items: center; gap: .7rem; color: #dce6f4; padding: .68rem .8rem; }
.workspace nav a[aria-current="page"] { color: white; background: #ffffff22; box-shadow: inset 3px 0 #91b9ee; }
.nav-icon { min-width: 1.3rem; text-align: center; font-size: 1.18rem; }
.nav-compact .nav-label { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
.nav-compact .brand { padding-left: 0; }
.nav-compact .brand img { max-width: 100%; }
.workspace main { margin: 0 0 0 var(--rail); max-width: 1670px; padding: 1.8rem clamp(1rem,3vw,2.4rem) 4.2rem; }
.workspace:has(dialog[open]) .scroll { scrollbar-gutter: stable; }
main:focus { outline: none; }
main > .access { margin: 3vh auto; }
.access-layout .header { background: transparent; position: absolute; z-index: 2; box-shadow: none; padding: .75rem 1.5rem; }
.access-layout .access-photo { position: fixed; inset: 0 50% 0 0; background: linear-gradient(155deg,#101d36a8,#243b55a8),url('./assets/acceso.jpg') center/cover; }
.access-layout main { margin-left: 50%; min-height: 100dvh; display: grid; align-content: center; padding: 1.75rem; }
.access-layout .access { width: min(100%,29rem); margin: 0 auto; padding: clamp(1.2rem,3vw,2.3rem); }
.access p + p, .access h1 + p { margin-top: .75rem; }
.scroll { overscroll-behavior-x: contain; }
th { background: #f7f9fc; color: #485977; font-size: .81rem; }
td { min-width: 6rem; }
.notice-bar { padding: .75rem 1rem; border-left: 4px solid var(--blue); border-radius: 8px; background: #eaf0fa; margin-bottom: 1rem; }
.view-switch { margin-bottom: .85rem; display: flex; flex-wrap: wrap; gap: .4rem; }
.view-switch button[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: white; }
.project-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%,15rem),1fr)); gap: .8rem; }
.project-card { text-align: left; background: linear-gradient(180deg,#eaf0fa 0 6px,#fff 6px); }
.project-card strong,.project-card small { display: block; }
.project-card strong { margin-bottom: .35rem; }
.project-card progress { width: 100%; height: .58rem; accent-color: var(--blue); margin-top: .8rem; }
.calendar { display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); gap: .25rem; margin-top: .6rem; }
.calendar button { min-width: 0; min-height: 3.15rem; padding: .25rem; }
.calendar button[aria-pressed="true"] { border-color: var(--blue); color: var(--navy); background: #eaf0fa; }
.calendar button small { display: block; font-size: .68rem; }
.calendar .weekday { text-align: center; font-size: .75rem; color: var(--muted); }
.calendar-heading { display: flex; align-items: center; justify-content: space-between; gap: .4rem; }
dialog.drawer { position: fixed; inset: 0 0 0 auto; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 15px 0 0 15px; padding: 1.5rem; animation: slide-in .19s ease-out; }
@keyframes slide-in { from { transform: translateX(1.25rem); opacity: .55; } }
@media (min-width: 691px) and (max-width: 1024px) {
  body.workspace:not(.nav-open) { --rail: 4.8rem; }
  .workspace:not(.nav-open) .nav-label { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
  .workspace:not(.nav-open) .brand { padding-left: 0; }
  .workspace:not(.nav-open) .brand img { max-width: 100%; }
  .workspace .metrics, .workspace .kanban { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 690px) {
  .workspace .header { height: 3.95rem; }
  .workspace .brand { width: auto; padding: 0; }
  .workspace .brand img { width: 60px; }
  .workspace nav { top: auto; bottom: 0; left: 0; right: 0; width: 100%; flex-direction: row; padding: .3rem .45rem max(.3rem,env(safe-area-inset-bottom)); box-shadow: 0 -3px 16px #17223820; }
  .workspace nav a { flex-direction: column; align-items: center; padding: .28rem .55rem; gap: .1rem; font-size: .72rem; }
  .workspace nav a[aria-current="page"] { box-shadow: inset 0 2px #91b9ee; }
  .workspace .nav-toggle { display: none; }
  .workspace main { margin-left: 0; padding-bottom: 5.85rem; }
  .workspace #notice:not(:empty) { bottom: 4.4rem; }
  .access-layout .access-photo { inset: 0 0 auto; height: 9.9rem; }
  .access-layout main { margin-left: 0; padding: 7rem .9rem 1.5rem; min-height: 0; }
}
@media (prefers-reduced-motion: reduce) { *,*::before,*::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
.account-options a { color: var(--navy); padding: .55rem .85rem; text-decoration: none; border-radius: 7px; }
.account-options a:hover { background: var(--paper); }
.phase-list { display: flex; gap: .35rem; list-style: none; flex-wrap: wrap; padding: 0; margin: 0; }
.phase-list li { padding: .22rem .55rem; border-radius: 6px; background: #edf3fc; }
.phase-list li[aria-current="step"] { background: var(--blue); color: white; }
