/* =========================================================
   tini Projects — v5 (SaaS app, no editorial)
   Inter only · No italic · Indigo accent · Compact density
   Software feel, not website feel.
   ========================================================= */

:root {
  /* Neutrals (Zinc, slightly warm) */
  --bg:        #FAFAFA;
  --bg-dim:    #F4F4F5;
  --surface:   #FFFFFF;
  --surface-2: #F7F7F8;
  --ink-1:     #18181B;
  --ink-2:     #3F3F46;
  --ink-3:     #71717A;
  --ink-4:     #A1A1AA;
  --line:      #E4E4E7;
  --line-soft: #EFEFF1;
  --line-strong: #D4D4D8;

  /* Accent — indigo (the SaaS color) */
  --accent:      #4F46E5;  /* indigo-600 */
  --accent-700:  #4338CA;
  --accent-500:  #6366F1;
  --accent-100:  #E0E7FF;
  --accent-50:   #EEF2FF;

  /* Semantic (warm-ish) */
  --positive:      #16A34A;
  --positive-soft: #DCFCE7;
  --warning:       #EA580C;
  --warning-soft:  #FFEDD5;
  --negative:      #DC2626;
  --negative-soft: #FEE2E2;

  /* Type — Inter only */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;

  /* Spacing — compact */
  --s-1:  2px;
  --s-2:  4px;
  --s-3:  6px;
  --s-4:  8px;
  --s-5: 12px;
  --s-6: 16px;
  --s-7: 20px;
  --s-8: 24px;
  --s-9: 32px;
  --s-10: 48px;
  --s-11: 64px;

  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 8px;

  --shadow-1: 0 1px 2px rgba(24, 24, 27, 0.04);
  --shadow-2: 0 1px 3px rgba(24, 24, 27, 0.06), 0 1px 2px rgba(24, 24, 27, 0.04);
  --shadow-3: 0 4px 12px -2px rgba(24, 24, 27, 0.08), 0 2px 4px rgba(24, 24, 27, 0.04);
  --shadow-focus: 0 0 0 3px rgba(79, 70, 229, 0.18);

  --ease:    cubic-bezier(0.4, 0, 0.2, 1);
  --t-fast:  120ms;
  --t-med:   180ms;
  --t-slide: 320ms;
}

*, *::before, *::after { box-sizing: border-box; }
html {
  margin: 0; padding: 0;
  color-scheme: light;
  -webkit-tap-highlight-color: rgba(79, 70, 229, 0.18);
}
body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink-1);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
  text-rendering: optimizeLegibility;
}

button, input, textarea, select { font-family: inherit; }
button { cursor: pointer; touch-action: manipulation; }
a { color: inherit; text-decoration: none; touch-action: manipulation; }
img, svg { display: block; max-width: 100%; }
::selection { background: var(--accent-100); color: var(--accent-700); }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-color: var(--accent);
}

.skip-link {
  position: absolute;
  top: -40px; left: 12px;
  background: var(--ink-1); color: var(--surface);
  padding: 6px 10px; border-radius: var(--r-sm);
  font-size: 12px; z-index: 100;
  transition: top var(--t-fast) var(--ease);
}
.skip-link:focus { top: 8px; }

.visually-hidden {
  position: absolute !important;
  clip: rect(0 0 0 0);
  width: 1px; height: 1px;
  overflow: hidden;
}

/* Legacy elements we no longer use */
.aurora, .phase-dots { display: none; }

/* =========================================================
   Layout
   ========================================================= */

.wrap {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 var(--s-8);
}
@media (max-width: 768px) {
  .wrap { padding: 0 var(--s-6); }
}

/* =========================================================
   Type primitives — no italic anywhere
   ========================================================= */

.display {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: clamp(20px, 2.2vw, 26px);
  line-height: 1.2;
  letter-spacing: -0.012em;
  margin: 0;
  color: var(--ink-1);
}
.display em { font-style: normal; color: var(--ink-1); font-weight: 600; }

.serif-h2 {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 15px;
  line-height: 1.3;
  letter-spacing: -0.005em;
  margin: 0;
  color: var(--ink-1);
}
.serif-h2 em { font-style: normal; color: var(--ink-1); font-weight: 600; }

.eyebrow {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-3);
  line-height: 1;
}

.lede { display: none; }
.pull-quote, .home-footer { display: none; }

.hint {
  font-size: 11px;
  color: var(--ink-3);
}

.num, .mono {
  font-family: var(--font-mono);
  font-feature-settings: "tnum" 1, "zero" 1;
  font-variant-numeric: tabular-nums;
}

/* =========================================================
   App chrome — header
   ========================================================= */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
  height: 48px;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-6);
  padding: 0;
  height: 48px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.012em;
  color: var(--ink-1);
}
.brand-mark { font-weight: 700; }
.brand-sub  { font-style: normal; font-weight: 500; color: var(--accent); }
.header-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
  background: var(--bg-dim);
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
}
.header-right {
  display: inline-flex;
  align-items: center;
  gap: var(--s-4);
}
.user-email {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  white-space: nowrap;
}
.user-email:empty { display: none; }
.btn-logout {
  padding: 4px 10px;
  font-size: 12px;
  color: var(--ink-2);
}
@media (max-width: 640px) {
  .user-email { display: none; }
}
@media (max-width: 540px) {
  .header-eyebrow { display: none; }
}

/* =========================================================
   Page head
   ========================================================= */

.page-head {
  padding: var(--s-9) 0 var(--s-7);
  border-bottom: 1px solid var(--line);
}
.page-head .eyebrow + .display { margin-top: var(--s-3); }

.detail-head {
  padding: var(--s-5) 0 var(--s-5);
  border-bottom: 1px solid var(--line);
}
/* Detail-head: tipografía un punto más pequeña que en home para ganar altura */
.detail-head .display { font-size: clamp(18px, 1.9vw, 22px); }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: var(--s-3) 0 var(--s-4);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
  transition: color var(--t-fast) var(--ease);
}
.back-link:hover { color: var(--accent); }

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-7);
  margin: var(--s-3) 0 0;
  padding: 0;
}
.meta-row > div { margin: 0; }
.meta-row dt {
  font-size: 11px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-3);
  font-weight: 500;
  margin-bottom: 2px;
}
.meta-row dd {
  font-size: 13px;
  color: var(--ink-1);
  margin: 0;
  font-weight: 500;
}

/* =========================================================
   Stats — software KPI tiles
   ========================================================= */

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s-5);
  margin: var(--s-7) 0 var(--s-9);
}
.stat {
  position: relative;
  padding: var(--s-6) var(--s-6);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  transition: border-color var(--t-fast) var(--ease);
}
.stat:hover { border-color: var(--line-strong); }
.stat .eyebrow {
  order: 1;
  font-size: 11px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}
.stat-value {
  order: 2;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 22px;
  color: var(--ink-1);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
@media (max-width: 768px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat-value { font-size: 20px; }
}

/* =========================================================
   Sections
   ========================================================= */

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-6);
  margin-bottom: var(--s-6);
  flex-wrap: wrap;
}
.section-head-actions {
  display: inline-flex;
  align-items: center;
  gap: var(--s-6);
}
@media (max-width: 540px) {
  .section-head-actions .hint { display: none; }
}
.projects-section { margin-top: var(--s-9); }

/* =========================================================
   Projects table
   ========================================================= */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-1);
}

.projects-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.projects-table thead th {
  background: var(--surface-2);
  text-align: left;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-3);
  padding: var(--s-5) var(--s-6);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.projects-table thead th.num { text-align: right; }
.projects-table tbody tr {
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease);
}
.projects-table tbody tr:last-child { border-bottom: none; }
.projects-table tbody tr:hover,
.projects-table tbody tr:focus-within {
  background: var(--accent-50);
  /* Left accent stripe via inset shadow — doesn't break table layout */
  box-shadow: inset 3px 0 0 var(--accent);
}
.projects-table tbody tr.is-lost { opacity: 0.55; }

.projects-table td {
  padding: var(--s-5) var(--s-6);
  vertical-align: middle;
}
.projects-table td.num { text-align: right; }

.col-id { width: 64px; color: var(--ink-3); font-family: var(--font-mono); font-size: 12px; font-variant-numeric: tabular-nums; }
.col-name { min-width: 240px; }
.col-phase { width: 220px; }
.col-margin, .col-benefit { width: 130px; }
.col-arrow { width: 32px; text-align: right; color: var(--ink-4); padding-right: var(--s-6); }

.cell-name { display: flex; flex-direction: column; gap: 1px; }
.cell-name .name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-1);
  letter-spacing: -0.005em;
  line-height: 1.3;
}
.cell-name .sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0;
}
.cell-arrow {
  font-size: 14px;
  color: var(--ink-4);
  transition: transform var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
tr:hover .cell-arrow { color: var(--accent); transform: translateX(2px); }

.num-cell {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 500;
}
.num-cell.pos { color: var(--positive); }
.num-cell.neu { color: var(--ink-1); }
.num-cell.warn { color: var(--warning); }
.num-cell.neg { color: var(--negative); }
.num-cell.muted { color: var(--ink-4); font-weight: 400; }

/* Tags — chip style */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-2);
  background: var(--bg-dim);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  white-space: nowrap;
  line-height: 1.2;
}
.tag .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-3);
  flex-shrink: 0;
}
.tag-estimacion              { background: var(--bg-dim); color: var(--ink-2); border-color: var(--line); }
.tag-estimacion .dot         { background: var(--ink-3); }
.tag-estimacion-fabricacion  { background: var(--accent-50); color: var(--accent-700); border-color: var(--accent-100); }
.tag-estimacion-fabricacion .dot { background: var(--accent); }
.tag-cambios                 { background: var(--warning-soft); color: #9A3412; border-color: #FED7AA; }
.tag-cambios .dot            { background: var(--warning); }
.tag-cierre-fabricacion      { background: var(--positive-soft); color: #166534; border-color: #BBF7D0; }
.tag-cierre-fabricacion .dot { background: var(--positive); }
.tag-certificacion           { background: var(--positive-soft); color: #166534; border-color: #BBF7D0; }
.tag-certificacion .dot      { background: var(--positive); }
.tag-caido                   { background: var(--negative-soft); color: #991B1B; border-color: #FECACA; }
.tag-caido .dot              { background: var(--negative); }

/* Mobile cards */
.projects-cards { display: none; list-style: none; padding: 0; margin: 0; }

@media (max-width: 768px) {
  .projects-table { display: none; }
  .table-wrap { background: transparent; border: none; padding: 0; box-shadow: none; }
  .projects-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--s-5);
  }
  .project-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: var(--s-6);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: var(--s-5);
    transition: border-color var(--t-fast) var(--ease);
  }
  .project-card:hover { border-color: var(--accent); }
  .project-card.is-lost { opacity: 0.55; }
  .project-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--s-5);
  }
  .project-card-id { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); }
  .project-card .name { font-size: 15px; font-weight: 600; color: var(--ink-1); margin-top: 2px; line-height: 1.3; }
  .project-card .sub { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); margin-top: 2px; }
  .project-card-kpis {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--s-4) var(--s-6);
    padding-top: var(--s-5);
    border-top: 1px solid var(--line-soft);
  }
  .project-card-kpis .k-label { font-size: 11px; color: var(--ink-3); }
  .project-card-kpis .k-val { font-family: var(--font-mono); font-size: 16px; font-variant-numeric: tabular-nums; margin-top: 2px; font-weight: 500; }
}

/* =========================================================
   Detail view
   ========================================================= */

.evolution { padding: var(--s-6) 0 var(--s-10); }

/* ---------- Phase stepper ---------- */

.phase-stepper-wrap {
  position: sticky;
  top: 48px;
  z-index: 20;
  background: var(--bg);
  padding: var(--s-5) 0 var(--s-6);
  border-bottom: 1px solid var(--line);
}

.phase-stepper {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 3px;
  box-shadow: var(--shadow-1);
}

.phase-step {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--s-5) var(--s-5);
  background: transparent;
  border: none;
  border-radius: var(--r-sm);
  text-align: left;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  min-width: 0;
  position: relative;
  color: var(--ink-2);
}
.phase-step:hover { background: var(--bg-dim); }
.phase-step.is-current {
  background: var(--accent);
  color: #FFFFFF;
}
.phase-step.is-current:hover { background: var(--accent-700); }

.step-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0;
  text-transform: none;
}
.step-row .step-num { font-weight: 600; color: var(--ink-2); }
.phase-step.is-current .step-row .step-num { color: rgba(255,255,255,0.9); }

.step-row .step-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px; height: 13px;
  border-radius: 50%;
  font-size: 8px;
  background: transparent;
  border: 1.5px solid var(--ink-4);
  color: var(--ink-3);
  line-height: 1;
}
.phase-step.is-done .step-state { background: var(--positive); border-color: var(--positive); color: #fff; }
.phase-step.is-active .step-state { background: var(--accent); border-color: var(--accent); color: #fff; }
.phase-step.is-current .step-state { background: #fff; border-color: #fff; color: var(--accent); }
.phase-step.is-pending .step-state { border-style: dashed; }
.phase-step.is-lost .step-state { background: var(--negative); border-color: var(--negative); color: #fff; }

.step-name {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: inherit;
}
.phase-step:not(.is-current) .step-name { color: var(--ink-1); }
.phase-step.is-pending .step-name { color: var(--ink-3); }

@media (max-width: 768px) {
  .phase-stepper { grid-template-columns: repeat(6, minmax(76px, 1fr)); overflow-x: auto; }
  .phase-step { padding: var(--s-4) var(--s-4); }
  .step-name { font-size: 11px; }
}

/* ---------- Sliding carousel ---------- */

.carousel-section { margin-top: var(--s-7); }

.carousel {
  /* viewport full-width: las flechas se superponen como overlay para que
     las cards laterales tengan más espacio para "continuar". */
  position: relative;
  display: block;
}

.carousel-viewport {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-md);
  padding: var(--s-3) 0;
  margin: calc(-1 * var(--s-3)) 0;
  /* Bordes laterales sfumados (Safari + Chrome + Firefox modernos): las cards
     laterales no se cortan en seco, se desvanecen hacia el borde. */
  -webkit-mask-image: linear-gradient(
    90deg,
    transparent 0%,
    rgba(0,0,0,0.4) 3%,
    #000 9%,
    #000 91%,
    rgba(0,0,0,0.4) 97%,
    transparent 100%
  );
  mask-image: linear-gradient(
    90deg,
    transparent 0%,
    rgba(0,0,0,0.4) 3%,
    #000 9%,
    #000 91%,
    rgba(0,0,0,0.4) 97%,
    transparent 100%
  );
}

.carousel-track {
  display: flex;
  gap: var(--s-6);
  transition: transform var(--t-slide) var(--ease);
  will-change: transform;
}

.carousel-track .slot {
  flex: 0 0 var(--card-w, 420px);
  min-width: 0;
  display: flex;
}

@media (max-width: 1100px) {
  .carousel-track .slot { flex-basis: 380px; }
}
@media (max-width: 768px) {
  .carousel-track .slot { flex-basis: calc(100vw - 32px); }
  .carousel-arrow { display: none; }
  .carousel-viewport {
    /* máscara más estrecha en mobile (sólo se ve 1 card) */
    -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 4%, #000 96%, transparent 100%);
    mask-image: linear-gradient(90deg, transparent 0%, #000 4%, #000 96%, transparent 100%);
  }
}

/* Flechas FIJAS al centro vertical del viewport del navegador.
   Siempre accesibles independientemente del scroll. */
.carousel-arrow {
  appearance: none;
  position: fixed;
  top: 50vh;
  transform: translateY(-50%);
  z-index: 50;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-2);
  width: 40px; height: 40px;
  border-radius: 50%;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease);
  font-weight: 600;
  box-shadow: var(--shadow-2);
}
/* Borde del .wrap (max 1280px). Las flechas viven justo al borde interior
   con un colchón de 12px para no pegarse al texto. */
.carousel-arrow-prev { left: max(16px, calc(50vw - 624px)); }
.carousel-arrow-next { right: max(16px, calc(50vw - 624px)); }
.carousel-arrow:hover:not(:disabled) {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  transform: translateY(-50%) scale(1.08);
  box-shadow: var(--shadow-3);
}
.carousel-arrow:disabled { opacity: 0.35; cursor: not-allowed; }

/* ---------- Carousel footer controls ---------- */

.carousel-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-6);
  margin-top: var(--s-7);
}
.ghost-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 5px 10px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--ink-2);
  transition: background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease);
  touch-action: manipulation;
}
.ghost-btn:hover:not(:disabled) {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.ghost-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.phase-counter {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  min-width: 100px;
  text-align: center;
}

.kbd-row {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--ink-3);
}
.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px; height: 18px;
  padding: 0 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-2);
  font-weight: 500;
}

/* =========================================================
   Phase card
   ========================================================= */

.phase-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s-7);
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
  width: 100%;
  cursor: pointer;
  text-align: left;
  transition: border-color var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease),
              opacity var(--t-fast) var(--ease);
  appearance: none;
  font-family: inherit;
  color: inherit;
  opacity: 0.55;
}
/* Fix 3: cursor + hover por aria-current (selector único, no por clase) */
.phase-card[aria-current="false"] { cursor: pointer; }
.phase-card[aria-current="false"]:hover {
  opacity: 0.95;
  border-color: var(--line-strong);
}
.phase-card[aria-current="true"],
.phase-card.is-current {
  opacity: 1;
  cursor: default;
  border-color: var(--accent);
  box-shadow: var(--shadow-3), 0 0 0 3px var(--accent-50);
}
/* Fix 2: el wrapper de la card NO cambia para estado "pendiente".
   Solo el body interno (.pending-state) recibe estilo distinto. */

.phase-card-head {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding-bottom: var(--s-5);
  border-bottom: 1px solid var(--line-soft);
}
.phase-card .phase-head-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-5);
}
.phase-head-top .eyebrow {
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0;
  text-transform: none;
  font-weight: 500;
}

.phase-current-badge {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: #fff;
  background: var(--accent);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.phase-card .phase-title {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 17px;
  line-height: 1.25;
  letter-spacing: -0.012em;
  margin: 0;
  color: var(--ink-1);
}
.phase-card.is-pending .phase-title { color: var(--ink-3); font-style: normal; }

.phase-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-5);
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}
.phase-meta .sep { color: var(--line-strong); }

/* Sections (vertical) */
.card-section {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  padding: var(--s-5) 0 var(--s-2);
  border-top: 1px solid var(--line-soft);
}
.card-section:first-of-type { border-top: none; padding-top: var(--s-3); }
.card-section-title {
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-3);
  margin-bottom: 2px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Headline stats — Margen / Beneficio in primo piano (vertical stack) */
.phase-headline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-5);
}
.headline-stat { display: flex; flex-direction: column; gap: 3px; }
.headline-stat .h-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-3);
}
.headline-stat .h-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 20px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink-1);
}
.headline-stat .h-value.pos   { color: var(--positive); }
.headline-stat .h-value.warn  { color: var(--warning); }
.headline-stat .h-value.neg   { color: var(--negative); }
.headline-stat .h-value.muted { color: var(--ink-4); }
@media (max-width: 540px) {
  .phase-headline { grid-template-columns: 1fr; }
}

/* Data rows */
.data-list { display: flex; flex-direction: column; }
.data-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s-5);
  align-items: center;
  padding: var(--s-4) 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12px;
  min-height: 28px;
}
.data-row:last-child { border-bottom: none; }
.data-row.is-strong { border-bottom-color: var(--line); }
.data-row .label {
  font-size: 11px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-2);
  font-weight: 400;
}
.data-row.is-strong .label { color: var(--ink-1); font-weight: 600; }
.data-row .value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink-1);
  font-size: 13px;
  text-align: right;
}
.data-row .value.zero { color: var(--ink-4); }

/* --- Totales: card-within-card para señalar "valores calculados" --- */
.totals-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s-4) var(--s-5) var(--s-3);
  margin-top: var(--s-3);
  position: relative;
}
.totals-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding-bottom: var(--s-3);
  margin-bottom: var(--s-2);
  border-bottom: 1px solid var(--line-soft);
}
.totals-card-head .card-section-title {
  /* la sección-title de la card ya tiene tipografía mono; aquí solo
     anulamos el margin-bottom default que viene de .card-section-title */
  margin: 0;
}
.totals-auto-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--ink-3);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px 2px 6px;
  line-height: 1;
  white-space: nowrap;
}
.totals-auto-badge svg {
  flex-shrink: 0;
  color: var(--ink-4);
}
/* Las filas dentro del totals-card pierden su borde inferior estándar
   en la última fila, para no chocar con el padding del contenedor. */
.totals-card .data-list:last-child .data-row:last-child { border-bottom: none; }
/* El divider entre intermedios y margenes (en lugar de doble border) */
.totals-card-divider {
  height: 1px;
  background: var(--line);
  margin: var(--s-3) calc(-1 * var(--s-5));
}

.phase-notes {
  font-style: normal;
  font-size: 12px;
  color: var(--ink-2);
  padding: var(--s-5);
  margin: var(--s-3) 0 0;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-sm);
  line-height: 1.5;
}

/* Pending state — Fix 2: solo dashed border en el body, no en el wrapper */
.pending-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--s-3);
  padding: var(--s-9) var(--s-5);
  color: var(--ink-3);
  border: 1.5px dashed var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.pending-glyph {
  font-style: normal;
  font-size: 28px;
  color: var(--ink-4);
  line-height: 1;
  font-weight: 300;
}
.pending-body .pending-text {
  font-style: normal;
  font-size: 13px;
  color: var(--ink-3);
  font-weight: 500;
}
.pending-body .pending-sub {
  font-size: 11px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-4);
}

/* =========================================================
   Edit mode — inputs replace values, save bar appears
   ========================================================= */

.phase-card.is-editing {
  cursor: default;
  border-color: var(--accent);
  box-shadow: var(--shadow-3), 0 0 0 3px var(--accent-50);
}

.edit-toolbar {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-1);
  transition: background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease);
  touch-action: manipulation;
  cursor: pointer;
  line-height: 1.4;
}
.btn:hover:not(:disabled) { background: var(--bg-dim); border-color: var(--line-strong); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-700); border-color: var(--accent-700); }
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-2);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-dim); color: var(--ink-1); }
.btn-icon {
  width: 14px; height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
}

/* Inputs in edit mode */
.input,
.input-num,
.input-text,
textarea.input {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--ink-1);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 4px 8px;
  width: 100%;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.input-num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  max-width: 140px;
}
.input::placeholder { color: var(--ink-4); }
.input:hover { border-color: var(--line-strong); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: var(--shadow-focus); }
textarea.input { min-height: 60px; resize: vertical; font-family: var(--font-sans); }

.data-row.is-editing { padding: var(--s-3) 0; }
.data-row.is-editing .value-edit {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  justify-self: end;
}
/* Etiqueta editable en partidas libres (3 filas: proveedor_libre_1/2/3) */
.data-row.is-free-provider .label-edit {
  display: block;
  min-width: 0;
  max-width: 220px;
}
.data-row.is-free-provider .input-label {
  font-family: var(--font-sans);
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-1);
  padding: 3px 7px;
  border-color: var(--line-soft);
  background: var(--surface);
  width: 100%;
  font-weight: 500;
}
.data-row.is-free-provider .input-label:hover { border-color: var(--line-strong); }
.data-row.is-free-provider .input-label:focus {
  border-color: var(--accent);
  background: var(--card);
}
.data-row.is-editing .value-edit .suffix {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
}

.meta-edit-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-4);
}
.meta-edit-row label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: var(--ink-3);
  font-weight: 500;
}

.edit-save-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-5);
  margin-top: var(--s-3);
  padding: var(--s-5);
  background: var(--accent-50);
  border: 1px solid var(--accent-100);
  border-radius: var(--r-sm);
}
.edit-save-bar .save-hint {
  font-size: 11px;
  color: var(--accent-700);
  font-weight: 500;
}
.edit-save-bar .save-actions {
  display: flex;
  gap: var(--s-3);
}

/* =========================================================
   Action: advance phase
   ========================================================= */

.phase-action {
  margin-top: var(--s-3);
  padding-top: var(--s-5);
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.phase-action .action-hint {
  font-size: 11px;
  color: var(--ink-3);
  font-weight: 500;
}
.btn-advance {
  appearance: none;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #FFFFFF;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-5);
  touch-action: manipulation;
}
.btn-advance:hover { background: var(--accent-700); border-color: var(--accent-700); }
.btn-advance .btn-icon { font-size: 14px; line-height: 1; }

/* =========================================================
   Toast
   ========================================================= */

.toast {
  position: fixed;
  left: 50%;
  bottom: var(--s-7);
  transform: translateX(-50%) translateY(6px);
  background: var(--ink-1);
  color: var(--surface);
  padding: 8px 12px;
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  box-shadow: var(--shadow-3);
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
  pointer-events: none;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent-500);
}

/* =========================================================
   States
   ========================================================= */

.view-state {
  padding: var(--s-11) 0;
  text-align: center;
}
.state-message {
  font-style: normal;
  font-size: 14px;
  color: var(--ink-2);
}
.state-message a { color: var(--accent); border-bottom: 1px solid var(--accent); }

/* =========================================================
   Modal (native <dialog>)
   ========================================================= */

.modal {
  padding: 0;
  border: none;
  background: transparent;
  max-width: none;
  max-height: none;
  width: 100%;
  height: 100%;
  margin: 0;
  inset: 0;
  color: var(--ink-1);
}
.modal::backdrop {
  background: rgba(24, 23, 27, 0.45);
  backdrop-filter: blur(2px);
}
.modal:not([open]) { display: none; }
.modal[open] {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 10vh var(--s-6) var(--s-6);
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: 0 24px 48px -12px rgba(24, 23, 27, 0.18), 0 12px 24px -8px rgba(24, 23, 27, 0.08);
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  max-height: 80vh;
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-6) var(--s-7);
  border-bottom: 1px solid var(--line-soft);
}
.modal-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--ink-1);
}
.modal-head .btn-ghost {
  width: 28px;
  height: 28px;
  padding: 0;
  justify-content: center;
  font-size: 16px;
  color: var(--ink-3);
}

.modal-body {
  padding: var(--s-7);
  display: flex;
  flex-direction: column;
  gap: var(--s-6);
  overflow-y: auto;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s-5);
  padding: var(--s-5) var(--s-7);
  border-top: 1px solid var(--line-soft);
  background: var(--surface-2);
}
.modal-actions {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
}
.modal-foot .form-help { color: var(--ink-3); font-size: 11px; }

/* Form primitives */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-5);
}
@media (max-width: 540px) {
  .form-row { grid-template-columns: 1fr; }
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.form-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
}
.form-req { color: var(--negative); font-weight: 600; }
.form-help { font-size: 11px; color: var(--ink-3); }

.form-fieldset {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s-5) var(--s-6) var(--s-6);
  margin: 0;
  background: var(--surface-2);
}
.form-legend {
  padding: 0 var(--s-3);
  margin-left: calc(-1 * var(--s-3));
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-3);
}

.form-error {
  margin: 0;
  font-size: 12px;
  color: var(--negative);
  min-height: 16px;
}
.form-error:empty { display: none; }

.form-field .value-edit {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: 100%;
}
.form-field .value-edit .input-num { max-width: none; flex: 1; }
.form-field .value-edit .suffix {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
}

/* =========================================================
   Iteration: KPI enrichment (no layout/palette/typography changes)
   ========================================================= */

/* Stat sublabel under the big number */
.stat-sub {
  order: 3;
  font-size: 11px;
  color: var(--ink-3);
  line-height: 1.2;
}
.stat[data-stat-card="cambios"].is-alert {
  border-color: var(--warning);
  box-shadow: inset 3px 0 0 var(--warning);
}
.stat[data-stat-card="cambios"].is-alert .stat-value { color: var(--warning); }

/* Tighten table padding slightly to fit the two extra columns without h-scroll */
.projects-table thead th { padding: var(--s-5) var(--s-5); }
.projects-table td       { padding: var(--s-5) var(--s-5); }
.col-margin, .col-benefit { width: 110px; }
.col-delta   { width: 110px; }
.col-changes { width: 80px;  }
.col-actions { width: 36px; text-align: center; padding-left: 0; padding-right: 4px; }

/* Bottone trash (eliminar proyecto) — appare solo sull'hover della riga */
.btn-row-delete {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-4);
  width: 26px; height: 26px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease);
}
.projects-table tbody tr:hover .btn-row-delete,
.projects-table tbody tr:focus-within .btn-row-delete { opacity: 1; }
.btn-row-delete:hover,
.btn-row-delete:focus-visible {
  color: var(--negative);
  background: var(--negative-soft);
  border-color: #FECACA;
  opacity: 1;
}

/* Su mobile il bottone è sempre visibile (no hover) */
@media (max-width: 768px) {
  .btn-row-delete--mobile {
    position: absolute;
    top: var(--s-4);
    right: var(--s-4);
    opacity: 0.5;
  }
  .project-card { position: relative; }
}

.delta-arrow {
  display: inline-block;
  margin-right: 3px;
  font-size: 9px;
  line-height: 1;
  position: relative;
  top: -1px;
}
.warn-icon {
  display: inline-block;
  margin-right: 4px;
  color: var(--warning);
  font-size: 11px;
}

@media (max-width: 1100px) {
  .col-margin, .col-benefit, .col-delta { width: auto; }
}

/* Mobile cards: extend KPI grid to 2x2 */
@media (max-width: 768px) {
  .project-card-kpis { grid-template-columns: 1fr 1fr; row-gap: var(--s-4); }
}

/* =========================================================
   Resumen del proyecto (header)
   ========================================================= */

.project-resumen {
  margin-top: var(--s-4);
  padding-top: var(--s-4);
  border-top: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  gap: var(--s-6);
  flex-wrap: wrap;
}
.resumen-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-3);
  white-space: nowrap;
}
.resumen-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, auto));
  gap: var(--s-5);
}
.resumen-kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.rk-label {
  font-size: 11px;
  color: var(--ink-3);
}
.rk-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-1);
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}
.rk-suffix {
  font-family: var(--font-sans);
  font-variant-numeric: normal;
  font-weight: 400;
  font-size: 11px;
  color: var(--ink-3);
}
@media (max-width: 768px) {
  .resumen-grid { grid-template-columns: 1fr; }
}

/* =========================================================
   KPI strip (inside phase cards) — replaces the Cabecera block
   ========================================================= */

.kpi-strip {
  display: grid;
  grid-template-columns: 1.2fr auto 1.2fr auto 1.4fr auto 1fr;
  align-items: stretch;
  gap: var(--s-5);
  padding: var(--s-5) 0 var(--s-4);
  border-top: none;
}
.kpi-strip:first-of-type { padding-top: var(--s-3); }

.kpi-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.kpi-label {
  font-size: 11px;
  color: var(--ink-3);
  font-weight: 500;
  line-height: 1.2;
}
.kpi-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 18px;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.015em;
  color: var(--ink-1);
}
.kpi-value.pos   { color: var(--positive); }
.kpi-value.warn  { color: var(--warning); }
.kpi-value.neg   { color: var(--negative); }
.kpi-value.muted { color: var(--ink-4); }
.kpi-value-sub {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.25;
  color: var(--ink-1);
}
.kpi-value-sub.pos   { color: var(--positive); }
.kpi-value-sub.warn  { color: var(--warning); }
.kpi-value-sub.neg   { color: var(--negative); }
.kpi-value-sub.muted { color: var(--ink-4); font-weight: 400; }

/* Primary blocks (Margen, Beneficio) bigger and bolder */
.kpi-block.is-primary .kpi-value { font-size: 22px; }
.kpi-block.is-primary .kpi-label { font-weight: 600; color: var(--ink-2); }

.kpi-divider {
  width: 1px;
  background: var(--line);
  align-self: stretch;
}

/* Compact strip on side cards (only 2 blocks + divider) */
.kpi-strip--compact {
  grid-template-columns: 1fr auto 1fr;
  padding: var(--s-4) 0 var(--s-3);
}
.kpi-strip--compact .kpi-value { font-size: 16px; }
.kpi-strip--compact .kpi-label { font-size: 10px; }

/* When delta has the "no-ref" state, hide its sub-grid feel and keep tidy */
.kpi-block--no-ref .kpi-value-sub { font-size: 12px; }

/* Wrap KPI strip on narrow desktop / mobile */
@media (max-width: 900px) {
  .kpi-strip {
    grid-template-columns: 1fr 1fr;
    row-gap: var(--s-4);
  }
  .kpi-strip .kpi-divider { display: none; }
}

/* =========================================================
   Changes panel — vive en el header del detalle (project-level)
   ========================================================= */

.changes-panel-host { margin-top: var(--s-4); }
.changes-panel-host[hidden] { display: none; }

.changes-panel {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s-4) var(--s-5);
}
/* Layout horizontal: head + KPIs + distribución en una sola fila si entra. */
.changes-panel {
  display: grid;
  grid-template-columns: minmax(120px, auto) auto 1fr;
  gap: var(--s-6);
  align-items: center;
}
.changes-panel-head {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.changes-panel-head .card-section-title {
  font-weight: 600;
  color: var(--ink-2);
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0;
}

.changes-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, auto);
  gap: var(--s-5);
  margin: 0;
}
.changes-mini-kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0;
}
.ck-label {
  font-size: 10px;
  color: var(--ink-3);
  font-weight: 500;
  white-space: nowrap;
}
.ck-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.015em;
  color: var(--ink-1);
}
.ck-value.pos  { color: var(--positive); }
.ck-value.warn { color: var(--warning); }
.ck-value.neg  { color: var(--negative); }
.ck-value.neu  { color: var(--ink-1); }
@media (max-width: 900px) {
  .changes-panel {
    grid-template-columns: 1fr;
    gap: var(--s-4);
  }
  .changes-distribution {
    border-left: none;
    border-top: 1px solid var(--line);
    padding-left: 0;
    padding-top: var(--s-3);
  }
}
@media (max-width: 540px) {
  .changes-kpi-row { grid-template-columns: 1fr 1fr; }
}

.changes-distribution {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: var(--s-5);
  border-left: 1px solid var(--line);
}
.dist-title {
  font-size: 10px;
  color: var(--ink-3);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}
.dist-list { display: flex; flex-direction: column; gap: 3px; }
.dist-row {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  align-items: center;
  gap: var(--s-3);
}
.dist-label {
  font-size: 11px;
  color: var(--ink-2);
}
.dist-bar-wrap {
  position: relative;
  height: 6px;
  background: var(--line-soft);
  border-radius: 3px;
  overflow: hidden;
}
.dist-bar {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: var(--accent);
  border-radius: 3px;
  transition: width var(--t-snappy, 180ms) var(--ease);
}
.dist-meta {
  display: inline-flex;
  align-items: baseline;
  gap: var(--s-3);
}
.dist-count {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-1);
  min-width: 16px;
  text-align: right;
}
.dist-amount {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--ink-3);
}

/* =========================================================
   Reduced motion
   ========================================================= */

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