/* ============================================================
   SMARTECH — Premium Dashboard
   Glassmorphism · Animated Gradients · Light & Dark Mode
   ============================================================ */

/* ── Keyframe Animations ────────────────────────────────────── */
@keyframes gradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes pulseOrb {
  0%, 100% { transform: scale(1);    opacity: 0.5; }
  50%       { transform: scale(1.2); opacity: 1;   }
}
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 15px rgba(41,171,226,0.35); }
  50%       { box-shadow: 0 0 35px rgba(41,171,226,0.65), 0 0 60px rgba(0,136,204,0.25); }
}
@keyframes shimmer {
  0%   { background-position: -200% center; }
  100% { background-position:  200% center; }
}
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0);    }
}
@keyframes countUp {
  from { opacity: 0; transform: scale(0.82); }
  to   { opacity: 1; transform: scale(1);    }
}
@keyframes ping {
  75%, 100% { transform: scale(2.2); opacity: 0; }
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes barGrow {
  from { width: 0 !important; }
}

/* ── CSS Custom Properties (Light — default) ────────────────── */
:root {
  /* Brand */
  --brand:          #29ABE2;
  --brand-dark:     #0088CC;
  --brand-deeper:   #005F99;
  --brand-light:    #E0F5FD;
  --brand-mid:      #B3E4F7;

  /* Backgrounds */
  --bg-body:        #F0F6FB;
  --bg-sidebar:     #ffffff;
  --bg-card:        #ffffff;
  --bg-card-hover:  #F8FBFE;
  --bg-input:       #F4F8FC;
  --bg-overlay:     rgba(240,246,251,0.85);

  /* Text */
  --text-main:      #1A2B3C;
  --text-muted:     #5A7A96;
  --text-dim:       #9BB5C8;

  /* Borders */
  --border:         rgba(41,171,226,0.15);
  --border-strong:  rgba(41,171,226,0.3);

  /* Status */
  --success:        #10B981;
  --success-bg:     rgba(16,185,129,0.10);
  --success-text:   #059669;
  --warning:        #F59E0B;
  --warning-text:   #D97706;
  --danger:         #EF4444;
  --danger-bg:      rgba(239,68,68,0.10);
  --danger-text:    #DC2626;

  /* Elevation */
  --shadow-card:    0 2px 16px rgba(41,171,226,0.08), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-hover:   0 12px 40px rgba(41,171,226,0.18), 0 4px 12px rgba(0,0,0,0.08);
  --shadow-glow:    0 0 30px rgba(41,171,226,0.12);

  /* Shape */
  --radius:         18px;
  --radius-sm:      10px;
  --sidebar-w:      260px;
  --font-family:    "Inter", "SF Pro Display", system-ui, -apple-system, sans-serif;

  /* Sidebar gradient (light) */
  --grad-sidebar: linear-gradient(170deg, #0a2540 0%, #0e3a60 40%, #0066aa 80%, #29ABE2 100%);

  /* Accent blobs (light) */
  --blob1: rgba(41,171,226,0.08);
  --blob2: rgba(0,136,204,0.06);

  /* Mode toggle icon */
  --toggle-icon: "☀️";
}

/* ── Dark Mode ───────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg-body:        #06080f;
  --bg-sidebar:     transparent;
  --bg-card:        rgba(255,255,255,0.04);
  --bg-card-hover:  rgba(255,255,255,0.07);
  --bg-input:       rgba(255,255,255,0.06);
  --bg-overlay:     rgba(6,8,15,0.85);

  --text-main:      #E0F0FF;
  --text-muted:     rgba(160,195,225,0.65);
  --text-dim:       rgba(100,150,190,0.45);

  --border:         rgba(41,171,226,0.12);
  --border-strong:  rgba(41,171,226,0.28);

  --success-bg:     rgba(16,185,129,0.12);
  --success-text:   #34D399;
  --danger-bg:      rgba(239,68,68,0.12);
  --danger-text:    #F87171;

  --shadow-card:    0 8px 32px rgba(0,0,0,0.45);
  --shadow-hover:   0 20px 60px rgba(0,0,0,0.6);
  --shadow-glow:    0 0 40px rgba(41,171,226,0.18);

  --grad-sidebar: linear-gradient(180deg, #060d1f 0%, #071530 40%, #0a2550 75%, #0d3875 100%);

  --brand-light:    rgba(41,171,226,0.12);
  --brand-mid:      rgba(41,171,226,0.25);

  --blob1: rgba(41,171,226,0.10);
  --blob2: rgba(0,136,204,0.08);
}

/* ── Base Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-family);
  background-color: var(--bg-body);
  color: var(--text-main);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.4s ease, color 0.4s ease;
}

/* Animated background orbs */
body::before, body::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  z-index: 0;
  pointer-events: none;
  animation: pulseOrb 9s ease-in-out infinite;
}
body::before {
  width: 500px; height: 500px;
  background: radial-gradient(circle, var(--blob1) 0%, transparent 70%);
  top: -80px; right: 250px;
}
body::after {
  width: 380px; height: 380px;
  background: radial-gradient(circle, var(--blob2) 0%, transparent 70%);
  bottom: 80px; left: 300px;
  animation-delay: -4.5s;
}

/* ── Layout ──────────────────────────────────────────────────── */
.app-container {
  display: flex;
  width: 100%;
  position: relative;
  z-index: 1;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--grad-sidebar);
  padding: 1.8rem 1.2rem;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 100;
  border-right: 1px solid rgba(255,255,255,0.07);
  overflow: hidden;
  transition: background 0.4s ease;
}

/* Sidebar inner glow orbs */
.sidebar::before {
  content: "";
  position: absolute;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(41,171,226,0.22) 0%, transparent 70%);
  top: 20px; right: -50px;
  border-radius: 50%;
  pointer-events: none;
  animation: pulseOrb 7s ease-in-out infinite;
}
.sidebar::after {
  content: "";
  position: absolute;
  width: 160px; height: 160px;
  background: radial-gradient(circle, rgba(0,136,204,0.18) 0%, transparent 70%);
  bottom: 60px; left: -30px;
  border-radius: 50%;
  pointer-events: none;
  animation: pulseOrb 8s ease-in-out infinite reverse;
}

/* ── Logo ────────────────────────────────────────────────────── */
.logo {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 2.5rem;
  padding: 0 0.4rem;
  position: relative;
  z-index: 1;
}

.logo-img {
  width: 42px; height: 42px;
  border-radius: 13px;
  object-fit: contain;
  background: rgba(255,255,255,0.15);
  padding: 5px;
  border: 1px solid rgba(255,255,255,0.2);
  animation: pulseGlow 3.5s ease-in-out infinite;
  flex-shrink: 0;
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 1.8px;
  background: linear-gradient(135deg, #fff 30%, #A8DCEF 70%, #29ABE2);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 3s linear infinite;
}

/* ── Navigation ──────────────────────────────────────────────── */
.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  position: relative;
  z-index: 1;
}

.nav-item {
  padding: 0.8rem 1.1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
  color: rgba(255,255,255,0.55);
  font-weight: 500;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: relative;
  overflow: hidden;
}
.nav-item::before {
  content: "";
  position: absolute; inset: 0;
  background: rgba(255,255,255,0.07);
  opacity: 0;
  transition: opacity 0.3s;
  border-radius: inherit;
}
.nav-item:hover { color: rgba(255,255,255,0.9); transform: translateX(4px); }
.nav-item:hover::before { opacity: 1; }

.nav-item.active {
  background: rgba(41,171,226,0.22);
  color: #fff;
  border: 1px solid rgba(41,171,226,0.35);
  box-shadow: inset 0 0 20px rgba(41,171,226,0.08), 0 0 18px rgba(41,171,226,0.12);
}
.nav-item.active::after {
  content: "";
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: linear-gradient(180deg, #29ABE2, #0088CC);
  border-radius: 0 4px 4px 0;
}
.nav-item i { font-size: 0.95rem; width: 18px; text-align: center; flex-shrink: 0; }

.nav-badge {
  background: var(--danger);
  color: white;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 20px;
  margin-left: auto;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.2);
  animation: badgePulse 2s infinite;
}

@keyframes badgePulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { transform: scale(1.05); box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.nav-badge.hidden {
  display: none;
}

/* ── Sidebar Footer & User Profile ─────────────────────────── */
.sidebar-footer {
  margin-top: auto;
  position: relative;
  z-index: 1;
  padding: 1.2rem 0.4rem 0.2rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background: rgba(255,255,255,0.06);
  padding: 0.7rem;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.08);
  transition: all 0.3s;
}
.sidebar-user:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.15);
}

.user-avatar-mini {
  width: 32px; height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 0.9rem;
  box-shadow: 0 4px 10px rgba(41,171,226,0.3);
  flex-shrink: 0;
}

.user-info-mini {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  flex: 1;
  overflow: hidden;
}
.user-name-sidebar { font-size: 0.78rem; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role-sidebar { font-size: 0.62rem; color: rgba(255,255,255,0.5); font-weight: 500; }

.btn-theme-sidebar {
  width: 30px; height: 30px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.1);
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.3s;
}
.btn-theme-sidebar:hover {
  background: #fff;
  color: var(--brand-dark);
  transform: scale(1.1) rotate(15deg);
}

.version-info {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.25);
  text-align: center;
  letter-spacing: 0.5px;
  font-weight: 500;
}

/* ── Main Content ────────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 2rem 2.5rem;
  min-height: 100vh;
  transition: background 0.4s ease;
}

/* ── Header ──────────────────────────────────────────────────── */
header {
  margin-bottom: 2.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  animation: fadeSlideIn 0.5s ease;
}
.header-left h1 {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.25rem;
  letter-spacing: -0.5px;
}
.subtitle { color: var(--text-muted); font-size: 0.88rem; }

/* ── Theme & Profile Icons (Legacy Removed) ──────────────────── */

/* ── Dashboard Grid ──────────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 1.5rem;
}

/* 4 KPIs en una fila — desktop */
.kpi-4col {
  grid-template-columns: repeat(4, 1fr);
}
@media (max-width: 1024px) {
  .kpi-4col { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .kpi-4col { grid-template-columns: repeat(2, 1fr); gap: 0.7rem; }
}

/* ── Glass Cards ─────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.8rem;
  border: 1px solid var(--border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-card);
  transition: transform 0.35s cubic-bezier(0.4,0,0.2,1),
              box-shadow 0.35s ease,
              border-color 0.35s ease,
              background 0.4s ease;
  position: relative;
  overflow: hidden;
  animation: fadeSlideIn 0.5s ease both;
}
/* Top shimmer line */
.card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(41,171,226,0.4), transparent);
  opacity: 0.6;
}
.card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-hover);
  border-color: var(--border-strong);
}

/* Accent stripes */
.card[data-accent="blue"]   { border-left: 3px solid var(--brand); }
.card[data-accent="cyan"]   { border-left: 3px solid #00BCD4; }
.card[data-accent="green"]  { border-left: 3px solid var(--success); }
.card[data-accent="coral"]  { border-left: 3px solid #F97316; }
.card[data-accent="blue"]:hover  { box-shadow: var(--shadow-hover), 0 0 40px rgba(41,171,226,0.15); }
.card[data-accent="green"]:hover { box-shadow: var(--shadow-hover), 0 0 40px rgba(16,185,129,0.15); }

/* Card stagger */
.card:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2) { animation-delay: 0.10s; }
.card:nth-child(3) { animation-delay: 0.15s; }
.card:nth-child(4) { animation-delay: 0.20s; }

/* Income / Expense special cards */
.card.income-card {
  border-left: 3px solid var(--success);
  background: linear-gradient(135deg,
    rgba(16,185,129,0.06) 0%,
    var(--bg-card) 100%);
}
.card.expense-card {
  border-left: 3px solid var(--danger);
  background: linear-gradient(135deg,
    rgba(239,68,68,0.06) 0%,
    var(--bg-card) 100%);
}

/* ── Card Title ──────────────────────────────────────────────── */
.card-title {
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

/* Card icon badges */
.card-icon {
  width: 34px; height: 34px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.card-icon.blue   { background: rgba(41,171,226,0.12); color: var(--brand); }
.card-icon.cyan   { background: rgba(0,188,212,0.12);  color: #00BCD4; }
.card-icon.green  { background: rgba(16,185,129,0.12); color: var(--success); }
.card-icon.coral  { background: rgba(249,115,22,0.12); color: #F97316; }

/* ── Stat Values ─────────────────────────────────────────────── */
.stat-value {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -1px;
  line-height: 1;
  margin: 0.4rem 0 0.6rem;
  animation: countUp 0.6s ease;
}
.stat-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Status badges */
.badge-ok {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--success-bg);
  color: var(--success-text);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  border: 1px solid rgba(16,185,129,0.2);
}
.badge-warn {
  background: rgba(245,158,11,0.10);
  color: var(--warning-text);
  border: 1px solid rgba(245,158,11,0.2);
}

/* Pulsing dots */
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  position: relative;
  flex-shrink: 0;
}
.status-dot.green {
  background: var(--success);
  box-shadow: 0 0 8px rgba(16,185,129,0.5);
}
.status-dot.green::after {
  content: "";
  position: absolute; inset: -3px;
  border-radius: 50%;
  background: rgba(16,185,129,0.25);
  animation: ping 1.5s cubic-bezier(0,0,0.2,1) infinite;
}
.status-dot.yellow { background: var(--warning); }
.status-dot.red    { background: var(--danger); }

/* ── Finance Table ───────────────────────────────────────────── */
.finance-table {
  width: 100%;
  border-collapse: collapse;
}
.finance-table th {
  text-align: left;
  padding: 0.85rem 1rem;
  color: var(--text-muted);
  font-size: 0.73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border-bottom: 1px solid var(--border);
}
.finance-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  color: var(--text-main);
}
.finance-table tbody tr { transition: background 0.2s; }
.finance-table tbody tr:hover { background: rgba(41,171,226,0.04); }
.finance-table tbody tr:last-child td { border-bottom: none; }

/* ── Clickable ───────────────────────────────────────────────── */
.clickable {
  cursor: pointer;
  color: var(--brand);
  font-weight: 600;
  text-decoration: none;
  transition: color 0.2s;
}
.clickable:hover { color: var(--brand-dark); }

/* ── Month Grid (Professional) ───────────────────────────────── */
.month-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  min-width: 340px;
}
.month-pill {
  padding: 8px 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: var(--text-muted);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  position: relative;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.month-pill:hover {
  border-color: var(--brand);
  background: var(--brand-light);
  color: var(--brand-dark);
  transform: translateY(-2px);
}
.month-pill.paid {
  background: linear-gradient(135deg, #10B981, #059669) !important;
  border-color: #059669;
  color: #fff !important;
  box-shadow: 0 4px 12px rgba(16,185,129,0.25);
}
.month-pill.partial {
  background: linear-gradient(135deg, var(--warning), var(--warning-text)) !important;
  border-color: var(--warning-text);
  color: #fff !important;
  box-shadow: 0 4px 12px rgba(245,158,11,0.25);
}
.month-pill.pending {
  border-style: dashed;
  border-width: 1.5px;
}
.month-pill.current-month:not(.paid) {
  border-color: var(--brand);
  border-width: 2px;
  background: rgba(41,171,226,0.12);
}
.month-pill.current-month::after {
  content: "ACTUAL";
  position: absolute;
  top: -8px;
  background: var(--brand);
  color: #fff;
  font-size: 0.5rem;
  padding: 1px 4px;
  border-radius: 4px;
  border: 1px solid #fff;
}
.month-pill.paid i {
  font-size: 0.75rem;
  margin-top: 2px;
}

/* ── Tabs ────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.3rem;
  width: fit-content;
  box-shadow: var(--shadow-card);
}
.tab-btn {
  padding: 0.55rem 1.2rem;
  font-weight: 600;
  font-size: 0.83rem;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 7px;
  transition: all 0.25s ease;
  border: 1px solid transparent;
}
.tab-btn:hover { color: var(--text-main); background: var(--brand-light); }
.tab-btn.active {
  color: var(--brand-dark);
  background: var(--brand-light);
  border-color: var(--brand-mid);
  box-shadow: 0 0 12px rgba(41,171,226,0.12);
  font-weight: 700;
}

/* ── Ledger Header ───────────────────────────────────────────── */
.ledger-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.amount-income { color: var(--success-text); font-weight: 700; }
.amount-expense { color: var(--danger-text); font-weight: 700; }

/* ── Projects Pipeline (Kanban) ────────────────────────────── */
.pipeline-board {
  display: flex;
  gap: 1.5rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  min-height: 500px;
}

.pipeline-column {
  flex: 0 0 300px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 500px; /* Altura mínima consistente */
  max-height: 85vh;
  box-shadow: var(--shadow-card);
  transition: background 0.2s, border-color 0.2s;
}

.pipeline-column.drag-over {
  background: var(--brand-light);
  border-color: var(--brand);
}

.pipeline-header {
  padding: 1rem 1.2rem;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 3px solid transparent;
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
}

.pipeline-count {
  background: rgba(41,171,226,0.15);
  color: var(--brand);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
}

.pipeline-content {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

/* Scrollbar para la columna */
.pipeline-content::-webkit-scrollbar {
  width: 6px;
}
.pipeline-content::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}

.pipeline-card {
  background: var(--bg-body);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.1rem;
  cursor: grab;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s;
  flex-shrink: 0; /* Evitar que se compriman */
}

.pipeline-card:active {
  cursor: grabbing;
}

.pipeline-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: var(--brand-mid);
}

.pipeline-card.dragging {
  opacity: 0.5;
}

.task-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-main);
  margin-bottom: 0.4rem;
  line-height: 1.3;
}

.task-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.8rem;
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.task-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.7rem;
  color: var(--text-dim);
}

.task-date {
  display: flex;
  align-items: center;
  gap: 4px;
}

.task-actions {
  display: flex;
  gap: 6px;
}

.task-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s;
}
.task-btn:hover { background: rgba(0,0,0,0.05); color: var(--text-main); }
[data-theme="dark"] .task-btn:hover { background: rgba(255,255,255,0.1); }

.task-checklist-progress {
  font-size: 0.7rem;
  color: var(--brand);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Select ──────────────────────────────────────────────────── */
#ledger-filter {
  padding: 0.5rem 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.83rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: all 0.2s;
}
#ledger-filter:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(41,171,226,0.1); }
#ledger-filter option { background: var(--bg-card); }

/* ── Custom Project Select ────────────────────────────────────── */
.project-select-custom {
  width: 100%;
  padding: 0.8rem 1.2rem;
  font-size: 1.1rem;
  font-weight: 700;
  font-family: var(--font-family);
  color: var(--text-main);
  background-color: var(--bg-card);
  border: 2px solid var(--border-strong);
  border-radius: 12px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%2329ABE2%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 1.2rem top 50%;
  background-size: 0.65rem auto;
  box-shadow: var(--shadow-card);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.project-select-custom:hover {
  border-color: var(--brand);
  background-color: var(--bg-card-hover);
  box-shadow: 0 4px 15px rgba(41,171,226,0.15);
}

.project-select-custom:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(41,171,226,0.15);
}

.project-select-custom option {
  background-color: var(--bg-body);
  color: var(--text-main);
  padding: 10px;
  font-weight: 500;
}

/* ── Modals ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(10,20,35,0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

/* Asegurar que la alerta del sistema esté siempre por encima de otros modales */
#modal-system-alert {
  z-index: 2000;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  padding: 1.5rem;
  border-radius: 22px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  box-shadow: var(--shadow-hover), 0 0 0 1px rgba(41,171,226,0.08);
  transform: scale(0.9) translateY(18px);
  transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1);
  position: relative;
  overflow-y: auto;
}
.modal::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(41,171,226,0.6), transparent);
}
.modal-overlay.open .modal { transform: scale(1) translateY(0); }

.modal h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* ── Form Groups ─────────────────────────────────────────────── */
.form-group { margin-bottom: 1.2rem; }
.form-group label {
  display: block;
  margin-bottom: 0.45rem;
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-group input,
.form-group select {
  width: 100%;
  padding: 0.82rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.93rem;
  color: var(--text-main);
  outline: none;
  transition: all 0.25s;
  -webkit-appearance: none;
  appearance: none;
}
.form-group input::placeholder { color: var(--text-dim); }
.form-group input:focus,
.form-group select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(41,171,226,0.12);
  background: rgba(41,171,226,0.04);
}

/* Select: flecha personalizada (appearance: none la elimina) */
.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2329ABE2' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  padding-right: 2.5rem;
}

/* Options: fondo del tema */
.form-group select option {
  background: var(--bg-card);
  color: var(--text-main);
}

/* Dark mode: forzar fondo oscuro en el select y sus opciones */
[data-theme="dark"] .form-group select {
  background-color: #1a2535;
  color: #E0F0FF;
  border-color: rgba(41,171,226,0.2);
  color-scheme: dark;
}
[data-theme="dark"] .form-group select option {
  background-color: #1a2535;
  color: #E0F0FF;
}
[data-theme="dark"] #ledger-filter {
  background-color: #1a2535;
  color: #E0F0FF;
  color-scheme: dark;
}
[data-theme="dark"] #ledger-filter option {
  background-color: #1a2535;
  color: #E0F0FF;
}
.form-group input:disabled { opacity: 0.4; cursor: not-allowed; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.8rem;
  margin-top: 1.8rem;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.875rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.btn-primary::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.18), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(41,171,226,0.4);
}
.btn-primary:hover::before { opacity: 1; }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.75rem 1.5rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.25s;
}
.btn-secondary:hover {
  background: var(--brand-light);
  color: var(--brand-dark);
  border-color: var(--brand-mid);
}

/* ── App Link & Cache Buttons ────────────────────────────────── */
.btn-app-link {
  background: linear-gradient(135deg, rgba(41,171,226,0.12), rgba(0,136,204,0.08));
  color: var(--brand-dark);
  border: 1px solid rgba(41,171,226,0.25);
  padding: 0.42rem 0.85rem;
  border-radius: 8px;
  font-size: 0.77rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  white-space: nowrap;
}
.btn-app-link:hover {
  transform: translateY(-2px);
  background: rgba(41,171,226,0.2);
  box-shadow: 0 4px 14px rgba(41,171,226,0.2);
}
.btn-cache {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.33rem 0.65rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.btn-cache:hover {
  background: var(--brand-light);
  color: var(--brand-dark);
  border-color: var(--brand-mid);
}
.cache-buttons {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.4rem;
  flex-wrap: wrap;
}
.action-buttons-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: flex-end;
}

/* ── App Info ────────────────────────────────────────────────── */
.app-info-with-logo {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}
.app-logo {
  width: 36px; height: 36px;
  border-radius: 9px;
  object-fit: contain;
  background: var(--brand-light);
  padding: 4px;
  border: 1px solid var(--border);
}
.app-logo-large { width: 44px; height: 44px; }
.app-details { display: flex; flex-direction: column; gap: 0.2rem; }
.app-name { font-weight: 700; font-size: 0.88rem; color: var(--text-main); }

/* ── Version Badge ───────────────────────────────────────────── */
.version-badge {
  display: inline-flex;
  align-items: center;
  background: var(--brand-light);
  color: var(--brand-dark);
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  border: 1px solid var(--brand-mid);
}

/* ── Status Module (Control Center) ───────────────────────────── */
.control-center-header {
    margin-bottom: 2rem;
    animation: fadeSlideIn 0.5s ease;
}

.status-overview-card {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    padding: 1rem 1.8rem;
    border-radius: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-card);
    gap: 1.8rem;
    backdrop-filter: blur(15px);
    width: fit-content;
    position: relative;
}

.overview-item { display: flex; flex-direction: column; gap: 0.1rem; }
.overview-label { font-size: 0.62rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.8px; }
.overview-value { font-size: 1.15rem; font-weight: 800; color: var(--text-main); }
.overview-value.success-text { color: var(--success); }
.overview-value.blue-text { color: var(--brand); }
.overview-divider { width: 1px; height: 30px; background: var(--border); }
.text-green { color: var(--success); }

/* Refresh Button */
.btn-refresh-all {
    width: 34px; height: 34px;
    border-radius: 10px;
    border: 1px solid var(--border-strong);
    background: var(--brand-light);
    color: var(--brand-dark);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.3s;
    margin-left: 0.2rem;
}
.btn-refresh-all:hover { transform: rotate(180deg); background: var(--brand); color: #fff; }

.control-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 1.5rem;
}

.control-card {
    background: var(--bg-card);
    border-radius: 22px;
    border: 1px solid var(--border);
    padding: 1.6rem;
    box-shadow: var(--shadow-card);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.control-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-hover); border-color: var(--brand-mid); }

.control-card-main { display: flex; justify-content: space-between; align-items: flex-start; }
.app-info-cluster { display: flex; gap: 1rem; align-items: center; }

.app-logo-box { position: relative; width: 48px; height: 48px; }
.app-logo-img { width: 100%; height: 100%; border-radius: 12px; object-fit: contain; background: var(--bg-input); padding: 5px; border: 1px solid var(--border); }

.status-indicator-dot {
    position: absolute; bottom: -2px; right: -2px;
    width: 14px; height: 14px;
    border-radius: 50%;
    border: 2px solid var(--bg-card);
    transition: background 0.4s;
}
.status-indicator-dot.green { background: var(--success); box-shadow: 0 0 10px var(--success); }
.status-indicator-dot.red   { background: var(--danger);  box-shadow: 0 0 10px var(--danger);  }
.status-indicator-dot.grey  { background: var(--text-dim); }

.app-text-box { display: flex; flex-direction: column; line-height: 1.2; }
.app-title { font-size: 1rem; font-weight: 800; color: var(--text-main); display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.1rem; }
.latency-text { font-size: 0.68rem; color: var(--brand); font-weight: 700; }

/* SSL Badge */
.ssl-badge {
    font-size: 0.65rem; color: var(--text-dim); font-weight: 700;
    display: inline-flex; align-items: center; gap: 0.2rem;
    transition: color 0.3s;
}
.ssl-badge.active { color: var(--success); }
.ssl-badge i { font-size: 0.75rem; }

/* Env Badge */
.env-badge {
    background: var(--bg-input);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border);
}
.badge-tag { font-size: 0.6rem; font-weight: 900; color: var(--text-muted); }

/* Infra Details */
.infra-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    background: var(--bg-input);
    padding: 0.8rem 1.1rem;
    border-radius: 12px;
    border: 1px solid var(--border);
}
.infra-item { display: flex; align-items: center; gap: 0.7rem; }
.infra-item i { font-size: 0.85rem; color: var(--brand); opacity: 0.7; }
.infra-text { display: flex; flex-direction: column; }
.infra-text label { font-size: 0.58rem; font-weight: 700; color: var(--text-dim); text-transform: uppercase; }
.infra-text span { font-size: 0.75rem; font-weight: 600; color: var(--text-main); }

.control-card-divider { height: 1px; background: linear-gradient(90deg, transparent, var(--border), transparent); }

.control-actions { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.quick-tools { display: flex; gap: 0.5rem; }

.btn-tool {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.45rem 0.7rem;
    border-radius: 8px;
    font-size: 0.68rem;
    font-weight: 700;
    cursor: pointer;
    display: flex; align-items: center; gap: 0.4rem;
    transition: all 0.25s;
}
.btn-tool:hover { background: var(--brand-light); color: var(--brand-dark); transform: scale(1.05); }

.btn-control-secondary {
    width: 32px; height: 32px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    text-decoration: none; font-size: 0.85rem;
    transition: all 0.25s;
}
.btn-control-secondary:hover { background: var(--brand-light); color: var(--brand-dark); transform: translateY(-2px); }

.btn-control-primary {
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    color: #fff;
    padding: 0 1rem;
    height: 32px;
    border-radius: 9px;
    font-size: 0.75rem;
    font-weight: 700;
    text-decoration: none;
    display: flex; align-items: center; gap: 0.4rem;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(41,171,226,0.15);
}
.btn-control-primary:hover { transform: translate(2px, -2px); box-shadow: 0 6px 16px rgba(41,171,226,0.3); }

.control-card-footer { display: flex; flex-direction: column; gap: 0.4rem; }
.footer-meta { display: flex; justify-content: space-between; align-items: center; }

.last-check-text { font-size: 0.6rem; color: var(--text-dim); font-weight: 500; display: flex; align-items: center; gap: 0.3rem; }
.uptime-percent { font-size: 0.62rem; color: var(--success-text); font-weight: 700; }

.uptime-bar { display: grid; grid-template-columns: repeat(14, 1fr); gap: 3px; height: 3px; }
.uptime-seg { border-radius: 2px; background: var(--border); }
.uptime-seg.active { background: var(--success); opacity: 0.8; }
.uptime-seg.warning { background: var(--warning); opacity: 0.8; }
.uptime-seg.danger { background: var(--danger); opacity: 0.8; }

/* ── Stats bar chart ─────────────────────────────────────────── */
.stat-bar { animation: barGrow 1.2s cubic-bezier(0.4,0,0.2,1) both; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   MOBILE BOTTOM NAVIGATION — estilo iOS nativo
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 200;
  background: var(--grad-sidebar);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255,255,255,0.10);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  justify-content: space-around;
  align-items: stretch;
}

.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 10px 4px;
  cursor: pointer;
  color: rgba(255,255,255,0.4);
  font-size: 0.6rem;
  font-weight: 600;
  transition: all 0.25s ease;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.mobile-nav-item i {
  font-size: 1.2rem;
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
.mobile-nav-item.active { color: var(--brand); }
.mobile-nav-item.active i { transform: scale(1.15); }
.mobile-nav-item.active::after {
  content: '';
  position: absolute;
  top: 0; left: 25%; right: 25%;
  height: 2px;
  background: var(--brand);
  border-radius: 0 0 3px 3px;
}
.mobile-nav-badge {
  position: absolute;
  top: 7px; right: 18%;
  background: var(--danger);
  color: #fff;
  font-size: 0.52rem;
  font-weight: 800;
  min-width: 14px; height: 14px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
}
.mobile-nav-badge.hidden { display: none; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   Utilities (sin duplicados)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.hidden { display: none !important; }
.view-section { animation: fadeSlideIn 0.4s ease; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(41,171,226,0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(41,171,226,0.5); }

.gradient-text {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 3s linear infinite;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   RESPONSIVE — Tablet (≤ 1024px)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
@media (max-width: 1024px) {
  .main-content { padding: 1.5rem; }
  .dashboard-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   RESPONSIVE — Tablet pequeña (≤ 768px)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
@media (max-width: 768px) {
  :root { --sidebar-w: 68px; }
  .sidebar {
    padding: 1.5rem 0.8rem;
    padding-top: max(1.5rem, env(safe-area-inset-top));
  }
  .logo-text, .nav-item span,
  .sidebar-footer .version-info,
  .sidebar-user .user-info-mini { display: none; }
  .nav-item { justify-content: center; gap: 0; }
  .logo { justify-content: center; }
  .header-left h1 { font-size: 1.4rem; }
  .main-content { padding: 1rem; }
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   RESPONSIVE — Móvil (≤ 600px)
   Sidebar oculto → bottom nav visible, layout 1 columna
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
@media (max-width: 600px) {
  :root { --sidebar-w: 0px; }

  /* Ocultar sidebar lateral — bottom nav lo reemplaza */
  .sidebar { display: none; }
  .mobile-bottom-nav { display: flex; }

  /* Layout */
  .app-container { flex-direction: column; }
  .main-content {
    margin-left: 0;
    padding: 0.9rem;
    /* Safe area iOS arriba (notch/Dynamic Island) */
    padding-top: max(0.9rem, env(safe-area-inset-top));
    /* Safe area abajo + altura del bottom nav (~60px) */
    padding-bottom: calc(62px + env(safe-area-inset-bottom, 16px));
    /* svh = small viewport height: ignora las barras retráctiles del browser */
    min-height: 100svh;
  }

  /* Header */
  header {
    margin-bottom: 1rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
  }
  .header-left h1 { font-size: 1.25rem; letter-spacing: -0.3px; }
  .subtitle { font-size: 0.76rem; }

  /* Cards */
  .dashboard-grid { grid-template-columns: 1fr 1fr; gap: 0.7rem; margin-bottom: 0.9rem !important; }
  .card { padding: 1.1rem; border-radius: 14px; }
  .card:hover { transform: none; }
  .card-title { font-size: 0.66rem; margin-bottom: 0.7rem; }
  .stat-value { font-size: 1.5rem; }

  /* Grids de 2 columnas → 1 columna */
  div[style*="grid-template-columns: 2fr 1fr"],
  div[style*="grid-template-columns: 1fr 1fr"] {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.8rem !important;
  }

  /* Tabla: scroll horizontal suave */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .finance-table th,
  .finance-table td { padding: 0.6rem 0.65rem; font-size: 0.78rem; }
  .month-grid { grid-template-columns: repeat(4, 1fr); min-width: 240px; gap: 3px; }
  .month-pill { padding: 5px 2px; font-size: 0.56rem; border-radius: 7px; }

  /* Tabs */
  .tabs { width: 100%; }
  .tab-btn { flex: 1; text-align: center; font-size: 0.76rem; padding: 0.5rem 0.3rem; }

  /* Ledger */
  .ledger-header { flex-direction: column; align-items: stretch; gap: 0.7rem; }
  .ledger-header > div { flex-wrap: wrap; }
  .ledger-header .btn-primary { width: 100%; justify-content: center; }

  /* MODALES — sheet desde abajo, estilo iOS */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    border-radius: 24px 24px 0 0;
    max-width: 100%;
    width: 100%;
    max-height: 92svh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 2rem 1.4rem;
    padding-bottom: max(2rem, env(safe-area-inset-bottom));
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.34,1.3,0.64,1);
  }
  .modal-overlay.open .modal { transform: translateY(0); }
  /* Pill drag handle */
  .modal::after {
    content: '';
    position: absolute;
    top: 10px; left: 50%;
    transform: translateX(-50%);
    width: 36px; height: 4px;
    background: var(--border-strong);
    border-radius: 2px;
  }

  /* Botones modales full-width */
  .modal-actions { flex-direction: column-reverse; gap: 0.6rem; margin-top: 1.2rem; }
  .modal-actions .btn-primary,
  .modal-actions .btn-secondary { width: 100%; justify-content: center; }

  /* iOS: evitar zoom al enfocar inputs (mínimo 16px) */
  input, select, textarea { font-size: 16px !important; }
  .form-group input,
  .form-group select { padding: 0.9rem 1rem; }

  /* Status center */
  .control-grid { grid-template-columns: 1fr; gap: 0.9rem; }
  .status-overview-card { flex-wrap: wrap; gap: 0.8rem; width: 100%; }
  .overview-divider { display: none; }

  /* Acciones tabla apps */
  .action-buttons-group { flex-direction: row; flex-wrap: wrap; justify-content: flex-end; gap: 0.4rem; }

  /* Apple HIG: áreas táctiles mínimas 44×44px */
  .btn-primary, .btn-secondary { min-height: 44px; }
  .month-pill { min-height: 36px; }

  /* Tabla de apps: ocultar en móvil, mostrar cards */
  .finance-table-wrapper { display: none !important; }
  .app-mobile-cards { display: flex !important; }
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   APP MOBILE CARD LAYOUT
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.app-mobile-cards {
  display: none; /* oculto en desktop, visible en móvil */
  flex-direction: column;
  gap: 0.9rem;
}

.app-mobile-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow-card);
  animation: fadeSlideIn 0.3s ease both;
}

.app-mobile-card-header {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 0.9rem;
}

.app-mobile-card-name {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--text-main);
  flex: 1;
}

.app-mobile-card-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.app-mobile-months {
  margin-bottom: 0.9rem;
}

.app-mobile-months-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
}

.app-mobile-months .month-grid {
  grid-template-columns: repeat(4, 1fr);
  min-width: unset;
  width: 100%;
  gap: 4px;
}

.app-mobile-card-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.app-mobile-card-actions .btn-primary,
.app-mobile-card-actions .btn-secondary {
  flex: 1;
  justify-content: center;
  font-size: 0.78rem;
  padding: 0.55rem 0.7rem;
  min-height: 40px;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   TASK CARD ENHANCEMENTS (KANBAN) - COMPACT & PREMIUM v2
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

.pipeline-card {
  cursor: pointer;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  transition: all 0.25s cubic-bezier(0.2, 0, 0, 1);
  box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}

.pipeline-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(0,0,0,0.08);
  border-color: var(--brand-mid);
}

/* Priority Side Indicator overlay */
.pipeline-card::after {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--brand);
  opacity: 0.8;
}

.priority-baja::after    { background: #10B981; }
.priority-media::after   { background: #F59E0B; }
.priority-alta::after    { background: #EF4444; }
.priority-urgente::after { background: #EF4444; border-right: 1px solid rgba(255,255,255,0.4); }

.task-card-main {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Header Row */
.task-header-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

/* Priority Badges */
.task-priority-badge {
  font-size: 0.62rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.prio-baja { 
  background: rgba(16, 185, 129, 0.15); 
  color: #059669; 
  border: 1px solid rgba(16, 185, 129, 0.2);
}
.prio-media { 
  background: rgba(245, 158, 11, 0.15); 
  color: #D97706; 
  border: 1px solid rgba(245, 158, 11, 0.2);
}
.prio-alta { 
  background: rgba(239, 68, 68, 0.15); 
  color: #DC2626; 
  border: 1px solid rgba(239, 68, 68, 0.2);
}
.prio-urgente { 
  background: linear-gradient(135deg, #EF4444, #b91c1c); 
  color: white; 
  box-shadow: 0 4px 10px rgba(239, 68, 68, 0.3);
  animation: pulseGlow 2s infinite;
}

.task-move-mini {
  display: flex;
  gap: 4px;
  flex: 1;
}

.task-move-mini button {
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  color: var(--brand-dark);
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.2s;
  opacity: 0.4; /* Slightly visible in light mode */
}

[data-theme="dark"] .task-move-mini button {
  background: rgba(255,255,255,0.05);
  color: var(--brand-mid);
  opacity: 0.25;
}

.pipeline-card:hover .task-move-mini button {
  opacity: 0.9;
}

.task-move-mini button:hover {
  opacity: 1 !important;
  background: var(--brand);
  color: white;
  border-color: var(--brand);
  transform: scale(1.1);
}

.task-edit-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 4px;
  margin-right: -4px;
  transition: color 0.2s;
}

.task-edit-btn:hover { color: var(--brand); }

/* Body */
.task-title-compact {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.task-desc-compact {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 2px;
}

/* Footer Row */
.task-footer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid rgba(0,0,0,0.03);
}

.task-date-mini {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.task-date-mini i {
  font-size: 0.8rem;
  opacity: 0.8;
  width: 12px;
  text-align: center;
}

.task-date-mini.has-due {
  color: var(--warning-text);
  font-weight: 700;
}

.task-badges-row {
  display: flex;
  gap: 6px;
}

.task-badge-mini {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.task-badge-mini.chat {
  background: rgba(41, 171, 226, 0.1);
  color: var(--brand);
  border-color: rgba(41, 171, 226, 0.2);
}

.task-badge-mini.checklist {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
  border-color: rgba(16, 185, 129, 0.2);
}

.task-badge-mini.files {
  background: rgba(245, 158, 11, 0.1);
  color: #D97706;
  border-color: rgba(245, 158, 11, 0.2);
}

.task-badge-mini i {
  font-size: 0.75rem;
}

/* Inline Checklist in Card - Premium v3 */
.task-checklist-card {
  margin-top: 10px;
  padding: 8px;
  background: rgba(41, 171, 226, 0.03);
  border-radius: 10px;
  border: 1px solid rgba(41, 171, 226, 0.05);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.task-checklist-item-mini {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background 0.2s;
}

.task-checklist-item-mini:hover {
  background: rgba(255,255,255,0.6);
}

.task-checklist-item-mini input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--brand-mid);
  border-radius: 4px;
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
  background: white;
  flex-shrink: 0;
}

.task-checklist-item-mini input[type="checkbox"]:checked {
  background: var(--brand);
  border-color: var(--brand);
}

.task-checklist-item-mini input[type="checkbox"]:checked::after {
  content: " \f00c";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  color: white;
  font-size: 8px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.task-checklist-item-mini span {
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  font-weight: 500;
}

.task-checklist-item-mini span.done {
  color: var(--text-muted);
  text-decoration: line-through;
  font-weight: 500;
  opacity: 0.7;
}

/* Modal Checklist Enhancement */
.checklist-item {
  background: var(--bg-input);
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 8px;
  transition: all 0.2s;
}

.checklist-item:hover {
  border-color: var(--brand-mid);
  transform: translateX(4px);
}

.cl-checkbox {
  appearance: none;
  width: 18px !important;
  height: 18px !important;
  border: 2px solid var(--brand-mid);
  border-radius: 5px;
  background: white;
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
}

.cl-checkbox:checked {
  background: var(--brand-dark) !important;
  border-color: var(--brand-dark) !important;
}

.cl-checkbox:checked::after {
  content: "\f00c" !important;
  font-family: "Font Awesome 6 Free" !important;
  font-weight: 900 !important;
  color: #ffffff !important;
  font-size: 10px !important;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex !important;
  align-items: center;
  justify-content: center;
  opacity: 1 !important;
}

.cl-text {
  border: none !important;
  background: transparent !important;
  font-weight: 600 !important;
  color: var(--text-main) !important;
  padding: 0 !important;
}

.cl-text:focus {
  outline: none;
}

.btn-ghost-danger {
  background: transparent;
  border: none;
  color: var(--danger);
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-ghost-danger:hover {
  background: rgba(239, 68, 68, 0.1);
  transform: scale(1.1);
}



/* Agenda Section */
.btn-filter {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-filter:hover {
  background: var(--brand-light);
  color: var(--brand);
}

.btn-filter.active {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}

.agenda-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem;
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--text-dim);
  transition: all 0.2s;
  cursor: pointer;
  gap: 1rem;
}

.agenda-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  border-color: var(--brand-mid);
}

.agenda-card[data-priority="urgente"] { border-left-color: var(--danger); }
.agenda-card[data-priority="alta"] { border-left-color: var(--danger); }
.agenda-card[data-priority="media"] { border-left-color: var(--warning); }
.agenda-card[data-priority="baja"] { border-left-color: var(--success); }

.dash-agenda-mini-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.dash-agenda-mini-card:hover {
  transform: scale(1.02);
  border-color: var(--brand-mid);
  box-shadow: var(--shadow-sm);
}

.agenda-task-details {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.agenda-project-label {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.agenda-task-name {
  font-weight: 700;
  color: var(--text-main);
  font-size: 1rem;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agenda-task-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.agenda-priority-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.prio-bg-urgente { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.prio-bg-alta { background: var(--danger); }
.prio-bg-media { background: var(--warning); }
.prio-bg-baja { background: var(--success); }

/* Dragging state */
.pipeline-card.dragging {
  opacity: 0.4;
  transform: scale(0.95);
  cursor: grabbing;
}

/* ── Task Modal Redesign (Wide & Fancy) ───────────────────────── */
.modal.modal-lg {
  max-width: 900px;
  width: 95%;
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 0.5rem;
}

.modal-column {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Fancy Checklist */
.fancy-checklist .checklist-item {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  margin-bottom: 0.3rem;
}

.fancy-checklist .checklist-item:hover {
  background: var(--bg-card);
  border-color: var(--brand-mid);
  transform: translateX(4px);
}

.fancy-checklist .cl-checkbox {
  width: 18px !important;
  height: 18px !important;
  cursor: pointer;
}

.fancy-checklist .cl-text {
  flex: 1;
  background: transparent !important;
  border: none !important;
  padding: 4px 0 !important;
  font-size: 0.85rem !important;
  color: var(--text-main);
}

/* Attachments Grid */
.attachments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
  margin-top: 1rem;
  background: rgba(0,0,0,0.02);
  padding: 12px;
  border-radius: 14px;
  border: 1px dashed var(--border);
}

/* Fancy Chat */
.fancy-chat-container {
  background: var(--bg-body);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 15px;
  height: 240px;
  overflow-y: auto;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.03);
}

.chat-msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  max-width: 90%;
  animation: slideInUp 0.3s ease;
}

.chat-msg-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
  gap: 10px;
}

.chat-msg-author {
  font-weight: 800;
  font-size: 0.75rem;
  color: var(--brand);
}

.chat-msg-time {
  font-size: 0.65rem;
  color: var(--text-dim);
}

.chat-msg-text {
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--text-main);
  word-wrap: break-word;
}

@keyframes slideInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 768px) {
  .modal-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
}

/* ── Financial Summary Grid (Responsive Custom) ───────────────── */
.summary-grid-responsive {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

@media (max-width: 1024px) {
  .summary-grid-responsive {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 630px) {
  .summary-grid-responsive {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.8rem;
  }
  
  /* Ordering to group Incomes in Column 1 and Others in Column 2 */
  #card-total-income  { order: 1; } /* Col 1 */
  #card-total-expense { order: 2; } /* Col 2 */
  #card-total-net     { order: 3; } /* Col 1 (was 5) */
  #card-month-pending { order: 4; } /* Col 2 */
  #card-month-income  { order: 5; } /* Col 1 (was 3) */
  #card-month-expense { order: 6; } /* Col 2 */
  
  #priority-reminder  { order: 7; grid-column: span 2; }
}

@media (min-width: 1025px) {
    /* Ensure the 6 cards take 2 rows of 3 on large screens */
    .summary-grid-responsive {
        grid-template-columns: repeat(3, 1fr);
    }
}


