/* =========================================================================
   Midnight Space · Cronograma de entregas
   Identidad: Midnight Purple Space — minimalista, elegante y tecnológica.
   ========================================================================= */

/* ---------- Tokens ---------- */
:root {
  --bg: #090710;
  --bg-2: #100D1B;
  --surface: #171226;
  --surface-2: #201832;
  --surface-3: #281F3D;
  --primary: #6D4AFF;
  --primary-bright: #8B6CFF;
  --primary-soft: #B7A4FF;
  --text: #F4F0FF;
  --text-2: #A49BB9;
  --text-3: #7D7494;
  --border: #302641;
  --border-strong: #42365A;

  --green: #5FD3A0;
  --amber: #F2C46D;
  --red: #F07A8A;
  --blue: #7FB7FF;
  --green-bg: rgba(95, 211, 160, .12);
  --amber-bg: rgba(242, 196, 109, .12);
  --red-bg: rgba(240, 122, 138, .12);
  --blue-bg: rgba(127, 183, 255, .12);
  --purple-bg: rgba(139, 108, 255, .14);
  --neutral-bg: rgba(164, 155, 185, .12);

  --glow: 0 0 0 1px rgba(139, 108, 255, .35), 0 8px 30px -8px rgba(109, 74, 255, .45);
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 10px 30px -18px rgba(0, 0, 0, .8);
  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .85);
  --radius: 14px;
  --radius-sm: 9px;
  --radius-xs: 6px;
  --sidebar-w: 252px;
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Code", "SF Mono", Consolas, monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --star: rgba(244, 240, 255, .75);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #F6F4FB;
  --bg-2: #EFEBF8;
  --surface: #FFFFFF;
  --surface-2: #F6F3FD;
  --surface-3: #ECE6FA;
  --primary: #6D4AFF;
  --primary-bright: #5B39F0;
  --primary-soft: #6B4FE8;
  --text: #1C1530;
  --text-2: #5E5675;
  --text-3: #8A829E;
  --border: #E3DDF0;
  --border-strong: #CFC6E4;
  --green: #1D9466;
  --amber: #A86F10;
  --red: #CC3F54;
  --blue: #2D68CC;
  --green-bg: rgba(29, 148, 102, .1);
  --amber-bg: rgba(214, 150, 30, .13);
  --red-bg: rgba(204, 63, 84, .1);
  --blue-bg: rgba(45, 104, 204, .1);
  --purple-bg: rgba(109, 74, 255, .1);
  --neutral-bg: rgba(94, 86, 117, .09);
  --glow: 0 0 0 1px rgba(109, 74, 255, .25), 0 8px 24px -10px rgba(109, 74, 255, .35);
  --shadow: 0 1px 2px rgba(28, 21, 48, .04), 0 8px 24px -16px rgba(28, 21, 48, .25);
  --shadow-lg: 0 24px 60px -20px rgba(28, 21, 48, .35);
  --star: transparent;
  color-scheme: light;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
body.modal-open { overflow: hidden; }
a { color: var(--primary-soft); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4, h5 { margin: 0; font-weight: 650; letter-spacing: -.01em; line-height: 1.25; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: .1em .35em; border-radius: 5px; }
::selection { background: rgba(139, 108, 255, .4); }
:focus-visible { outline: 2px solid var(--primary-bright); outline-offset: 2px; border-radius: 6px; }
.icon { flex: none; display: inline-block; vertical-align: middle; }

.muted { color: var(--text-2); }
.small { font-size: .84rem; }
.strong { font-weight: 600; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.spacer { flex: 1 1 auto; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.stack > * + * { margin-top: 14px; }
.tone-text-green { color: var(--green); }
.ok-text { color: var(--green); font-weight: 550; }
.warn-text { color: var(--amber); }

.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--primary); color: #fff; padding: 8px 14px; border-radius: 8px; }
.skip-link:focus { top: 12px; }

/* ---------- Estrellas (decorativas, solo tema oscuro) ---------- */
.starfield, .starfield-soft { position: relative; isolation: isolate; }
.starfield::before, .starfield-soft::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; border-radius: inherit;
  background-image:
    radial-gradient(1px 1px at 12% 18%, var(--star), transparent 60%),
    radial-gradient(1px 1px at 28% 72%, var(--star), transparent 60%),
    radial-gradient(1.4px 1.4px at 44% 34%, var(--star), transparent 60%),
    radial-gradient(1px 1px at 58% 82%, var(--star), transparent 60%),
    radial-gradient(1px 1px at 66% 14%, var(--star), transparent 60%),
    radial-gradient(1.6px 1.6px at 79% 46%, var(--star), transparent 60%),
    radial-gradient(1px 1px at 88% 76%, var(--star), transparent 60%),
    radial-gradient(1px 1px at 94% 24%, var(--star), transparent 60%),
    radial-gradient(1px 1px at 6% 56%, var(--star), transparent 60%),
    radial-gradient(1.2px 1.2px at 36% 92%, var(--star), transparent 60%);
  opacity: .55;
}
.starfield-soft::before { opacity: .3; }

/* ---------- Estructura ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
  display: flex; flex-direction: column; gap: 18px; padding: 20px 14px 16px;
  background: linear-gradient(180deg, var(--bg-2), var(--bg) 85%);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.sidebar::after {
  content: ""; position: absolute; left: -60px; top: -80px; width: 260px; height: 220px; pointer-events: none; z-index: -1;
  background: radial-gradient(closest-side, rgba(109, 74, 255, .22), transparent);
}
[data-theme="light"] .sidebar { background: var(--surface); }
[data-theme="light"] .sidebar::after { opacity: .5; }

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 6px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-logo { filter: drop-shadow(0 0 10px rgba(109, 74, 255, .45)); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 700; letter-spacing: .01em; }
.brand-sub { font-size: .76rem; color: var(--text-2); }

.nav ul { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; font-size: .94rem; position: relative;
  transition: background .25s var(--ease), color .25s var(--ease);
}
.nav-link::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary-bright); box-shadow: 0 0 12px var(--primary-bright); scale: 1 0; opacity: 0; transition: scale .5s var(--spring), opacity .25s; }
.nav-link .icon { transition: translate .45s var(--spring), color .25s; }
.nav-link:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.nav-link:hover .icon { translate: 2px 0; }
.nav-link.active { background: var(--purple-bg); color: var(--text); }
.nav-link.active::before { scale: 1 1; opacity: 1; }
.nav-link.active .icon { color: var(--primary-soft); }

.sidebar-foot { margin-top: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 12px 10px 2px; font-size: .76rem; color: var(--text-2); border-top: 1px solid var(--border); }
.sidebar-backdrop { position: fixed; inset: 0; z-index: 35; background: rgba(5, 3, 10, .6); backdrop-filter: blur(2px); }

.main-wrap { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px;
  padding: 10px 28px; min-height: 58px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}
.topbar .menu-btn, .topbar .topbar-brand { display: none; }
.topbar-brand { font-weight: 650; }
main { flex: 1; padding: 26px 28px 60px; outline: none; }
#view { max-width: 1320px; margin: 0 auto; }
.view > * + * { margin-top: 22px; }
.boot { padding: 60px 20px; text-align: center; color: var(--text-2); }
.boot h2 { color: var(--text); margin-bottom: 10px; }
.boot p + p { margin-top: 8px; }
#app-banner:not(:empty) { padding: 14px 28px 0; }

.save-status { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--text-2); padding: 4px 10px; border-radius: 999px; }
.save-status.saved { color: var(--text-3); }
.save-status.saved .icon { color: var(--green); }
.save-status.error { color: var(--red); background: var(--red-bg); }
.save-status .link-btn { color: inherit; text-decoration: underline; margin-left: 4px; font-size: inherit; }
.save-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 38px; padding: 0 15px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 560; font-size: .9rem; cursor: pointer; white-space: nowrap; text-decoration: none !important;
  transition: background .2s var(--ease), border-color .2s var(--ease), box-shadow .3s var(--ease), transform .45s var(--spring), filter .2s;
}
.btn:active:not(:disabled) { transform: scale(.96); transition-duration: .08s; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-sm { min-height: 32px; padding: 0 11px; font-size: .84rem; border-radius: 8px; }
.btn-primary { background: linear-gradient(180deg, var(--primary-bright), var(--primary)); color: #fff; box-shadow: 0 6px 18px -8px rgba(109, 74, 255, .8); }
.btn-primary:hover:not(:disabled) { box-shadow: var(--glow); }
.btn-secondary { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn-secondary:hover:not(:disabled) { border-color: var(--border-strong); background: var(--surface-3); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--red); color: #fff; }
[data-theme="dark"] .btn-danger { background: #C9475B; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.08); }
.btn-success { background: var(--green-bg); color: var(--green); border-color: color-mix(in srgb, var(--green) 35%, transparent); }
.btn-success:hover:not(:disabled) { background: color-mix(in srgb, var(--green) 22%, transparent); }

.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none;
  border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer;
  transition: background .18s, color .18s, border-color .18s, transform .45s var(--spring);
}
.icon-btn:active:not(:disabled) { transform: scale(.88); transition-duration: .08s; }
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.icon-btn[aria-expanded="true"] { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.icon-btn-sm { width: 30px; height: 30px; }
.icon-btn.success:hover { color: var(--green); background: var(--green-bg); }
.icon-btn.danger:hover { color: var(--red); background: var(--red-bg); }
.link-btn { background: none; border: 0; padding: 0; cursor: pointer; color: var(--text); text-align: left; font: inherit; }
.link-btn:hover { color: var(--primary-soft); text-decoration: underline; text-underline-offset: 3px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Tarjetas y encabezados ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card > * + * { margin-top: 14px; }
.card-title { display: flex; align-items: center; gap: 8px; font-size: 1rem; }
.section-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-title { font-size: 1.05rem; }
h2.section-title { font-size: 1.12rem; }
.section-subtitle { color: var(--text-2); font-size: .88rem; margin-top: 2px; }
.section-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-title { font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; }
.page-sub { color: var(--text-2); margin-top: 4px; max-width: 70ch; }

.notice { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 11px 15px; border-radius: var(--radius-sm); border: 1px solid; font-size: .9rem; }
.notice.tone-blue { background: var(--blue-bg); border-color: color-mix(in srgb, var(--blue) 30%, transparent); color: var(--text); }
.notice.tone-blue .icon { color: var(--blue); }
.notice.tone-red { background: var(--red-bg); border-color: color-mix(in srgb, var(--red) 35%, transparent); }
.notice.tone-red .icon { color: var(--red); }
.notice.tone-green { background: var(--green-bg); border-color: color-mix(in srgb, var(--green) 30%, transparent); }
.notice.banner { align-items: flex-start; }

/* ---------- Insignias y estados ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px;
  font-size: .76rem; font-weight: 560; white-space: nowrap; line-height: 1.6;
  background: var(--neutral-bg); color: var(--text-2);
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.tone-purple { background: var(--purple-bg); color: var(--primary-soft); }
.badge.tone-green { background: var(--green-bg); color: var(--green); }
.badge.tone-amber { background: var(--amber-bg); color: var(--amber); }
.badge.tone-red { background: var(--red-bg); color: var(--red); }
.badge.tone-blue { background: var(--blue-bg); color: var(--blue); }

.priority { display: inline-flex; align-items: center; gap: 4px; font-size: .76rem; font-weight: 550; color: var(--text-2); }
.prio-high { color: var(--red); }
.prio-low { color: var(--text-3); }

.due { display: inline-flex; align-items: center; gap: 5px; font-size: .82rem; color: var(--text-2); white-space: nowrap; }
.due-soon { color: var(--amber); }
.due-overdue { color: var(--red); font-weight: 560; }
.due-rel { opacity: .85; font-weight: 450; }

/* ---------- Progreso ---------- */
.progress { display: flex; align-items: center; gap: 10px; min-width: 0; }
.progress-track { flex: 1; height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; min-width: 40px; }
.progress-sm .progress-track { height: 5px; }
.progress-fill { width: 100%; height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-bright)); transition: transform .9s var(--spring-soft); transform-origin: left center; }
.progress-fill.complete { background: linear-gradient(90deg, #3FB884, var(--green)); }
.progress-label { font-size: .8rem; font-variant-numeric: tabular-nums; color: var(--text-2); min-width: 38px; text-align: right; }

.ring-wrap { position: relative; display: inline-grid; place-items: center; flex: none; }
.ring-bg { fill: none; stroke: var(--surface-3); stroke-width: 4.5; }
.ring-fg { fill: none; stroke: var(--primary-bright); stroke-width: 4.5; stroke-linecap: round; transition: stroke-dasharray 1s var(--spring-soft); filter: drop-shadow(0 0 4px rgba(139, 108, 255, .5)); }
.ring-fg.complete { stroke: var(--green); filter: none; }
.ring-label { position: absolute; font-size: .78rem; font-weight: 650; font-variant-numeric: tabular-nums; }

/* ---------- Estados vacíos ---------- */
.empty { text-align: center; padding: 46px 20px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty.compact { padding: 26px 14px; }
.empty-orb {
  width: 70px; height: 70px; border-radius: 50%; display: grid; place-items: center; color: var(--primary-soft); margin-bottom: 4px;
  background: radial-gradient(circle at 35% 30%, rgba(183, 164, 255, .25), rgba(109, 74, 255, .08) 60%, transparent 70%);
  box-shadow: 0 0 0 1px var(--border), 0 0 40px -10px rgba(109, 74, 255, .6);
}
.empty.compact .empty-orb { width: 50px; height: 50px; }
.empty-title { font-size: 1.05rem; }
.empty.compact .empty-title { font-size: .96rem; }
.empty-text { color: var(--text-2); max-width: 46ch; font-size: .9rem; }
.empty .btn { margin-top: 6px; }

/* ---------- Formularios ---------- */
.input {
  width: 100%; min-height: 38px; padding: 7px 11px; border-radius: var(--radius-sm);
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
[data-theme="light"] .input { background: var(--surface); }
.input::placeholder { color: var(--text-3); }
.input:hover { border-color: var(--border-strong); }
.input:focus { outline: none; border-color: var(--primary-bright); box-shadow: 0 0 0 3px rgba(139, 108, 255, .22); }
.input:disabled { opacity: .55; }
.textarea { resize: vertical; min-height: 70px; line-height: 1.5; }
.select { appearance: none; padding-right: 32px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
.select option { background: var(--surface); color: var(--text); }
.select-sm, .input-sm { min-height: 32px; font-size: .85rem; padding-top: 4px; padding-bottom: 4px; }
.input-narrow { width: 96px; }
input[type="date"] { color-scheme: inherit; }
[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(.8); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: .84rem; font-weight: 560; color: var(--text-2); }
.req { color: var(--primary-soft); }
.field-hint { font-size: .78rem; color: var(--text-3); }
.form-context { font-size: .88rem; color: var(--text-2); padding: 8px 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.form-note { display: flex; gap: 8px; align-items: flex-start; font-size: .82rem; color: var(--text-2); padding: 10px 12px; border-radius: var(--radius-sm); background: var(--purple-bg); }
.form-note .icon { color: var(--primary-soft); margin-top: 2px; }
.readonly-field { min-height: 38px; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; padding: 6px 11px; border-radius: var(--radius-sm); background: var(--green-bg); color: var(--green); font-weight: 560; font-size: .9rem; }
.form-error { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--red-bg); color: var(--red); font-size: .88rem; margin-top: 14px; }
.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: .9rem; user-select: none; }
.check-sm { font-size: .84rem; color: var(--text-2); }
input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--primary-bright); cursor: pointer; flex: none; margin: 0; }

.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.search-box { position: relative; flex: 1 1 240px; min-width: 200px; }
.search-box .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search-box .input { padding-left: 34px; }
.filter { display: flex; flex-direction: column; gap: 4px; min-width: 130px; }
.filter-label { font-size: .74rem; color: var(--text-3); font-weight: 560; text-transform: uppercase; letter-spacing: .05em; }
.filter .select { min-height: 38px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px;
  background: rgba(5, 3, 12, .66); backdrop-filter: blur(4px);
  animation: fadeIn .25s var(--ease-out);
}
[data-theme="light"] .modal-overlay { background: rgba(28, 21, 48, .35); }
.modal-overlay.closing { animation: fadeOut .18s var(--ease) forwards; }
.modal-overlay.closing .modal { animation: modalOut .18s cubic-bezier(.4, 0, 1, 1) forwards; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
.modal {
  width: 100%; max-height: calc(100vh - 40px); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 18px; box-shadow: var(--shadow-lg), 0 0 80px -30px rgba(109, 74, 255, .4);
  animation: modalIn .55s var(--spring);
}
@keyframes modalIn { from { opacity: 0; translate: 0 18px; scale: .94; } }
@keyframes modalOut { to { opacity: 0; translate: 0 10px; scale: .96; } }
.modal-sm { max-width: 480px; }
.modal-md { max-width: 620px; }
.modal-lg { max-width: 780px; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 6px; }
.modal-title { font-size: 1.15rem; }
.modal-subtitle { color: var(--text-2); font-size: .86rem; margin-top: 3px; }
.modal-content { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.modal-body { padding: 12px 22px 18px; overflow-y: auto; }
.modal-body > p + * { margin-top: 12px; }
.modal-footer { display: flex; align-items: center; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.confirm-body { display: flex; gap: 14px; align-items: flex-start; }
.confirm-body p + * { margin-top: 10px; }
.confirm-icon { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--purple-bg); color: var(--primary-soft); }
.confirm-icon.danger { background: var(--red-bg); color: var(--red); }
.confirm-icon.success { background: var(--green-bg); color: var(--green); }
.confirm-details { padding-left: 18px; color: var(--text-2); font-size: .88rem; display: flex; flex-direction: column; gap: 4px; }
.mi-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.mi-row { display: grid; grid-template-columns: auto 1fr 130px; gap: 10px; align-items: center; }
.import-summary:not(:empty) { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); }
.import-summary > * + * { margin-top: 8px; }

/* ---------- Menú de acciones ---------- */
.menu {
  position: fixed; z-index: 90; min-width: 210px; padding: 6px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg);
  animation: menuIn .38s var(--spring); transform-origin: top right;
}
@keyframes menuIn { from { opacity: 0; scale: .9; translate: 0 -6px; } }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text); font-size: .88rem; text-align: left; cursor: pointer; transition: background .15s, translate .35s var(--spring);
}
.menu-item:hover:not(:disabled) { translate: 2px 0; }
.menu-item .icon { color: var(--text-2); }
.menu-item:hover, .menu-item:focus { background: var(--surface-3); outline: none; }
.menu-item.danger, .menu-item.danger .icon { color: var(--red); }
.menu-item:disabled { opacity: .4; cursor: not-allowed; }
.menu-sep { height: 1px; background: var(--border); margin: 5px 4px; }

/* ---------- Notificaciones ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 40px)); }
.toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 12px 12px 14px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); font-size: .9rem;
  animation: toastIn .6s var(--spring);
}
.toast > .icon { margin-top: 2px; }
.modal-open .toasts { bottom: auto; top: 20px; }
.toast-text { flex: 1; }
.toast-success > .icon { color: var(--green); }
.toast-error { border-color: color-mix(in srgb, var(--red) 50%, transparent); }
.toast-error > .icon { color: var(--red); }
.toast-warning > .icon { color: var(--amber); }
.toast-info > .icon { color: var(--blue); }
.toast.leaving { animation: toastOut .24s cubic-bezier(.4, 0, 1, 1) forwards; }
@keyframes toastIn { from { opacity: 0; translate: 48px 0; scale: .96; } }
@keyframes toastOut { to { opacity: 0; translate: 48px 0; scale: .96; } }

/* ---------- Panel principal ---------- */
.hero {
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  padding: 28px 30px; border-radius: 20px; border: 1px solid var(--border); overflow: hidden;
  background:
    radial-gradient(600px 260px at 85% -20%, rgba(109, 74, 255, .35), transparent 70%),
    radial-gradient(400px 200px at 0% 120%, rgba(139, 108, 255, .14), transparent 70%),
    linear-gradient(135deg, var(--bg-2), var(--surface));
}
[data-theme="light"] .hero { background: radial-gradient(600px 260px at 85% -20%, rgba(109, 74, 255, .16), transparent 70%), var(--surface); }
.hero-date { color: var(--primary-soft); font-size: .86rem; font-weight: 560; letter-spacing: .02em; }
.hero-title { font-size: 2rem; font-weight: 720; letter-spacing: -.025em; margin-top: 4px; }
.hero-sub { color: var(--text-2); margin-top: 6px; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(142px, 1fr)); gap: 12px; }
.stat-card {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); color: var(--text); box-shadow: var(--shadow);
  transition: border-color .25s, transform .55s var(--spring), box-shadow .35s;
  position: relative; overflow: hidden;
}
.stat-card.is-link:hover { text-decoration: none; border-color: var(--border-strong); transform: translateY(-3px); }
.stat-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--neutral-bg); color: var(--text-2); }
.stat-icon.tone-purple { background: var(--purple-bg); color: var(--primary-soft); }
.stat-icon.tone-green { background: var(--green-bg); color: var(--green); }
.stat-icon.tone-amber { background: var(--amber-bg); color: var(--amber); }
.stat-icon.tone-red { background: var(--red-bg); color: var(--red); }
.stat-icon.tone-blue { background: var(--blue-bg); color: var(--blue); }
.stat-value { font-size: 1.45rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { font-size: .8rem; color: var(--text-2); }
.stat-hint { font-size: .72rem; color: var(--text-3); }

.dash-columns { display: grid; grid-template-columns: 1.15fr 1fr; gap: 18px; align-items: start; }
.dash-projects > * + * { margin-top: 14px; }

.delivery-list { list-style: none; display: flex; flex-direction: column; }
.delivery { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.delivery:last-child { border-bottom: 0; }
.delivery-main { flex: 1; min-width: 0; }
.delivery-title { color: var(--text); font-weight: 550; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.delivery-sub { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: .8rem; color: var(--text-2); }
.delivery.is-overdue .delivery-title { color: var(--text); }
.delivery.is-overdue { box-shadow: inset 2px 0 0 var(--red); padding-left: 10px; }
.delivery.is-soon { box-shadow: inset 2px 0 0 var(--amber); padding-left: 10px; }
.project-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--project-color, var(--primary)); box-shadow: 0 0 8px var(--project-color, var(--primary)); display: inline-block; }
.delivery-group.tone-red .card-title { color: var(--red); }
.delivery-group.tone-amber .card-title { color: var(--amber); }

.activity-list { list-style: none; display: flex; flex-direction: column; gap: 2px; max-height: 460px; overflow-y: auto; }
.tab-activity .activity-list { max-height: none; }
.activity { display: flex; gap: 12px; padding: 8px 2px; position: relative; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex: none; background: var(--text-3); }
.activity.phase_completed .activity-dot, .activity.task_completed .activity-dot, .activity.improvement_resolved .activity-dot, .activity.improvements_reviewed .activity-dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.activity.phase_reopened .activity-dot, .activity.improvement_reopened .activity-dot, .activity.improvements_review_invalidated .activity-dot { background: var(--amber); }
.activity[class*="deleted"] .activity-dot { background: var(--red); }
.activity.type-project .activity-dot, .activity.type-meeting .activity-dot { background: var(--primary-bright); }
.activity-msg { font-size: .9rem; overflow-wrap: anywhere; }
.activity-meta { font-size: .76rem; color: var(--text-3); }

/* ---------- Tarjetas de proyecto ---------- */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.project-card {
  display: flex; flex-direction: column; gap: 12px; padding: 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); color: var(--text); position: relative; overflow: hidden;
  box-shadow: var(--shadow); transition: border-color .25s, transform .55s var(--spring), box-shadow .35s var(--ease);
}
.project-card::before { content: ""; position: absolute; left: 0; top: 0; right: 0; height: 2px; background: linear-gradient(90deg, var(--project-color), transparent 80%); opacity: .9; }
.project-card:hover { text-decoration: none; border-color: var(--border-strong); transform: translateY(-5px); box-shadow: var(--shadow), 0 14px 40px -20px rgba(109, 74, 255, .5); }
.project-card.status-paused { opacity: .82; }
.pc-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.pc-title-wrap { min-width: 0; }
.pc-title { font-size: 1.05rem; overflow-wrap: anywhere; }
.pc-client { display: flex; align-items: center; gap: 5px; font-size: .82rem; color: var(--text-2); margin-top: 3px; }
.pc-desc { font-size: .86rem; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pc-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.pc-meta { display: grid; gap: 6px; margin: 0; font-size: .82rem; }
.pc-meta > div { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.pc-meta dt { color: var(--text-3); }
.pc-meta dd { margin: 0; text-align: right; min-width: 0; }
.pc-next { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; }
.pc-next-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px; color: var(--text-2); }
.pc-alerts { display: flex; gap: 6px; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid var(--border); }
.browser > * + * { margin-top: 16px; }

/* ---------- Encabezado de proyecto / fase ---------- */
.project-header, .node-header {
  padding: 22px 24px; border-radius: 20px; border: 1px solid var(--border); overflow: hidden;
  background: radial-gradient(520px 220px at 100% 0%, color-mix(in srgb, var(--project-color, var(--primary)) 22%, transparent), transparent 70%), var(--surface);
}
.project-header > * + *, .node-header > * + * { margin-top: 16px; }
.breadcrumb { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: .84rem; color: var(--text-3); }
.breadcrumb a { color: var(--text-2); display: inline-flex; align-items: center; gap: 5px; }
.breadcrumb a:hover { color: var(--text); }
.ph-main { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.ph-text { min-width: 0; }
.ph-text > * + * { margin-top: 8px; }
.ph-badges { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ph-client { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.ph-desc { color: var(--text-2); max-width: 80ch; }
.ph-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px 22px; padding: 14px 0 0; border-top: 1px solid var(--border); }
.ph-facts > div { display: flex; flex-direction: column; gap: 5px; min-width: 0; font-size: .9rem; }
.fact-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 600; }
.fact-link { color: var(--text); display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.ph-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-field .select { min-height: 38px; width: auto; }
.approval-banner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 12px; background: var(--green-bg); color: var(--green); border: 1px solid color-mix(in srgb, var(--green) 30%, transparent); }
.approval-banner span { color: var(--text-2); }

.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--border); scrollbar-width: thin; }
.tab {
  display: inline-flex; align-items: center; gap: 7px; padding: 10px 13px; white-space: nowrap; font-size: .88rem; font-weight: 550;
  color: var(--text-2); border-radius: 8px 8px 0 0; position: relative; transition: color .2s, background .2s;
}
.tab::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 2px; border-radius: 2px; background: var(--primary-bright); box-shadow: 0 0 10px var(--primary-bright); scale: 0 1; transition: scale .5s var(--spring); }
.tab.active::after { scale: 1 1; }
.tab:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.tab.active { color: var(--text); }
.tab.active .icon { color: var(--primary-soft); }
.tab-count { background: var(--amber-bg); color: var(--amber); border-radius: 999px; padding: 0 7px; font-size: .72rem; }
.view .tabs + .tab-panel { margin-top: 18px; }
.tab-panel > * + * { margin-top: 16px; }
.tab-heading { font-size: 1.25rem; }

.metrics-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.metric { display: flex; flex-direction: column; gap: 2px; padding: 13px 15px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.metric strong { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.metric span { font-size: .78rem; color: var(--text-2); }
.metric.tone-purple strong { color: var(--primary-soft); }
.metric.tone-green strong { color: var(--green); }
.metric.tone-amber strong { color: var(--amber); }
.metric.tone-red strong { color: var(--red); }
.metric.tone-blue strong { color: var(--blue); }
.summary-columns { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }
.summary-side > * + * { margin-top: 16px; }
.phase-progress-list { list-style: none; display: flex; flex-direction: column; gap: 14px; }
.phase-progress-list li > * + * { margin-top: 6px; }
.ppl-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.ppl-head a { color: var(--text); font-weight: 550; overflow-wrap: anywhere; }
.ppl-meta { display: flex; gap: 12px; flex-wrap: wrap; }
.details-list { margin: 0; display: grid; gap: 8px; font-size: .88rem; }
.details-list > div { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.details-list dt { color: var(--text-3); }
.details-list dd { margin: 0; text-align: right; }
.simple-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.simple-list li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.formula { background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 12px 16px; font-size: .88rem; color: var(--text-2); }
.formula summary { cursor: pointer; display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 550; }
.formula ul { margin-top: 10px; padding-left: 20px; display: flex; flex-direction: column; gap: 5px; }

/* ---------- Árbol de fases ---------- */
.tree, .tree-children { list-style: none; }
.tree { display: flex; flex-direction: column; gap: 10px; }
.tree-sub { gap: 6px; }
.tree-children { margin: 6px 0 4px 18px; padding-left: 14px; border-left: 1px dashed var(--border-strong); display: flex; flex-direction: column; gap: 4px; }
.node-row {
  display: grid; grid-template-columns: auto auto minmax(0, 1fr) 150px auto; gap: 10px; align-items: center;
  padding: 10px 10px 10px 8px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border);
  transition: border-color .15s;
}
.node-row:hover { border-color: var(--border-strong); }
.node-row.is-root { padding: 13px 12px 13px 10px; box-shadow: var(--shadow); }
.tree-sub .node-row, .tree-children .node-row { background: var(--bg-2); }
[data-theme="light"] .tree-children .node-row { background: var(--surface-2); }
.node-row.status-done { border-color: color-mix(in srgb, var(--green) 30%, var(--border)); }
.node-row.status-done .node-num { background: var(--green-bg); color: var(--green); }
.node-row.status-review { border-left: 3px solid var(--blue); }
.node-row.status-changes { border-left: 3px solid var(--amber); }
.tree-toggle { width: 26px; height: 26px; display: grid; place-items: center; border: 0; background: transparent; border-radius: 7px; color: var(--text-2); cursor: pointer; transition: transform .15s var(--ease), background .15s; }
.tree-toggle:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.tree-toggle.open .icon { rotate: 90deg; }
.tree-toggle:disabled { opacity: .35; cursor: default; }
.node-num { font-size: .76rem; font-weight: 650; font-variant-numeric: tabular-nums; color: var(--primary-soft); background: var(--purple-bg); border-radius: 7px; padding: 2px 7px; }
.node-main { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.node-name { color: var(--text); font-weight: 600; overflow-wrap: anywhere; }
.is-root .node-name { font-size: 1rem; }
.node-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.node-count { display: inline-flex; gap: 4px; align-items: center; font-size: .78rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
.node-actions { display: flex; gap: 2px; align-items: center; }
.tree-task .task-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 8px 5px 10px; border-radius: 9px; }
.tree-task .task-row:hover { background: var(--surface-2); }
.task-check { display: flex; align-items: center; gap: 10px; cursor: pointer; min-width: 0; flex: 1; }
.task-name { overflow-wrap: anywhere; font-size: .92rem; }
.tree-task.done .task-name, .task-item.done .task-name { color: var(--text-3); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--text-3) 60%, transparent); }
.task-meta { display: flex; align-items: center; gap: 8px; flex: none; }
.tree-quick { display: flex; align-items: center; gap: 8px; padding: 2px 8px 2px 10px; color: var(--text-3); }
.tree-quick .input { background: transparent; border-style: dashed; max-width: 420px; }
.tree-quick .input:focus { border-style: solid; background: var(--bg-2); }

/* ---------- Gantt ---------- */
.gantt-view > * + * { margin-top: 14px; }
.gantt-controls { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.gantt-nav { display: flex; align-items: center; gap: 6px; }
.gantt-range { font-size: 1.02rem; margin-left: 8px; }
.gantt-options { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.segmented { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); }
.segmented button { border: 0; background: transparent; padding: 6px 13px; border-radius: 7px; font-size: .85rem; color: var(--text-2); cursor: pointer; font-weight: 550; }
.segmented button.active { background: var(--purple-bg); color: var(--text); box-shadow: inset 0 0 0 1px rgba(139, 108, 255, .35); }
.gantt-card { padding: 0; overflow: hidden; }
.gantt-card > * + * { margin-top: 0; }
.gantt-scroll { overflow-x: auto; }
.gantt { --label-w: 240px; min-width: 820px; position: relative; }
.gantt.scale-month { min-width: 980px; }
.gantt.scale-quarter { min-width: 900px; }
.gantt-head { display: grid; grid-template-columns: var(--label-w) 1fr; background: var(--bg-2); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 3; }
[data-theme="light"] .gantt-head { background: var(--surface-2); }
.gantt-label-head { padding: 10px 14px; font-size: .74rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); border-right: 1px solid var(--border); position: sticky; left: 0; background: inherit; z-index: 2; }
.gantt-scale { position: relative; }
.gantt-scale-row { position: relative; height: 34px; }
.gantt-scale-row.small { height: 22px; border-top: 1px solid var(--border); }
.gantt-cell { position: absolute; top: 0; bottom: 0; display: flex; align-items: center; justify-content: center; font-size: .74rem; color: var(--text-2); border-left: 1px solid color-mix(in srgb, var(--border) 50%, transparent); font-variant-numeric: tabular-nums; overflow: hidden; white-space: nowrap; }
.gantt-cell.month { font-weight: 600; color: var(--text); font-size: .8rem; border-left-color: var(--border); }
.gantt-cell.weekend { color: var(--text-3); }
.gantt-cell.today { color: var(--primary-soft); font-weight: 700; background: var(--purple-bg); }
.gantt-cell .wd { text-transform: capitalize; margin-right: 3px; color: var(--text-3); }
.gantt-tick { position: absolute; top: 0; bottom: 0; font-size: .68rem; color: var(--text-3); padding-left: 3px; border-left: 1px solid var(--border); display: flex; align-items: center; }
.gantt-body { position: relative; }
.gantt-grid { position: absolute; top: 0; bottom: 0; left: var(--label-w); right: 0; pointer-events: none; }
.gantt-gridline { position: absolute; top: 0; bottom: 0; width: 1px; background: color-mix(in srgb, var(--border) 60%, transparent); }
.gantt-gridline.strong { background: var(--border); }
.gantt-weekend { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--bg-2) 70%, transparent); }
[data-theme="light"] .gantt-weekend { background: rgba(28, 21, 48, .025); }
.gantt-today { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--primary-bright); box-shadow: 0 0 10px var(--primary-bright); z-index: 2; opacity: .85; }
.gantt-row { display: grid; grid-template-columns: var(--label-w) 1fr; min-height: 40px; border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent); position: relative; }
.gantt-row:last-child { border-bottom: 0; }
.gantt-row:hover { background: color-mix(in srgb, var(--surface-2) 50%, transparent); }
.gantt-label {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px calc(14px + var(--depth, 0) * 14px); min-width: 0;
  border-right: 1px solid var(--border); position: sticky; left: 0; z-index: 2; background: var(--surface);
  box-shadow: inset 3px 0 0 var(--project-color, transparent);
}
.gantt-row.sub-row .gantt-label { font-size: .86rem; }
.project-row { background: color-mix(in srgb, var(--bg-2) 60%, transparent); }
.project-row .gantt-label { background: var(--bg-2); }
[data-theme="light"] .project-row .gantt-label { background: var(--surface-2); }
.gl-num { font-size: .72rem; color: var(--text-3); font-variant-numeric: tabular-nums; flex: none; }
.gl-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.gl-name.strong { font-weight: 650; }
.gantt-track { position: relative; min-height: 40px; }
.gantt-span { position: absolute; top: 50%; height: 4px; transform: translateY(-50%); border-radius: 4px; background: color-mix(in srgb, var(--project-color) 45%, transparent); }
.gantt-flag { position: absolute; top: 50%; transform: translate(-50%, -50%); color: var(--project-color, var(--primary-soft)); z-index: 1; display: grid; }
.gantt-flag.is-overdue { color: var(--red); }
.gantt-bar {
  position: absolute; top: 8px; bottom: 8px; min-width: 6px; display: flex; align-items: center; gap: 5px; padding: 0 8px; overflow: hidden;
  border-radius: 7px; border: 1px solid transparent; cursor: pointer; font-size: .76rem; font-weight: 560; text-align: left;
  background: var(--neutral-bg); color: var(--text); z-index: 1;
  transition: filter .15s, box-shadow .15s;
}
.gantt-bar:hover, .gantt-bar:focus-visible { filter: brightness(1.15); box-shadow: var(--glow); z-index: 3; }
.gantt-bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gantt-bar.tone-neutral { background: color-mix(in srgb, var(--text-2) 22%, var(--surface)); border-color: color-mix(in srgb, var(--text-2) 30%, transparent); }
.gantt-bar.tone-purple { background: linear-gradient(90deg, var(--primary), var(--primary-bright)); color: #fff; }
.gantt-bar.tone-blue { background: color-mix(in srgb, var(--blue) 35%, var(--surface)); border-color: color-mix(in srgb, var(--blue) 55%, transparent); }
.gantt-bar.tone-amber { background: color-mix(in srgb, var(--amber) 30%, var(--surface)); border-color: color-mix(in srgb, var(--amber) 55%, transparent); }
.gantt-bar.tone-green { background: color-mix(in srgb, var(--green) 30%, var(--surface)); border-color: color-mix(in srgb, var(--green) 55%, transparent); color: var(--text); }
.gantt-bar.is-overdue { border-color: var(--red); background-image: repeating-linear-gradient(135deg, transparent 0 6px, rgba(240, 122, 138, .22) 6px 10px); }
.gantt-bar.is-overdue .icon { color: var(--red); }
.gantt-bar.tone-purple.is-overdue .icon { color: #fff; }
.gantt-bar.is-soon { box-shadow: 0 0 0 2px color-mix(in srgb, var(--amber) 70%, transparent); }
.gantt-bar.clip-left { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.gantt-bar.clip-right { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.gantt-off {
  position: absolute; top: 50%; transform: translateY(-50%); display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; font-size: .72rem; border-radius: 999px; border: 1px dashed var(--border-strong); background: var(--surface); color: var(--text-2); cursor: pointer; z-index: 1;
}
.gantt-off.left { left: 6px; }
.gantt-off.right { right: 6px; }
.gantt-off.is-overdue { border-color: var(--red); color: var(--red); }
.gantt-off:hover { color: var(--text); border-style: solid; }
.gantt-milestone { position: absolute; top: 50%; transform: translate(-7px, -50%); display: inline-flex; align-items: center; gap: 7px; background: none; border: 0; padding: 0; cursor: pointer; color: var(--text); font-size: .76rem; z-index: 1; white-space: nowrap; }
.diamond { width: 13px; height: 13px; transform: rotate(45deg); border-radius: 3px; background: var(--primary-bright); box-shadow: 0 0 10px rgba(139, 108, 255, .6); flex: none; }
.gantt-milestone.tone-green .diamond { background: var(--green); box-shadow: none; }
.gantt-milestone.tone-amber .diamond { background: var(--amber); }
.gantt-milestone.tone-blue .diamond { background: var(--blue); }
.gantt-milestone.tone-neutral .diamond { background: var(--text-2); box-shadow: none; }
.gantt-milestone.is-overdue .diamond { background: var(--red); box-shadow: 0 0 10px var(--red); }
.gantt-milestone:hover .gantt-ms-label { text-decoration: underline; }
.gantt-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 12px 16px; border-top: 1px solid var(--border); font-size: .78rem; color: var(--text-2); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 16px; height: 9px; border-radius: 3px; display: inline-block; }
.legend-swatch.tone-neutral { background: color-mix(in srgb, var(--text-2) 35%, var(--surface)); }
.legend-swatch.tone-purple { background: var(--primary-bright); }
.legend-swatch.tone-blue { background: var(--blue); }
.legend-swatch.tone-amber { background: var(--amber); }
.legend-swatch.tone-green { background: var(--green); }
.legend-swatch.is-overdue { background: repeating-linear-gradient(135deg, transparent 0 3px, var(--red) 3px 5px); border: 1px solid var(--red); }
.legend-swatch.is-soon { border: 2px solid var(--amber); }
.legend-diamond { width: 9px; height: 9px; transform: rotate(45deg); background: var(--primary-bright); border-radius: 2px; display: inline-block; }
.undated-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.undated-list li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.undated-list a { color: var(--text); font-weight: 550; }
.gantt-foot { text-align: right; }

/* ---------- Archivos ---------- */
.panel > * + * { margin-top: 14px; }
.upload-area { display: flex; flex-direction: column; gap: 10px; }
.upload-area .filter { max-width: 360px; }
.dropzone {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 16px 18px; border-radius: var(--radius);
  border: 1.5px dashed var(--border-strong); background: color-mix(in srgb, var(--purple-bg) 50%, transparent); color: var(--primary-soft);
  transition: border-color .2s, background .2s, scale .45s var(--spring);
}
.dropzone > div { flex: 1; min-width: 200px; }
.dropzone.over { border-color: var(--primary-bright); background: var(--purple-bg); scale: 1.012; }
.dz-title { color: var(--text); font-weight: 560; }
.dz-sub { color: var(--text-2); font-size: .8rem; }
.list-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.file-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.file-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg-2); }
[data-theme="light"] .file-row { background: var(--surface); }
.file-row.unavailable { opacity: .75; border-style: dashed; }
.file-icon { width: 42px; height: 46px; border-radius: 9px; flex: none; display: grid; place-items: center; font-size: .62rem; font-weight: 750; letter-spacing: .04em; color: var(--primary-soft); background: var(--purple-bg); border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent); }
.file-icon.ext-pdf { color: var(--red); background: var(--red-bg); border-color: color-mix(in srgb, var(--red) 30%, transparent); }
.file-icon.ext-ppt, .file-icon.ext-pptx, .file-icon.ext-key, .file-icon.ext-odp { color: var(--amber); background: var(--amber-bg); border-color: color-mix(in srgb, var(--amber) 30%, transparent); }
.file-icon.ext-doc, .file-icon.ext-docx, .file-icon.ext-odt { color: var(--blue); background: var(--blue-bg); border-color: color-mix(in srgb, var(--blue) 30%, transparent); }
.file-icon.ext-xls, .file-icon.ext-xlsx, .file-icon.ext-csv { color: var(--green); background: var(--green-bg); border-color: color-mix(in srgb, var(--green) 30%, transparent); }
.file-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.file-name { font-weight: 560; overflow-wrap: anywhere; }
.file-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .78rem; color: var(--text-2); align-items: center; }
.file-actions { display: flex; gap: 2px; }
.chip-link { display: inline-flex; align-items: center; gap: 5px; font-size: .78rem; color: var(--text-2); padding: 1px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-link:hover { color: var(--text); text-decoration: none; border-color: var(--border-strong); }
.chip-link .project-dot { width: 7px; height: 7px; box-shadow: none; }

/* ---------- Mejoras ---------- */
.mini-stats { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.mini-stat { display: flex; flex-direction: column; padding: 8px 14px; border-radius: 11px; background: var(--surface); border: 1px solid var(--border); min-width: 92px; }
.mini-stat strong { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.mini-stat span { font-size: .74rem; color: var(--text-2); }
.mini-stat.tone-amber strong { color: var(--amber); }
.mini-stat.tone-blue strong { color: var(--blue); }
.mini-stat.tone-green strong { color: var(--green); }
.review-card { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); }
.review-card > div { flex: 1; min-width: 220px; }
.review-card p { color: var(--text-2); margin-top: 2px; }
.review-card.ok { background: var(--green-bg); border-color: color-mix(in srgb, var(--green) 35%, transparent); }
.review-card.ok > .icon { color: var(--green); }
.review-card.pending > .icon { color: var(--amber); }
.review-card.ready > .icon { color: var(--primary-soft); }
.imp-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.imp-card { padding: 14px 16px; border-radius: 13px; border: 1px solid var(--border); background: var(--surface); box-shadow: inset 3px 0 0 var(--amber); }
.imp-card > * + * { margin-top: 8px; }
.imp-card.group-resolved { box-shadow: inset 3px 0 0 var(--blue); }
.imp-card.status-accepted { box-shadow: inset 3px 0 0 var(--green); }
.imp-card.status-in_dev { box-shadow: inset 3px 0 0 var(--primary-bright); }
.imp-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.imp-title { font-size: .98rem; overflow-wrap: anywhere; flex: 1; min-width: 180px; }
.imp-actions { display: flex; gap: 4px; align-items: center; }
.imp-actions .select { width: auto; }
.imp-desc { color: var(--text-2); font-size: .9rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.imp-meta { display: flex; gap: 6px 12px; flex-wrap: wrap; align-items: center; }
.imp-notes { color: var(--text-2); white-space: pre-wrap; }

/* ---------- Reuniones ---------- */
.meeting-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.meeting-card { display: flex; gap: 16px; padding: 16px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); }
.meeting-date { flex: none; width: 60px; height: 64px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--purple-bg); border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent); }
.md-day { font-size: 1.35rem; font-weight: 700; line-height: 1; }
.md-month { font-size: .7rem; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; margin-top: 4px; text-align: center; }
.meeting-card.result-approved .meeting-date { background: var(--green-bg); border-color: color-mix(in srgb, var(--green) 30%, transparent); }
.meeting-card.result-changes .meeting-date { background: var(--amber-bg); border-color: color-mix(in srgb, var(--amber) 30%, transparent); }
.meeting-main { flex: 1; min-width: 0; }
.meeting-main > * + * { margin-top: 10px; }
.meeting-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.meeting-badges { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.meeting-block h5 { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin-bottom: 3px; }
.meeting-block p { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .9rem; }
.meeting-foot { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.meeting-foot:empty { display: none; }

/* ---------- Notas ---------- */
.note-grid { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.note-card { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border-radius: 13px; border: 1px solid var(--border); background: var(--surface); min-height: 140px; }
.node-col-side .note-grid { grid-template-columns: 1fr; }
.note-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.note-title { font-weight: 620; overflow-wrap: anywhere; }
.note-content { flex: 1; font-size: .88rem; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.note-meta { display: flex; gap: 6px 10px; flex-wrap: wrap; align-items: center; }

/* ---------- Detalle de fase ---------- */
.node-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.node-col-main > * + *, .node-col-side > * + * { margin-top: 16px; }
.text-card p { font-size: .9rem; }
.approval-history { list-style: none; display: flex; flex-direction: column; gap: 10px; font-size: .84rem; }
.approval-history li { padding-left: 10px; border-left: 2px solid var(--border-strong); }
.approval-history .icon { color: var(--green); }
.approval-history .muted .icon { color: var(--amber); }

/* ---------- Tareas (vista general) ---------- */
.task-list { list-style: none; padding: 6px; }
.task-list.card > * + * { margin-top: 0; }
.task-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; }
.task-item + .task-item { border-top: 1px solid var(--border); }
.task-item:hover { background: var(--surface-2); }
.task-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.task-item-main .task-name { cursor: pointer; font-weight: 520; }
.task-item-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.task-item-side { display: flex; gap: 10px; align-items: center; flex: none; }

/* ---------- Configuración ---------- */
.theme-options { display: flex; gap: 12px; flex-wrap: wrap; }
.theme-option { display: flex; align-items: center; gap: 10px; padding: 10px 14px 10px 10px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg-2); cursor: pointer; color: var(--text); font-weight: 550; }
.theme-option.active { border-color: var(--primary-bright); box-shadow: var(--glow); }
.theme-preview { width: 44px; height: 30px; border-radius: 7px; border: 1px solid var(--border); }
.theme-option.dark .theme-preview { background: radial-gradient(1px 1px at 30% 30%, #fff, transparent), radial-gradient(1px 1px at 70% 60%, #fff, transparent), linear-gradient(135deg, #100D1B, #201832); }
.theme-option.light .theme-preview { background: linear-gradient(135deg, #FFFFFF, #ECE6FA); }
.settings-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; padding-top: 14px; border-top: 1px solid var(--border); }
.storage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.backup-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.backup-option { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 13px; border: 1px solid var(--border); background: var(--bg-2); }
[data-theme="light"] .backup-option { background: var(--surface-2); }
.backup-option p { flex: 1; }
.backup-option .btn { align-self: flex-start; }
.bo-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bo-head h3 { font-size: .98rem; }
.bo-head .icon { color: var(--primary-soft); }
.danger-zone { border-color: color-mix(in srgb, var(--red) 35%, var(--border)); }


/* =========================================================================
   Movimiento fluido (pensado para pantallas de alta frecuencia: 120/144 Hz)
   Solo se animan propiedades compuestas por la GPU (transform, scale, translate,
   rotate, opacity) con curvas de tipo muelle. Las entradas escalonadas se
   reproducen únicamente al cambiar de vista.
   ========================================================================= */
:root {
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --spring: cubic-bezier(.34, 1.4, .64, 1);
  --spring-soft: cubic-bezier(.25, 1.1, .5, 1);
}
@supports (transition-timing-function: linear(0, 1)) {
  :root {
    --spring: linear(0, .009, .035 2.1%, .141, .281 6.7%, .723 12.9%, .938 16.7%, 1.017, 1.077, 1.121, 1.149 24.3%, 1.159, 1.163, 1.161, 1.154 29.9%, 1.129 32.8%, 1.051 39.6%, 1.017 43.1%, .991, .977 51%, .974 53.8%, .975 57.1%, .997 69.8%, 1.003 76.9%, 1);
    --spring-soft: linear(0, .0175 1.4%, .0685 2.8%, .2575 6%, .5235 10.1%, .7765 14.7%, .8935 17.6%, .9745 20.8%, 1.0225 24.1%, 1.0425 27.5%, 1.0435 31%, 1.0305 35.6%, 1.0045 44.5%, .9965 52.6%, 1.0005 75.5%, 1);
  }
}

@keyframes riseIn { from { opacity: 0; translate: 0 16px; scale: .985; } }
@keyframes riseInSmall { from { opacity: 0; translate: 0 8px; } }
@keyframes growX { from { scale: 0 1; opacity: .3; } }
@keyframes popIn { from { opacity: 0; scale: 0; } }
@keyframes ringIn { from { stroke-dasharray: 0 200; } }
@keyframes expandIn { from { opacity: 0; translate: 0 -8px; } }
@keyframes check { 0% { scale: 1; } 35% { scale: .7; } 100% { scale: 1; } }
@keyframes flash { from { background-color: var(--purple-bg); } to { background-color: transparent; } }
@keyframes turnOpen { from { rotate: 0deg; } }
@keyframes turnClose { from { rotate: 90deg; } }
@keyframes orbIn { from { opacity: 0; scale: .4; rotate: -40deg; } }

/* Entrada de la vista: bloques principales escalonados */
.view-enter > .view > * { animation: riseIn .7s var(--spring-soft) both; }
.view-enter > .view > :nth-child(2) { animation-delay: 50ms; }
.view-enter > .view > :nth-child(3) { animation-delay: 100ms; }
.view-enter > .view > :nth-child(4) { animation-delay: 150ms; }
.view-enter > .view > :nth-child(5) { animation-delay: 200ms; }
.view-enter > .view > :nth-child(n+6) { animation-delay: 250ms; }

/* Elementos de listas y rejillas: cascada */
.view-enter :is(.project-card, .stat-card, .metric, .mini-stat, .delivery, .activity, .imp-card, .note-card, .file-row, .meeting-card, .task-item, .tree > .tree-node, .phase-progress-list > li, .backup-option, .undated-list > li) { animation: riseIn .65s var(--spring-soft) both; animation-delay: 120ms; }
.view-enter :is(.project-card, .stat-card, .metric, .mini-stat, .delivery, .activity, .imp-card, .note-card, .file-row, .meeting-card, .task-item, .tree > .tree-node, .phase-progress-list > li, .backup-option, .undated-list > li):nth-child(2) { animation-delay: 155ms; }
.view-enter :is(.project-card, .stat-card, .metric, .mini-stat, .delivery, .activity, .imp-card, .note-card, .file-row, .meeting-card, .task-item, .tree > .tree-node, .phase-progress-list > li, .backup-option, .undated-list > li):nth-child(3) { animation-delay: 190ms; }
.view-enter :is(.project-card, .stat-card, .metric, .mini-stat, .delivery, .activity, .imp-card, .note-card, .file-row, .meeting-card, .task-item, .tree > .tree-node, .phase-progress-list > li, .backup-option, .undated-list > li):nth-child(4) { animation-delay: 225ms; }
.view-enter :is(.project-card, .stat-card, .metric, .mini-stat, .delivery, .activity, .imp-card, .note-card, .file-row, .meeting-card, .task-item, .tree > .tree-node, .phase-progress-list > li, .backup-option, .undated-list > li):nth-child(5) { animation-delay: 260ms; }
.view-enter :is(.project-card, .stat-card, .metric, .mini-stat, .delivery, .activity, .imp-card, .note-card, .file-row, .meeting-card, .task-item, .tree > .tree-node, .phase-progress-list > li, .backup-option, .undated-list > li):nth-child(6) { animation-delay: 295ms; }
.view-enter :is(.project-card, .stat-card, .metric, .mini-stat, .delivery, .activity, .imp-card, .note-card, .file-row, .meeting-card, .task-item, .tree > .tree-node, .phase-progress-list > li, .backup-option, .undated-list > li):nth-child(7) { animation-delay: 330ms; }
.view-enter :is(.project-card, .stat-card, .metric, .mini-stat, .delivery, .activity, .imp-card, .note-card, .file-row, .meeting-card, .task-item, .tree > .tree-node, .phase-progress-list > li, .backup-option, .undated-list > li):nth-child(8) { animation-delay: 365ms; }
.view-enter :is(.project-card, .stat-card, .metric, .mini-stat, .delivery, .activity, .imp-card, .note-card, .file-row, .meeting-card, .task-item, .tree > .tree-node, .phase-progress-list > li, .backup-option, .undated-list > li):nth-child(n+9) { animation-delay: 400ms; }

/* Progreso: las barras y anillos se rellenan al entrar */
.view-enter .progress-fill { animation: growX 1.1s var(--spring-soft) both; animation-delay: 220ms; }
.view-enter .ring-fg { animation: ringIn 1.3s var(--ease-out) both; animation-delay: 200ms; }
.view-enter .empty-orb { animation: orbIn .8s var(--spring) both; animation-delay: 120ms; }
.view-enter .tab.active::after { animation: growX .6s var(--spring) both; animation-delay: 150ms; }

/* Gantt: las barras crecen desde su fecha de inicio, fila a fila */
.view-enter .gantt-row { animation: riseInSmall .5s var(--ease-out) both; }
.view-enter .gantt-bar { animation: growX .9s var(--spring-soft) both; transform-origin: left center; animation-delay: 200ms; }
.view-enter :is(.gantt-milestone .diamond, .gantt-flag, .gantt-off) { animation: popIn .6s var(--spring) both; animation-delay: 380ms; }
.view-enter .gantt-today { animation: riseInSmall .8s var(--ease-out) both; animation-delay: 300ms; }
.view-enter .gantt-row:nth-child(2) .gantt-bar { animation-delay: 230ms; }
.view-enter .gantt-row:nth-child(3) .gantt-bar { animation-delay: 260ms; }
.view-enter .gantt-row:nth-child(4) .gantt-bar { animation-delay: 290ms; }
.view-enter .gantt-row:nth-child(5) .gantt-bar { animation-delay: 320ms; }
.view-enter .gantt-row:nth-child(6) .gantt-bar { animation-delay: 350ms; }
.view-enter .gantt-row:nth-child(7) .gantt-bar { animation-delay: 380ms; }
.view-enter .gantt-row:nth-child(8) .gantt-bar { animation-delay: 410ms; }
.view-enter .gantt-row:nth-child(n+9) .gantt-bar { animation-delay: 440ms; }
.gantt-bar { transition: filter .2s, box-shadow .25s, translate .4s var(--spring); }
.gantt-bar:hover, .gantt-bar:focus-visible { translate: 0 -2px; }
.gantt-milestone .diamond { transition: scale .4s var(--spring); }
.gantt-milestone:hover .diamond { scale: 1.3; }

/* Árbol: expandir/contraer y marcar tareas */
.tree-children.fx-open { animation: expandIn .45s var(--spring-soft); }
.tree-children.fx-open > li { animation: riseInSmall .45s var(--spring-soft) both; }
.tree-children.fx-open > li:nth-child(2) { animation-delay: 30ms; }
.tree-children.fx-open > li:nth-child(3) { animation-delay: 60ms; }
.tree-children.fx-open > li:nth-child(4) { animation-delay: 90ms; }
.tree-children.fx-open > li:nth-child(n+5) { animation-delay: 120ms; }
.tree-toggle.fx-turn-open .icon { animation: turnOpen .5s var(--spring); }
.tree-toggle.fx-turn-close .icon { animation: turnClose .5s var(--spring); }
.fx-pop input[type="checkbox"] { animation: check .45s var(--spring); }
.fx-pop .task-row, .task-item.fx-pop { animation: flash 1s var(--ease-out); }
.fx-new { animation: riseIn .5s var(--spring-soft); }
.node-row { transition: border-color .2s, transform .45s var(--spring), box-shadow .3s; }
.node-row:hover { transform: translateX(2px); }

/* Resplandor que sigue al cursor */
.project-card::after, .stat-card::after, .backup-option::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit; opacity: 0; transition: opacity .35s var(--ease);
  background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 0%), rgba(139, 108, 255, .16), transparent 65%);
}
.project-card:hover::after, .stat-card:hover::after, .backup-option:hover::after { opacity: 1; }
.backup-option { position: relative; overflow: hidden; transition: border-color .25s, transform .5s var(--spring); }
.backup-option:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.stat-card .stat-icon, .project-card .ring-wrap { transition: scale .5s var(--spring), rotate .5s var(--spring); }
.stat-card:hover .stat-icon { scale: 1.12; rotate: -6deg; }
.project-card:hover .ring-wrap { scale: 1.06; }
.theme-option { transition: border-color .25s, box-shadow .3s, transform .45s var(--spring); }
.theme-option:hover { transform: translateY(-2px); }
.check input[type="checkbox"] { transition: scale .3s var(--spring); }
.check input[type="checkbox"]:active { scale: .85; }
.input { transition: border-color .2s, box-shadow .3s var(--ease-out), background .2s; }

/* Cambio de tema: revelado circular (View Transitions API) */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { z-index: 2; }


/* =========================================================================
   Inicio de sesión, portal del cliente y accesos
   ========================================================================= */
.mono { font-family: var(--mono); font-size: .88em; }
.badge-link:hover { text-decoration: none; filter: brightness(1.15); }

/* Modos de la aplicación */
.is-auth .app, .is-auth .skip-link { display: none; }
.is-portal .sidebar, .is-portal .sidebar-backdrop, .is-portal .topbar .menu-btn, .is-portal #new-project-btn { display: none !important; }
.is-portal .main-wrap { margin-left: 0; }
.is-portal .topbar .topbar-brand { display: inline; }
.is-portal #view { max-width: 1180px; }

/* Pantalla de inicio de sesión */
.login-screen {
  min-height: 100vh; display: grid; place-items: center; padding: 24px; overflow: hidden;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(109, 74, 255, .32), transparent 70%),
    radial-gradient(700px 420px at -10% 110%, rgba(139, 108, 255, .16), transparent 70%),
    var(--bg);
}
.login-screen::before { opacity: .8; }
.login-orbit {
  position: absolute; width: 760px; height: 760px; border-radius: 50%; pointer-events: none;
  border: 1px solid color-mix(in srgb, var(--primary-soft) 18%, transparent);
  box-shadow: inset 0 0 120px -40px rgba(109, 74, 255, .45);
  animation: orbitIn 1.4s var(--ease-out) both;
}
.login-orbit::after { content: ""; position: absolute; top: 12%; left: 14%; width: 9px; height: 9px; border-radius: 50%; background: var(--primary-soft); box-shadow: 0 0 18px var(--primary-bright); }
@keyframes orbitIn { from { opacity: 0; scale: .7; rotate: -25deg; } }
.login-card {
  position: relative; width: 100%; max-width: 420px; padding: 32px 30px 26px; border-radius: 22px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(14px);
  border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg), 0 0 90px -30px rgba(109, 74, 255, .55);
  animation: riseIn .8s var(--spring-soft) both .1s;
}
.login-brand { display: flex; align-items: center; gap: 14px; }
.login-brand h1 { font-size: 1.35rem; }
.login-brand p { color: var(--text-2); font-size: .86rem; }
.login-logo { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; color: #fff; background: radial-gradient(circle at 30% 25%, var(--primary-soft), var(--primary) 60%, #2A1A66); box-shadow: 0 10px 30px -10px rgba(109, 74, 255, .9); }
.login-intro { color: var(--text-2); font-size: .9rem; margin: 18px 0 6px; }
.login-form { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.login-form .form-error { margin-top: 0; }
.login-submit { width: 100%; min-height: 44px; font-size: .95rem; margin-top: 4px; }
.login-submit .flip { rotate: 180deg; transition: translate .4s var(--spring); }
.login-submit:hover .flip { translate: 3px 0; }
.login-submit.loading { opacity: .8; pointer-events: none; }
.login-submit.loading .flip { animation: pulse .8s infinite; }
.login-foot { display: flex; align-items: center; gap: 7px; margin-top: 18px; font-size: .8rem; color: var(--text-3); }
.shake { animation: shake .42s var(--ease-out); }
@keyframes shake { 20% { translate: -8px 0; } 40% { translate: 7px 0; } 60% { translate: -5px 0; } 80% { translate: 3px 0; } }

/* Indicador en vivo */
.live { display: inline-flex; align-items: center; gap: 7px; font-size: .76rem; font-weight: 560; color: var(--green); padding: 2px 10px; border-radius: 999px; background: var(--green-bg); }
.live.offline { color: var(--amber); background: var(--amber-bg); }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); position: relative; flex: none; }
.live-dot::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--green); opacity: 0; animation: livePing 2.4s var(--ease-out) infinite; }
.live.offline .live-dot, .live-dot.off { background: var(--amber); }
.live.offline .live-dot::after, .live-dot.off::after { border-color: var(--amber); }
@keyframes livePing { 0% { opacity: .7; scale: .5; } 80%, 100% { opacity: 0; scale: 1.6; } }
.is-portal .save-status { color: var(--green); }

/* Portal del cliente */
.portal-hero .ph-main .ring-wrap .ring-label { font-size: 1rem; }
.portal-summary > * + * { margin-top: 18px; }
.portal-columns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.portal-col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.portal-col-title { display: flex; align-items: center; gap: 8px; font-size: 1rem; margin-bottom: 12px; }
.portal-col-title .count { margin-left: auto; font-size: .78rem; padding: 1px 9px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); }
.portal-col.tone-green .portal-col-title .icon { color: var(--green); }
.portal-col.tone-purple .portal-col-title .icon { color: var(--primary-soft); }
.portal-col.tone-neutral .portal-col-title .icon { color: var(--text-2); }
.portal-col.tone-green { box-shadow: var(--shadow), inset 0 2px 0 var(--green); }
.portal-col.tone-purple { box-shadow: var(--shadow), inset 0 2px 0 var(--primary-bright); }
.portal-col-list { display: flex; flex-direction: column; gap: 10px; }
.empty-col { padding: 10px 2px; }
.portal-phase {
  display: flex; flex-direction: column; gap: 9px; padding: 12px 13px; border-radius: 12px; color: var(--text);
  background: var(--bg-2); border: 1px solid var(--border); transition: border-color .25s, transform .5s var(--spring), box-shadow .3s;
}
[data-theme="light"] .portal-phase { background: var(--surface-2); }
.portal-phase:hover { text-decoration: none; border-color: var(--border-strong); transform: translateY(-2px); box-shadow: 0 12px 30px -18px rgba(109, 74, 255, .6); }
.pp-head { display: flex; align-items: center; gap: 8px; }
.pp-name { flex: 1; font-weight: 600; overflow-wrap: anywhere; }
.pp-head .icon { color: var(--text-3); transition: translate .4s var(--spring); }
.portal-phase:hover .pp-head .icon { translate: 3px 0; color: var(--primary-soft); }
.pp-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.portal-phase.status-done .node-num { background: var(--green-bg); color: var(--green); }
.portal-docs > * + *, .portal-imps > * + *, .portal-phase-detail > * + * { margin-top: 16px; }
.portal-tasks { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.portal-tasks li { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 9px; font-size: .92rem; }
.portal-tasks li:hover { background: var(--surface-2); }
.portal-tasks li.done span:last-child { color: var(--text-3); text-decoration: line-through; }
.pt-check { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--border-strong); display: grid; place-items: center; flex: none; }
.portal-tasks li.done .pt-check { background: var(--primary-bright); border-color: var(--primary-bright); color: #fff; }
.portal-foot { text-align: center; padding-top: 8px; }
.view-enter :is(.portal-col, .portal-phase) { animation: riseIn .65s var(--spring-soft) both; animation-delay: 140ms; }
.view-enter .portal-col:nth-child(2) { animation-delay: 190ms; }
.view-enter .portal-col:nth-child(3) { animation-delay: 240ms; }
.view-enter .portal-phase:nth-child(2) { animation-delay: 220ms; }
.view-enter .portal-phase:nth-child(n+3) { animation-delay: 260ms; }

/* Panel de accesos (administrador) */
.portal-admin > * + * { margin-top: 16px; }
.sees-list { list-style: none; display: flex; flex-direction: column; gap: 8px; font-size: .9rem; }
.sees-list li { display: flex; gap: 9px; align-items: flex-start; }
.sees-list .icon { color: var(--green); margin-top: 3px; }
.sees-list li.no { color: var(--text-2); }
.sees-list li.no .icon { color: var(--red); }
.credentials .cred-hero { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--purple-bg); }
.credentials .cred-hero .icon { color: var(--primary-soft); }
.copy-row { display: flex; gap: 8px; }
.copy-row .input { flex: 1; }
.input.secret { letter-spacing: .06em; font-weight: 600; color: var(--primary-soft); }
.settings-row.first { border-top: 0; padding-top: 0; }

/* Subida de archivos */
.upload-options { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.upload-indicator {
  position: fixed; left: 20px; bottom: 20px; z-index: 95; display: flex; align-items: center; gap: 12px; width: min(360px, calc(100vw - 40px));
  padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg);
  animation: toastIn .5s var(--spring);
}
.upload-indicator > .icon { color: var(--primary-soft); }
.upload-indicator.leaving { animation: toastOut .24s forwards; }
.upload-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.upload-label { font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-track { height: 5px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.upload-fill { height: 100%; width: 100%; transform: scaleX(0); transform-origin: left; background: linear-gradient(90deg, var(--primary), var(--primary-bright)); transition: transform .3s var(--ease-out); }
.file-row.cat-internal { border-style: dashed; }

@media (max-width: 900px) {
  .portal-columns { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .login-card { padding: 26px 20px 22px; }
  .login-orbit { width: 520px; height: 520px; }
  .copy-row { flex-wrap: wrap; }
  .upload-indicator { left: 12px; bottom: 12px; }
  /* Barra superior compacta: el indicador de guardado muestra solo su icono. */
  .topbar { gap: 6px; padding: 8px 12px; }
  .save-status { font-size: 0; gap: 0; padding: 4px 6px; }
  .topbar .topbar-brand { font-size: .95rem; white-space: nowrap; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .node-grid { grid-template-columns: 1fr; }
  .summary-columns { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .42s var(--ease-out); box-shadow: var(--shadow-lg); }
  .sidebar-backdrop:not([hidden]) { animation: fadeIn .3s var(--ease-out); }
  .sidebar.open { transform: none; }
  .main-wrap { margin-left: 0; }
  .topbar .menu-btn { display: inline-grid; }
  .topbar .topbar-brand { display: inline; }
  .topbar { padding: 8px 16px; }
  main { padding: 18px 16px 50px; }
  #app-banner:not(:empty) { padding: 12px 16px 0; }
  .dash-columns { grid-template-columns: 1fr; }
  .node-row { grid-template-columns: auto auto minmax(0, 1fr) auto; }
  .node-progress { grid-column: 3 / -1; grid-row: 2; }
}

@media (max-width: 600px) {
  body { font-size: 14.5px; }
  .hide-sm { display: none; }
  .hero { padding: 22px 18px; }
  .hero-title { font-size: 1.6rem; }
  .page-title { font-size: 1.4rem; }
  .project-header, .node-header { padding: 18px 16px; }
  .ph-main { flex-direction: column-reverse; }
  .ph-main .ring-wrap { align-self: flex-start; }
  .card { padding: 16px 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .project-grid { grid-template-columns: 1fr; }
  .filter { flex: 1 1 140px; }
  .search-box { flex-basis: 100%; }
  .node-row { grid-template-columns: auto minmax(0, 1fr) auto; padding: 10px 8px; gap: 8px; }
  .node-num { display: none; }
  .node-progress { grid-column: 1 / -1; }
  .tree-children { margin-left: 8px; padding-left: 8px; }
  .task-meta .due-rel { display: none; }
  .gantt { --label-w: 150px; }
  .gantt-range { font-size: .92rem; width: 100%; margin: 6px 0 0; }
  .gantt-nav { flex-wrap: wrap; }
  .meeting-card { flex-direction: column; }
  .meeting-date { flex-direction: row; width: auto; height: auto; padding: 6px 12px; gap: 8px; align-self: flex-start; }
  .md-month { margin-top: 0; }
  .task-item { flex-wrap: wrap; }
  .task-item-side { width: 100%; padding-left: 29px; }
  .mi-row { grid-template-columns: auto 1fr; }
  .mi-row .select { grid-column: 2; }
  .modal-overlay { padding: 0; place-items: end center; }
  .modal { max-height: 94vh; border-radius: 18px 18px 0 0; animation: sheetIn .45s var(--ease-out); }
  @keyframes sheetIn { from { translate: 0 100%; } }
  @keyframes toastIn { from { opacity: 0; translate: 0 30px; scale: .96; } }
  .modal-footer .btn { flex: 1; }
  .modal-footer .spacer { display: none; }
  .toasts { left: 12px; right: 12px; bottom: 12px; max-width: none; }
  .modal-open .toasts { top: 12px; bottom: auto; }
  .file-row { flex-wrap: wrap; }
  .file-actions { margin-left: auto; }
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

@media print {
  .sidebar, .topbar, .toasts, .ph-actions, .node-actions { display: none !important; }
  .main-wrap { margin-left: 0; }
  body { background: #fff; color: #000; }
}
