/* Design tokens — minimalist, white, pastel accents */

@import url('https://fonts.googleapis.com/css2?family=Onest:wght@300;400;500;600;700&family=Playfair+Display:wght@500;600;700&display=swap');

:root {
  /* Type */
  --font: 'Onest', 'Aptos', ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-logo: 'Playfair Display', 'Bodoni Moda', 'Times New Roman', serif;

  /* Surfaces */
  --bg: #ffffff;
  --bg-soft: #fafafa;
  --surface: #ffffff;
  --surface-2: #f7f7f5;
  --border: #ececec;
  --border-strong: #d9d9d9;

  /* Ink */
  --ink: #18181a;
  --ink-2: #3a3a3d;
  --ink-muted: #777779;
  --ink-faint: #a5a5a7;
  --ink-disabled: #c8c8c9;

  /* Pastel accents — soft, evenly toned */
  --pastel-mint:   #DCEFE0;
  --pastel-sage:   #E5EDDC;
  --pastel-peach:  #FBE4D2;
  --pastel-coral:  #FCDDDC;
  --pastel-lilac:  #EDE5F6;
  --pastel-sky:    #DEE9F4;
  --pastel-cream:  #F6EFDC;
  --pastel-stone:  #EBE7DF;

  /* Pastel ink (text on its respective pastel surface) */
  --ink-mint:   #2d5a36;
  --ink-sage:   #475a32;
  --ink-peach:  #7a432a;
  --ink-coral:  #7a3a3a;
  --ink-lilac:  #4a3a73;
  --ink-sky:    #2c4d75;
  --ink-cream:  #6a5226;
  --ink-stone:  #4a4234;

  /* Semantic */
  --positive: #2d8c4f;
  --positive-soft: #DCEFE0;
  --negative: #b8413a;
  --negative-soft: #FCDDDC;
  --neutral: #6a6a6c;

  /* Brand (CORE) */
  --brand: #e23e57;
  --brand-ink: #b32f44;
  --brand-soft: #FCE1E5;
  --brand-tint: #FBEAED;

  /* Radius */
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;

  /* Shadows — very subtle */
  --sh-sm: 0 1px 2px rgba(20,20,20,0.04);
  --sh-md: 0 2px 8px rgba(20,20,20,0.05), 0 1px 2px rgba(20,20,20,0.03);
  --sh-lg: 0 10px 28px rgba(20,20,20,0.06), 0 2px 6px rgba(20,20,20,0.03);

  /* Layout */
  --header-h: 68px;
  --rail-w: 232px;
  --pad-page: 36px;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html, body, #root { margin: 0; padding: 0; min-height: 100vh; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
  font-size: 15px;
  line-height: 1.45;
}
button { font-family: inherit; cursor: pointer; border: 0; background: transparent; color: inherit; padding: 0; }
input, select, textarea { font-family: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--pastel-mint); color: var(--ink); }

/* Number tabular */
.num { font-variant-numeric: tabular-nums; }

/* Scrollbar */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; border: 2px solid var(--bg); }
*::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* App shell — left rail */
.app {
  display: grid;
  grid-template-rows: var(--header-h) 1fr;
  grid-template-columns: var(--rail-w) 1fr;
  grid-template-areas:
    "header header"
    "rail   main";
  min-height: 100vh;
}
.app-header {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky; top: 0; z-index: 10;
}
.app-main {
  grid-area: main;
  padding: 40px var(--pad-page) 80px;
  min-width: 0;
}
.app-rail {
  grid-area: rail;
  padding: 24px 16px 24px;
  border-right: 1px solid var(--border);
  background: var(--bg);
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* Header */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
.brand-img {
  height: 30px;
  width: auto;
  display: block;
}

/* Botón hamburguesa + menú desplegable (solo móvil) */
.header-left { display: flex; align-items: center; gap: 8px; }
.nav-toggle {
  display: none; /* visible solo en móvil */
  align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px;
  color: var(--ink-2);
  transition: background .12s;
}
.nav-toggle:hover { background: var(--surface-2); }
.nav-toggle .bar, .nav-toggle .bar::before, .nav-toggle .bar::after {
  content: ''; display: block;
  width: 18px; height: 2px; border-radius: 2px;
  background: currentColor;
}
.nav-toggle .bar { position: relative; }
.nav-toggle .bar::before { position: absolute; top: -6px; left: 0; }
.nav-toggle .bar::after  { position: absolute; top: 6px;  left: 0; }
.nav-backdrop { display: none; }

/* User chip top-right */
.user-chip {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 6px 14px 6px 6px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: default;
  transition: border-color .14s, background .14s;
}
.user-chip:hover { border-color: var(--border-strong); background: var(--surface-2); }
.user-chip .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--pastel-mint); color: var(--ink-mint);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 12px; letter-spacing: 0.02em;
}
.user-chip .name {
  font-size: 13.5px; font-weight: 500; color: var(--ink-2);
}

/* (1) Indicador de conexión offline */
.offline-pill {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 500;
  color: var(--ink-cream);
  background: var(--pastel-cream);
  padding: 6px 14px; border-radius: 999px;
}
.offline-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: currentColor;
  animation: offline-blink 1.4s ease-in-out infinite;
}
@keyframes offline-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.header-tools {
  display: flex; align-items: center; gap: 12px;
  color: var(--ink-muted);
  font-size: 13.5px;
}
.header-period {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
}
.header-period:hover { border-color: var(--border-strong); }
.header-period .chev { width: 10px; height: 10px; opacity: 0.5; }

/* Rail nav — left side, larger items with icons */
.nav {
  display: flex; flex-direction: column;
  gap: 4px;
}
.nav-section-label {
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 0 16px 12px;
  margin-top: 20px;
}
.nav-section-label:first-child { margin-top: 4px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  border-radius: 12px;
  color: var(--ink-2);
  font-size: 14.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  position: relative;
  width: 100%;
  text-align: left;
  transition: background .14s, color .14s, transform .08s;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item .nav-icon { display: inline-flex; color: var(--ink-faint); transition: color .14s; flex-shrink: 0; }
.nav-item:hover .nav-icon { color: var(--ink-2); }
.nav-item.active {
  background: var(--pastel-mint);
  color: var(--ink-mint);
}
.nav-item.active .nav-icon { color: var(--ink-mint); }
.nav-item.is-pastel-peach.active { background: var(--pastel-peach); color: var(--ink-peach); }
.nav-item.is-pastel-peach.active .nav-icon { color: var(--ink-peach); }
.nav-item.is-pastel-lilac.active { background: var(--pastel-lilac); color: var(--ink-lilac); }
.nav-item.is-pastel-lilac.active .nav-icon { color: var(--ink-lilac); }
.nav-item.is-pastel-sky.active { background: var(--pastel-sky); color: var(--ink-sky); }
.nav-item.is-pastel-sky.active .nav-icon { color: var(--ink-sky); }
.nav-item.is-pastel-cream.active { background: var(--pastel-cream); color: var(--ink-cream); }
.nav-item.is-pastel-cream.active .nav-icon { color: var(--ink-cream); }
.nav-item.is-pastel-coral.active { background: var(--pastel-coral); color: var(--ink-coral); }
.nav-item.is-pastel-coral.active .nav-icon { color: var(--ink-coral); }
.nav-item.is-pastel-sage.active { background: var(--pastel-sage); color: var(--ink-sage); }
.nav-item.is-pastel-sage.active .nav-icon { color: var(--ink-sage); }
.nav-item.is-pastel-stone.active { background: var(--pastel-stone); color: var(--ink-stone); }
.nav-item.is-pastel-stone.active .nav-icon { color: var(--ink-stone); }

/* Typography */
.page-title {
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin: 0 0 6px;
}
.page-subtitle {
  font-size: 14.5px;
  color: var(--ink-muted);
  margin: 0 0 32px;
  max-width: 56ch;
}
.section-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-faint);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0 0 14px;
}

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 20px;
  min-width: 0;
}
.card.pastel-mint   { background: var(--pastel-mint);   border-color: transparent; color: var(--ink-mint); }
.card.pastel-peach  { background: var(--pastel-peach);  border-color: transparent; color: var(--ink-peach); }
.card.pastel-lilac  { background: var(--pastel-lilac);  border-color: transparent; color: var(--ink-lilac); }
.card.pastel-sky    { background: var(--pastel-sky);    border-color: transparent; color: var(--ink-sky); }
.card.pastel-cream  { background: var(--pastel-cream);  border-color: transparent; color: var(--ink-cream); }
.card.pastel-coral  { background: var(--pastel-coral);  border-color: transparent; color: var(--ink-coral); }
.card.pastel-sage   { background: var(--pastel-sage);   border-color: transparent; color: var(--ink-sage); }
.card.pastel-stone  { background: var(--pastel-stone);  border-color: transparent; color: var(--ink-stone); }

/* Stat */
.stat-label {
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.7;
  margin-bottom: 12px;
}
.stat-value {
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  word-break: break-word;
}
.stat-value .currency {
  font-size: 0.55em;
  font-weight: 400;
  opacity: 0.55;
  margin-left: 4px;
}
.stat-delta {
  font-size: 12.5px;
  margin-top: 8px;
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  transition: background .12s, color .12s, border-color .12s, transform .08s;
  border: 1px solid transparent;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--ink);
  color: #fff;
}
.btn-primary:hover { background: #000; }
.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--ink-2);
}
.btn-ghost:hover { border-color: var(--ink-2); color: var(--ink); }
.btn-pastel-mint  { background: var(--pastel-mint);  color: var(--ink-mint); }
.btn-pastel-peach { background: var(--pastel-peach); color: var(--ink-peach); }

/* Inputs */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 500;
}
.input, .select, .textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  font-size: 14.5px;
  color: var(--ink);
  outline: none;
  transition: border-color .12s, background .12s;
  width: 100%;
  appearance: none;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--ink); background: var(--bg); }
.select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='none' stroke='%23777' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1 1l5 5 5-5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
}
.textarea { resize: vertical; min-height: 80px; line-height: 1.5; }

/* Segmented */
.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 4px;
  gap: 2px;
}
.segmented button {
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-muted);
  transition: background .12s, color .12s;
}
.segmented button.active {
  background: var(--bg);
  color: var(--ink);
  box-shadow: var(--sh-sm);
}

/* Table */
.t-list { width: 100%; border-collapse: collapse; }
.t-list th, .t-list td {
  text-align: left;
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.t-list th {
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding-top: 8px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border-strong);
}
.t-list td.num { text-align: right; }
.t-list tr:hover td { background: var(--surface-2); }

/* Tag (category chip) */
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--ink-2);
}
.tag .swatch { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-faint); }
.tag.is-mint   { background: var(--pastel-mint);   color: var(--ink-mint); }
.tag.is-mint .swatch   { background: var(--ink-mint); }
.tag.is-peach  { background: var(--pastel-peach);  color: var(--ink-peach); }
.tag.is-peach .swatch  { background: var(--ink-peach); }
.tag.is-lilac  { background: var(--pastel-lilac);  color: var(--ink-lilac); }
.tag.is-lilac .swatch  { background: var(--ink-lilac); }
.tag.is-sky    { background: var(--pastel-sky);    color: var(--ink-sky); }
.tag.is-sky .swatch    { background: var(--ink-sky); }
.tag.is-cream  { background: var(--pastel-cream);  color: var(--ink-cream); }
.tag.is-cream .swatch  { background: var(--ink-cream); }
.tag.is-coral  { background: var(--pastel-coral);  color: var(--ink-coral); }
.tag.is-coral .swatch  { background: var(--ink-coral); }
.tag.is-sage   { background: var(--pastel-sage);   color: var(--ink-sage); }
.tag.is-sage .swatch   { background: var(--ink-sage); }
.tag.is-stone  { background: var(--pastel-stone);  color: var(--ink-stone); }
.tag.is-stone .swatch  { background: var(--ink-stone); }

/* Progress */
.progress {
  height: 8px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}
.progress > div {
  height: 100%;
  background: var(--ink);
  border-radius: 999px;
  transition: width .4s cubic-bezier(.2,.7,.3,1);
}
.progress.is-mint  > div { background: #82bf94; }
.progress.is-peach > div { background: #e3a376; }
.progress.is-lilac > div { background: #a690cf; }
.progress.is-sky   > div { background: #7da4d3; }
.progress.is-cream > div { background: #ccaf6c; }
.progress.is-coral > div { background: #d68080; }
.progress.is-sage  > div { background: #9ab37c; }
.progress.is-stone > div { background: #a89b80; }
.progress.over > div { background: var(--negative); }

/* Grid helpers */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; gap: 16px; align-items: center; }
.col { display: flex; flex-direction: column; gap: 12px; }
.spacer { flex: 1; }

/* Misc */
.divider { height: 1px; background: var(--border); margin: 24px 0; }
.muted { color: var(--ink-muted); }
.faint { color: var(--ink-faint); }
.pos { color: var(--positive); }
.neg { color: var(--negative); }

/* Animations */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeUp .35s cubic-bezier(.2,.7,.3,1) forwards; }
@media (prefers-reduced-motion: reduce) {
  .fade-in { animation: none; opacity: 1; transform: none; }
}

/* Focus */
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(20,20,22,0.32);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fadeUp .18s ease both;
}
.modal {
  background: var(--bg);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow: hidden;
  display: flex; flex-direction: column;
  animation: fadeUp .22s cubic-bezier(.2,.7,.3,1) both;
}
.modal.wide { max-width: 920px; }
.modal.xwide { max-width: 1040px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 26px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 19px; font-weight: 500; letter-spacing: -0.02em; }
.modal-close {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-muted);
  transition: background .12s, color .12s;
}
.modal-close:hover { background: var(--surface-2); color: var(--ink); }
.modal-body {
  padding: 22px 26px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 16px 26px;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px; align-items: center; justify-content: flex-end;
}
.modal-footer.split { justify-content: space-between; }

/* Switch toggle */
.switch {
  display: inline-flex; align-items: center;
  width: 38px; height: 22px;
  border-radius: 999px;
  background: var(--border-strong);
  padding: 2px;
  cursor: pointer;
  transition: background .14s;
  flex-shrink: 0;
}
.switch::after {
  content: '';
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
  transition: transform .16s cubic-bezier(.4,.2,.3,1);
}
.switch.on { background: var(--ink-mint); }
.switch.on::after { transform: translateX(16px); }

/* Color swatch picker */
.swatch-row { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch-btn {
  width: 34px; height: 34px;
  border-radius: 10px;
  border: 2px solid transparent;
  transition: transform .1s, border-color .14s;
  cursor: pointer;
}
.swatch-btn:hover { transform: scale(1.05); }
.swatch-btn.selected { border-color: var(--ink); }
.swatch-mint  { background: var(--pastel-mint); }
.swatch-peach { background: var(--pastel-peach); }
.swatch-lilac { background: var(--pastel-lilac); }
.swatch-sky   { background: var(--pastel-sky); }
.swatch-cream { background: var(--pastel-cream); }
.swatch-coral { background: var(--pastel-coral); }
.swatch-sage  { background: var(--pastel-sage); }
.swatch-stone { background: var(--pastel-stone); }

/* Sub category chip (no color, just title) */
.sub-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--ink-2);
  font-weight: 500;
}
.sub-chip .x {
  display: inline-flex; padding: 2px; margin-right: -4px;
  border-radius: 50%;
  color: var(--ink-faint);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.sub-chip .x:hover { background: var(--surface-2); color: var(--ink); }

/* File drop */
.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-md);
  padding: 36px 24px;
  text-align: center;
  color: var(--ink-muted);
  background: var(--surface-2);
  transition: border-color .14s, background .14s;
  cursor: pointer;
}
.dropzone:hover, .dropzone.is-over {
  border-color: var(--ink-mint);
  background: var(--pastel-mint);
  color: var(--ink-mint);
}

/* Period picker */
.period-picker {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  font-size: 13px; font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color .14s, background .14s;
}
.period-picker:hover { border-color: var(--border-strong); background: var(--surface-2); }
.period-picker .chev { color: var(--ink-faint); }

.period-pop {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--sh-lg);
  padding: 8px;
  min-width: 240px;
  z-index: 50;
}
.period-pop-section {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  padding: 8px 12px 6px;
  font-weight: 500;
}
.period-pop button {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-2);
  text-align: left;
  transition: background .12s;
}
.period-pop button:hover { background: var(--surface-2); color: var(--ink); }
.period-pop button.selected { background: var(--pastel-mint); color: var(--ink-mint); }
.period-pop button.selected .check { color: var(--ink-mint); }
.period-pop .sep { height: 1px; background: var(--border); margin: 6px 4px; }

/* Logout */
.app-rail-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.btn-logout {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  color: var(--negative);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  background: transparent;
  transition: background .14s;
}
.btn-logout:hover { background: var(--negative-soft); }
.btn-logout .nav-icon { color: var(--negative); }

/* Login screen */
.login-shell {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, var(--brand-soft) 0%, var(--brand-tint) 32%, var(--bg) 64%);
  padding: 40px 24px;
}
.login-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 44px 40px;
  width: 100%; max-width: 420px;
  box-shadow: var(--sh-lg);
}
.login-logo-img {
  display: block;
  width: 210px;
  height: auto;
  margin: 0 auto 16px;
}
.login-tag {
  text-align: center;
  color: var(--ink-muted);
  font-size: 13px;
  letter-spacing: 0.02em;
  margin-bottom: 32px;
}
.login-switch {
  text-align: center;
  font-size: 13px;
  color: var(--ink-muted);
  margin-top: 4px;
}
.login-switch button {
  color: var(--brand-ink);
  font-weight: 500;
  font-size: 13px;
}
.login-switch button:hover { text-decoration: underline; }
.login-hint {
  font-size: 12px; color: var(--ink-faint);
  text-align: center; margin-top: 24px;
}
.login-hint strong { color: var(--ink-2); font-weight: 500; }

/* Ocultar valores — difumina todas las cifras */
.values-hidden .num {
  filter: blur(7px);
  -webkit-filter: blur(7px);
  user-select: none;
}
/* En la tabla de Control las celdas numéricas no llevan .num: todas las
   columnas salvo la primera (concepto) son cifras, así que las difuminamos. */
.values-hidden .ctrl-table tbody td:not(:first-child) {
  filter: blur(7px);
  -webkit-filter: blur(7px);
  user-select: none;
}

/* Control table */
.ctrl-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: auto;
  background: var(--bg);
}
.ctrl-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.ctrl-table th, .ctrl-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-align: right;
}
.ctrl-table th:first-child, .ctrl-table td:first-child {
  text-align: left;
  position: sticky; left: 0;
  background: var(--bg);
  z-index: 2;
  min-width: 220px;
  border-right: 1px solid var(--border);
}
.ctrl-table thead th {
  position: sticky; top: 0;
  background: var(--bg);
  z-index: 3;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 12px;
}
.ctrl-table thead th:first-child { z-index: 4; }
.ctrl-table .group-head td {
  padding: 18px 12px 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--border-strong);
  font-size: 11.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
}
.ctrl-table .group-head td:first-child { background: var(--bg); }
.ctrl-table .cat-row td:first-child { font-weight: 500; }
.ctrl-table .cat-row .toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 4px;
  color: var(--ink-faint);
  margin-right: 6px;
  transition: background .12s, color .12s, transform .12s;
}
.ctrl-table .cat-row .toggle:hover { background: var(--surface-2); color: var(--ink-2); }
.ctrl-table .cat-row .toggle.open { transform: rotate(90deg); }
.ctrl-table .sub-row td { font-size: 12.5px; color: var(--ink-muted); padding-top: 6px; padding-bottom: 6px; }
.ctrl-table .sub-row td:first-child { padding-left: 50px; color: var(--ink-2); }
.ctrl-table .total-row td {
  background: var(--surface-2);
  font-weight: 500;
  color: var(--ink);
  border-bottom: 1px solid var(--border-strong);
}
.ctrl-table .total-row td:first-child { background: var(--surface-2); }
.ctrl-table .net-row td {
  background: var(--pastel-sage);
  color: var(--ink-sage);
  font-weight: 500;
  font-size: 13.5px;
  padding-top: 12px; padding-bottom: 12px;
  border-bottom: none;
}
.ctrl-table .net-row td:first-child { background: var(--pastel-sage); color: var(--ink-sage); }
.ctrl-table tbody tr:hover td { background: var(--surface-2); }
.ctrl-table tbody tr.net-row:hover td { background: var(--pastel-sage); }
.ctrl-table tbody tr.group-head:hover td { background: var(--bg); }
.ctrl-table .col-total { font-weight: 500; color: var(--ink); border-left: 1px solid var(--border-strong); }
.ctrl-table .col-budget { color: var(--ink-muted); border-left: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.ctrl-table .col-dev { color: var(--ink-muted); border-left: 1px solid var(--border); }
.ctrl-table .col-dev.pos { color: var(--positive); }
.ctrl-table .col-dev.neg { color: var(--negative); }
.ctrl-table .zero { color: var(--ink-faint); }

/* Role chip */
.role-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 500;
  letter-spacing: 0.04em;
}
.role-administrador { background: var(--pastel-mint); color: var(--ink-mint); }
.role-controlador   { background: var(--pastel-sky);  color: var(--ink-sky); }
.role-visualizador  { background: var(--pastel-stone); color: var(--ink-stone); }

/* Chart (SVG) */
.chart-svg { width: 100%; height: 100%; display: block; }
.chart-grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 2 3; }
.chart-axis { stroke: var(--border-strong); stroke-width: 1; }
.chart-axis-label { font-family: var(--font); font-size: 10.5px; fill: var(--ink-faint); font-variant-numeric: tabular-nums; }
.chart-line { fill: none; stroke: var(--ink-mint); stroke-width: 2.4; }
.chart-area { fill: var(--pastel-mint); opacity: 0.35; }
.chart-dot { fill: var(--ink-mint); }
.chart-line.contracted { stroke: var(--ink-coral); stroke-dasharray: 7 5; stroke-width: 2; }
.chart-line.projected  { stroke: var(--ink-sky); stroke-dasharray: 1 6; stroke-linecap: round; stroke-width: 3; }

/* Matrícula */
.plate {
  font-family: var(--font-mono, ui-monospace, 'SFMono-Regular', Menlo, monospace);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  padding: 4px 10px;
  white-space: nowrap;
}

/* Clickable row */
.row-click {
  cursor: pointer;
  transition: background .12s;
}
.row-click:hover { background: var(--surface-2); }

/* Bien card (gestor de bienes) */
.bien-card {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  transition: border-color .12s, background .12s, transform .08s;
}
.bien-card:hover { border-color: var(--border-strong); background: var(--surface-2); }
.bien-card:active { transform: translateY(1px); }

/* Inline date range */
.range-pair { display: flex; align-items: center; gap: 6px; }
.range-pair span { color: var(--ink-faint); font-size: 12px; }

/* Stat — small */
.stat-mini {
  padding: 14px 16px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.stat-mini .stat-label { margin-bottom: 6px; opacity: 0.8; }
.stat-mini .stat-value { font-size: 22px; }

/* ───────────────── Responsive ───────────────── */

/* Tablet: rejillas anchas a 2 columnas, menos padding */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  :root { --pad-page: 28px; }
}

/* Móvil: barra inferior, una sola columna, modales a pantalla completa */
@media (max-width: 768px) {
  /* Shell: solo header + main; el rail pasa a barra inferior fija */
  .app {
    grid-template-columns: 1fr;
    grid-template-areas: "header" "main";
  }
  .app-header { padding: 0 16px; gap: 10px; }
  .brand-img { height: 26px; }
  .nav-toggle { display: flex; }
  .app-main { padding: 22px 16px 48px; }

  /* Menú desplegable desde la cabecera */
  .app-rail {
    position: fixed; top: var(--header-h); left: 0; right: 0; bottom: auto;
    width: 100%; height: auto;
    max-height: calc(100vh - var(--header-h));
    flex-direction: column; gap: 4px;
    padding: 12px 12px calc(16px + env(safe-area-inset-bottom, 0px));
    border-right: 0;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    overflow-y: auto;
    box-shadow: var(--sh-lg);
    z-index: 45;
    transform: translateY(-10px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .16s ease, transform .16s ease;
  }
  .app-rail.open { transform: translateY(0); opacity: 1; pointer-events: auto; }
  .nav { flex-direction: column; gap: 4px; }
  .nav-section-label { display: none; }
  .nav-item { padding: 12px 16px; }
  .app-rail-footer { margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--border); display: block; }

  /* Fondo para cerrar el menú al tocar fuera */
  .nav-backdrop {
    display: block; position: fixed;
    inset: var(--header-h) 0 0 0;
    background: rgba(20,20,22,0.25);
    z-index: 44;
  }

  /* Todas las rejillas a una columna (vence a los estilos inline) */
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr !important; }
  .modal .grid { grid-template-columns: 1fr !important; }

  /* Tipografía un punto más compacta */
  .page-title { font-size: 24px; }
  .page-subtitle { margin-bottom: 22px; font-size: 13.5px; }
  .stat-value { font-size: 22px; }

  /* Modales a pantalla completa */
  .modal-backdrop { padding: 0; align-items: stretch; }
  .modal, .modal.wide, .modal.xwide {
    max-width: 100%; width: 100%;
    max-height: 100%; height: 100%;
    border-radius: 0;
  }
  .modal-header { padding: 16px; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px; flex-wrap: wrap; }

  /* Popovers de periodo no se salen de la pantalla */
  .period-pop { max-width: calc(100vw - 24px); }
  .header-period { font-size: 12px; }
}

/* Móvil estrecho: oculta el nombre del usuario y el aviso largo de offline */
@media (max-width: 480px) {
  .user-chip .name { display: none; }
  .offline-pill { display: none; }
}

/* Spinner de carga */
.spinner {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--brand-ink);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Estado de base vacía */
.empty-db {
  min-height: 60vh;
  display: flex; align-items: center; justify-content: center;
  padding: 48px 24px;
}
.empty-db-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--sh-md);
  padding: 40px 44px;
  max-width: 560px;
  text-align: center;
  display: flex; flex-direction: column; align-items: center;
}
