/* ============================================================
   Crypto Manager — Hoja de estilos principal
   Tema: Dark financial — preciso, denso, profesional
   Fuentes: IBM Plex Mono (datos) + Syne (títulos) + Inter (cuerpo)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=IBM+Plex+Mono:wght@400;500&family=Inter:wght@400;500;600&display=swap');

/* ---- Variables ------------------------------------------- */
:root {
  --bg:         #0d0f14;
  --bg-card:    #131720;
  --bg-hover:   #1a1f2e;
  --border:     #1e2535;
  --border-hi:  #2a3349;

  --text:       #e2e8f0;
  --text-muted: #64748b;
  --text-dim:   #94a3b8;

  --accent:     #3b82f6;
  --accent-dim: #1d4ed8;
  --accent-glow:rgba(59,130,246,.15);

  --green:      #10b981;
  --green-dim:  rgba(16,185,129,.12);
  --red:        #ef4444;
  --red-dim:    rgba(239,68,68,.12);
  --yellow:     #f59e0b;
  --yellow-dim: rgba(245,158,11,.12);

  --radius:     8px;
  --radius-lg:  12px;
  --nav-w:      220px;
  --shadow:     0 4px 24px rgba(0,0,0,.4);

  --font-body:  'Inter', system-ui, sans-serif;
  --font-head:  'Syne', sans-serif;
  --font-mono:  'IBM Plex Mono', monospace;
}

/* ---- Reset ----------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: #60a5fa; }

/* ---- Navbar ---------------------------------------------- */
.navbar {
  position: fixed;
  top: 0; left: 0;
  width: var(--nav-w);
  height: 100vh;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  z-index: 100;
  overflow-y: auto;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 20px;
  border-bottom: 1px solid var(--border);
}

.logo-mark {
  font-size: 22px;
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 700;
  flex-shrink: 0;
}

.logo-text {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
}

.navbar-menu {
  list-style: none;
  padding: 12px 0;
  flex: 1;
}

.navbar-menu li { padding: 2px 8px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--text-dim);
  font-weight: 500;
  transition: all .15s;
}

.nav-link:hover { background: var(--bg-hover); color: var(--text); }
.nav-link.active { background: var(--accent-glow); color: var(--accent); border: 1px solid rgba(59,130,246,.3); }

.nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-label { font-size: 13px; }

.navbar-user {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-name {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Main content ---------------------------------------- */
.main-content {
  margin-left: var(--nav-w);
  padding: 28px 32px;
  min-height: 100vh;
  max-width: 1400px;
}

/* ---- Page header ----------------------------------------- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header h2 {
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 700;
}

.page-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 12px;
  background: var(--border);
  padding: 2px 8px;
  border-radius: 100px;
}

.page-actions { display: flex; gap: 8px; align-items: center; }

/* ---- Cards ----------------------------------------------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.card-header h3 {
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: .3px;
}

.card-note { font-size: 11px; color: var(--text-muted); margin-top: 12px; }
.card-note-inline { font-size: 11px; color: var(--text-muted); }
.card-fiscal { border-left: 3px solid var(--yellow); }

/* ---- KPI Grid -------------------------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  gap: 14px;
  align-items: center;
  transition: border-color .2s;
}
.kpi-card:hover { border-color: var(--border-hi); }
.kpi-card.kpi-positive { border-left: 3px solid var(--green); }
.kpi-card.kpi-negative { border-left: 3px solid var(--red); }

.kpi-icon { font-size: 28px; }
.kpi-data { display: flex; flex-direction: column; gap: 2px; }
.kpi-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.kpi-value { font-family: var(--font-mono); font-size: 18px; font-weight: 500; color: var(--text); }
.kpi-sub   { font-size: 11px; color: var(--text-muted); }

/* ---- Dashboard grid -------------------------------------- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

/* ---- Tables ---------------------------------------------- */
.table-responsive { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  vertical-align: middle;
}

.table-hover tbody tr:hover td { background: var(--bg-hover); }
.table-sm td, .table-sm th { padding: 6px 8px; font-size: 12px; }

.table-total td {
  background: var(--bg-hover);
  color: var(--text);
  font-weight: 600;
  border-top: 2px solid var(--border-hi);
}

.text-right { text-align: right !important; }

/* ---- Badges ---------------------------------------------- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.badge-compra { background: var(--green-dim); color: var(--green); }
.badge-venta  { background: var(--red-dim);   color: var(--red); }
.badge-info   { background: var(--yellow-dim); color: var(--yellow); }

.badge-crypto {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ---- P&L colors ------------------------------------------ */
.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }
.neutral  { color: var(--text-dim); }

/* ---- Mono ----------------------------------------------- */
.mono { font-family: var(--font-mono); font-size: 12px; }
.date-cell { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); white-space: nowrap; }

/* ---- Buttons --------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s;
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-dim); color: #fff; }

.btn-outline {
  background: transparent;
  color: var(--text-dim);
  border-color: var(--border-hi);
}
.btn-outline:hover { background: var(--bg-hover); color: var(--text); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

.btn-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 4px 6px;
  border-radius: 4px;
  transition: background .15s;
}
.btn-icon:hover { background: var(--bg-hover); }
.btn-danger:hover { background: var(--red-dim) !important; }

.btn-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 4px;
}
.btn-close:hover { background: var(--bg-hover); color: var(--text); }

/* ---- Forms ----------------------------------------------- */
.form-card {
  display: none;
  margin-bottom: 20px;
}
.form-card.visible { display: block; }

.form-row {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
  min-width: 180px;
}

.form-group-wide { flex: 2; }

.form-group label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.form-group input,
.form-group select,
.form-group textarea {
  background: var(--bg);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--font-body);
  transition: border-color .15s;
  width: 100%;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group select option { background: var(--bg-card); }

.label-hint {
  cursor: help;
  color: var(--text-muted);
  font-size: 12px;
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  margin-top: 16px;
}

/* Toggle COMPRA/VENTA */
.toggle-group {
  display: flex;
  gap: 0;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  overflow: hidden;
}

.toggle-opt input { display: none; }

.toggle-label {
  display: block;
  padding: 8px 18px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg);
  transition: all .15s;
}

.toggle-opt input:checked + .toggle-label.compra {
  background: var(--green-dim);
  color: var(--green);
}
.toggle-opt input:checked + .toggle-label.venta {
  background: var(--red-dim);
  color: var(--red);
}

/* Calc preview */
.calc-preview {
  display: flex;
  gap: 24px;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-muted);
}
.calc-preview strong { font-family: var(--font-mono); color: var(--text); }

/* ---- Filters -------------------------------------------- */
.filters-card { padding: 14px 20px; }
.filter-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.filter-form input, .filter-form select {
  background: var(--bg);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  color: var(--text);
  padding: 7px 10px;
  font-size: 12px;
}
.filter-form input:focus, .filter-form select:focus {
  outline: none;
  border-color: var(--accent);
}
.filter-form span { color: var(--text-muted); }

/* ---- Pagination ------------------------------------------ */
.pagination {
  display: flex;
  gap: 4px;
  padding: 16px 0 4px;
  justify-content: center;
  flex-wrap: wrap;
}
.page-btn {
  padding: 5px 10px;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--border-hi);
  color: var(--text-dim);
  font-size: 12px;
  font-family: var(--font-mono);
  transition: all .15s;
}
.page-btn:hover { background: var(--bg-hover); color: var(--text); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---- Alerts ---------------------------------------------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
}
.alert p { margin: 0; }
.alert-success { background: var(--green-dim); border: 1px solid rgba(16,185,129,.3); color: var(--green); }
.alert-error   { background: var(--red-dim);   border: 1px solid rgba(239,68,68,.3);  color: var(--red); }
.alert-info    { background: var(--yellow-dim); border: 1px solid rgba(245,158,11,.3); color: var(--yellow); }

/* ---- Empty state ----------------------------------------- */
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 32px;
  font-size: 13px;
}

/* ---- Inline form ----------------------------------------- */
.inline-form { display: inline; }

/* ---- Select year ----------------------------------------- */
.select-year {
  background: var(--bg-card);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  color: var(--text);
  padding: 6px 10px;
  font-size: 13px;
}

/* ---- Login ----------------------------------------------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(59,130,246,.07) 0, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(16,185,129,.05) 0, transparent 50%),
    var(--bg);
}

.login-container {
  width: 100%;
  max-width: 380px;
  padding: 40px;
  background: var(--bg-card);
  border: 1px solid var(--border-hi);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px; height: 56px;
  background: var(--accent);
  border-radius: 14px;
  font-size: 26px;
  margin-bottom: 12px;
}

.login-logo h1 {
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 4px;
}

.login-logo p { font-size: 13px; color: var(--text-muted); }

.login-form { display: flex; flex-direction: column; gap: 16px; }

/* ---- Scrollbar ------------------------------------------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---- Responsive ------------------------------------------ */
@media (max-width: 768px) {
  :root { --nav-w: 0px; }

  .navbar {
    width: 100%;
    height: auto;
    position: relative;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 8px;
  }

  .navbar-menu {
    display: flex;
    flex-direction: row;
    padding: 0;
    gap: 4px;
  }

  .navbar-menu li { padding: 0; }
  .nav-label { display: none; }

  .main-content { padding: 16px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
}
