/* ============================================================
   Orbexa Studio · Sistema de Cuentas de Cobro
   Diseño inspirado en Stripe Dashboard / Linear / Vercel
   Color corporativo: #E8B09F
   ============================================================ */
:root {
  --bg: #0B0F14;
  --bg-sidebar: #0E1219;
  --surface: #12161E;
  --surface-2: #171D27;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text: #E8EAF0;
  --muted: #8F98A8;
  --accent: #E8B09F;
  --accent-hover: #F3C6B8;
  --accent-soft: rgba(232, 176, 159, 0.12);
  --accent-border: rgba(232, 176, 159, 0.35);
  --green: #34D399;
  --green-soft: rgba(52, 211, 153, 0.12);
  --red: #F87171;
  --red-soft: rgba(248, 113, 113, 0.12);
  --amber: #FBBF24;
  --amber-soft: rgba(251, 191, 36, 0.12);
  --blue: #60A5FA;
  --blue-soft: rgba(96, 165, 250, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.18);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

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

::selection { background: var(--accent-soft); }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 20;
}

.main {
  flex: 1;
  margin-left: 240px;
  min-width: 0;
}

/* ---------- Sidebar ---------- */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid var(--border);
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 6px;
  object-fit: contain;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: 0.2px; }
.brand-sub { color: var(--muted); font-size: 11px; }

.nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 500;
  font-size: 13.5px;
  transition: background 0.15s, color 0.15s;
}
.nav-link .ico { width: 17px; height: 17px; flex-shrink: 0; }
.nav-link:hover { background: rgba(255, 255, 255, 0.04); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }

.sidebar-foot {
  padding: 14px 12px;
  border-top: 1px solid var(--border);
}
.usuario {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #0B0F14;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.usuario-info { flex: 1; min-width: 0; line-height: 1.25; }
.usuario-nombre { display: block; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.usuario-rol { color: var(--muted); font-size: 11px; text-transform: capitalize; }
.logout { color: var(--muted); display: flex; padding: 6px; border-radius: 6px; }
.logout:hover { color: var(--red); background: var(--red-soft); }
.logout .ico { width: 16px; height: 16px; }

/* ---------- Main / topbar ---------- */
.main { display: flex; flex-direction: column; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 32px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(11, 15, 20, 0.85);
  backdrop-filter: blur(10px);
  z-index: 10;
}
.page-title { font-size: 17px; font-weight: 700; letter-spacing: -0.2px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.content { padding: 28px 32px 48px; max-width: 1280px; width: 100%; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  text-decoration: none;
  line-height: 1.2;
  white-space: nowrap;
}
.btn .ico { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: #0B0F14; }
.btn-primary:hover { background: var(--accent-hover); color: #0B0F14; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.2); }
.btn-danger { background: var(--red-soft); color: var(--red); border-color: rgba(248, 113, 113, 0.25); }
.btn-danger:hover { background: rgba(248, 113, 113, 0.2); color: var(--red); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-xs { padding: 4px 9px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Formularios ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text); }
.field label .req { color: var(--accent); }
.field input,
.field select,
.field textarea {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field input::placeholder, .field textarea::placeholder { color: #5A6374; }
.field-full { grid-column: 1 / -1; }

.input-prefix { position: relative; display: flex; align-items: center; }
.input-prefix span { position: absolute; left: 12px; color: var(--muted); font-weight: 600; }
.input-prefix input { padding-left: 28px; }

.password-wrap { position: relative; }
.password-wrap input { padding-right: 42px; }
.toggle-pass {
  position: absolute; right: 6px; top: 50%;
  transform: translateY(-50%);
  background: transparent; border: none; cursor: pointer;
  color: var(--muted); padding: 6px; display: flex;
}
.toggle-pass:hover { color: var(--text); }
.toggle-pass svg { width: 17px; height: 17px; }

.form-actions { display: flex; align-items: center; gap: 10px; margin-top: 20px; }

/* ---------- Paneles y tablas ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.panel-lg { padding: 28px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.panel-head h2 { font-size: 15px; font-weight: 700; letter-spacing: -0.2px; }
.link { font-size: 13px; font-weight: 600; }
.link-danger { color: var(--red); }
.link-danger:hover { color: #fca5a5; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.muted { color: var(--muted); }
.accent { color: var(--accent); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: rgba(255, 255, 255, 0.02); }
.td-truncate { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-acciones { text-align: right; white-space: nowrap; }
.th-acciones { text-align: right; }
.td-acciones .btn, .td-acciones form { margin-left: 6px; }

.table-detalle td { padding: 12px; }
.table-detalle .k { color: var(--muted); width: 38%; font-weight: 500; }
.valor-grande { font-size: 20px; font-weight: 800; color: var(--accent); }
.fila-total td { border-top: 1px solid var(--border-strong); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-lg { padding: 6px 14px; font-size: 12.5px; }

/* ---------- Stats ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.stat-card::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.5;
}
.stat-ico {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-ico svg { width: 20px; height: 20px; }
.stat-ico-blue { background: var(--blue-soft); color: var(--blue); }
.stat-ico-green { background: var(--green-soft); color: var(--green); }
.stat-ico-amber { background: var(--amber-soft); color: var(--amber); }
.stat-ico-rose { background: var(--accent-soft); color: var(--accent); }
.stat-info { display: flex; flex-direction: column; min-width: 0; }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 500; }
.stat-value { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; line-height: 1.2; margin-top: 2px; }
.stat-sub { position: absolute; bottom: 14px; right: 16px; font-size: 11.5px; color: var(--muted); }
.stat-sub-green { color: var(--green); }
.stat-sub-amber { color: var(--amber); }

/* ---------- Alertas ---------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 18px;
  border: 1px solid;
}
.alert-success { background: var(--green-soft); color: var(--green); border-color: rgba(52, 211, 153, 0.25); }
.alert-error { background: var(--red-soft); color: var(--red); border-color: rgba(248, 113, 113, 0.25); }

/* ---------- Empty / misc ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty p { margin-bottom: 16px; }

.list-meta { padding: 0 2px 14px; font-size: 13px; }

.section-sub {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--accent);
  margin: 26px 0 4px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.section-sub + .muted { margin-bottom: 16px; }

.paginacion { display: flex; justify-content: center; gap: 6px; margin: 20px 0 30px; }
.pag {
  min-width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  font-size: 13px;
}
.pag:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.25); }
.pag.active { background: var(--accent); color: #0B0F14; border-color: var(--accent); font-weight: 700; }

/* ---------- Filtros ---------- */
.filtros {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.filtros .field { margin-bottom: 0; }
.filtros select, .filtros input[type="date"] { min-width: 150px; }
.filtro-busqueda { position: relative; flex: 1; min-width: 220px; }
.filtro-busqueda .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.filtro-busqueda input {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 12px 9px 36px;
  width: 100%;
  font-size: 13.5px;
  outline: none;
}
.filtro-busqueda input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.filtro-busqueda input::placeholder { color: #5A6374; }

/* ---------- Dropzone ---------- */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  display: block;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dz-ico { width: 40px; height: 40px; color: var(--accent); margin-bottom: 12px; }
.dz-title { font-size: 15px; font-weight: 600; }
.dz-link { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.dz-sub { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.dz-name { margin-top: 12px; color: var(--green); font-weight: 600; font-size: 13px; }

/* ---------- Detail ---------- */
.detail-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.detalle-etiqueta {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--accent);
}
.detail-titulo h2 { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; margin: 4px 0 2px; }
.detail-acciones { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.raw { margin-top: 20px; }
.raw summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.raw pre {
  margin-top: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 12px;
  white-space: pre-wrap;
  color: var(--muted);
  max-height: 260px;
  overflow: auto;
}

/* ---------- Gráfico ---------- */
.chart {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  height: 200px;
  padding-top: 20px;
}
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.chart-bar-wrap { width: 100%; display: flex; align-items: flex-end; justify-content: center; height: 100%; }
.chart-bar {
  width: 60%;
  background: linear-gradient(180deg, var(--accent), rgba(232, 176, 159, 0.35));
  border-radius: 6px 6px 0 0;
  min-height: 4px;
  position: relative;
  transition: opacity 0.15s;
}
.chart-bar:hover { opacity: 0.85; }
.chart-bar .tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 11px;
  white-space: nowrap;
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 5;
}
.chart-bar:hover .tooltip { opacity: 1; }
.chart-label { font-size: 11px; color: var(--muted); font-weight: 600; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(3px); }
.modal-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 560px;
  padding: 24px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-head h3 { font-size: 16px; font-weight: 700; }
.modal-close {
  background: transparent; border: none; color: var(--muted);
  font-size: 22px; cursor: pointer; line-height: 1; padding: 4px;
}
.modal-close:hover { color: var(--text); }

/* ---------- Login ---------- */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.auth-bg {
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(600px 400px at 15% 20%, rgba(232, 176, 159, 0.09), transparent 60%),
    radial-gradient(700px 500px at 85% 80%, rgba(96, 165, 250, 0.06), transparent 60%),
    var(--bg);
}
.auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 36px 32px;
}
.auth-logo { text-align: center; margin-bottom: 24px; }
.auth-logo img { width: 56px; height: 56px; border-radius: 14px; }
.auth-logo h1 { font-size: 20px; font-weight: 800; margin-top: 12px; letter-spacing: -0.3px; }
.auth-logo p { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.auth-form { display: flex; flex-direction: column; gap: 2px; }
.auth-hint { text-align: center; color: var(--muted); font-size: 12px; margin-top: 20px; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { width: 64px; }
  .sidebar-brand { justify-content: center; padding: 16px 8px; }
  .brand-text, .nav-link span, .usuario-info, .logout { display: none; }
  .nav { padding: 12px 8px; }
  .nav-link { justify-content: center; padding: 10px; }
  .usuario { justify-content: center; padding: 8px; }
  .main { margin-left: 64px; }
  .content { padding: 20px 16px 40px; }
  .topbar { padding: 14px 16px; }
  .stats-grid { grid-template-columns: 1fr; }
}
