/* ========== VARIABLES ========== */
:root {
  --pc-green: #10b981;
  --pc-green-dim: #34d399;
  --pc-red: #ef4444;
  --pc-orange: #f59e0b;
  --pc-blue: #3b82f6;
  --pc-purple: #8b5cf6;
  --pc-radius: 0.75rem;
  --pc-shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  --pc-shadow: 0 4px 12px rgba(0,0,0,0.15);
  --pc-shadow-lg: 0 10px 30px rgba(0,0,0,0.2);
}

[data-theme="dark"] {
  --pc-card-bg: #1a2332;
  --pc-card-border: #2a3447;
  --pc-card-hover: #1e2839;
  --pc-text-muted: rgba(255,255,255,0.55);
  --pc-bg-soft: rgba(255,255,255,0.03);
}

[data-theme="light"] {
  --pc-card-bg: #ffffff;
  --pc-card-border: #e5e7eb;
  --pc-card-hover: #f9fafb;
  --pc-text-muted: rgba(0,0,0,0.55);
  --pc-bg-soft: rgba(0,0,0,0.02);
}

/* ========== LAYOUT ========== */
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
main.container-fluid { padding: 1.5rem 2rem; max-width: 1600px; margin: 0 auto; }

/* ========== NAV ========== */
nav.container-fluid {
  background: var(--pc-card-bg);
  border-bottom: 1px solid var(--pc-card-border);
  padding: 0.5rem 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--pc-shadow-sm);
  transition: transform 0.25s ease;
}
nav.container-fluid.nav-hidden { transform: translateY(-100%); }
nav.container-fluid > ul { flex-wrap: wrap; gap: 0.25rem; margin: 0; }
nav a { font-weight: 500; }
.hamburger {
  background: transparent !important;
  border: 1px solid var(--pc-card-border) !important;
  color: inherit !important;
  font-size: 1.4rem !important;
  padding: 0.25rem 0.6rem !important;
  margin: 0 !important;
  cursor: pointer;
  line-height: 1;
}

/* Default: desktop layout */
.mobile-only { display: none !important; }
nav ul li { list-style: none; }

/* Mobile breakpoint */
@media (max-width: 900px) {
  nav.container-fluid {
    padding: 0.5rem 0.75rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
  }
  /* Reordenar: logo (ul1) | nueva-op+hamburger (ul3) | menu (ul2) */
  nav.container-fluid > ul:nth-child(1) { order: 1; flex: 1 1 auto; }
  nav.container-fluid > ul.nav-actions { order: 2; }
  nav.container-fluid > ul.nav-links { order: 3; flex-basis: 100%; }
  nav.container-fluid > ul { display: flex; align-items: center; gap: 0.5rem; }

  .desktop-only { display: none !important; }
  .mobile-only { display: list-item !important; }

  .nav-links {
    flex-direction: column;
    align-items: stretch !important;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    margin-top: 0 !important;
    padding: 0;
  }
  .nav-links.mobile-open {
    max-height: 600px;
    margin-top: 0.5rem !important;
  }
  .nav-links li {
    width: 100%;
    padding: 0;
    list-style: none;
  }
  .nav-links a, .nav-links button {
    display: block !important;
    padding: 0.65rem 0.85rem !important;
    border-radius: 0.5rem;
    width: 100% !important;
    text-align: left !important;
    margin: 0 !important;
    border: none !important;
    background: transparent !important;
    color: inherit !important;
    font-size: 1rem !important;
  }
  .nav-links a:hover, .nav-links button:hover { background: var(--pc-card-hover) !important; }

  .btn-new-op {
    padding: 0.4rem 0.85rem !important;
    font-size: 0.85rem !important;
  }
  main.container-fluid { padding: 1rem 0.75rem; }
  .hero-value { font-size: 1.6rem !important; }
  .hero-card { padding: 1rem 1.15rem !important; }
  .hero-grid, .accounts-grid, .grid-dashboard { grid-template-columns: 1fr !important; }
}

.btn-new-op {
  background: var(--pc-green) !important;
  border-color: var(--pc-green) !important;
  color: white !important;
  font-weight: 600;
  padding: 0.55rem 1.25rem !important;
  font-size: 0.95rem !important;
  margin: 0 !important;
  border-radius: var(--pc-radius);
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.4);
  transition: all 0.2s;
}
.btn-new-op:hover {
  background: var(--pc-green-dim) !important;
  border-color: var(--pc-green-dim) !important;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.6);
  transform: translateY(-1px);
}

.theme-toggle {
  background: transparent !important;
  border: 1px solid var(--pc-card-border) !important;
  color: var(--pc-text-muted) !important;
  padding: 0.4rem 0.6rem !important;
  margin: 0 !important;
  font-size: 1rem !important;
  border-radius: var(--pc-radius);
  cursor: pointer;
}
.theme-toggle:hover { color: inherit !important; border-color: var(--pc-blue) !important; }

/* ========== CARDS / ARTICLES ========== */
article {
  background: var(--pc-card-bg);
  border: 1px solid var(--pc-card-border);
  border-radius: var(--pc-radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--pc-shadow-sm);
}
article header { padding: 0; margin-bottom: 1rem; border-bottom: 1px solid var(--pc-card-border); padding-bottom: 0.75rem; }
article header h4 { margin: 0; font-size: 1rem; font-weight: 600; letter-spacing: 0.02em; }

/* ========== DASHBOARD GRID ========== */
.grid-dashboard {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 1100px) { .grid-dashboard { grid-template-columns: 1fr; } }

.summary-card { grid-column: 1 / -1; }

/* ========== METRICS ========== */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.metric {
  padding: 0.75rem;
  background: var(--pc-bg-soft);
  border-radius: 0.5rem;
  border: 1px solid var(--pc-card-border);
}
.metric small {
  display: block;
  color: var(--pc-text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
  font-weight: 600;
}
.metric strong { font-size: 1.25rem; font-weight: 700; line-height: 1.2; }
.metric span { font-size: 1rem; font-weight: 500; }

.metric-hero {
  grid-column: span 2;
  padding: 1.25rem;
  background: linear-gradient(135deg, var(--pc-bg-soft), transparent);
}
.metric-hero strong { font-size: 1.75rem; }

/* ========== TEXT COLORS ========== */
.text-right { text-align: right; }
.text-green { color: var(--pc-green); }
.text-red { color: var(--pc-red); }
.text-orange { color: var(--pc-orange); }
.text-muted { color: var(--pc-text-muted); }

/* ========== ROW COLORS ========== */
.row-moroso, .row-moroso td { color: var(--pc-red) !important; font-weight: 600; }
.row-debt-them, .row-debt-them td { color: var(--pc-orange) !important; }
.row-debt-us, .row-debt-us td { color: var(--pc-blue) !important; }
.row-inactive { opacity: 0.4; }

/* ========== TABLES ========== */
table { font-size: 0.9rem; }
.compact-table { font-size: 0.85rem; }
.compact-table td, .compact-table th { padding: 0.35rem 0.6rem; }

table thead th {
  background: var(--pc-card-bg);
  border-bottom: 2px solid var(--pc-card-border);
}

.account-list details { margin-bottom: 0.75rem; border-bottom: 1px solid var(--pc-card-border); padding-bottom: 0.5rem; }
.account-list details:last-child { border-bottom: none; }
.account-list summary {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--pc-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.5rem 0;
  cursor: pointer;
}
.account-list summary:hover { color: inherit; }
.account-list table tr td { padding: 0.4rem 0.5rem; border: none; }
.account-list table tr:hover td { background: var(--pc-card-hover); }

/* ========== BUTTONS ========== */
.btn-sm {
  padding: 0.35rem 0.85rem !important;
  font-size: 0.85rem !important;
  border-radius: 0.5rem !important;
  margin: 0 !important;
}
.btn-delete {
  padding: 0.15rem 0.5rem !important;
  font-size: 0.75rem !important;
  margin: 0 !important;
}

/* ========== AUTOCOMPLETE ========== */
.autocomplete-wrap { position: relative; }
.ac-results {
  position: absolute;
  top: 100%; left: 0; right: 0;
  background: var(--pc-card-bg);
  border: 1px solid var(--pc-card-border);
  border-radius: var(--pc-radius);
  max-height: 320px; overflow-y: auto;
  z-index: 50;
  display: none;
  box-shadow: var(--pc-shadow-lg);
  margin-top: 4px;
}
.ac-item {
  padding: 0.6rem 0.85rem;
  cursor: pointer;
  border-bottom: 1px solid var(--pc-card-border);
  font-size: 0.9rem;
  transition: background 0.1s;
}
.ac-item:hover { background: var(--pc-card-hover); }
.ac-item:last-child { border-bottom: none; }
.ac-item small { color: var(--pc-text-muted); }
.ac-empty { opacity: 0.5; cursor: default; }

/* ========== FORMS ========== */
fieldset {
  border: 1px solid var(--pc-card-border);
  border-radius: var(--pc-radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  background: var(--pc-bg-soft);
}
legend { font-weight: 700; padding: 0 0.5rem; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; }

/* ========== DIALOGS ========== */
dialog { max-width: 500px; border-radius: var(--pc-radius); border: 1px solid var(--pc-card-border); box-shadow: var(--pc-shadow-lg); }
dialog::backdrop { background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); }
dialog article { margin: 0; border: none; box-shadow: none; }
dialog footer { display: flex; gap: 1rem; justify-content: flex-end; margin-top: 1rem; }

/* ========== FLASH ========== */
.flash {
  padding: 0.85rem 1.25rem;
  border-radius: var(--pc-radius);
  margin-bottom: 1rem;
  background: var(--pc-green);
  color: white;
  font-weight: 500;
}

/* ========== UTILS ========== */
.overflow-auto { overflow-x: auto; }
hr { border: none; border-top: 1px solid var(--pc-card-border); margin: 1rem 0; }

/* ========== BADGES ========== */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 0.25rem;
  background: var(--pc-bg-soft);
  color: var(--pc-text-muted);
  border: 1px solid var(--pc-card-border);
}
.badge-green { background: rgba(16,185,129,0.15); color: var(--pc-green); border-color: rgba(16,185,129,0.3); }
.badge-red { background: rgba(239,68,68,0.15); color: var(--pc-red); border-color: rgba(239,68,68,0.3); }
.badge-orange { background: rgba(245,158,11,0.15); color: var(--pc-orange); border-color: rgba(245,158,11,0.3); }
.badge-blue { background: rgba(59,130,246,0.15); color: var(--pc-blue); border-color: rgba(59,130,246,0.3); }

/* ========== HERO CARDS ========== */
.hero-grid {
  display: grid;
  grid-template-columns: 2fr 2fr 1.5fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 1100px) { .hero-grid { grid-template-columns: 1fr; } }

.hero-card {
  margin: 0;
  padding: 1.5rem 1.75rem;
}
.hero-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--pc-text-muted);
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.hero-value { font-size: 2.25rem; font-weight: 800; line-height: 1.1; margin-bottom: 0.75rem; }
.hero-sub { font-size: 0.9rem; }
.hero-sub .dot { margin: 0 0.5rem; color: var(--pc-text-muted); }

.hero-ganancia { position: relative; overflow: hidden; }
.hero-ganancia.positive { border-color: rgba(16, 185, 129, 0.4); background: linear-gradient(135deg, rgba(16,185,129,0.05), var(--pc-card-bg)); }
.hero-ganancia.negative { border-color: rgba(239, 68, 68, 0.4); background: linear-gradient(135deg, rgba(239,68,68,0.05), var(--pc-card-bg)); }

.hero-rates .rate-row { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 0.75rem; }
.hero-rates .rate-cell small { display: block; color: var(--pc-text-muted); font-size: 0.7rem; text-transform: uppercase; margin-bottom: 0.2rem; }
.hero-rates .rate-cell strong { font-size: 1.15rem; }

/* ========== STRIP ========== */
.strip-card { padding: 0.85rem 1.25rem; }
.strip-card small { color: var(--pc-text-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; display: block; margin-bottom: 0.2rem; }
.strip-grid { display: grid; grid-template-columns: 1fr auto; gap: 1rem; align-items: center; }

/* ========== ACCOUNTS GRID ========== */
.accounts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 1100px) { .accounts-grid { grid-template-columns: 1fr; } }

article header { display: flex; justify-content: space-between; align-items: center; }

.cat-total {
  font-weight: 700;
  color: var(--pc-text-muted);
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.85rem;
  margin-left: auto;
  padding-right: 1.5rem;
}
.account-list summary { display: flex; justify-content: flex-start; align-items: center; }

.acc-link { color: inherit; text-decoration: none; }
.acc-link:hover { color: var(--pc-blue); }
.warn-icon { text-decoration: none; margin-left: 0.25rem; }

/* Old grid-dashboard kept for compat */
.grid-dashboard { display: grid; grid-template-columns: 1fr; gap: 1.25rem; margin-bottom: 1.25rem; }

/* ========== SETTINGS OP TYPES ========== */
.op-type-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin: 0;
  flex-wrap: wrap;
}
.op-name-input { text-transform: uppercase; margin: 0; flex: 1 1 200px; min-width: 200px; }
.op-check { margin: 0; white-space: nowrap; display: flex; align-items: center; gap: 0.35rem; font-size: 0.85rem; }
.op-check input { margin: 0; }
.op-save-btn, .op-add-btn { white-space: nowrap; flex: 0 0 auto !important; width: auto !important; min-width: 0 !important; padding: 0.35rem 1rem !important; }
.op-add-btn { white-space: nowrap; flex: 0 0 auto; min-width: unset; width: auto; }

.op-type-add {
  display: flex;
  gap: 0.75rem;
  align-items: end;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.op-name-label { flex: 1 1 200px; min-width: 200px; }
.op-name-label input { text-transform: uppercase; }
.op-check-add { display: flex; align-items: center; gap: 0.5rem; margin: 0; padding-bottom: 0.55rem; white-space: nowrap; }

/* ========== DROP ZONE ========== */
.drop-zone {
  border: 2px dashed var(--pc-card-border);
  border-radius: var(--pc-radius);
  padding: 1.5rem;
  text-align: center;
  background: var(--pc-bg-soft);
  transition: all 0.2s;
  margin-bottom: 1rem;
}
.drop-zone:hover { border-color: var(--pc-blue); }
.drop-zone.drag-over {
  border-color: var(--pc-green);
  background: rgba(16, 185, 129, 0.05);
  transform: scale(1.01);
}
.drop-zone kbd {
  background: var(--pc-card-border);
  padding: 0.15rem 0.4rem;
  border-radius: 0.25rem;
  font-size: 0.85rem;
  font-family: monospace;
}
.drop-zone a { color: var(--pc-blue); cursor: pointer; }
