/* ============================================================
   LIBRO MAYOR — Aplicación Autónomo ES
   Estética: editorial financiera mediterránea
   ============================================================ */

:root {
  /* Paleta cálida editorial */
  --bg-base:        #F1EBE0;
  --bg-paper:       #FBF7EE;
  --bg-card:        #FFFCF5;
  --bg-elevated:    #F7F1E5;
  --ink:            #1A1815;
  --ink-soft:       #3A342C;
  --ink-mute:       #6B6356;
  --ink-faint:      #9A9180;
  --line:           #DDD3BE;
  --line-soft:      #E8E0CC;

  --accent:         #B8442C;          /* terracota */
  --accent-deep:    #8B2F1F;
  --accent-soft:    #E8B5A4;
  --forest:         #2D4F3C;          /* verde bosque */
  --forest-soft:    #A8C1A8;
  --gold:           #B8860B;
  --gold-soft:      #E5C76B;
  --plum:           #5B3A5A;
  --ocean:          #2C4F6B;

  --success:        #2D5F3F;
  --warning:        #B8860B;
  --danger:         #8B2B2B;

  /* Tipografía */
  --font-display:   'Fraunces', 'Times New Roman', serif;
  --font-body:      'Inter Tight', system-ui, sans-serif;
  --font-mono:      'JetBrains Mono', ui-monospace, monospace;

  /* Espacios */
  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 14px;
  --r-xl: 22px;

  --shadow-sm: 0 1px 2px rgba(26,24,21,0.06);
  --shadow-md: 0 4px 16px -4px rgba(26,24,21,0.1), 0 2px 4px rgba(26,24,21,0.04);
  --shadow-lg: 0 18px 40px -12px rgba(26,24,21,0.18), 0 4px 12px rgba(26,24,21,0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg-base);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Textura de grano sutil */
.ambient-grain {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.1 0 0 0 0 0.08 0 0 0 0 0.06 0 0 0 0.18 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }

/* ============================================================
   APP SHELL
   ============================================================ */
.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  background: linear-gradient(180deg, #2A2520 0%, #1F1B17 100%);
  color: #E8DFCD;
  padding: 28px 22px 24px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #1A1612;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 36px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(232,223,205,0.12);
}
.brand-mark {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  color: var(--gold-soft);
}
.brand-mark svg { width: 100%; height: 100%; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 21px;
  letter-spacing: 0.01em;
  color: #FBF7EE;
}
.brand-sub {
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(232,223,205,0.55);
  margin-top: 2px;
}

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 11px 14px;
  border-radius: var(--r-md);
  color: rgba(232,223,205,0.7);
  text-decoration: none;
  font-size: 14.5px;
  letter-spacing: 0.01em;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  position: relative;
}
.nav-item:hover {
  color: #FBF7EE;
  background: rgba(232,223,205,0.05);
}
.nav-item.active {
  color: var(--gold-soft);
  background: rgba(184,134,11,0.08);
}
.nav-item.active::before {
  content: ''; position: absolute;
  left: -22px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px;
  background: var(--gold-soft);
  border-radius: 0 2px 2px 0;
}
.nav-num {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: rgba(232,223,205,0.4);
  letter-spacing: 0.05em;
}
.nav-item.active .nav-num { color: var(--gold-soft); opacity: 0.7; }

.sidebar-footer {
  margin-top: 16px;
  padding-top: 18px;
  border-top: 1px solid rgba(232,223,205,0.12);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.year-pill {
  display: flex; flex-direction: column;
  background: rgba(232,223,205,0.05);
  border: 1px solid rgba(232,223,205,0.1);
  border-radius: var(--r-md);
  padding: 8px 12px;
  margin-bottom: 4px;
}
.year-label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: rgba(232,223,205,0.55);
}
.year-select {
  background: transparent;
  border: none;
  color: var(--gold-soft);
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 500;
  padding: 0;
  margin-top: 2px;
  outline: none;
  cursor: pointer;
}
.year-select option { color: var(--ink); }

.ghost-btn {
  background: transparent;
  border: 1px solid rgba(232,223,205,0.18);
  color: rgba(232,223,205,0.75);
  padding: 8px 12px;
  border-radius: var(--r-md);
  font-size: 12.5px;
  letter-spacing: 0.02em;
  text-align: left;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.ghost-btn:hover {
  background: rgba(232,223,205,0.06);
  color: #FBF7EE;
  border-color: rgba(232,223,205,0.3);
}

/* ============================================================
   MAIN
   ============================================================ */
.main {
  background: var(--bg-base);
  min-height: 100vh;
  overflow-x: hidden;
}
.view-container {
  padding: 36px 48px 80px;
  max-width: 1400px;
  animation: fadeIn 0.35s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   TÍTULOS / HEADER DE VISTA
   ============================================================ */
.view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 32px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
  gap: 24px;
}
.view-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-mute);
  margin-bottom: 8px;
}
.view-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 44px;
  line-height: 1;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--ink);
}
.view-title em {
  font-style: italic;
  color: var(--accent);
  font-weight: 300;
}
.view-sub {
  font-size: 14px;
  color: var(--ink-mute);
  margin-top: 8px;
  max-width: 60ch;
}
.view-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ============================================================
   BOTONES
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  transition: background 0.18s, color 0.18s, border-color 0.18s, box-shadow 0.18s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--ink);
  color: var(--bg-paper);
  border-color: var(--ink);
}
.btn-primary:hover { background: var(--accent); border-color: var(--accent); }

.btn-accent {
  background: var(--accent);
  color: var(--bg-paper);
  border-color: var(--accent);
}
.btn-accent:hover { background: var(--accent-deep); border-color: var(--accent-deep); }

.btn-outline {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.btn-outline:hover {
  background: var(--bg-card);
  border-color: var(--ink);
}

.btn-soft {
  background: var(--bg-elevated);
  color: var(--ink-soft);
  border-color: var(--line-soft);
}
.btn-soft:hover { background: var(--bg-card); border-color: var(--line); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: rgba(139,43,43,0.3);
}
.btn-danger:hover { background: rgba(139,43,43,0.08); }

.btn-sm { padding: 6px 12px; font-size: 12.5px; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.card-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 22px;
  letter-spacing: -0.01em;
  margin: 0 0 16px;
}
.card-eyebrow {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 6px;
}

/* ============================================================
   GRID DE KPI / DASHBOARD
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.kpi {
  background: var(--bg-card);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: 22px 22px 20px;
  position: relative;
  overflow: hidden;
  transition: background 0.25s, color 0.25s, border-color 0.25s, box-shadow 0.25s;
}
.kpi:hover {
  border-color: var(--line);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.kpi::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 3px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--gold) 100%);
  opacity: 0;
  transition: opacity 0.2s;
}
.kpi:hover::before { opacity: 1; }
.kpi.kpi-accent::before { opacity: 1; background: var(--accent); }
.kpi.kpi-forest::before { opacity: 1; background: var(--forest); }
.kpi.kpi-gold::before { opacity: 1; background: var(--gold); }
.kpi.kpi-ocean::before { opacity: 1; background: var(--ocean); }

.kpi-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 14px;
}
.kpi-value {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: var(--ink);
}
.kpi-value .currency {
  font-size: 18px;
  color: var(--ink-mute);
  margin-right: 4px;
  font-weight: 300;
}
.kpi-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-mute);
}
.kpi-delta { font-weight: 500; }
.kpi-delta.up   { color: var(--success); }
.kpi-delta.down { color: var(--danger); }

/* ============================================================
   GRID DE PANELES
   ============================================================ */
.panel-grid {
  display: grid;
  gap: 18px;
}
.panel-grid.two-cols { grid-template-columns: 2fr 1fr; }
.panel-grid.three-cols { grid-template-columns: repeat(3, 1fr); }
.panel-grid + .panel-grid { margin-top: 18px; }

.panel {
  background: var(--bg-card);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: 24px 26px;
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-soft);
  gap: 12px;
}
.panel-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 22px;
  letter-spacing: -0.01em;
  margin: 0;
}
.panel-title em { color: var(--accent); font-style: italic; }
.panel-actions { display: flex; gap: 8px; align-items: center; }

/* ============================================================
   TABLAS
   ============================================================ */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--r-md);
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.data thead th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-mute);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-weight: 500;
  background: var(--bg-elevated);
}
table.data tbody td {
  padding: 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--bg-elevated); }
table.data tbody td.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }
table.data tbody td.actions { text-align: right; white-space: nowrap; }
table.data tbody td.actions button { margin-left: 4px; }

/* ============================================================
   BADGES / TAGS
   ============================================================ */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
  background: var(--bg-elevated);
  color: var(--ink-soft);
  border: 1px solid var(--line-soft);
}
.badge.badge-success { background: rgba(45,95,63,0.1); color: var(--success); border-color: rgba(45,95,63,0.25); }
.badge.badge-warning { background: rgba(184,134,11,0.12); color: var(--gold); border-color: rgba(184,134,11,0.3); }
.badge.badge-danger  { background: rgba(139,43,43,0.1); color: var(--danger); border-color: rgba(139,43,43,0.25); }
.badge.badge-accent  { background: rgba(184,68,44,0.1); color: var(--accent); border-color: rgba(184,68,44,0.25); }
.badge.badge-ocean   { background: rgba(44,79,107,0.1); color: var(--ocean); border-color: rgba(44,79,107,0.25); }

/* ============================================================
   FORMULARIOS
   ============================================================ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px 18px;
}
.form-grid.three-col { grid-template-columns: repeat(3, 1fr); }
.form-grid .full { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-mute);
}
.form-group input,
.form-group select,
.form-group textarea {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg-paper);
  font-size: 14px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--ink);
  background: var(--bg-card);
}
.form-group textarea { resize: vertical; min-height: 80px; font-family: inherit; }
.form-help { font-size: 11.5px; color: var(--ink-faint); }

/* ============================================================
   PROGRESS BARS / IRPF TRAMOS
   ============================================================ */
.bracket-bar {
  position: relative;
  height: 56px;
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--line-soft);
}
.bracket-segment {
  position: absolute;
  top: 0; bottom: 0;
  border-right: 1px solid rgba(255,255,255,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: rgba(0,0,0,0.55);
  transition: background 0.3s, color 0.3s, border-color 0.3s, opacity 0.3s;
}
.bracket-segment.active { color: white; font-weight: 600; }
.bracket-marker {
  position: absolute;
  top: -8px; bottom: -8px;
  width: 2px;
  background: var(--ink);
  z-index: 2;
  transition: left 0.6s cubic-bezier(0.2,0.8,0.2,1);
}
.bracket-marker::before {
  content: '';
  position: absolute; top: -5px; left: -4px;
  width: 10px; height: 10px;
  background: var(--ink);
  border-radius: 50%;
}
.bracket-marker::after {
  content: attr(data-label);
  position: absolute; bottom: -22px;
  left: 50%; transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}

.bracket-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bracket-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 14px;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: var(--bg-elevated);
  border: 1px solid transparent;
  transition: background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.bracket-row.active {
  border-color: var(--accent);
  background: rgba(184,68,44,0.05);
}
.bracket-row .swatch {
  width: 12px; height: 12px;
  border-radius: 3px;
}
.bracket-row .range {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-soft);
}
.bracket-row .rate {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 500;
  color: var(--ink);
}
.bracket-row .amount {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(26,24,21,0.55);
  backdrop-filter: blur(4px);
  display: none;
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; animation: fadeIn 0.18s; }
.modal {
  background: var(--bg-paper);
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
  animation: modalIn 0.25s cubic-bezier(0.2,0.8,0.2,1);
}
.modal.modal-lg { max-width: 1000px; }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  padding: 22px 28px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 26px;
  letter-spacing: -0.01em;
  margin: 0;
}
.modal-close {
  width: 32px; height: 32px;
  font-size: 24px;
  color: var(--ink-mute);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.modal-close:hover {
  background: var(--bg-elevated);
  color: var(--ink);
}
.modal-body {
  padding: 24px 28px 28px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}
.modal-body img, .modal-body canvas, .modal-body video {
  max-width: 100%;
  height: auto;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 22px;
  margin-top: 22px;
  border-top: 1px solid var(--line-soft);
}

/* ============================================================
   TOAST
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
}
.toast {
  background: var(--ink);
  color: var(--bg-paper);
  padding: 12px 18px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.25s ease, toastOut 0.3s ease 3.7s forwards;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 360px;
}
.toast.success { background: var(--forest); }
.toast.error   { background: var(--accent-deep); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateX(20px); }
}

/* ============================================================
   ESTADOS VACÍOS
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--ink-mute);
}
.empty-state .empty-icon {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 56px;
  color: var(--ink-faint);
  margin-bottom: 12px;
  font-weight: 300;
}
.empty-state .empty-title {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--ink);
  margin-bottom: 6px;
}

/* ============================================================
   GRÁFICOS
   ============================================================ */
.chart-wrap {
  position: relative;
  height: 280px;
  width: 100%;
}
.chart-wrap.tall { height: 360px; }

/* ============================================================
   FACTURA - PREVIEW
   ============================================================ */
.invoice-preview {
  background: white;
  color: #1a1a1a;
  padding: 48px 56px;
  font-family: var(--font-body);
  font-size: 12px;
  line-height: 1.55;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  max-width: 700px;
  margin: 0 auto;
}
.invoice-preview h1 {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 36px;
  margin: 0 0 4px;
  letter-spacing: -0.02em;
}
.invoice-preview .label {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: #777;
}
.invoice-preview table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
}
.invoice-preview table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #555;
  padding: 8px 0;
  border-bottom: 1px solid #1a1a1a;
}
.invoice-preview table td { padding: 10px 0; border-bottom: 1px solid #eee; }
.invoice-preview .totals { margin-top: 16px; font-family: var(--font-mono); }
.invoice-preview .totals .row {
  display: flex; justify-content: space-between;
  padding: 4px 0;
}
.invoice-preview .totals .row.total {
  font-family: var(--font-display);
  font-size: 20px;
  border-top: 2px solid #1a1a1a;
  margin-top: 8px;
  padding-top: 10px;
  font-weight: 500;
}

/* ============================================================
   CHIPS / FILTERS
   ============================================================ */
.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.chip {
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  font-size: 12.5px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.chip:hover { border-color: var(--line); }
.chip.active {
  background: var(--ink);
  color: var(--bg-paper);
  border-color: var(--ink);
}

/* Search bar inline */
.inline-search {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: 0 0 0 12px;
}
.inline-search input {
  border: none;
  background: transparent;
  padding: 8px 4px 8px 8px;
  outline: none;
  font-size: 13px;
  width: 200px;
}
.inline-search-icon { color: var(--ink-faint); font-size: 13px; }

/* Stats inline */
.stat-line {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line-soft);
  font-size: 13px;
}
.stat-line:last-child { border-bottom: none; }
.stat-line .lbl { color: var(--ink-mute); }
.stat-line .val { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Pull-quote in dashboard */
.pullquote {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 300;
  font-size: 22px;
  line-height: 1.35;
  color: var(--ink-soft);
  border-left: 3px solid var(--accent);
  padding: 4px 0 4px 18px;
  margin: 8px 0;
  letter-spacing: -0.005em;
}
.pullquote .em { color: var(--accent); font-style: normal; font-weight: 500; }

/* Skeleton / loading */
.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 0%, var(--bg-card) 50%, var(--bg-elevated) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r-md);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Item row inventory/expense */
.list-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
  transition: background 0.15s;
}
.list-item:hover { background: var(--bg-elevated); }
.list-item:last-child { border-bottom: none; }
.list-item .li-title { font-weight: 500; color: var(--ink); }
.list-item .li-meta { font-size: 12px; color: var(--ink-mute); margin-top: 2px; }

/* Quarterly summary widget */
.quarter-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.quarter {
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: 14px;
  position: relative;
}
.quarter.active {
  background: var(--bg-card);
  border-color: var(--accent);
}
.quarter-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-mute);
  margin-bottom: 4px;
}
.quarter-period {
  font-size: 11px;
  color: var(--ink-faint);
  margin-bottom: 10px;
}
.quarter-value {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.quarter-detail {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-mute);
  margin-top: 4px;
}

/* responsive base */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .panel-grid.two-cols, .panel-grid.three-cols { grid-template-columns: 1fr; }
  .quarter-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .view-container { padding: 24px 20px 60px; }
  .view-title { font-size: 32px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid.three-col { grid-template-columns: 1fr; }
}

/* ============================================================
   COMPLEMENTOS — settings, taxes, dashboard
   ============================================================ */
.form-grid.two-cols { grid-template-columns: repeat(2, 1fr); }
.form-grid .span-2 { grid-column: 1 / -1; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field .lbl {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-mute);
}
.field input,
.field select,
.field textarea {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg-paper);
  font-size: 14px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--ink);
  background: var(--bg-card);
}
.field textarea { resize: vertical; min-height: 70px; font-family: inherit; }

.hint {
  font-size: 11.5px;
  color: var(--ink-faint);
  margin-top: 4px;
  font-style: italic;
}

.row-active {
  background: rgba(184,68,44,0.04);
}
.row-active td:first-child {
  border-left: 3px solid var(--accent);
}

.templates-list { margin-top: 6px; }

@media (max-width: 720px) {
  .form-grid.two-cols { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
}

/* ============================================================
   INPUTS NUMÉRICOS — quitar flechas y mejorar UX táctil
   ============================================================ */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* Radio cards (toggle modo precio) más bonitos */
input[type="radio"] {
  cursor: pointer;
}

/* ============================================================
   ESTADÍSTICAS DE GASTOS — drill-down por categoría/subcategoría
   ============================================================ */
.stats-filter-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-soft);
}
.stats-chip {
  padding: 6px 12px;
  border: 1px solid var(--line);
  background: var(--bg-paper);
  border-radius: 999px;
  font-size: 12.5px;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink-soft);
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.stats-chip:hover {
  border-color: var(--ink-mute);
  color: var(--ink);
}
.stats-chip.active {
  background: var(--ink);
  color: var(--bg-card);
  border-color: var(--ink);
}

.stats-cat-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.stats-cat-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}
.stats-cat-item:last-child { border-bottom: none; }
.stats-cat-item.expanded { padding-bottom: 4px; }

.stats-cat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  user-select: none;
}
.stats-cat-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.stats-cat-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}
.stats-cat-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stats-cat-toggle {
  font-size: 11px;
  color: var(--ink-mute);
  margin-left: 4px;
}
.stats-cat-amounts {
  display: flex;
  align-items: baseline;
  gap: 14px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.stats-cat-pct {
  font-size: 11.5px;
  color: var(--ink-mute);
  min-width: 50px;
  text-align: right;
}
.stats-cat-total {
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink);
}
.stats-cat-bar {
  height: 8px;
  background: var(--bg-elevated);
  border-radius: 999px;
  overflow: hidden;
}
.stats-cat-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

.stats-subcat-list {
  margin-top: 14px;
  margin-left: 22px;
  padding-left: 14px;
  border-left: 1.5px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.stats-subcat-item {
  padding: 4px 0;
}
.stats-subcat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
}
.stats-subcat-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.stats-subcat-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}
.stats-subcat-name {
  font-size: 13px;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stats-subcat-count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-mute);
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: 999px;
}
.stats-subcat-amounts {
  display: flex;
  gap: 10px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.stats-subcat-pct {
  font-size: 11px;
  color: var(--ink-mute);
  min-width: 42px;
  text-align: right;
}
.stats-subcat-total {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
}
.stats-subcat-bar {
  height: 5px;
  background: var(--bg-elevated);
  border-radius: 999px;
  overflow: hidden;
  opacity: 0.85;
}
.stats-subcat-bar-fill {
  height: 100%;
  border-radius: 999px;
}

/* Badges adicionales para presupuestos */
.badge-info {
  background: rgba(44,79,107,0.12);
  color: var(--ocean);
}
.badge-danger {
  background: rgba(139,43,43,0.12);
  color: #8B2B2B;
}

/* Tamaño pequeño de form group */
.form-group.btn-sm-wrap input,
.form-group.btn-sm-wrap select {
  font-size: 12.5px;
  padding: 6px 8px;
}

/* ============================================================
   FILTROS AVANZADOS — barras de filtro reutilizables
   ============================================================ */
.filter-bar {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-soft);
}
.filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}
.filter-search {
  flex: 1;
  position: relative;
}
.filter-search input {
  width: 100%;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg-paper);
  font-size: 13.5px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}
.filter-search input:focus {
  border-color: var(--ink);
  background: var(--bg-card);
}
.filter-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.filter-advanced {
  margin-top: 10px;
  padding: 14px;
  background: var(--bg-elevated);
  border-radius: var(--r-md);
}
.filter-advanced .form-grid { gap: 10px; }
.filter-advanced label { font-size: 10px; }

.form-grid.four-col { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 880px) {
  .form-grid.four-col { grid-template-columns: 1fr 1fr; }
}

/* ============================================================
   TAREAS
   ============================================================ */
.task-filters {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-soft);
}
.task-filter-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.task-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  background: var(--bg-paper);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--line);
  border-radius: var(--r-md);
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.task-row:hover {
  border-color: var(--line);
  background: var(--bg-card);
}
.task-row.task-overdue {
  border-left-color: var(--accent);
  background: rgba(184,68,44,0.03);
}
.task-row.task-priority-high { border-left-color: var(--accent); border-left-width: 4px; }
.task-row.task-priority-low { opacity: 0.7; }
.task-row.task-done {
  opacity: 0.55;
  border-left-color: var(--success, #2D4F3C);
}
.task-row.task-done .task-title { text-decoration: line-through; }

.task-checkbox {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--ink-mute);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--success, #2D4F3C);
  flex-shrink: 0;
  margin-top: 2px;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.task-checkbox:hover { border-color: var(--ink); }
.task-row.task-done .task-checkbox {
  background: var(--success, #2D4F3C);
  color: white;
  border-color: var(--success, #2D4F3C);
}
.task-content { flex: 1; min-width: 0; }
.task-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.task-cat-icon { font-size: 14px; }
.task-title {
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink);
}
.task-auto-badge {
  font-family: var(--font-mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 2px 6px;
  background: var(--bg-elevated);
  color: var(--ink-mute);
  border-radius: 999px;
}
.task-priority-badge {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  padding: 2px 7px;
  background: var(--accent);
  color: white;
  border-radius: 999px;
}
.task-description {
  font-size: 12.5px;
  color: var(--ink-soft);
  margin-bottom: 6px;
  line-height: 1.45;
}
.task-meta {
  display: flex;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-mute);
  align-items: center;
}
.task-due-overdue { color: var(--accent); font-weight: 500; }
.task-related-link {
  border: none;
  background: transparent;
  color: var(--ocean);
  cursor: pointer;
  text-decoration: underline;
  font-family: inherit;
  font-size: inherit;
  padding: 0;
}
.task-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: 8px;
  background: var(--accent);
  color: white;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
  display: inline-block;
}

/* ============================================================
   CALENDARIO
   ============================================================ */
.cal-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
}
.cal-title {
  flex: 1;
  text-align: center;
}
.cal-month-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-style: italic;
  letter-spacing: -0.01em;
  margin-right: 8px;
}
.cal-year {
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--ink-mute);
}
.cal-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 11.5px;
  color: var(--ink-soft);
}
.cal-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}
.cal-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}
.cal-dot-task { background: var(--gold); }
.cal-dot-invoice { background: var(--accent); }

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-mute);
  margin-bottom: 6px;
}
.cal-weekdays > div {
  padding: 6px 8px;
  text-align: center;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(110px, auto);
  gap: 4px;
}
.cal-cell {
  background: var(--bg-paper);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm, 6px);
  padding: 6px;
  display: flex;
  flex-direction: column;
  min-height: 110px;
  transition: background 0.15s;
}
.cal-cell:hover { background: var(--bg-card); }
.cal-cell-out {
  background: transparent;
  border-color: transparent;
  opacity: 0.35;
}
.cal-cell-out:hover { background: transparent; }
.cal-cell-weekend { background: var(--bg-elevated); }
.cal-cell-today {
  border-color: var(--accent);
  border-width: 1.5px;
}
.cal-cell-today .cal-day-num {
  background: var(--accent);
  color: white;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  line-height: 22px;
  text-align: center;
}
.cal-cell-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.cal-day-num {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
}
.cal-add-btn {
  border: none;
  background: transparent;
  color: var(--ink-mute);
  font-size: 14px;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.cal-cell:hover .cal-add-btn { opacity: 1; }
.cal-add-btn:hover { color: var(--accent); }
.cal-cell-events {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow: hidden;
}
.cal-event {
  font-size: 11px;
  padding: 3px 6px;
  border-radius: 3px;
  border-left: 2px solid var(--ink-mute);
  background: var(--bg-elevated);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: filter 0.15s;
}
.cal-event:hover { filter: brightness(0.95); }
.cal-event-task {
  background: rgba(184,134,11,0.1);
  border-left-color: var(--gold);
  color: var(--ink);
}
.cal-event-invoice {
  background: rgba(184,68,44,0.1);
  border-left-color: var(--accent);
  color: var(--ink);
}
.cal-event-quote {
  background: rgba(44,79,107,0.1);
  border-left-color: var(--ocean);
  color: var(--ink);
}
.cal-event-time {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--ink-mute);
  margin-right: 3px;
}
.cal-event-prefix { margin-right: 3px; }
.cal-more {
  border: none;
  background: transparent;
  color: var(--ink-mute);
  font-size: 10.5px;
  cursor: pointer;
  text-align: left;
  padding: 2px 6px;
  font-family: inherit;
}
.cal-more:hover { color: var(--accent); }

.cal-day-detail-row {
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 0.15s;
}
.cal-day-detail-row:hover { background: var(--bg-paper); }

@media (max-width: 720px) {
  .cal-grid { grid-auto-rows: minmax(70px, auto); }
  .cal-cell { padding: 3px; min-height: 70px; }
  .cal-event { font-size: 9.5px; padding: 2px 4px; }
  .cal-day-num { font-size: 10.5px; }
  .cal-weekdays > div { padding: 3px 2px; font-size: 9.5px; }
}

/* ============================================================
   PROYECTOS
   ============================================================ */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}
.project-card {
  padding: 16px 18px;
  background: var(--bg-paper);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.project-card:hover {
  border-color: var(--line);
  background: var(--bg-card);
}
.project-status-cancelled { opacity: 0.55; }
.project-card-header {
  padding-left: 12px;
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.project-name {
  font-family: var(--font-display);
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 2px;
}
.project-client {
  font-size: 12px;
  color: var(--ink-mute);
}
.project-status-badge {
  font-family: var(--font-mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.project-status-badge.status-active {
  background: rgba(45,79,60,0.12);
  color: #2D4F3C;
}
.project-status-badge.status-completed {
  background: rgba(44,79,107,0.12);
  color: var(--ocean);
}
.project-status-badge.status-cancelled {
  background: var(--bg-elevated);
  color: var(--ink-mute);
}
.project-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
.project-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.project-stat-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-mute);
}
.project-stat-value {
  font-family: var(--font-mono);
  font-size: 14.5px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.project-stat-profit { padding-left: 10px; border-left: 1px solid var(--line-soft); }
.project-stats-secondary {
  display: flex;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-mute);
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
}
.project-card-actions {
  display: flex;
  gap: 6px;
}

.hours-row {
  display: grid;
  grid-template-columns: 100px 1fr 1fr 110px 32px;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-elevated);
  border-radius: var(--r-sm, 6px);
  align-items: center;
  font-size: 13px;
}
.hours-date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-mute);
}
.hours-desc {
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hours-amount {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-size: 13px;
}
@media (max-width: 720px) {
  .hours-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

/* ============================================================
   MODO PERSONAL — Estilos
   ============================================================ */

/* ---- Mode switcher en sidebar ---- */
.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 8px 14px 12px;
  padding: 4px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}
.mode-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 6px;
  background: transparent;
  border: none;
  border-radius: 7px;
  color: rgba(255, 255, 255, 0.55);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
}
.mode-toggle-btn:hover {
  color: rgba(255, 255, 255, 0.85);
}
.mode-toggle-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.mode-toggle-icon {
  font-size: 13px;
  line-height: 1;
}
.mode-toggle-label {
  font-size: 12px;
}

/* ---- Visibilidad de nav según modo ---- */
.nav.nav-business,
.nav.nav-personal {
  display: none;
}
body.mode-business .nav-business { display: flex; }
body.mode-personal .nav-personal { display: flex; }
body.mode-personal .business-only { display: none !important; }

/* Por defecto (sin clase de modo aún), mostramos business */
body:not(.mode-business):not(.mode-personal) .nav-business { display: flex; }

/* ---- Mode selector (modal de bienvenida) ---- */
.mode-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 22px;
  background: var(--bg-elevated);
  border: 1.5px solid var(--line-soft);
  border-radius: var(--r-md);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.18s, transform 0.18s, box-shadow 0.18s;
  font-family: inherit;
  color: inherit;
}
.mode-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.06);
}
.mode-card-icon {
  font-size: 36px;
  line-height: 1;
}
.mode-card-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.mode-card-desc {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.5;
}
.mode-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.mode-card-tags span {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-mute);
  padding: 2px 8px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 999px;
}
@media (max-width: 600px) {
  .mode-card {
    padding: 16px;
  }
}

/* ============================================================
   MERCADOS
   ============================================================ */

/* Tabs */
.tabs-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  padding: 4px;
  background: var(--bg-elevated);
  border-radius: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs-bar::-webkit-scrollbar { display: none; }
.tab-btn {
  flex: 1;
  min-width: max-content;
  padding: 9px 14px;
  background: transparent;
  border: none;
  border-radius: 7px;
  color: var(--ink-soft);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
  white-space: nowrap;
}
.tab-btn:hover {
  color: var(--ink);
}
.tab-btn.active {
  background: var(--ink);
  color: var(--bg);
}

/* Banner offline */
.offline-banner {
  background: linear-gradient(135deg, #FBE9D8, #F5DCC2);
  color: #6B4218;
  border: 1px solid #E5C898;
  border-radius: var(--r-md);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 14px;
  font-family: var(--font-sans);
}

/* Markets grid */
.markets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.markets-grid > * { min-width: 0; }
.market-card {
  padding: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color 0.18s, transform 0.18s, box-shadow 0.18s;
  contain: layout style;
  overflow: hidden;
}
.market-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
}
.market-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}
.market-card-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.2;
  margin-bottom: 2px;
}
.market-card-symbol {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.market-card-price {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  line-height: 1.1;
  margin-bottom: 2px;
}
.market-card-change {
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.market-card-star {
  background: transparent;
  border: none;
  font-size: 16px;
  color: var(--gold, #B8860B);
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
}
.market-card-star:hover { transform: scale(1.15); }

/* Detail stats */
.detail-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}
.detail-stat {
  padding: 10px 12px;
  background: var(--bg-elevated);
  border-radius: var(--r-sm, 6px);
}
.detail-stat-lbl {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-mute);
  margin-bottom: 4px;
}
.detail-stat-val {
  font-family: var(--font-mono);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

/* Mini empty state */
.empty-state-mini {
  padding: 20px;
  text-align: center;
  color: var(--ink-mute);
  font-size: 13px;
  font-style: italic;
}

/* ============================================================
   NOTAS
   ============================================================ */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.note-card {
  padding: 14px 16px;
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  border-top: 1px solid var(--line-soft);
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.note-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
}
.note-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.note-card-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.25;
  margin: 0;
  flex: 1;
}
.note-card-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}
.note-pin-btn,
.note-del-btn {
  background: transparent;
  border: none;
  color: var(--ink-mute);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.18s, background 0.18s;
}
.note-pin-btn:hover,
.note-del-btn:hover {
  color: var(--ink);
  background: rgba(0, 0, 0, 0.04);
}
.note-pin-btn.pinned { color: var(--gold, #B8860B); }
.note-del-btn:hover { color: var(--accent); }
.note-card-body {
  font-size: 13.5px;
  color: var(--ink-soft);
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.note-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 6px;
  border-top: 1px solid var(--line-soft);
}
.note-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.note-tag {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-mute);
  padding: 2px 7px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 999px;
  text-transform: lowercase;
}
.note-card-meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-mute);
}

/* Mini note card (dashboard preview) */
.note-card-mini {
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-radius: var(--r-sm, 6px);
}
.note-card-mini .note-card-title {
  font-size: 14px;
  margin-bottom: 4px;
}
.note-card-mini .note-card-content {
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.45;
  margin-bottom: 6px;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.note-card-mini .note-card-date {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-mute);
}

/* Color picker */
.color-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--line-soft);
  cursor: pointer;
  transition: transform 0.18s, border-color 0.18s;
  padding: 0;
}
.color-swatch:hover {
  transform: scale(1.1);
}
.color-swatch.active {
  border-color: var(--ink);
  border-width: 3px;
  transform: scale(1.05);
}

/* ============================================================
   FINANZAS PERSONALES
   ============================================================ */

/* Toggle income/expense */
.finance-type-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 14px;
}
.finance-type-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  background: var(--bg-elevated);
  border: 2px solid var(--line-soft);
  border-radius: var(--r-md);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.18s, color 0.18s, border-color 0.18s, box-shadow 0.18s;
}
.finance-type-btn:hover {
  border-color: var(--ink-mute);
  color: var(--ink);
}
.finance-type-btn.active.expense {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.finance-type-btn.active.income {
  background: #2D4F3C;
  border-color: #2D4F3C;
  color: #fff;
}

/* List of transactions */
.finances-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.finance-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border-radius: var(--r-sm, 6px);
  align-items: center;
  cursor: pointer;
  transition: background 0.18s;
}
.finance-row > * { min-width: 0; }
.finance-row .finance-text {
  overflow: hidden;
  min-width: 0;
}
.finance-row .finance-text > * {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.finance-row:hover {
  background: rgba(0, 0, 0, 0.03);
}
.finance-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 500;
}
.finance-main {
  min-width: 0;
}
.finance-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.3;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.finance-meta {
  font-size: 11.5px;
  color: var(--ink-mute);
}
.finance-side {
  text-align: right;
}
.finance-amount {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  margin-bottom: 2px;
}
.finance-date {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-mute);
}

/* Breakdown 2 cols */
.finances-breakdown {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.finances-breakdown > div {
  min-width: 0;
  overflow: hidden;
}
.finances-breakdown [data-cat-filter] {
  min-width: 0;
}
.finances-breakdown [data-cat-filter] > div:first-child {
  min-width: 0;
  flex-wrap: wrap;
  gap: 8px;
}
.finances-breakdown [data-cat-filter] > div:first-child > span:first-child {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 720px) {
  .finances-breakdown {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }
}

/* ============================================================
   INVERSIONES — mini cards en dashboard personal
   ============================================================ */
.position-card-mini {
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-radius: var(--r-sm, 6px);
  border: 1px solid var(--line-soft);
}


/* ============================================================
   KANBAN
   ============================================================ */
.kanban-board-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  overflow-x: auto;
  padding: 4px 0;
  scrollbar-width: thin;
}
.kanban-board-tab {
  position: relative;
  padding: 8px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm, 6px);
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
}
.kanban-board-tab:hover {
  color: var(--ink);
  border-color: var(--ink-mute);
}
.kanban-board-tab.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.kanban-board-scope {
  margin-left: 6px;
  font-size: 11px;
  opacity: 0.7;
}
.kanban-board-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
  padding: 0 4px;
}
.kanban-board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 280px;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 12px;
  scrollbar-width: thin;
  min-height: 60vh;
}
.kanban-col {
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  display: flex;
  flex-direction: column;
  min-height: 200px;
}
.kanban-col-header {
  padding: 12px 14px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: var(--r-md) var(--r-md) 0 0;
}
.kanban-col-header h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.kanban-col-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-mute);
  background: rgba(0,0,0,0.05);
  padding: 1px 7px;
  border-radius: 999px;
}
.kanban-col-body {
  padding: 4px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-height: 100px;
  transition: background 0.18s;
  border-radius: 0 0 var(--r-md) var(--r-md);
}
.kanban-drop-over {
  background: rgba(184, 68, 44, 0.06);
}
.kanban-card {
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm, 6px);
  padding: 8px 10px;
  cursor: grab;
  transition: box-shadow 0.18s, transform 0.18s;
  user-select: none;
}
.kanban-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transform: translateY(-1px);
}
.kanban-card:active { cursor: grabbing; }
.kanban-dragging { opacity: 0.4; }
.kanban-card-labels {
  display: flex;
  gap: 3px;
  margin-bottom: 6px;
}
.kanban-label {
  display: inline-block;
  height: 4px;
  width: 28px;
  border-radius: 2px;
}
.kanban-card-title {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.3;
  margin-bottom: 3px;
}
.kanban-card-desc {
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.4;
  margin-bottom: 6px;
}
.kanban-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.kanban-pill {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(0,0,0,0.04);
  color: var(--ink-soft);
}
.kanban-pill.overdue {
  background: rgba(184,68,44,0.15) !important;
  color: var(--accent) !important;
}
.kanban-add-card {
  display: block;
  width: 100%;
  padding: 8px;
  background: transparent;
  border: 1.5px dashed var(--line-soft);
  border-radius: var(--r-sm, 6px);
  color: var(--ink-mute);
  font-family: var(--font-sans);
  font-size: 12px;
  cursor: pointer;
  margin-top: 4px;
  transition: border-color 0.18s, color 0.18s;
}
.kanban-add-card:hover {
  border-color: var(--ink-mute);
  color: var(--ink-soft);
}
.kanban-labels-picker {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.kanban-label-pick {
  width: 30px;
  height: 24px;
  border-radius: 4px;
  border: 2px solid transparent;
  cursor: pointer;
  color: white;
  font-size: 13px;
  transition: transform 0.15s;
}
.kanban-label-pick:hover { transform: scale(1.05); }
.kanban-label-pick.active {
  border-color: var(--ink);
}

/* ============================================================
   GARANTÍAS
   ============================================================ */
.warranties-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}
.warranty-card {
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  padding: 14px 16px;
  cursor: pointer;
  position: relative;
  transition: transform 0.18s, box-shadow 0.18s;
}
.warranty-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.06);
}
.warranty-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}
.warranty-card-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.25;
}
.warranty-card-sub {
  font-size: 12px;
  color: var(--ink-mute);
  margin-top: 2px;
}
.warranty-status {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.warranty-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 14px;
  margin-bottom: 10px;
}
.warranty-card-grid > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12.5px;
  border-bottom: 1px dotted var(--line-soft);
  padding: 3px 0;
}
.warranty-lbl {
  color: var(--ink-mute);
  font-size: 11px;
}
.warranty-val {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.warranty-attach {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}
.warranty-scope-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 10px;
  color: var(--ink-mute);
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--line-soft);
}

/* ============================================================
   ARCHIVOS IMPORTANTES
   ============================================================ */
.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}
.file-card {
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  padding: 12px 14px;
  cursor: pointer;
  position: relative;
  transition: transform 0.18s, box-shadow 0.18s;
}
.file-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.06);
}
.file-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}
.file-card-cat {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}
.file-card-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.25;
}
.file-card-desc {
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.4;
  margin-bottom: 8px;
}
.file-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}
.file-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
}
.file-card-meta {
  font-size: 11px;
  color: var(--ink-mute);
  font-family: var(--font-mono);
}
.file-scope-badge {
  font-size: 12px;
  color: var(--ink-mute);
  padding: 2px 6px;
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
}

/* ============================================================
   LICENCIAS
   ============================================================ */
.licenses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}
.license-card {
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  padding: 14px 16px;
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s;
}
.license-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.06);
}
.license-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}
.license-card-name {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
}
.license-version {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-mute);
  font-weight: 400;
}
.license-card-vendor {
  font-size: 12px;
  color: var(--ink-mute);
  margin-top: 2px;
}
.license-type-pill {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 3px 9px;
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  color: var(--ink-soft);
  white-space: nowrap;
}
.license-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 14px;
  margin-bottom: 10px;
}
.license-card-grid > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12.5px;
  padding: 4px 0;
  border-bottom: 1px dotted var(--line-soft);
}
.license-lbl {
  color: var(--ink-mute);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.license-val {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.license-key-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm, 6px);
  margin-top: 6px;
}
.license-key-masked {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink);
  flex: 1;
  letter-spacing: 0.05em;
  word-break: break-all;
}
.license-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
}

/* ============================================================
   DIARIO
   ============================================================ */
.diary-cal-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  padding: 0 4px 8px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 8px;
}
.diary-cal-header > div {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-mute);
  padding: 4px 0;
}
.diary-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.diary-cal-cell {
  aspect-ratio: 1;
  background: var(--bg-elevated);
  border-radius: var(--r-sm, 6px);
  padding: 6px;
  cursor: pointer;
  transition: background 0.18s, transform 0.18s;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid transparent;
}
.diary-cal-cell:hover { background: var(--bg-card, var(--bg)); border-color: var(--ink-mute); }
.diary-cal-cell.empty { background: transparent; cursor: default; pointer-events: none; }
.diary-cal-cell.has-entry { border-color: var(--gold, #B8860B); }
.diary-cal-cell.today { background: rgba(184,134,11,0.12); border-color: var(--gold, #B8860B); }
.diary-cal-day {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink);
  font-weight: 500;
}
.diary-cal-moods {
  text-align: center;
  font-size: 14px;
  line-height: 1;
}
.diary-cal-count {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-mute);
  text-align: center;
}
.diary-mini-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border-radius: var(--r-sm, 6px);
  cursor: pointer;
  transition: background 0.18s;
}
.diary-mini-card:hover { background: var(--bg-card, var(--bg)); }
.diary-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.diary-entry-card {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 16px;
  padding: 14px 16px;
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 0.18s, transform 0.18s;
}
.diary-entry-card:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0,0,0,0.05); }
.diary-entry-side {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  border-right: 1px solid var(--line-soft);
  padding-right: 14px;
}
.diary-entry-date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.diary-entry-mood, .diary-entry-weather { font-size: 22px; }
.diary-entry-main { min-width: 0; }
.diary-entry-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 500;
  margin: 0 0 6px;
  color: var(--ink);
}
.diary-entry-content {
  font-size: 13.5px;
  color: var(--ink-soft);
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.diary-entry-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}
.mood-picker, .weather-picker {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.mood-btn, .weather-btn {
  padding: 8px 10px;
  background: var(--bg-elevated);
  border: 1.5px solid var(--line-soft);
  border-radius: var(--r-sm, 6px);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 60px;
  transition: border-color 0.18s, background 0.18s;
}
.weather-btn { min-width: 44px; }
.mood-btn:hover, .weather-btn:hover { border-color: var(--ink-mute); }
.mood-btn.active, .weather-btn.active {
  border-color: var(--accent);
  background: rgba(184,68,44,0.06);
}

/* ============================================================
   INFORME ANUAL
   ============================================================ */
.report-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 720px) {
  .report-2col { grid-template-columns: 1fr; }
}
.report-subtitle {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-mute);
  margin-bottom: 10px;
  font-weight: 500;
}
.report-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.report-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border-radius: var(--r-sm, 6px);
}
.report-rank {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(45,79,60,0.12);
  color: var(--success, #2D4F3C);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
}
.report-main { min-width: 0; }
.report-row-title {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.report-row-meta {
  font-size: 11px;
  color: var(--ink-mute);
  margin-top: 2px;
}
.report-amount {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
/* Servicio row */
.service-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border-radius: var(--r-sm, 6px);
}
.service-main { min-width: 0; }
.service-desc {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: capitalize;
}
.service-meta {
  font-size: 11px;
  color: var(--ink-mute);
  margin: 3px 0 5px;
}
.service-bar {
  height: 4px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
}
.service-bar-fill {
  height: 100%;
  background: var(--gold, #B8860B);
  border-radius: 999px;
}
.service-amount { text-align: right; }

/* Bar chart de meses */
.month-bars {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 4px;
  align-items: end;
  margin-top: 12px;
  padding: 10px;
  background: var(--bg-elevated);
  border-radius: var(--r-md);
}
.month-bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.month-bar-stack {
  height: 100px;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  position: relative;
}
.month-bar {
  width: 100%;
  background: var(--gold, #B8860B);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  transition: opacity 0.18s;
}
.month-bar:hover { opacity: 0.8; }
.month-bar-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  text-transform: uppercase;
  color: var(--ink-mute);
  letter-spacing: 0.04em;
}
.month-bar-value {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Evolución */
.evolution-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.evolution-card {
  padding: 14px;
  background: var(--bg-elevated);
  border-radius: var(--r-md);
}
.evolution-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-mute);
  margin-bottom: 6px;
}
.evolution-current {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--ink);
  line-height: 1;
}
.evolution-prev {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-mute);
  margin-top: 4px;
}
.evolution-change {
  font-family: var(--font-mono);
  font-size: 12px;
  margin-top: 6px;
}

/* Conclusiones */
.conclusions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.conclusion-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border-radius: var(--r-sm, 6px);
  border-left: 4px solid var(--ink-mute);
}
.conclusion-card.success { border-left-color: var(--success, #2D4F3C); }
.conclusion-card.warning { border-left-color: var(--accent); }
.conclusion-card.info    { border-left-color: var(--gold, #B8860B); }
.conclusion-icon {
  font-size: 22px;
  line-height: 1;
}
.conclusion-text {
  font-size: 13.5px;
  color: var(--ink);
  line-height: 1.5;
}
.conclusion-text strong {
  font-weight: 600;
  color: var(--ink);
}

/* Sparklines en cards de mercado */
canvas.market-spark {
  display: block;
  width: 100% !important;
  height: 36px !important;
  max-height: 36px;
  margin: 6px 0;
  contain: strict;
}

/* Permitir scroll en sidebar con muchos items */
.sidebar .nav {
  overflow-y: auto;
  scrollbar-width: thin;
  flex: 1;
  min-height: 0;
}
.sidebar .nav::-webkit-scrollbar { width: 4px; }
.sidebar .nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 999px; }


/* ============================================================
   SISTEMA — Widget de salud
   ============================================================ */
.sys-status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.sys-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: var(--bg-elevated);
  border-radius: 999px;
  border: 1px solid var(--line-soft);
  font-size: 12.5px;
  color: var(--ink-soft);
  font-family: var(--font-sans);
}
.sys-status-pill strong {
  font-weight: 600;
  color: var(--ink);
}
.sys-status-pill.success { border-color: rgba(45,79,60,0.25); }
.sys-status-pill.success .sys-status-dot { background: #2D4F3C; }
.sys-status-pill.warning { border-color: rgba(184,134,11,0.30); }
.sys-status-pill.warning .sys-status-dot { background: #B8860B; }
.sys-status-pill.critical { border-color: rgba(184,68,44,0.30); }
.sys-status-pill.critical .sys-status-dot { background: #B8442C; }
.sys-status-pill.info { background: var(--bg-elevated); }
.sys-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9A9180;
  display: inline-block;
  animation: pulse 2.5s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.15); }
}
.sys-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
.sys-card {
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
}
.sys-card-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.sys-card-sub {
  font-size: 11.5px;
  color: var(--ink-mute);
  margin-bottom: 12px;
  line-height: 1.4;
}
.sys-tag {
  font-family: var(--font-mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(0,0,0,0.05);
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--ink-mute);
  font-weight: 400;
}
.sys-big-value {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1;
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}
.sys-unit {
  font-size: 14px;
  color: var(--ink-mute);
  font-weight: 400;
  font-family: var(--font-mono);
}
.sys-spark-wrap {
  margin: 8px 0;
  height: 60px;
}
.sys-spark-wrap canvas {
  display: block;
  width: 100% !important;
}
.sys-donut-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px 0 12px;
}
.sys-donut-wrap canvas {
  display: block;
  width: 160px !important;
  margin: 0 auto;
}
.sys-donut-caption {
  position: absolute;
  bottom: -4px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--ink-mute);
  font-family: var(--font-mono);
}
.sys-donut-caption strong {
  color: var(--ink);
  font-weight: 600;
}
.sys-card-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-mute);
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
}
.sys-empty-mini {
  font-size: 12.5px;
  color: var(--ink-mute);
  padding: 18px 14px;
  background: var(--bg);
  border-radius: var(--r-sm, 6px);
  text-align: center;
  line-height: 1.5;
}
.sys-empty-mini code {
  font-family: var(--font-mono);
  background: rgba(0,0,0,0.05);
  padding: 1px 5px;
  border-radius: 3px;
}
.sys-bar-row {
  display: grid;
  grid-template-columns: 180px 1fr 100px;
  gap: 10px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px dotted var(--line-soft);
}
.sys-bar-row:last-child { border-bottom: none; }
.sys-bar-label {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sys-bar-track {
  height: 8px;
  background: rgba(0,0,0,0.05);
  border-radius: 999px;
  overflow: hidden;
}
.sys-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}
.sys-bar-value {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.sys-disclaimer {
  margin-top: 14px;
  padding: 14px 18px;
  background: linear-gradient(135deg, #FBE9D8, #F5DCC2);
  border: 1px solid #E5C898;
  border-radius: var(--r-md);
  color: #6B4218;
  font-size: 12.5px;
  line-height: 1.6;
}
.sys-disclaimer strong { color: #5A3712; }

/* ============================================================
   WISHLIST
   ============================================================ */
.wishlist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.wishlist-card {
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s;
  display: flex;
  flex-direction: column;
}
.wishlist-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
.wishlist-card.target-reached {
  outline: 2px solid #2D4F3C;
  outline-offset: -2px;
}
.wishlist-img {
  width: 100%;
  aspect-ratio: 1.3;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.wishlist-img img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: white;
}
.wishlist-img-placeholder {
  font-size: 48px;
  opacity: 0.3;
}
.wishlist-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.wishlist-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}
.wishlist-cat {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}
.wishlist-prio {
  font-family: var(--font-mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 999px;
}
.wishlist-title {
  font-family: var(--font-display);
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.3;
  margin: 0;
}
.wishlist-fetched-title {
  font-size: 11.5px;
  color: var(--ink-mute);
  line-height: 1.35;
  font-style: italic;
  min-height: 16px;
}
.wishlist-price {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.wishlist-price-num {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.wishlist-target-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #2D4F3C;
  color: white;
  padding: 3px 8px;
  border-radius: 999px;
  animation: pulse 2s ease-in-out infinite;
}
.wishlist-target {
  font-size: 12px;
  color: var(--ink-mute);
  font-family: var(--font-mono);
}
.wishlist-card-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
}
.wishlist-site {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-mute);
  text-transform: lowercase;
}

/* ============================================================
   PRICE TRACKER
   ============================================================ */
.tracker-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tracker-row {
  display: grid;
  grid-template-columns: 80px 1fr auto auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s;
}
.tracker-row:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.06);
}
.tracker-row.target-reached {
  outline: 2px solid #2D4F3C;
  outline-offset: -2px;
  background: linear-gradient(135deg, var(--bg-elevated) 60%, rgba(45,79,60,0.06));
}
.tracker-img {
  width: 80px;
  height: 80px;
  background: var(--bg);
  border-radius: var(--r-sm, 6px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.tracker-img img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: white;
}
.tracker-img-placeholder {
  font-size: 36px;
  opacity: 0.3;
}
.tracker-main {
  min-width: 0;
}
.tracker-title {
  font-family: var(--font-display);
  font-size: 15.5px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.tracker-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-mute);
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.tracker-spark {
  width: 100% !important;
  margin-top: 6px;
  display: block;
}
.tracker-prices {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tracker-current {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}
.tracker-trend {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
}
.tracker-target {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-mute);
}
.tracker-target.reached {
  color: #2D4F3C;
  font-weight: 600;
}
.tracker-target-flag {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 7px;
  background: #2D4F3C;
  color: white;
  border-radius: 999px;
  font-size: 9.5px;
  letter-spacing: 0.06em;
  animation: pulse 2s ease-in-out infinite;
}
.tracker-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
@media (max-width: 720px) {
  .tracker-row {
    grid-template-columns: 60px 1fr;
    grid-template-areas: "img main" "prices prices" "actions actions";
  }
  .tracker-img { width: 60px; height: 60px; grid-area: img; }
  .tracker-main { grid-area: main; }
  .tracker-prices { grid-area: prices; text-align: left; }
  .tracker-actions { grid-area: actions; flex-direction: row; }
}

/* ============================================================
   PACKAGE TRACKER
   ============================================================ */
.packages-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.package-row {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s;
}
.package-row:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.06);
}
.package-row.archived {
  opacity: 0.6;
}
.package-status {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding-right: 14px;
  border-right: 1px solid var(--line-soft);
}
.package-status-icon {
  font-size: 28px;
  line-height: 1;
}
.package-status-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}
.package-main { min-width: 0; }
.package-title {
  font-family: var(--font-display);
  font-size: 15.5px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}
.package-courier {
  font-size: 12.5px;
  color: var(--ink-soft);
  margin-bottom: 4px;
}
.package-code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: 4px;
}
.package-meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-mute);
  margin-top: 2px;
}
.package-last-event {
  font-size: 11.5px;
  color: var(--ink-soft);
  font-style: italic;
  margin-top: 4px;
  padding: 4px 8px;
  background: var(--bg);
  border-radius: 4px;
  display: inline-block;
}
.package-actions {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* Timeline modal */
.package-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 320px;
  overflow-y: auto;
  padding: 8px 0;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}
.package-event {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px dotted var(--line-soft);
  position: relative;
}
.package-event:last-child { border-bottom: none; }
.package-event-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ink);
  margin-top: 4px;
  position: relative;
}
.package-event-dot::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 12px;
  bottom: -16px;
  width: 2px;
  background: var(--line-soft);
}
.package-event:last-child .package-event-dot::before { display: none; }
.package-event-content { min-width: 0; }
.package-event-status {
  font-weight: 500;
  font-size: 13.5px;
  color: var(--ink);
}
.package-event-loc {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-mute);
  margin-top: 2px;
}
.package-event-notes {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 4px;
  font-style: italic;
}
.package-event-date {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-mute);
  margin-top: 4px;
}

@media (max-width: 720px) {
  .package-row {
    grid-template-columns: 1fr auto;
    grid-template-areas: "status actions" "main main";
  }
  .package-status { grid-area: status; border-right: none; padding-right: 0; flex-direction: row; }
  .package-actions { grid-area: actions; flex-direction: row; }
  .package-main { grid-area: main; padding-top: 8px; border-top: 1px solid var(--line-soft); }
}

/* ============================================================
   IP MANAGER
   ============================================================ */
.ipmgr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.ipmgr-card {
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  padding: 12px 14px;
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s;
}
.ipmgr-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.06);
}
.ipmgr-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.ipmgr-card-type {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}
.ipmgr-card-online {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #9A9180;
}
.ipmgr-card-online.on {
  background: #2D4F3C;
  box-shadow: 0 0 0 2px rgba(45,79,60,0.2);
  animation: pulse 2.5s ease-in-out infinite;
}
.ipmgr-card-online.off { background: #B8442C40; }
.ipmgr-card-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 2px;
}
.ipmgr-card-host {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-mute);
  margin-bottom: 4px;
}
.ipmgr-card-ip {
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--ink);
  font-weight: 500;
  margin: 6px 0 4px;
  font-variant-numeric: tabular-nums;
}
.ipmgr-card-mac {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-mute);
}
.ipmgr-card-net {
  font-family: var(--font-mono);
  font-size: 11px;
  margin: 6px 0;
}
.ipmgr-card-ports {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
}
.ipmgr-port-chip {
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: rgba(91,117,68,0.10);
  color: #5B7544;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 500;
}
.ipmgr-port-chip-more {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-mute);
  padding: 2px 5px;
}
.ipmgr-card-static {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--gold, #B8860B);
  margin-top: 6px;
}
.ipmgr-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

/* Subnet view */
.ipmgr-subnet-info {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-radius: var(--r-sm, 6px);
  margin-bottom: 14px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-soft);
}
.ipmgr-subnet-info strong {
  color: var(--ink-mute);
  font-weight: 500;
  margin-right: 4px;
}
.ipmgr-subnet-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 16), 1fr);
  gap: 3px;
  padding: 12px;
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  margin-bottom: 12px;
}
.ipmgr-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  background: rgba(0,0,0,0.04);
  border: 1px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 9px;
  transition: filter 0.12s ease, border-color 0.12s ease;
  min-height: 24px;
}
.ipmgr-cell:hover {
  filter: brightness(1.15);
  z-index: 2;
  border-color: var(--ink);
  outline: 2px solid var(--ink);
  outline-offset: -1px;
}
.ipmgr-cell.free { background: rgba(0,0,0,0.04); }
.ipmgr-cell.used { background: rgba(91,117,68,0.40); border-color: rgba(91,117,68,0.6); }
.ipmgr-cell.used.online {
  box-shadow: 0 0 0 1px rgba(45,79,60,0.3);
}
.ipmgr-cell.gateway {
  background: rgba(184,134,11,0.40);
  border-color: rgba(184,134,11,0.7);
}
.ipmgr-cell.network, .ipmgr-cell.broadcast {
  background: rgba(184,68,44,0.20);
  border-color: rgba(184,68,44,0.4);
  cursor: not-allowed;
}
.ipmgr-subnet-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 8px 14px;
  background: var(--bg);
  border-radius: var(--r-sm, 6px);
  font-size: 11.5px;
  color: var(--ink-soft);
  align-items: center;
}
.ipmgr-subnet-legend > span {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ipmgr-subnet-legend .ipmgr-cell {
  width: 14px !important;
  height: 14px !important;
  min-height: 14px !important;
  aspect-ratio: 1;
  border-radius: 2px;
}

/* Ports view */
.ipmgr-ports-table {
  display: flex;
  flex-direction: column;
}
.ipmgr-ports-thead {
  display: grid;
  grid-template-columns: 100px 1fr 1.5fr 130px 1fr;
  gap: 12px;
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
  border-bottom: 1px solid var(--line-soft);
}
.ipmgr-ports-row {
  display: grid;
  grid-template-columns: 100px 1fr 1.5fr 130px 1fr;
  gap: 12px;
  padding: 10px 14px;
  align-items: center;
  border-bottom: 1px dotted var(--line-soft);
  cursor: pointer;
  transition: background 0.18s;
}
.ipmgr-ports-row:hover { background: var(--bg-elevated); }
.ipmgr-ports-row:last-child { border-bottom: none; }
.ipmgr-mono {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink);
}
.ipmgr-notes-cell {
  font-size: 12px;
  color: var(--ink-mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ipmgr-port-row {
  display: grid;
  grid-template-columns: 80px 90px 1fr 1fr auto;
  gap: 6px;
  align-items: center;
}
@media (max-width: 720px) {
  .ipmgr-ports-thead, .ipmgr-ports-row {
    grid-template-columns: 80px 1fr;
    gap: 8px;
  }
  .ipmgr-ports-thead > *:nth-child(n+3),
  .ipmgr-ports-row > *:nth-child(n+3) { display: none; }
}

/* ============================================================
   ASSET LIBRARY
   ============================================================ */
.asset-stores-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.asset-store-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-elevated);
  border: 1.5px solid var(--line-soft);
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 12.5px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color 0.18s, color 0.18s, background 0.18s;
}
.asset-store-chip:hover { color: var(--ink); border-color: var(--ink-mute); }
.asset-store-chip.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.asset-store-chip.active .asset-store-count {
  background: rgba(255,255,255,0.2);
  color: var(--bg);
}
.asset-store-count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: rgba(0,0,0,0.06);
  padding: 1px 7px;
  border-radius: 999px;
  color: var(--ink-mute);
}
.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.asset-card {
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s;
  display: flex;
  flex-direction: column;
}
.asset-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
.asset-card-thumb {
  width: 100%;
  aspect-ratio: 1.4;
  background: var(--bg);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.asset-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.asset-card-thumb-placeholder {
  font-size: 40px;
  opacity: 0.3;
}
.asset-store-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: white;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.asset-card-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.asset-card-cat {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}
.asset-card-name {
  font-family: var(--font-display);
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.asset-card-store {
  font-size: 11.5px;
  color: var(--ink-mute);
}
.asset-card-price {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.asset-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.asset-card-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
}
.asset-card-license {
  margin-left: auto;
  font-size: 14px;
}

/* Tag chip especial para filtros activables */
.note-tag-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 9px;
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.18s, color 0.18s, border-color 0.18s, box-shadow 0.18s;
}
.note-tag-chip:hover { border-color: var(--ink-mute); color: var(--ink); }
.note-tag-chip.active {
  background: var(--gold, #B8860B);
  color: white;
  border-color: var(--gold, #B8860B);
}

/* Bulk import progress */
.bulk-progress-track {
  height: 8px;
  background: var(--bg-elevated);
  border-radius: 999px;
  overflow: hidden;
}
.bulk-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #5B7544, #B8860B);
  transition: width 0.3s ease;
  border-radius: 999px;
}

/* Stores config list */
.store-config-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
  padding: 4px;
}
.store-config-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border-radius: var(--r-sm, 6px);
}

/* ============================================================
   ASSET IMPORTER (bookmarklet + paste)
   ============================================================ */
.importer-method {
  padding: 16px 18px;
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  margin-bottom: 14px;
}
.importer-method-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.importer-method-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
}
.importer-method-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}
.importer-recommended {
  font-family: var(--font-mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--success, #2D4F3C);
  color: white;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 500;
}
.importer-method-desc {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.55;
}
.importer-method-desc code {
  font-family: var(--font-mono);
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11.5px;
}
.importer-bookmarklet-zone {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: linear-gradient(135deg, #FBE9D8 0%, #F5DCC2 100%);
  border: 2px dashed #B8860B;
  border-radius: var(--r-md);
}
.bookmarklet-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: linear-gradient(135deg, #2D4F3C, #5B7544);
  color: white !important;
  border-radius: 999px;
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  cursor: grab;
  user-select: none;
  box-shadow: 0 3px 10px rgba(45,79,60,0.25);
  transition: transform 0.18s, box-shadow 0.18s;
  white-space: nowrap;
}
.bookmarklet-pill:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(45,79,60,0.35);
}
.bookmarklet-pill:active { cursor: grabbing; }
.importer-arrow {
  font-size: 13px;
  color: #6B4218;
  font-style: italic;
}
.importer-details {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--ink-soft);
}
.importer-details summary {
  cursor: pointer;
  color: var(--ink-mute);
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 4px 0;
}
.importer-details summary:hover { color: var(--ink); }
.importer-details p {
  margin: 6px 0 0;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: var(--r-sm, 6px);
  line-height: 1.5;
}
.importer-details code {
  font-family: var(--font-mono);
  background: var(--bg-elevated);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
}

@media (max-width: 720px) {
  .importer-bookmarklet-zone { flex-direction: column; align-items: flex-start; }
}

/* ============================================================
   ADDRESS FIELDS + NIF FEEDBACK
   ============================================================ */
.form-fieldset {
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: 14px 16px 6px;
  margin: 14px 0;
}
.form-fieldset legend {
  padding: 0 8px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.address-fields-block .form-grid { gap: 10px 12px; margin-bottom: 6px; }

.nif-feedback {
  font-size: 12px;
  margin-top: 4px;
  padding: 0;
  line-height: 1.4;
}
.nif-feedback.valid {
  color: var(--success, #2D4F3C);
  display: flex;
  align-items: center;
  gap: 6px;
}
.nif-feedback.invalid {
  background: rgba(184,68,44,0.06);
  border: 1px solid rgba(184,68,44,0.25);
  color: #B8442C;
  padding: 8px 12px;
  border-radius: var(--r-sm, 6px);
  margin-top: 6px;
}
.nif-feedback.invalid > div { display: flex; gap: 6px; align-items: flex-start; }
.nif-feedback.invalid strong { color: #8B2E1B; font-weight: 600; }
.nif-hint {
  margin-top: 4px;
  font-size: 11.5px;
  color: rgba(184,68,44,0.85);
  font-style: italic;
  padding-left: 14px;
}

/* ============================================================
   TRASH
   ============================================================ */
.trash-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.trash-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border-radius: var(--r-sm, 6px);
  transition: background 0.18s;
}
.trash-row:hover { background: var(--bg); }
.trash-icon {
  font-size: 22px;
  text-align: center;
  opacity: 0.7;
}
.trash-main { min-width: 0; }
.trash-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.trash-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-mute);
  margin-top: 2px;
}
.trash-actions {
  display: flex;
  gap: 6px;
}

/* ============================================================
   AUTO-BACKUP LIST
   ============================================================ */
.autobackup-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}
.autobackup-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border-radius: var(--r-sm, 6px);
}
.autobackup-row-main { min-width: 0; }
.autobackup-row-date {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink);
}
.autobackup-row-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-mute);
  margin-top: 2px;
}

/* ============================================================
   PDF EDITOR
   ============================================================ */
.pdf-drop-zone {
  border: 3px dashed var(--line-soft);
  border-radius: var(--r-lg, 16px);
  padding: 60px 40px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s;
}
.pdf-drop-zone:hover, .pdf-drop-zone.drag-over {
  border-color: var(--gold, #B8860B);
  background: rgba(184,134,11,0.04);
}
.pdf-features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 24px;
}
.pdf-feature {
  padding: 16px;
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  text-align: center;
}
.pdf-feature-icon { font-size: 32px; margin-bottom: 8px; }
.pdf-feature-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
}
.pdf-feature-desc {
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.5;
}

/* Toolbar */
.pdf-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--r-md);
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.pdf-toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pdf-toolbar-group + .pdf-toolbar-group {
  border-left: 1px solid rgba(255,255,255,0.15);
  padding-left: 14px;
}
.pdf-toolbar-label {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.95);
}
.pdf-toolbar-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: rgba(255,255,255,0.55);
}
.pdf-tool {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s;
}
.pdf-tool:hover { background: rgba(255,255,255,0.1); }
.pdf-tool.active {
  background: var(--gold, #B8860B);
  border-color: var(--gold, #B8860B);
}
.pdf-zoom-label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: rgba(255,255,255,0.85);
  min-width: 50px;
  text-align: center;
}

/* Layout */
.pdf-editor-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 12px;
  height: 75vh;
  min-height: 500px;
}
@media (max-width: 720px) {
  .pdf-editor-layout { grid-template-columns: 1fr; height: auto; }
}
.pdf-sidebar {
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  padding: 12px;
  overflow-y: auto;
}
.pdf-sidebar-title {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-mute);
  margin-bottom: 10px;
  padding: 0 4px;
}
#pdf-thumbnails {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pdf-thumb {
  background: var(--bg);
  border-radius: var(--r-sm, 6px);
  border: 2px solid transparent;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s;
  position: relative;
}
.pdf-thumb:hover { border-color: var(--ink-mute); }
.pdf-thumb.active { border-color: var(--gold, #B8860B); }
.pdf-thumb.deleted { opacity: 0.4; cursor: not-allowed; }
.pdf-thumb.dragging { opacity: 0.4; }
.pdf-thumb.drag-target { border-color: var(--accent); transform: scale(1.02); }
.pdf-thumb-num {
  font-family: var(--font-mono);
  font-size: 10px;
  text-align: center;
  padding: 3px;
  background: rgba(0,0,0,0.04);
  color: var(--ink-mute);
}
.pdf-thumb-canvas-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  padding: 4px;
}
.pdf-thumb-canvas {
  max-width: 100%;
  max-height: 200px;
  display: block;
}
.pdf-thumb-deleted-overlay {
  position: absolute;
  inset: 0;
  background: rgba(184,68,44,0.5);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
}
.pdf-thumb-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--gold, #B8860B);
  color: white;
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 600;
}
.pdf-thumb-actions {
  display: flex;
  gap: 0;
  border-top: 1px solid var(--line-soft);
}
.pdf-thumb-btn {
  flex: 1;
  background: transparent;
  border: 0;
  padding: 4px;
  cursor: pointer;
  font-size: 12px;
  color: var(--ink-soft);
}
.pdf-thumb-btn:hover { background: rgba(0,0,0,0.05); color: var(--ink); }
.pdf-thumb-btn + .pdf-thumb-btn { border-left: 1px solid var(--line-soft); }

/* Viewer */
.pdf-viewer {
  background: #4a4a4a;
  border-radius: var(--r-md);
  padding: 20px;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
#pdf-page-container[data-tool="redact-white"],
#pdf-page-container[data-tool="redact-black"] {
  cursor: crosshair;
}
#pdf-page-container[data-tool="text-add"] {
  cursor: text;
}
.pdf-page-wrap {
  position: relative;
  background: white;
  box-shadow: 0 6px 30px rgba(0,0,0,0.3);
  margin: 0 auto;
}
.pdf-annotation-layer {
  position: absolute;
  inset: 0;
}
.pdf-annotation {
  position: absolute;
  box-sizing: border-box;
}

/* ============================================================
   POINTER-EVENTS por herramienta (CLAVE para selección/dibujo)
   ============================================================ */

/* Por defecto la capa de texto NO recibe eventos (queda detrás
   visualmente para que el cursor sea el de la herramienta) */
.textLayer { pointer-events: none; }

/* En modo SELECT, la capa de texto sí recibe eventos para selección */
#pdf-page-container[data-tool="select"] .textLayer { pointer-events: auto; cursor: text; }
/* Y la capa de anotaciones queda transparente a eventos para no estorbar */
#pdf-page-container[data-tool="select"] .pdf-annotation-layer { pointer-events: none; }
/* Pero las propias anotaciones (clic para borrar/inspeccionar) siguen activas */
#pdf-page-container[data-tool="select"] .pdf-annotation { pointer-events: auto; }

/* En modo EDIT: la capa de texto pasiva, los markers reciben dblclick */
#pdf-page-container[data-tool="edit"] .pdf-annotation-layer { pointer-events: auto; }

/* En modo REDACT/TEXT-ADD: la capa de anotaciones recibe arrastre */
#pdf-page-container[data-tool="redact-white"] .pdf-annotation-layer,
#pdf-page-container[data-tool="redact-black"] .pdf-annotation-layer,
#pdf-page-container[data-tool="text-add"] .pdf-annotation-layer { pointer-events: auto; }

/* En ERASER: las anotaciones reciben click para borrar */
#pdf-page-container[data-tool="eraser"] .pdf-annotation-layer { pointer-events: none; }
#pdf-page-container[data-tool="eraser"] .pdf-annotation {
  pointer-events: auto;
  cursor: pointer;
  outline: 2px dashed transparent;
}
#pdf-page-container[data-tool="eraser"] .pdf-annotation:hover { outline-color: #B8442C; }

/* ============================================================
   PDF EDITOR — capa de texto seleccionable + edición
   ============================================================ */

/* Banner explicativo de la herramienta activa */
.pdf-tool-banner {
  padding: 8px 14px;
  background: linear-gradient(135deg, #FBE9D8, #F5DCC2);
  border: 1px solid #E5C898;
  border-radius: var(--r-sm, 6px);
  font-size: 13px;
  color: #6B4218;
  margin-bottom: 12px;
  line-height: 1.5;
}
.pdf-tool-banner strong { color: #5A3712; }
.pdf-tool-banner kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 6px;
  background: rgba(0,0,0,0.06);
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 3px;
}

/* Color de selección personalizado de la app (dorado) */
.textLayer ::selection { background: rgba(184, 134, 11, 0.35); }
.textLayer ::-moz-selection { background: rgba(184, 134, 11, 0.35); }

/* Marcadores de líneas en modo edit */
.pdf-edit-markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.pdf-edit-line-marker {
  position: absolute;
  background: rgba(184, 134, 11, 0.10);
  border: 1px dashed rgba(184, 134, 11, 0.4);
  cursor: text;
  pointer-events: auto;
  transition: background 0.15s, border-color 0.15s;
  border-radius: 2px;
}
.pdf-edit-line-marker:hover {
  background: rgba(184, 134, 11, 0.25);
  border-color: rgba(184, 134, 11, 0.7);
}
.pdf-edit-line-marker:hover::after {
  content: '✏ doble clic';
  position: absolute;
  top: -22px;
  left: 0;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
}

/* Popup inline para editar texto */
.pdf-edit-popup {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: white;
  border: 2px solid var(--gold, #B8860B);
  border-radius: 6px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.2);
  z-index: 10;
}
.pdf-edit-input {
  border: 0;
  outline: 0;
  padding: 4px 6px;
  background: transparent;
  font-family: Helvetica, Arial, sans-serif;
  flex: 1;
  min-width: 100px;
}
.pdf-edit-font {
  width: 60px;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  font-family: var(--font-mono);
}
.pdf-edit-btn {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}
.pdf-edit-btn.ok    { background: var(--success, #2D4F3C); color: white; }
.pdf-edit-btn.cancel { background: rgba(184,68,44,0.1); color: #B8442C; }

/* Anotación de texto editado: indicar visualmente */
.pdf-annotation.type-edit-text {
  border: 1px dotted var(--gold, #B8860B) !important;
  cursor: pointer;
}
.pdf-annotation.type-edit-text::after {
  content: '✏';
  position: absolute;
  top: -16px;
  right: -2px;
  font-size: 10px;
  background: var(--gold, #B8860B);
  color: white;
  padding: 1px 4px;
  border-radius: 3px;
}

/* ============================================================
   PDF EDITOR PRO — Editor PDF profesional embebido
   ============================================================ */

/* Modo activo del view-container */
.pdf-pro-mode {
  display: flex !important;
  flex-direction: column;
  height: calc(100vh - 60px);
  max-height: calc(100vh - 60px);
  overflow: hidden;
}

/* Pantalla de carga inicial */
.pdf-pro-loading {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.pdf-pro-loading-card {
  background: var(--bg-elevated);
  border-radius: var(--r-lg, 16px);
  padding: 40px;
  max-width: 520px;
  width: 100%;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.08);
}
.pdf-pro-loading-icon {
  position: relative;
  width: 100px;
  height: 100px;
  margin: 0 auto 20px;
}
.pdf-pro-loading-spinner {
  position: absolute;
  inset: 0;
  border: 4px solid rgba(184,134,11,0.15);
  border-top-color: var(--gold, #B8860B);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.pdf-pro-loading-emoji {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
}
.pdf-pro-loading-card h2 {
  font-family: var(--font-display);
  font-size: 24px;
  margin: 0 0 8px;
  color: var(--ink);
}
.pdf-pro-loading-card > p {
  color: var(--ink-soft);
  margin: 0 0 24px;
}
.pdf-pro-progress { margin: 24px 0; }
.pdf-pro-progress-track {
  height: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 8px;
}
.pdf-pro-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--gold, #B8860B), #DAA520);
  transition: width 0.4s ease;
  border-radius: 999px;
}
.pdf-pro-progress-text {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-soft);
}
.pdf-pro-loading-info {
  text-align: left;
  margin-top: 24px;
  padding: 16px;
  background: var(--bg);
  border-radius: var(--r-md);
  font-size: 12px;
}
.pdf-pro-loading-info-item {
  padding: 4px 0;
  color: var(--ink-soft);
  font-family: var(--font-mono);
}
.pdf-pro-loading-info-item strong {
  color: var(--ink);
}
.pdf-pro-loading-info-note {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  font-style: italic;
  color: var(--ink-mute);
  text-align: center;
}

/* Estado vacío */
.pdf-pro-empty { padding: 40px 20px; }
.pdf-pro-status {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-elevated);
}
.pdf-pro-status.on { background: rgba(45,79,60,0.1); color: var(--success, #2D4F3C); }
.pdf-pro-status.off { background: rgba(184,68,44,0.1); color: var(--accent, #B8442C); }

.pdf-pro-drop-zone {
  border: 3px dashed var(--line-soft);
  border-radius: var(--r-lg, 16px);
  padding: 80px 40px;
  text-align: center;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s;
  background: var(--bg);
}
.pdf-pro-drop-zone:hover, .pdf-pro-drop-zone.drag-over {
  border-color: var(--gold, #B8860B);
  background: rgba(184,134,11,0.04);
}
.pdf-pro-drop-icon { font-size: 80px; margin-bottom: 16px; opacity: 0.7; }
.pdf-pro-drop-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--ink);
}
.pdf-pro-drop-sub {
  color: var(--ink-soft);
  margin-bottom: 24px;
  font-size: 14px;
}
.pdf-pro-drop-shortcut {
  margin-top: 16px;
  font-size: 12px;
  color: var(--ink-mute);
}
.pdf-pro-drop-shortcut kbd {
  background: var(--ink);
  color: var(--bg);
  font-family: var(--font-mono);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
}
.btn-lg { padding: 12px 28px !important; font-size: 15px; }

.pdf-pro-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 32px;
}
.pdf-pro-feature {
  padding: 18px;
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  text-align: left;
}
.pdf-pro-feature-icon { font-size: 28px; margin-bottom: 8px; }
.pdf-pro-feature h4 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  margin: 0 0 6px;
  color: var(--ink);
}
.pdf-pro-feature p {
  font-size: 12.5px;
  color: var(--ink-soft);
  margin: 0;
  line-height: 1.5;
}

/* TABS BAR */
.pdf-pro-tabs-bar {
  display: flex;
  align-items: center;
  background: var(--ink);
  border-radius: var(--r-md) var(--r-md) 0 0;
  padding: 0;
  flex-shrink: 0;
}
.pdf-pro-tabs-list {
  display: flex;
  flex: 1;
  overflow-x: auto;
  gap: 1px;
}
.pdf-pro-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.6);
  border-radius: var(--r-md) var(--r-md) 0 0;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  max-width: 240px;
  white-space: nowrap;
  font-size: 12.5px;
}
.pdf-pro-tab:hover { background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.9); }
.pdf-pro-tab.active {
  background: var(--bg);
  color: var(--ink);
}
.pdf-pro-tab.active .pdf-pro-tab-close { color: var(--ink-mute); }
.pdf-pro-tab-icon { font-size: 14px; }
.pdf-pro-tab-name {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}
.pdf-pro-tab-dirty {
  color: var(--gold, #B8860B);
  font-size: 18px;
  line-height: 0.5;
}
.pdf-pro-tab-close {
  background: transparent;
  border: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  padding: 0;
}
.pdf-pro-tab-close:hover { background: rgba(184,68,44,0.5); color: white; }
.pdf-pro-tabs-actions {
  display: flex;
  gap: 4px;
  padding: 0 8px;
  border-left: 1px solid rgba(255,255,255,0.1);
}
.pdf-pro-tab-action {
  width: 32px;
  height: 32px;
  background: transparent;
  border: 0;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  border-radius: 6px;
  font-size: 14px;
}
.pdf-pro-tab-action:hover { background: rgba(255,255,255,0.1); color: white; }

/* TOOLBAR */
.pdf-pro-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--line-soft);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.pdf-pro-toolbar-section {
  display: flex;
  align-items: center;
  gap: 4px;
}
.pdf-pro-toolbar-section + .pdf-pro-toolbar-section {
  border-left: 1px solid var(--line-soft);
  padding-left: 12px;
}
.pdf-pro-tools { gap: 2px; }
.pdf-pro-tool {
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
  color: var(--ink-soft);
}
.pdf-pro-tool:hover {
  background: var(--bg);
  color: var(--ink);
}
.pdf-pro-tool.active {
  background: var(--gold, #B8860B);
  color: white;
  border-color: var(--gold, #B8860B);
}
.pdf-pro-tool:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.pdf-pro-tool-icon { line-height: 1; }
.pdf-pro-tbtn {
  background: transparent;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 13px;
}
.pdf-pro-tbtn:hover:not(:disabled) {
  background: var(--bg);
  color: var(--ink);
}
.pdf-pro-tbtn:disabled { opacity: 0.4; cursor: not-allowed; }
.pdf-pro-zoom-label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink);
  min-width: 50px;
  text-align: center;
  padding: 0 4px;
}

/* SUB-TOOLBAR */
.pdf-pro-subtoolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  background: linear-gradient(135deg, #FBE9D8, #F5DCC2);
  border-bottom: 1px solid #E5C898;
  flex-shrink: 0;
  flex-wrap: wrap;
  font-size: 12.5px;
}
.pdf-pro-subtoolbar-hint {
  color: #6B4218;
  flex: 1;
  min-width: 200px;
}
.pdf-pro-subtoolbar-hint strong { color: #5A3712; }
.pdf-pro-subtoolbar-props {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.pdf-pro-subprop {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pdf-pro-subprop-label {
  font-size: 11.5px;
  color: var(--ink-soft);
  font-family: var(--font-mono);
}
.pdf-pro-subprop-value {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-mute);
  min-width: 28px;
}
.pdf-pro-color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.15);
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s;
}
.pdf-pro-color-swatch:hover { transform: scale(1.1); }
.pdf-pro-color-swatch.active {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px white, 0 0 0 4px var(--gold, #B8860B);
}

/* LAYOUT PRINCIPAL */
.pdf-pro-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 220px 1fr;
  overflow: hidden;
  min-height: 0;
}
.pdf-pro-sidebar-left {
  background: var(--bg-elevated);
  border-right: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.pdf-pro-sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--line-soft);
  padding: 4px;
  gap: 2px;
}
.pdf-pro-sidebar-tab {
  flex: 1;
  padding: 8px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: var(--ink-soft);
}
.pdf-pro-sidebar-tab:hover { background: var(--bg); }
.pdf-pro-sidebar-tab.active {
  background: var(--bg);
  color: var(--ink);
  font-weight: 500;
}
.pdf-pro-sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}
.pdf-pro-sidebar-title {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-mute);
  margin-bottom: 10px;
  padding: 4px 6px;
}

/* THUMBNAILS */
.pdf-pro-thumbs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pdf-pro-thumb {
  background: var(--bg);
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  overflow: hidden;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.pdf-pro-thumb:hover { border-color: var(--ink-mute); }
.pdf-pro-thumb.active { border-color: var(--gold, #B8860B); }
.pdf-pro-thumb.deleted { opacity: 0.4; cursor: not-allowed; }
.pdf-pro-thumb.dragging { opacity: 0.4; }
.pdf-pro-thumb.drag-target {
  border-color: var(--accent);
  transform: scale(1.02);
}
.pdf-pro-thumb-num {
  font-family: var(--font-mono);
  font-size: 10px;
  text-align: center;
  padding: 3px;
  background: rgba(0,0,0,0.04);
  color: var(--ink-mute);
}
.pdf-pro-thumb-canvas-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  padding: 4px;
}
.pdf-pro-thumb-canvas-wrap canvas {
  max-width: 100%;
  max-height: 200px;
  display: block;
}
.pdf-pro-thumb-overlay {
  position: absolute;
  inset: 0;
  background: rgba(184,68,44,0.5);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
}
.pdf-pro-thumb-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--gold, #B8860B);
  color: white;
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 600;
}
.pdf-pro-thumb-actions {
  display: flex;
  border-top: 1px solid var(--line-soft);
}
.pdf-pro-thumb-actions button {
  flex: 1;
  background: transparent;
  border: 0;
  padding: 4px;
  cursor: pointer;
  font-size: 12px;
  color: var(--ink-soft);
}
.pdf-pro-thumb-actions button:hover { background: rgba(0,0,0,0.05); color: var(--ink); }
.pdf-pro-thumb-actions button + button { border-left: 1px solid var(--line-soft); }

/* SEARCH SIDEBAR */
.pdf-pro-search-box {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
  background: var(--bg);
  border-radius: 6px;
  padding: 4px 6px;
}
.pdf-pro-search-box input {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 6px;
  font-size: 13px;
  outline: none;
}
.pdf-pro-search-box button {
  background: transparent;
  border: 0;
  cursor: pointer;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: var(--ink-mute);
}
.pdf-pro-search-box button:hover { background: rgba(0,0,0,0.05); color: var(--ink); }
.pdf-pro-search-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}
.pdf-pro-search-controls button {
  width: 30px;
  height: 28px;
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  color: var(--ink-soft);
}
.pdf-pro-search-controls button:hover:not(:disabled) { background: var(--bg-elevated); color: var(--ink); }
.pdf-pro-search-controls button:disabled { opacity: 0.4; cursor: not-allowed; }
.pdf-pro-search-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-soft);
  flex: 1;
  text-align: center;
}
.pdf-pro-search-results {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pdf-pro-search-result {
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 12px;
}
.pdf-pro-search-result:hover { background: var(--bg-elevated); }
.pdf-pro-search-result.active {
  background: var(--gold, #B8860B);
  color: white;
}
.pdf-pro-search-result.active .pdf-pro-search-result-page,
.pdf-pro-search-result.active .pdf-pro-search-result-text { color: white; }
.pdf-pro-search-result-page {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-mute);
  margin-bottom: 2px;
}
.pdf-pro-search-result-text {
  color: var(--ink);
  font-size: 11.5px;
  line-height: 1.4;
  word-break: break-word;
}

/* ANNOTATIONS SIDEBAR */
.pdf-pro-annotations-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pdf-pro-annotation-item {
  display: grid;
  grid-template-columns: 28px 1fr 24px;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
}
.pdf-pro-annotation-item:hover { background: var(--bg-elevated); }
.pdf-pro-annotation-icon {
  font-size: 16px;
  text-align: center;
}
.pdf-pro-annotation-info { min-width: 0; }
.pdf-pro-annotation-type {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
}
.pdf-pro-annotation-page {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-mute);
}
.pdf-pro-annotation-text {
  font-size: 11px;
  color: var(--ink-soft);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.pdf-pro-annotation-delete {
  width: 22px;
  height: 22px;
  border: 0;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  color: var(--ink-mute);
  font-size: 14px;
}
.pdf-pro-annotation-delete:hover {
  background: rgba(184,68,44,0.15);
  color: var(--accent);
}
.pdf-pro-empty-mini {
  text-align: center;
  padding: 30px 10px;
  color: var(--ink-mute);
  font-size: 12px;
  font-style: italic;
}

/* VIEWER */
.pdf-pro-viewer {
  background: #4a4a4a;
  overflow: auto;
  padding: 24px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
.pdf-pro-page {
  background: white;
  box-shadow: 0 6px 30px rgba(0,0,0,0.4);
  margin: 0 auto;
  position: relative;
}
.pdf-pro-page-deleted {
  padding: 60px 40px;
  text-align: center;
  color: rgba(255,255,255,0.7);
  font-style: italic;
}

/* TextLayer (from PDF.js) — selección dorada */
.textLayer ::selection {
  background: rgba(184, 134, 11, 0.4);
}
.textLayer ::-moz-selection {
  background: rgba(184, 134, 11, 0.4);
}

#pdf-pro-page-container[data-tool="select"] .textLayer { cursor: text; }
#pdf-pro-page-container[data-tool="edit"] .textLayer { pointer-events: none; }
#pdf-pro-page-container[data-tool="redact-white"],
#pdf-pro-page-container[data-tool="redact-black"],
#pdf-pro-page-container[data-tool="highlight"],
#pdf-pro-page-container[data-tool="underline"],
#pdf-pro-page-container[data-tool="strikethrough"],
#pdf-pro-page-container[data-tool="shape-rect"],
#pdf-pro-page-container[data-tool="shape-circle"],
#pdf-pro-page-container[data-tool="shape-arrow"],
#pdf-pro-page-container[data-tool="pen"] { cursor: crosshair; }
#pdf-pro-page-container[data-tool="text-add"],
#pdf-pro-page-container[data-tool="image"],
#pdf-pro-page-container[data-tool="signature"] { cursor: copy; }
#pdf-pro-page-container[data-tool="eraser"] .pdf-pro-annotation { cursor: pointer; }

/* Annotation layer */
.pdf-pro-annotation-layer {
  position: absolute;
  inset: 0;
}
.pdf-pro-annotation { box-sizing: border-box; }
.pdf-pro-annotation.type-edit-text-mu::after {
  content: '✏';
  position: absolute;
  top: -16px;
  right: -2px;
  font-size: 10px;
  background: var(--gold, #B8860B);
  color: white;
  padding: 1px 4px;
  border-radius: 3px;
}

.pdf-pro-search-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Edit markers (modo edit) */
.pdf-pro-edit-markers { position: absolute; inset: 0; }
.pdf-pro-edit-marker {
  position: absolute;
  background: rgba(184,134,11,0.10);
  border: 1px dashed rgba(184,134,11,0.4);
  cursor: text;
  border-radius: 2px;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.pdf-pro-edit-marker:hover {
  background: rgba(184,134,11,0.25);
  border-color: rgba(184,134,11,0.7);
}
.pdf-pro-edit-warning {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(184,134,11,0.95);
  color: white;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  z-index: 5;
}

/* Line editor popup (edit text) */
.pdf-pro-line-editor {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: white;
  border: 2px solid var(--gold, #B8860B);
  border-radius: 6px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.2);
  z-index: 10;
}
.pdf-pro-line-editor input.text {
  border: 0;
  outline: 0;
  padding: 4px 6px;
  background: transparent;
  font-family: Helvetica, Arial, sans-serif;
  flex: 1;
  min-width: 200px;
}
.pdf-pro-line-editor input.font {
  width: 60px;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  font-family: var(--font-mono);
}
.pdf-pro-line-editor button {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}
.pdf-pro-line-editor button.ok { background: var(--success, #2D4F3C); color: white; }
.pdf-pro-line-editor button.cancel { background: rgba(184,68,44,0.1); color: var(--accent); }

/* Text-add popup */
.pdf-pro-text-popup {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: white;
  border: 2px solid var(--gold, #B8860B);
  border-radius: 6px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.2);
  z-index: 10;
}
.pdf-pro-text-popup input {
  border: 1px solid var(--line-soft);
  outline: 0;
  padding: 6px 8px;
  border-radius: 4px;
  flex: 1;
  min-width: 200px;
  font-size: 13px;
}
.pdf-pro-text-popup button {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}
.pdf-pro-text-popup button.ok { background: var(--success, #2D4F3C); color: white; }
.pdf-pro-text-popup button.cancel { background: rgba(184,68,44,0.1); color: var(--accent); }

/* Drawing preview */
.pdf-pro-drawing-preview {
  pointer-events: none;
}

/* Signature canvas */
.pdf-pro-sig-canvas-wrap {
  position: relative;
  border: 2px dashed var(--line-soft);
  border-radius: 6px;
  background: white;
  margin: 10px 0;
}
.pdf-pro-sig-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 200px;
  cursor: crosshair;
  touch-action: none;
}
.pdf-pro-sig-baseline {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(0,0,0,0.15);
  font-size: 14px;
  font-style: italic;
  pointer-events: none;
}

/* STATUS BAR */
.pdf-pro-statusbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 6px 16px;
  background: var(--ink);
  color: rgba(255,255,255,0.85);
  font-family: var(--font-mono);
  font-size: 11px;
  flex-shrink: 0;
}
.pdf-pro-statusbar strong { color: white; }
.pdf-pro-statusbar .ok { color: #6FB87B; }
.pdf-pro-statusbar .err { color: #F47B5C; }
.pdf-pro-statusbar .warn { color: #F4D766; }

/* Responsive */
@media (max-width: 720px) {
  .pdf-pro-layout { grid-template-columns: 1fr; }
  .pdf-pro-sidebar-left { display: none; }
  .pdf-pro-toolbar { gap: 6px; padding: 6px 8px; }
  .pdf-pro-tool { width: 32px; height: 32px; font-size: 14px; }
}

/* ============================================================
   FIX UI — estabilización de layout
   ============================================================ */

/* Imágenes dentro de tarjetas: dimensiones predecibles para que
   no provoquen reflow al cargarse */
.asset-card-thumb,
.asset-card img,
.kanban-card img,
.warranty-card img,
.note-img-grid img,
.diary-attachment img,
.wishlist-card-thumb,
.tracker-thumb,
.package-card-img {
  contain: layout;
  max-width: 100%;
}
.asset-card-thumb img,
.wishlist-card-thumb img,
.tracker-thumb img,
.package-card-img img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Fix: title nativos del navegador en elementos pequeños generan
   tooltips amplios. Convertimos los tooltips críticos en
   tooltip CSS con posicionamiento controlado. */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  font-family: var(--font-sans);
  font-size: 11px;
  padding: 5px 9px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  max-width: 280px;
  text-overflow: ellipsis;
  overflow: hidden;
}
[data-tooltip]:hover::after { opacity: 1; }

/* Fix: contenedores de listas que crecen continuamente.
   Si el contenido es dinámico, asegurar que el padre tenga
   contain:layout para aislar el reflow */
.kpi-grid, .asset-grid, .markets-grid,
.kanban-cards, .warranty-grid, .files-grid,
.ipmgr-grid, .project-list, .invoice-list {
  contain: layout style;
}

/* Fix: prevenir que tarjetas con elementos dinámicos
   (precios cambiantes, sparklines) provoquen saltos */
.kpi, .market-card, .stock-card, .crypto-card,
.tracker-card, .package-card, .wishlist-card {
  contain: layout style;
}

/* Fix: sparklines con altura fija obligatoria */
.sparkline, .market-sparkline svg, .tracker-sparkline svg {
  display: block;
  height: 32px;
  width: 100%;
}

/* Fix: inputs y selects con tamaño consistente para no
   producir reflow al focus/blur */
.form-group input,
.form-group select,
.form-group textarea {
  box-sizing: border-box;
}

/* Fix: dropdowns / datalists nativos con max-height
   para no expandir el viewport */
datalist option { max-width: 400px; }

/* Fix: tooltips nativos en elementos con data-tooltip
   no se solapan con el tooltip del navegador */
[data-tooltip][title] { /* prefer data-tooltip */ }

/* Fix: notificaciones de toast no se solapan con sidebar */
@media (max-width: 1280px) {
  .toast-container { right: 16px; bottom: 16px; max-width: calc(100vw - 32px); }
}

/* Fix: scrollbars custom para no afectar al ancho
   del contenido cuando aparecen/desaparecen */
.view-container,
.modal-body,
.pdf-pro-viewer,
.pdf-pro-sidebar-content {
  scrollbar-gutter: stable;
}

/* Fix: cards interactivas que cambian fondo al hover
   no deben mover el contenido */
.kanban-card, .warranty-card, .file-card,
.invoice-row, .quote-row, .client-row,
.project-card, .asset-card, .market-card,
.kpi, .stat-card {
  will-change: auto;
}


/* ============================================================
   COMMAND PALETTE (Ctrl+K)
   ============================================================ */
.cmd-palette-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,15,15,0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1500;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 12vh;
  animation: cmdPaletteFadeIn 0.18s ease;
}
@keyframes cmdPaletteFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.cmd-palette {
  width: min(640px, 92vw);
  max-height: 70vh;
  background: var(--bg-paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: cmdPaletteSlideIn 0.22s cubic-bezier(0.2,0.8,0.2,1);
}
@keyframes cmdPaletteSlideIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.cmd-palette-search {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.cmd-palette-icon {
  font-size: 18px;
  opacity: 0.6;
}
.cmd-palette-search input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 16px;
  font-family: var(--font-sans);
  color: var(--ink);
}
.cmd-palette-search input::placeholder { color: var(--ink-mute); }
.cmd-palette-esc {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-elevated);
  color: var(--ink-mute);
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--line-soft);
}
.cmd-palette-results {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}
.cmd-palette-group-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-mute);
  padding: 10px 18px 4px;
  font-weight: 500;
}
.cmd-palette-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  cursor: pointer;
  transition: background 0.12s;
}
.cmd-palette-item:hover, .cmd-palette-item.selected {
  background: var(--bg-elevated);
}
.cmd-palette-item.selected {
  background: rgba(184,134,11,0.08);
}
.cmd-palette-item-icon {
  font-size: 18px;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}
.cmd-palette-item-body { flex: 1; min-width: 0; }
.cmd-palette-item-label {
  font-size: 14px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmd-palette-item-sub {
  font-size: 12px;
  color: var(--ink-mute);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmd-palette-item-hint {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-elevated);
  color: var(--ink-mute);
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid var(--line-soft);
}
.cmd-palette-mark {
  background: rgba(184,134,11,0.25);
  color: var(--ink);
  font-weight: 500;
  border-radius: 2px;
  padding: 0 1px;
}
.cmd-palette-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--ink-soft);
}
.cmd-palette-footer {
  display: flex;
  gap: 14px;
  padding: 10px 18px;
  border-top: 1px solid var(--line-soft);
  background: var(--bg-elevated);
  font-size: 11px;
  color: var(--ink-mute);
  align-items: center;
}
.cmd-palette-footer kbd {
  font-family: var(--font-mono);
  background: var(--bg-paper);
  color: var(--ink);
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid var(--line-soft);
  font-size: 10px;
  margin-right: 4px;
}
.cmd-palette-count {
  margin-left: auto;
  font-family: var(--font-mono);
}

@media (max-width: 600px) {
  .cmd-palette-overlay { padding-top: 4vh; }
  .cmd-palette { width: 95vw; max-height: 90vh; }
}

/* ============================================================
   DARK MODE — override de variables CSS
   ============================================================ */
:root[data-theme="dark"] {
  --bg-base:        #1A1815;
  --bg-paper:       #211E1A;
  --bg-card:        #25221E;
  --bg-elevated:    #1F1C18;
  --ink:            #F1EBE0;
  --ink-soft:       #DDD3BE;
  --ink-mute:       #9A9180;
  --ink-faint:      #6B6356;
  --line:           #3A342C;
  --line-soft:      #2A251F;

  --accent:         #D9624A;
  --accent-deep:    #B8442C;
  --accent-soft:    #5B2418;
  --forest:         #6FA77F;
  --forest-soft:    #4A6F58;
  --gold:           #DAA520;
  --gold-soft:      #B8860B;
  --plum:           #8B5A8A;
  --ocean:          #5A8FB8;

  --success:        #5FA371;
  --warning:        #DAA520;
  --danger:         #C5544D;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px -4px rgba(0,0,0,0.4), 0 2px 4px rgba(0,0,0,0.2);
  --shadow-lg: 0 18px 40px -12px rgba(0,0,0,0.6), 0 4px 12px rgba(0,0,0,0.3);
}

/* Forzar background base en dark mode */
:root[data-theme="dark"] body {
  background: var(--bg-base);
  color: var(--ink);
}

/* Imágenes en dark mode: ligero atenuado */
:root[data-theme="dark"] img:not(.no-darken) {
  filter: brightness(0.92);
}

/* PDF viewer en dark mode */
:root[data-theme="dark"] .pdf-pro-viewer {
  background: #0F0E0C;
}

/* Inputs en dark mode con borde más visible */
:root[data-theme="dark"] input,
:root[data-theme="dark"] textarea,
:root[data-theme="dark"] select {
  background: var(--bg-elevated);
  color: var(--ink);
  border-color: var(--line);
}
:root[data-theme="dark"] input:focus,
:root[data-theme="dark"] textarea:focus,
:root[data-theme="dark"] select:focus {
  border-color: var(--gold);
  outline: none;
  box-shadow: 0 0 0 3px rgba(218,165,32,0.15);
}

/* Botón flotante de toggle dark/light */
.theme-toggle-btn {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-paper);
  border: 1px solid var(--line);
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  z-index: 50;
  transition: background 0.2s, transform 0.2s;
}
.theme-toggle-btn:hover {
  background: var(--bg-elevated);
}
.theme-toggle-btn:active {
  transform: scale(0.92);
}


/* ============================================================
   AYUDA DE ATAJOS
   ============================================================ */
.shortcuts-help-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,15,15,0.55);
  backdrop-filter: blur(6px);
  z-index: 1500;
  display: flex;
  justify-content: center;
  align-items: center;
  animation: cmdPaletteFadeIn 0.18s;
}
.shortcuts-help {
  width: min(580px, 92vw);
  max-height: 85vh;
  background: var(--bg-paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.shortcuts-help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line-soft);
}
.shortcuts-help-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
}
.shortcuts-help-close {
  width: 32px; height: 32px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 22px;
  color: var(--ink-mute);
  border-radius: 50%;
}
.shortcuts-help-close:hover {
  background: var(--bg-elevated);
  color: var(--ink);
}
.shortcuts-help-body {
  padding: 20px 22px;
  overflow-y: auto;
}
.shortcuts-section {
  margin-bottom: 22px;
}
.shortcuts-section h3 {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-mute);
  margin: 0 0 10px;
  font-weight: 500;
}
.shortcut-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  align-items: center;
  padding: 6px 0;
  gap: 10px;
}
.shortcut-row kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-elevated);
  color: var(--ink);
  padding: 3px 8px;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  margin-right: 4px;
}
.shortcut-row span {
  color: var(--ink-soft);
  font-size: 13px;
}

/* ============================================================
   INDICADOR DE GUARDADO
   ============================================================ */
.save-indicator {
  position: fixed;
  top: 16px;
  right: 16px;
  background: var(--bg-paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12px;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 200;
}
.save-indicator.show {
  opacity: 1;
  transform: translateY(0);
}
.save-indicator.saved {
  border-color: var(--success);
  color: var(--success);
}
.save-indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  animation: pulse 1.4s ease-in-out infinite;
}
.save-indicator-check {
  color: var(--success);
  font-weight: 600;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ============================================================
   FIX FINAL: prevenir saltos de layout en cards
   ============================================================ */

/* Las imágenes con object-fit:cover no expanden el padre */
img {
  max-width: 100%;
  height: auto;
}

/* Prevenir que los textos largos rompan el layout */
.kpi-value,
.market-card-name,
.asset-card-name,
.invoice-row td,
.client-row td,
.kanban-card-title {
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Prevenir que tablas explotan en mobile */
table {
  table-layout: auto;
}
table.fixed { table-layout: fixed; }

/* Skeleton placeholders para listas que cargan datos asincronos */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-elevated) 0%,
    var(--bg) 50%,
    var(--bg-elevated) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s infinite;
  border-radius: var(--r-sm, 4px);
}
@keyframes skeleton-shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}


/* ============================================================
   PAGINACIÓN — listas escalables (1000+ items)
   ============================================================ */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--line-soft);
  font-size: 12.5px;
  color: var(--ink-soft);
  flex-wrap: wrap;
  gap: 12px;
}
.pagination-info strong { color: var(--ink); font-family: var(--font-mono); }
.pagination-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}
.pagination-current {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 0 12px;
  color: var(--ink);
}
.pagination-controls button:disabled { opacity: 0.4; cursor: not-allowed; }
@media (max-width: 600px) {
  .pagination { flex-direction: column; align-items: stretch; }
  .pagination-info { text-align: center; }
  .pagination-controls { justify-content: center; }
}

/* ============================================================
   PERSONAL HOUSE — Compra de vivienda
   ============================================================ */

/* Tabs de secciones */
.house-tabs {
  display: flex;
  gap: 4px;
  margin: 18px 0 14px;
  background: var(--bg-elevated);
  padding: 6px;
  border-radius: var(--r-md, 10px);
  flex-wrap: wrap;
}
.house-tab {
  flex: 1;
  min-width: 130px;
  padding: 10px 14px;
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s, color 0.15s;
}
.house-tab:hover {
  color: var(--ink);
  background: var(--bg-paper);
}
.house-tab.active {
  background: var(--bg-paper);
  color: var(--ink);
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.house-tab-icon { font-size: 16px; }

/* Barra de progreso */
.house-progress-wrap {
  padding: 16px 4px 4px;
}
.house-progress-bar {
  height: 14px;
  background: var(--bg-elevated);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--line-soft);
}
.house-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold, #B8860B), var(--success, #2D4F3C));
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.house-progress-marker {
  position: absolute;
  top: -4px;
  width: 22px;
  height: 22px;
  background: white;
  border: 3px solid var(--gold, #B8860B);
  border-radius: 50%;
  transform: translateX(-50%);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.house-progress-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  font-size: 12px;
  color: var(--ink-mute);
}

/* Stats de ahorros */
.savings-stat {
  background: var(--bg-elevated);
  padding: 14px;
  border-radius: var(--r-md, 8px);
  text-align: center;
}
.savings-stat-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-mute);
  margin-bottom: 6px;
}
.savings-stat-value {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 500;
  color: var(--ink);
}

/* Mini-cards en overview */
.house-mini-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  padding-top: 8px;
}
.house-mini-card {
  background: var(--bg-elevated);
  padding: 14px;
  border-radius: var(--r-md, 8px);
  border-left: 3px solid var(--gold, #B8860B);
}
.house-mini-rating {
  color: var(--gold, #B8860B);
  font-size: 13px;
  margin-bottom: 6px;
  letter-spacing: 1px;
}
.house-mini-name {
  font-size: 14px;
  margin-bottom: 6px;
}
.house-mini-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 4px;
}
.house-mini-addr {
  font-size: 11.5px;
  color: var(--ink-mute);
  margin-top: 4px;
}

/* CALCULADORA HIPOTECA */
.mortgage-result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-top: 18px;
}
.mortgage-result {
  background: var(--bg-elevated);
  padding: 18px 20px;
  border-radius: var(--r-md, 8px);
  border-top: 3px solid var(--line);
}
.mortgage-result-primary {
  background: linear-gradient(135deg, rgba(184,134,11,0.08), rgba(45,79,60,0.05));
  border-top-color: var(--gold, #B8860B);
}
.mortgage-result-warn {
  border-top-color: var(--accent);
}
.mortgage-result-label {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-mute);
  margin-bottom: 8px;
}
.mortgage-result-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 500;
  color: var(--ink);
}
.mortgage-result-meta {
  font-size: 12px;
  color: var(--ink-mute);
  margin-top: 6px;
}

/* Comparador de plazos */
.mortgage-compare {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  padding: 14px 0;
}
.mortgage-period {
  background: var(--bg-elevated);
  padding: 14px;
  border-radius: var(--r-md, 8px);
  text-align: center;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.15s;
}
.mortgage-period:hover {
  border-color: var(--ink-mute);
}
.mortgage-period.current {
  border-color: var(--gold, #B8860B);
  background: rgba(184,134,11,0.06);
}
.mortgage-period-years {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-mute);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.mortgage-period-monthly {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  color: var(--ink);
}
.mortgage-period-meta {
  font-size: 11px;
  color: var(--ink-mute);
  margin-bottom: 8px;
}
.mortgage-period-interest {
  font-size: 11px;
  color: var(--accent);
  margin-top: 6px;
}

/* Tabla amortización */
.schedule-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
}
.schedule-bar-fill {
  height: 100%;
  background: var(--success, #2D4F3C);
  border-radius: 999px;
  transition: width 0.4s;
}

/* CASAS GUARDADAS */
.houses-grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  padding: 12px 0;
}
.house-card {
  background: var(--bg-paper);
  border-radius: var(--r-md, 10px);
  border: 1px solid var(--line-soft);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
}
.house-card:hover {
  border-color: var(--gold, #B8860B);
  box-shadow: 0 4px 18px rgba(0,0,0,0.06);
}
.house-card-photo {
  position: relative;
  height: 160px;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
}
.house-card-photo-placeholder {
  font-size: 56px;
  opacity: 0.4;
}
.house-card-rating {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0,0,0,0.55);
  color: var(--gold, #FFD93D);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 1px;
}
.house-card-status {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}
.house-card-status.status-shortlist {
  background: rgba(45,122,62,0.9);
  color: white;
}
.house-card-status.status-discarded {
  background: rgba(154,145,128,0.9);
  color: white;
}
.house-card-status.status-visited {
  background: rgba(184,134,11,0.9);
  color: white;
}
.house-card-status.status-considered {
  background: rgba(90,143,184,0.9);
  color: white;
}
.house-card-body {
  padding: 14px 16px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.house-card-title {
  font-family: var(--font-display);
  font-size: 16px;
  margin: 0 0 4px;
  font-weight: 500;
  color: var(--ink);
}
.house-card-addr {
  font-size: 12px;
  color: var(--ink-mute);
  margin-bottom: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.house-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 12.5px;
  color: var(--ink-soft);
}
.house-card-stat strong {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--ink);
}
.house-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
}
.house-tag {
  background: var(--bg-elevated);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  color: var(--ink-soft);
  border: 1px solid var(--line-soft);
}
.house-card-actions {
  display: flex;
  gap: 6px;
  margin-top: auto;
  flex-wrap: wrap;
}

/* Estrellas de valoración (input) */
.rating-input {
  display: flex;
  gap: 4px;
}
.rating-star {
  width: 36px;
  height: 36px;
  border: 0;
  background: var(--bg-elevated);
  cursor: pointer;
  font-size: 22px;
  color: var(--line);
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.rating-star:hover {
  background: var(--bg-paper);
}
.rating-star.active {
  color: var(--gold, #B8860B);
}

/* DETALLE CASA */
.house-detail-photos {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 18px;
  padding-bottom: 8px;
}
.house-detail-photos img {
  height: 200px;
  width: auto;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}
.house-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 14px;
}
.house-detail-section {
  margin: 14px 0;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border-radius: var(--r-md, 8px);
}
.house-detail-section strong {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
}
.house-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin: 14px 0;
}
.house-detail-stat {
  background: var(--bg-elevated);
  padding: 10px 12px;
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}
.house-detail-stat span {
  color: var(--ink-mute);
  font-size: 12px;
}
.house-detail-list {
  margin: 0;
  padding-left: 20px;
  line-height: 1.7;
}
.house-detail-list li {
  font-size: 13.5px;
  color: var(--ink);
}

/* MAPA */
.house-map-container {
  height: 600px;
  border-radius: var(--r-md, 8px);
  overflow: hidden;
  background: var(--bg-elevated);
  margin-top: 14px;
}
/* Marcadores custom */
.house-map-marker { background: transparent !important; border: 0 !important; }
.house-marker-pin {
  width: 36px;
  height: 36px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid white;
  box-shadow: 0 3px 10px rgba(0,0,0,0.3);
}
.house-marker-pin span {
  transform: rotate(45deg);
  font-size: 16px;
}

/* Popup en mapa */
.leaflet-popup-content-wrapper {
  border-radius: var(--r-md, 10px) !important;
  padding: 0 !important;
}
.leaflet-popup-content {
  margin: 0 !important;
  width: 280px !important;
}
.house-popup {
  border-radius: var(--r-md, 10px);
  overflow: hidden;
}
.house-popup-photo {
  height: 140px;
  background-color: #ddd;
}
.house-popup-body {
  padding: 12px 14px;
}
.house-popup-rating {
  color: #B8860B;
  font-size: 13px;
  letter-spacing: 1px;
  margin-bottom: 4px;
}
.house-popup-title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
  color: #2A2520;
}
.house-popup-addr {
  font-size: 12px;
  color: #6B6356;
  margin-bottom: 8px;
}
.house-popup-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 12px;
  color: #4A4540;
  margin-bottom: 8px;
}
.house-popup-price {
  font-size: 16px;
  font-weight: 600;
  color: #2A2520;
}
.house-popup-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}
.house-popup-tags .house-tag {
  background: rgba(0,0,0,0.04);
  font-size: 10.5px;
  padding: 2px 6px;
}
.house-popup-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  border-top: 1px solid #eee;
  padding-top: 10px;
}
.house-popup-actions a, .house-popup-actions button {
  padding: 6px 12px;
  border-radius: 5px;
  border: 0;
  background: #B8860B;
  color: white;
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
  flex: 1;
  text-align: center;
}
.house-popup-actions a:hover, .house-popup-actions button:hover {
  background: #9A7008;
}
.house-popup-actions button {
  background: #f0ece4;
  color: #2A2520;
}
.house-popup-actions button:hover {
  background: #e0dccc;
}

/* Responsive */
@media (max-width: 720px) {
  .house-tabs { padding: 4px; }
  .house-tab { min-width: auto; padding: 8px 10px; font-size: 12px; }
  .house-tab span:not(.house-tab-icon) { display: none; }
  .houses-grid-cards { grid-template-columns: 1fr; }
  .house-map-container { height: 450px; }
}

/* ============================================================
   DATA HEALTH — Auditoría de salud
   ============================================================ */
.dh-findings-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.dh-finding {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 14px;
  padding: 14px;
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  border: 1px solid var(--line-soft);
}
.dh-finding-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  background: var(--bg-paper);
}
.dh-finding-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  margin-bottom: 4px;
}
.dh-finding-message {
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.5;
  margin-bottom: 8px;
}
.dh-finding-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.dh-finding-item {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  background: var(--bg-paper);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  font-size: 11.5px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-mono);
  transition: background 0.15s, border-color 0.15s;
}
.dh-finding-item:hover {
  background: var(--bg);
  border-color: var(--ink-mute);
}
.dh-finding-more {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 11.5px;
  color: var(--ink-mute);
  font-style: italic;
}

/* ============================================================
   COMPARADOR DE HIPOTECAS
   ============================================================ */
.mortgage-compare-grid {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}
@media (max-width: 900px) {
  .mortgage-compare-grid {
    grid-template-columns: 1fr !important;
  }
}
.mortgage-compare-card {
  background: var(--bg-paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.mortgage-compare-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.mortgage-compare-bank {
  flex: 1;
  border: 0;
  background: transparent;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  color: var(--ink);
  padding: 4px 0;
  border-bottom: 2px solid var(--line-soft);
  outline: none;
}
.mortgage-compare-bank:focus {
  border-bottom-color: var(--gold);
}
.mortgage-compare-remove {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-mute);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.mortgage-compare-remove:hover {
  background: rgba(184,68,44,0.1);
  color: var(--accent);
  border-color: var(--accent);
}
.mortgage-compare-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.mortgage-compare-fields label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mortgage-compare-fields label span {
  font-size: 10.5px;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: var(--font-mono);
}
.mortgage-compare-fields input {
  padding: 5px 8px;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  font-size: 13px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  background: var(--bg);
  color: var(--ink);
}
.mortgage-compare-fields input:focus {
  outline: none;
  border-color: var(--gold);
}
.mortgage-compare-results {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mortgage-compare-cuota {
  text-align: center;
  margin-bottom: 8px;
  padding: 10px;
  background: var(--bg);
  border-radius: 6px;
}
.mortgage-compare-cuota .lbl {
  font-size: 10.5px;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: var(--font-mono);
}
.mortgage-compare-cuota .val {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 500;
  color: var(--ink);
  margin-top: 4px;
}
.mortgage-compare-stat {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 3px 0;
}
.mortgage-compare-stat span {
  color: var(--ink-soft);
}
.mortgage-compare-stat strong {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.mortgage-compare-total {
  display: flex;
  justify-content: space-between;
  padding-top: 10px;
  margin-top: 6px;
  border-top: 2px solid var(--line);
  font-size: 13px;
}
.mortgage-compare-total span {
  color: var(--ink);
  font-weight: 600;
  letter-spacing: 0.04em;
}
.mortgage-compare-total strong {
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--accent);
}

/* ============================================================
   GENERADOR DE INFORMES PDF
   ============================================================ */
.reports-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
@media (max-width: 600px) {
  .reports-grid { grid-template-columns: 1fr; }
}
.report-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  text-align: left;
  padding: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-family: inherit;
  width: 100%;
}
.report-card:hover {
  border-color: var(--gold);
  background: var(--bg-paper);
}
.report-icon {
  font-size: 28px;
  flex-shrink: 0;
}
.report-body {
  flex: 1;
  min-width: 0;
}
.report-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 4px;
}
.report-desc {
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.5;
}

/* ============================================================
   TAGS — Sistema de etiquetas global
   ============================================================ */
.tags-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.tag-card {
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}
.tag-card:hover {
  border-color: var(--gold);
  background: var(--bg-paper);
}
.tag-card-name {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--ink);
  font-weight: 500;
  margin-bottom: 4px;
}
.tag-card-count {
  font-size: 11px;
  color: var(--ink-mute);
  margin-bottom: 8px;
}
.tag-card-stores {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--ink-soft);
}
.tag-card-store {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  background: var(--bg);
  border-radius: 999px;
  font-family: var(--font-mono);
}
.tag-card-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}
.tag-card:hover .tag-card-actions { opacity: 1; }
.tag-card-actions button {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--line-soft);
  cursor: pointer;
  font-size: 11px;
  color: var(--ink-mute);
}
.tag-card-actions button:hover {
  background: var(--bg-paper);
  color: var(--ink);
}

.tag-detail-groups {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.tag-detail-group-header {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line-soft);
}
.tag-detail-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tag-detail-item {
  padding: 4px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  font-size: 12px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-mono);
}
.tag-detail-item:hover {
  background: var(--bg-paper);
  border-color: var(--gold);
}

/* ============================================================
   PRESENTATION MODE — pantalla completa
   ============================================================ */
.pres-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-base);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  animation: presFadeIn 0.3s ease;
}
@keyframes presFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.pres-loading {
  text-align: center;
}
.pres-close {
  position: fixed;
  top: 24px;
  right: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  color: var(--ink);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}
.pres-close:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.pres-slide-counter {
  position: fixed;
  top: 24px;
  left: 24px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-mute);
  letter-spacing: 0.1em;
}
.pres-progress {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
}
.pres-progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line);
  transition: background 0.3s;
}
.pres-progress-dot.active {
  background: var(--gold);
  width: 24px;
  border-radius: 4px;
}
.pres-progress-dot.done {
  background: var(--ink-mute);
}
.pres-slide-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 1200px;
}
.pres-slide {
  text-align: center;
  width: 100%;
  animation: presSlideIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes presSlideIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.pres-eyebrow {
  font-family: var(--font-mono);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--ink-mute);
  margin-bottom: 18px;
}
.pres-title-slide {
  text-align: center;
}
.pres-title-big {
  font-family: var(--font-display);
  font-size: clamp(80px, 16vw, 200px);
  font-weight: 300;
  line-height: 0.9;
  color: var(--gold);
  letter-spacing: -0.02em;
}
.pres-title-sub {
  font-size: clamp(16px, 2vw, 22px);
  color: var(--ink-soft);
  margin-top: 24px;
}
.pres-metric-huge {
  font-family: var(--font-display);
  font-size: clamp(60px, 10vw, 130px);
  font-weight: 400;
  line-height: 1;
  color: var(--ink);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.pres-metric-mid {
  font-family: var(--font-display);
  font-size: clamp(34px, 5vw, 56px);
  font-weight: 400;
  line-height: 1.1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.pres-metric-sub {
  font-size: clamp(14px, 1.6vw, 20px);
  color: var(--ink-soft);
  margin-top: 14px;
}
.pres-metric-secondary {
  border-top: 1px solid var(--line-soft);
  padding-top: 26px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}
.pres-yoy {
  font-family: var(--font-mono);
  font-size: clamp(18px, 2.4vw, 26px);
  margin-top: 28px;
  font-weight: 500;
}
.pres-yoy.up { color: var(--success); }
.pres-yoy.down { color: var(--accent); }
.pres-bars {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 6px;
  height: 200px;
  align-items: end;
}
.pres-bar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  position: relative;
}
.pres-bar {
  width: 100%;
  background: var(--ocean);
  border-radius: 3px 3px 0 0;
  transition: height 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.pres-bar-value {
  position: absolute;
  top: -22px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--ink-mute);
  white-space: nowrap;
}
.pres-bar-label {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-mute);
}
.pres-controls {
  position: fixed;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 14px;
}
.pres-control {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  color: var(--ink);
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pres-control:hover:not(:disabled) {
  background: var(--gold);
  color: white;
  border-color: var(--gold);
}
.pres-control:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.pres-help {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--ink-mute);
}
.pres-help kbd {
  font-family: var(--font-mono);
  background: var(--bg-elevated);
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid var(--line-soft);
  font-size: 10px;
  margin: 0 2px;
}

/* ============================================================
   CSV IMPORTER
   ============================================================ */
.csv-type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.csv-type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px;
  background: var(--bg-elevated);
  border: 2px solid var(--line-soft);
  border-radius: var(--r-md);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.csv-type-card:hover {
  border-color: var(--gold);
  background: var(--bg-paper);
}
.csv-type-card.active {
  border-color: var(--gold);
  background: rgba(184,134,11,0.06);
}
.csv-type-icon { font-size: 28px; }
.csv-type-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}
.csv-drop-zone {
  border: 2px dashed var(--line);
  border-radius: var(--r-md);
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.csv-drop-zone:hover, .csv-drop-zone.drag-over {
  border-color: var(--gold);
  background: rgba(184,134,11,0.04);
}
.csv-mapping {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 60vh;
  overflow-y: auto;
}
.csv-mapping-row {
  display: grid;
  grid-template-columns: 2fr 3fr;
  gap: 14px;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-radius: var(--r-md);
}
.csv-mapping-label {
  font-size: 13px;
  color: var(--ink);
}
.csv-mapping-select {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg-paper);
  color: var(--ink);
  font-size: 12px;
}
.csv-preview-wrap {
  max-height: 50vh;
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  margin-top: 12px;
}
.csv-preview-table {
  font-size: 11px;
}
.csv-preview-table th {
  position: sticky;
  top: 0;
  background: var(--ink);
  color: var(--bg);
  z-index: 1;
  font-size: 10px;
}
.csv-preview-table td {
  font-family: var(--font-mono);
  padding: 4px 8px;
}

/* ============================================================
   OCR RECEIPTS
   ============================================================ */
.ocr-drop-zone {
  border: 2px dashed var(--line);
  border-radius: var(--r-md);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.ocr-drop-zone:hover, .ocr-drop-zone.drag-over {
  border-color: var(--ocean);
  background: rgba(91,143,184,0.04);
}
.ocr-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ocr-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ocr-field label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-mute);
  font-family: var(--font-mono);
}
.ocr-field input,
.ocr-field select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg-paper);
  color: var(--ink);
  font-size: 13px;
}
.ocr-field-row {
  display: grid;
  grid-template-columns: 1fr 80px 1fr;
  gap: 10px;
}
.ocr-confidence {
  font-size: 10px;
  color: var(--success);
  margin-top: 2px;
}
.ocr-confidence.missing { color: var(--accent); }

/* ============================================================
   FIX GLOBAL DE GRID OVERFLOW
   Los grids con 1fr no contienen su contenido si los hijos
   tienen contenido que excede el ancho. Esto causa que el grid
   "se hinche" hacia los lados o el contenido se salga del flujo.
   minmax(0, 1fr) fuerza al grid a respetar el ancho disponible.
   ============================================================ */
.panel-grid.two-cols {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
}
.panel-grid.two-cols > * { min-width: 0; }

/* Cualquier grid de 1fr 1fr en panel debería contenerse */
.panel [style*="grid-template-columns:1fr 1fr"],
.panel [style*="grid-template-columns: 1fr 1fr"],
.panel [style*="repeat(2, 1fr)"] {
  min-width: 0;
}
.panel [style*="grid-template-columns:1fr 1fr"] > *,
.panel [style*="grid-template-columns: 1fr 1fr"] > *,
.panel [style*="repeat(2, 1fr)"] > * {
  min-width: 0;
}

/* Texto dentro de cualquier KPI o tarjeta no debe expandir el contenedor */
.kpi *, .market-card *, .stat-card *,
.tracker-card *, .package-card *, .wishlist-card *,
.tag-card *, .house-card * {
  min-width: 0;
}
.kpi-value, .market-card-name, .market-card-price,
.stat-card-value, .tracker-name, .wishlist-card-title {
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}

/* ============================================================
   PRÓXIMOS VENCIMIENTOS
   ============================================================ */
.upcoming-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.upcoming-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  border-left: 3px solid var(--line);
  text-decoration: none;
  color: inherit;
  transition: background 0.15s, border-color 0.15s;
  align-items: center;
}
.upcoming-row:hover {
  background: var(--bg-paper);
  border-left-color: var(--gold);
}
.upcoming-row.priority-high {
  border-left-color: var(--accent);
  background: rgba(184,68,44,0.04);
}
.upcoming-row.priority-normal {
  border-left-color: var(--gold);
}
.upcoming-row.priority-low {
  border-left-color: var(--ocean);
}
.upcoming-row.is-overdue {
  border-left-color: var(--accent) !important;
  background: rgba(184,68,44,0.06);
}
.upcoming-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: var(--bg);
  border-radius: 50%;
}
.upcoming-body {
  min-width: 0;
}
.upcoming-title {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.upcoming-meta {
  font-size: 11.5px;
  color: var(--ink-mute);
  margin-top: 2px;
  font-family: var(--font-mono);
}
.upcoming-row.is-overdue .upcoming-meta {
  color: var(--accent);
  font-weight: 500;
}
.upcoming-arrow {
  color: var(--ink-mute);
  font-size: 16px;
  transition: transform 0.15s, color 0.15s;
}
.upcoming-row:hover .upcoming-arrow {
  color: var(--gold);
  transform: translateX(2px);
}

/* ============================================================
   BOTÓN DE NOTIFICACIONES en sidebar / settings
   ============================================================ */
.notif-toggle-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-family: var(--font-mono);
  background: var(--bg-elevated);
}
.notif-toggle-status.on { color: var(--success); }
.notif-toggle-status.off { color: var(--ink-mute); }
.notif-toggle-status.denied { color: var(--accent); }

/* ============================================================
   PLANIFICADOR DE VIAJES
   ============================================================ */

/* Lista de viajes */
.trips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}
.trips-grid > * { min-width: 0; }

.trip-card {
  background: var(--bg-paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  contain: layout style;
}
.trip-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(0,0,0,0.08);
  border-color: var(--gold);
}
.trip-card-cover {
  height: 140px;
  background-size: cover;
  background-position: center;
  background-color: var(--bg-elevated);
  position: relative;
}
.trip-card-cover-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 56px;
  font-weight: 300;
  color: var(--ink-mute);
  background: linear-gradient(135deg, var(--bg-elevated), var(--bg));
}
.trip-card-body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.trip-card-status {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
  align-self: flex-start;
  margin-bottom: 4px;
}
.trip-card-name {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.trip-card-destination {
  font-size: 12.5px;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.trip-card-dates {
  font-size: 12px;
  color: var(--ink-soft);
  font-family: var(--font-mono);
}
.trip-card-countdown {
  display: inline-block;
  padding: 3px 9px;
  background: rgba(184,134,11,0.12);
  color: var(--gold);
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 500;
  font-family: var(--font-mono);
  margin-top: 2px;
  align-self: flex-start;
}
.trip-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 11.5px;
  color: var(--ink-mute);
  font-family: var(--font-mono);
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
}

/* Header del detalle */
.trip-detail-header {
  align-items: flex-start;
}

/* Tabs horizontales */
.trip-tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 2px;
  scrollbar-width: thin;
}
.trip-tabs::-webkit-scrollbar {
  height: 6px;
}
.trip-tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 13px;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.trip-tab:hover {
  color: var(--ink);
}
.trip-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 500;
}
.trip-tab-icon {
  font-size: 14px;
}
.trip-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--ink-mute);
  color: white;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font-mono);
}
.trip-tab.active .trip-tab-badge {
  background: var(--accent);
}

/* Barra de presupuesto */
.trip-budget-bar {
  height: 12px;
  background: var(--bg-elevated);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.trip-budget-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success), var(--gold));
  border-radius: 999px;
  transition: width 0.3s;
}
.trip-budget-fill.over {
  background: linear-gradient(90deg, var(--gold), var(--accent));
}

/* Selector de día (itinerario) */
.trip-day-selector {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 12px;
  margin-bottom: 16px;
  scrollbar-width: thin;
}
.trip-day {
  flex-shrink: 0;
  width: 78px;
  padding: 10px 8px;
  background: var(--bg-elevated);
  border: 2px solid transparent;
  border-radius: var(--r-md);
  cursor: pointer;
  text-align: center;
  position: relative;
  transition: border-color 0.15s, background 0.15s;
}
.trip-day:hover {
  border-color: var(--gold);
}
.trip-day.active {
  background: var(--bg-paper);
  border-color: var(--accent);
}
.trip-day-num {
  font-size: 10px;
  color: var(--ink-mute);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.trip-day-date {
  font-size: 10.5px;
  color: var(--ink-soft);
  margin-top: 2px;
  text-transform: capitalize;
}
.trip-day-num-big {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 500;
  color: var(--ink);
  margin: 4px 0 2px;
  line-height: 1;
}
.trip-day-month {
  font-size: 10px;
  color: var(--ink-mute);
  text-transform: uppercase;
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
}
.trip-day-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
}

/* Eventos por hora */
.timed-events {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.timed-event {
  display: grid;
  grid-template-columns: 70px 1fr auto;
  gap: 14px;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border-left: 3px solid var(--ocean);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  align-items: center;
}
.timed-event > * { min-width: 0; }
.timed-event-time {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 500;
  color: var(--accent);
  text-align: center;
}
.timed-event-title {
  font-weight: 500;
  font-size: 14px;
  color: var(--ink);
}
.timed-event-location, .timed-event-duration {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 3px;
}
.timed-event-notes {
  font-size: 12px;
  color: var(--ink-mute);
  margin-top: 5px;
  font-style: italic;
}
.timed-event-actions {
  display: flex;
  gap: 4px;
}

/* Eventos por bloques */
.trip-block {
  margin-bottom: 16px;
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  overflow: hidden;
}
.trip-block-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-paper);
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--font-display);
}
.trip-block-icon {
  font-size: 18px;
}
.trip-block-label {
  font-weight: 500;
  font-size: 14px;
  color: var(--ink);
}
.trip-block-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-mute);
}
.trip-block-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--ink-mute);
  font-family: var(--font-mono);
}
.trip-block-events {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.trip-block-empty {
  text-align: center;
  padding: 14px;
  color: var(--ink-mute);
  font-size: 12.5px;
  font-style: italic;
}
.trip-event-card {
  background: var(--bg-paper);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  padding: 10px 14px;
  position: relative;
}
.trip-event-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.trip-event-icon {
  font-size: 16px;
}
.trip-event-title {
  flex: 1;
  font-weight: 500;
  font-size: 13.5px;
  color: var(--ink);
  min-width: 0;
}
.trip-event-time {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--accent);
  font-weight: 500;
}
.trip-event-location {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 4px;
}
.trip-event-notes {
  font-size: 12px;
  color: var(--ink-mute);
  margin-top: 4px;
  font-style: italic;
}
.trip-event-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}
.trip-event-card:hover .trip-event-actions,
.timed-event:hover .timed-event-actions,
.trip-freeform-row:hover .trip-event-actions {
  opacity: 1;
}

/* Freeform */
.trip-freeform {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.trip-freeform-row {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-radius: var(--r-sm);
  align-items: center;
  position: relative;
}
.trip-freeform-row > * { min-width: 0; }
.trip-freeform-body {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.trip-freeform-body.completed {
  opacity: 0.5;
  text-decoration: line-through;
}
.trip-freeform-title {
  font-weight: 500;
  font-size: 13.5px;
}
.trip-freeform-location {
  font-size: 12px;
  color: var(--ink-soft);
}

/* Icon picker */
.icon-picker {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
}
.icon-option {
  aspect-ratio: 1;
  background: var(--bg-elevated);
  border: 2px solid transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s;
}
.icon-option:hover {
  background: var(--bg-paper);
}
.icon-option.active {
  border-color: var(--accent);
  background: var(--bg-paper);
}

/* Mapa de viaje */
.trip-map-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  margin-bottom: 12px;
}
.trip-map-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.trip-map-filter {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 11px;
  background: var(--bg-paper);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  cursor: pointer;
  font-size: 11.5px;
  color: var(--ink-soft);
  user-select: none;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.trip-map-filter:hover {
  border-color: var(--ink-mute);
}
.trip-map-filter input {
  display: none;
}
.trip-map-filter.active {
  border-color: var(--filter-color, var(--accent));
  background: rgba(184,68,44,0.08);
  color: var(--ink);
  font-weight: 500;
}
.trip-map-route-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-soft);
  cursor: pointer;
}
.trip-map-wrap {
  position: relative;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--line);
}
.trip-map-canvas {
  width: 100%;
  height: 600px;
  position: relative;
}
.trip-map-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  color: var(--ink-soft);
  font-size: 13px;
  z-index: 1;
}
.trip-map-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 500;
  pointer-events: none;
}

/* Markers personalizados Leaflet */
.trip-map-marker {
  background: transparent !important;
  border: 0 !important;
}
.trip-map-marker-pin {
  width: 38px;
  height: 38px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  position: relative;
}
.trip-map-marker-emoji {
  transform: rotate(45deg);
  font-size: 16px;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.3));
}
.trip-map-marker-num {
  position: absolute;
  top: -4px;
  right: -4px;
  background: white;
  color: var(--ink);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(45deg);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* Popup del mapa */
.leaflet-popup-content-wrapper {
  padding: 0 !important;
  border-radius: var(--r-md) !important;
  overflow: hidden;
}
.leaflet-popup-content {
  margin: 0 !important;
  min-width: 200px;
}
.trip-popup-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  color: white;
}
.trip-popup-icon {
  font-size: 16px;
}
.trip-popup-title {
  font-weight: 500;
  font-size: 13.5px;
}
.trip-popup-body {
  padding: 10px 12px;
  background: var(--bg-paper);
}
.trip-popup-sub {
  font-size: 12px;
  color: var(--ink-soft);
}
.trip-popup-meta {
  font-size: 11.5px;
  color: var(--ink-mute);
  margin-top: 4px;
  font-family: var(--font-mono);
}

/* Lista de items */
.trip-items-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.trip-item-card {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  border-left: 3px solid var(--accent);
  align-items: flex-start;
}
.trip-item-card > * { min-width: 0; }
.trip-item-card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
.trip-item-card-name {
  font-weight: 500;
  font-size: 14px;
  color: var(--ink);
}
.trip-item-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 5px;
  font-size: 12px;
  color: var(--ink-soft);
}
.trip-item-card-tag {
  display: inline-flex;
  padding: 2px 8px;
  background: var(--bg-paper);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  font-size: 11px;
  color: var(--ink-soft);
}
.trip-item-card-confirm {
  margin-top: 6px;
  font-size: 12px;
  color: var(--ink-soft);
  font-family: var(--font-mono);
}
.trip-item-card-notes {
  margin-top: 6px;
  font-size: 12px;
  color: var(--ink-mute);
  font-style: italic;
}
.trip-item-card-url {
  margin-top: 6px;
  font-size: 12px;
}
.trip-item-card-url a {
  color: var(--accent);
  text-decoration: none;
}
.trip-item-card-url a:hover {
  text-decoration: underline;
}
.trip-item-card-actions {
  display: flex;
  gap: 4px;
}

/* Packing */
.trip-packing-progress {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 8px;
}
.trip-packing-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-elevated);
  border-radius: 999px;
  overflow: hidden;
}
.trip-packing-fill {
  height: 100%;
  background: var(--success);
  border-radius: 999px;
  transition: width 0.3s;
}
.trip-packing-count {
  font-size: 12px;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-weight: 500;
}
.trip-packing-group {
  margin-bottom: 16px;
}
.trip-packing-group-header {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 6px;
  text-transform: capitalize;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line-soft);
}
.trip-packing-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.trip-packing-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border-radius: var(--r-sm);
  align-items: center;
  cursor: pointer;
  transition: background 0.15s;
}
.trip-packing-item > * { min-width: 0; }
.trip-packing-item:hover {
  background: var(--bg-paper);
}
.trip-packing-item.checked {
  opacity: 0.55;
}
.trip-packing-item.checked .trip-packing-name {
  text-decoration: line-through;
}
.trip-packing-name {
  font-size: 13px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.trip-packing-notes {
  font-size: 11px;
  color: var(--ink-mute);
  font-style: italic;
}
.trip-packing-item .btn-icon {
  opacity: 0;
  transition: opacity 0.15s;
}
.trip-packing-item:hover .btn-icon {
  opacity: 1;
}

/* Distribución de gastos */
.trip-expense-categories {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}
.trip-expense-cat {
  padding: 0;
}
.trip-expense-cat-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  font-size: 13px;
}
.trip-expense-cat-name {
  text-transform: capitalize;
  color: var(--ink);
  font-weight: 500;
}
.trip-expense-cat-amount {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.trip-expense-cat-bar {
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 999px;
  overflow: hidden;
}
.trip-expense-cat-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ocean), var(--accent));
  border-radius: 999px;
  transition: width 0.3s;
}

/* Botón icono pequeño reutilizable */
.btn-icon {
  width: 26px;
  height: 26px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  color: var(--ink-mute);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-icon:hover {
  background: var(--bg-elevated);
  border-color: var(--line-soft);
  color: var(--ink);
}

/* Responsive */
@media (max-width: 720px) {
  .trip-tabs {
    margin-left: -16px;
    margin-right: -16px;
    padding-left: 16px;
    padding-right: 16px;
  }
  .trip-map-canvas {
    height: 500px;
  }
  .timed-event {
    grid-template-columns: 60px 1fr auto;
    gap: 10px;
  }
  .timed-event-time {
    font-size: 16px;
  }
}

/* ============================================================
   TRIPS — Estilos complementarios y refuerzos
   ============================================================ */

/* Container del popup de Leaflet con borde redondeado */
.trip-popup {
  min-width: 220px;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--bg-paper);
}

/* Tab content wrapper - contiene los componentes según pestaña */
.trip-tab-content {
  margin-top: 14px;
}

/* Tab label visible junto al icono */
.trip-tab-label {
  font-size: 13px;
  font-weight: 500;
}

/* Item card body (el grid centro) */
.trip-item-card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Refuerzos para evitar overflow en el item card al haber descripciones largas */
.trip-item-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--ink-mute);
  border-radius: var(--r-md);
  transition: border-color 0.15s, background 0.15s;
}
.trip-item-card:hover {
  background: var(--bg-paper);
  border-color: var(--line);
}
.trip-item-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

/* Animación discreta al cargar el mapa */
.trip-map-wrap {
  position: relative;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--line-soft);
}
.trip-map-canvas {
  height: 600px;
  width: 100%;
  background: var(--bg-elevated);
}
.trip-map-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  color: var(--ink-mute);
  font-size: 13px;
  z-index: 1;
}
.trip-map-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 500;
  pointer-events: none;
}

/* Marker pin custom */
.trip-map-marker { background: transparent !important; border: 0 !important; }
.trip-map-marker-pin {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.25);
  border: 2px solid white;
}
.trip-map-marker-emoji {
  transform: rotate(45deg);
  font-size: 16px;
  line-height: 1;
}
.trip-map-marker-num {
  position: absolute;
  top: -6px;
  right: -8px;
  transform: rotate(45deg);
  background: var(--ink);
  color: white;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
}

/* Filtros como chips arriba del mapa */
.trip-map-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.trip-map-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.trip-map-filter {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  background: var(--bg-paper);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  color: var(--ink-soft);
}
.trip-map-filter:hover {
  border-color: var(--ink-mute);
}
.trip-map-filter.active {
  border-color: var(--filter-color, var(--ink));
  background: color-mix(in srgb, var(--filter-color, var(--ink)) 12%, var(--bg-paper));
  color: var(--ink);
  font-weight: 500;
}
.trip-map-filter input { display: none; }
.trip-map-route-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
}

/* ============================================================
   FALLBACK: Si color-mix no está soportado,
   usamos colores explícitos por tipo
   ============================================================ */
.trip-map-filter.active[data-filter="all"] { background: rgba(45,35,25,0.08); }
.trip-map-filter.active[data-filter="transport"] { background: rgba(26,93,184,0.12); }
.trip-map-filter.active[data-filter="lodging"] { background: rgba(123,63,160,0.12); }
.trip-map-filter.active[data-filter="activity"] { background: rgba(217,98,74,0.12); }
.trip-map-filter.active[data-filter="food"] { background: rgba(230,126,34,0.12); }
.trip-map-filter.active[data-filter="document"] { background: rgba(107,99,86,0.12); }
.trip-map-filter.active[data-filter="expense"] { background: rgba(184,68,44,0.12); }
.trip-map-filter.active[data-filter="events"] { background: rgba(184,134,11,0.14); }
.trip-map-filter.active[data-filter="packing"] { background: rgba(91,170,140,0.12); }

/* ============================================================
   TRIPS — Vista dual (Lista / Mapa Global)
   ============================================================ */
.trips-view-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 0;
}
.trips-view-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink-mute);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}
.trips-view-tab:hover {
  color: var(--ink);
}
.trips-view-tab.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
  font-weight: 500;
}
.trips-view-tab-icon {
  font-size: 16px;
}
.trips-view-tab-label {
  font-size: 13px;
}

/* Mapa global - controles superiores */
.trip-globalmap-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding-bottom: 12px;
}

/* Marker pin del mapa global - más grande, con número y status */
.trip-globalmap-marker {
  background: transparent !important;
  border: 0 !important;
}
.trip-globalmap-pin {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  border: 3px solid white;
}
.trip-globalmap-pin-icon {
  transform: rotate(45deg);
  font-size: 18px;
  color: white;
  font-weight: 600;
  line-height: 1;
}
.trip-globalmap-pin-num {
  position: absolute;
  top: -8px;
  right: -10px;
  transform: rotate(45deg);
  background: var(--ink);
  color: white;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
}

/* Popup del mapa global - rico con foto */
.trip-globalmap-popup {
  width: 240px;
  font-family: var(--font-body, system-ui);
  margin: -12px -20px;
  /* Fix para que el popup no use padding negativo y se vea raro */
}
.leaflet-popup-content-wrapper:has(.trip-globalmap-popup) {
  padding: 0;
  overflow: hidden;
}
.leaflet-popup-content {
  margin: 0 !important;
  padding: 0 !important;
}
.trip-globalmap-popup-cover {
  width: 100%;
  height: 100px;
  background-size: cover;
  background-position: center;
  background-color: var(--bg-elevated);
}
.trip-globalmap-popup-status {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  margin: 12px 14px 0;
}
.trip-globalmap-popup-name {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 500;
  color: var(--ink);
  margin: 6px 14px 0;
  line-height: 1.2;
}
.trip-globalmap-popup-destination {
  font-size: 12.5px;
  color: var(--ink-soft);
  margin: 4px 14px 0;
}
.trip-globalmap-popup-dates {
  font-size: 12px;
  color: var(--ink-soft);
  margin: 4px 14px 0;
  font-family: var(--font-mono);
}
.trip-globalmap-popup-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 14px 0;
  font-size: 11.5px;
  color: var(--ink-soft);
}
.trip-globalmap-popup-stats span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.trip-globalmap-popup-btn {
  width: calc(100% - 28px);
  margin: 12px 14px 14px;
  padding: 8px 12px;
  background: var(--accent);
  color: white;
  border: 0;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.trip-globalmap-popup-btn:hover {
  background: var(--accent-strong, #9c3920);
}

/* Leyenda inferior */
.trip-globalmap-legend {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  border: 1px solid var(--line-soft);
}
.trip-globalmap-legend-info {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--ink-soft);
}
.trip-globalmap-legend-info strong {
  color: var(--ink);
}

/* Filtros de status */
.trip-map-filter[data-status-filter].active {
  background: color-mix(in srgb, var(--filter-color) 12%, var(--bg-paper));
}
.trip-map-filter[data-status-filter="ongoing"].active { background: rgba(45,122,62,0.12); }
.trip-map-filter[data-status-filter="upcoming"].active { background: rgba(26,93,184,0.12); }
.trip-map-filter[data-status-filter="planning"].active { background: rgba(184,134,11,0.12); }
.trip-map-filter[data-status-filter="completed"].active { background: rgba(107,99,86,0.12); }
.trip-map-filter[data-status-filter="all"].active { background: rgba(45,35,25,0.08); }

/* ============================================================
   LOGIN SCREEN
   ============================================================ */

/* Cuando auth-pending está en body: ocultar la app, mostrar login */
body.auth-pending .app-shell { display: none !important; }
body:not(.auth-pending) #login-screen { display: none !important; }

#login-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 40px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  box-shadow: 0 8px 40px rgba(26, 24, 21, 0.08);
}

.login-logo {
  width: 40px;
  height: 40px;
  color: var(--accent);
  margin-bottom: 8px;
}
.login-logo svg { width: 100%; height: 100%; }

.login-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
  color: var(--ink);
  margin: 0;
  letter-spacing: -0.02em;
}

.login-sub {
  font-size: 12px;
  color: var(--ink-mute);
  margin: 0 0 20px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

#login-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.login-field label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-mute);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.login-field input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-base);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}

.login-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(184, 68, 44, 0.12);
}

.login-error {
  font-size: 12.5px;
  color: var(--accent);
  text-align: center;
  min-height: 16px;
  margin: 0;
}

.login-btn {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  margin-top: 4px;
}

.login-btn:hover:not(:disabled) { background: var(--accent-deep); }
.login-btn:active:not(:disabled) { transform: scale(0.98); }
.login-btn:disabled { opacity: 0.6; cursor: not-allowed; }

@media (max-width: 480px) {
  .login-card { padding: 32px 24px; border-radius: 8px; }
}

/* ============================================================
   PRINT — Modelos fiscales
   ============================================================ */
@media print {
  /* Ocultar elementos de navegación */
  #sidebar, #topbar, .view-actions, #btn-print-taxes,
  .modal-overlay, .toast-container { display: none !important; }

  /* Expandir el contenido al ancho completo */
  #main, #view-container { margin: 0; padding: 0; width: 100%; }

  /* Fondo blanco, texto negro */
  body, .panel, .kpi, .quarter { background: white !important; color: black !important; }
  .kpi-value, .quarter-value { color: black !important; }

  /* Evitar cortes de página dentro de paneles */
  .panel, .kpi-grid, .quarter-grid { page-break-inside: avoid; break-inside: avoid; }

  /* Encabezado de impresión */
  #view-container::before {
    content: "Libro Mayor · Modelos Fiscales";
    display: block;
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #333;
  }
}
