:root {
  --bg: #12151c;
  --surface: #1b2028;
  --surface-2: #232a35;
  --text: #e7e4dc;
  --text-muted: #8a8f98;
  --accent: #c9a227;
  --error: #c1443c;
  --radius: 10px;
  --font-display: Georgia, 'Iowan Old Style', 'Times New Roman', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Courier New', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Login ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  padding: 40px 32px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.seal {
  color: var(--accent);
  display: inline-flex;
  transform: rotate(-6deg);
  margin-bottom: 4px;
}

.login-card h1 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  margin: 4px 0 4px;
  letter-spacing: 0.02em;
}

.subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 28px;
  line-height: 1.4;
}

.login-card form {
  text-align: left;
  display: flex;
  flex-direction: column;
}

.login-card label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-top: 14px;
  margin-bottom: 6px;
}

.login-card input {
  background: var(--surface-2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 11px 12px;
  color: var(--text);
  font-size: 15px;
  font-family: var(--font-body);
}

.login-card input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

.login-card button {
  margin-top: 22px;
  background: var(--accent);
  color: #1b1503;
  border: none;
  border-radius: 6px;
  padding: 12px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.login-card button:hover { background: #dcb62d; }
.login-card button:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

.error {
  background: rgba(193, 68, 60, 0.12);
  border: 1px solid rgba(193, 68, 60, 0.4);
  color: #e39089;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 6px;
  margin-bottom: 4px;
  text-align: left;
}

/* ---------- Estructura general (topbar + contenido) ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.topbar .brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  color: var(--accent);
}

.topbar .mainnav { display: flex; gap: 4px; }
.topbar .mainnav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  padding: 6px 12px;
  border-radius: 6px;
}
.topbar .mainnav a svg { width: 16px; height: 16px; flex-shrink: 0; }
.topbar .mainnav a:hover { color: var(--text); }
.topbar .mainnav a.active { color: var(--accent); background: rgba(201, 162, 39, 0.1); }

.topbar .user { color: var(--text-muted); font-size: 13px; margin-left: auto; }

.topbar .logout {
  color: var(--text);
  font-size: 13px;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 6px 12px;
  border-radius: 6px;
}
.topbar .logout:hover { border-color: var(--accent); color: var(--accent); }

.content {
  max-width: 1000px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

.placeholder { padding: 40px 24px; color: var(--text-muted); }

/* ---------- Encabezado de página ---------- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.page-header h1 {
  font-family: var(--font-display);
  font-size: 22px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.page-header h1 svg { width: 19px; height: 19px; color: var(--accent); flex-shrink: 0; }
.page-header a { color: var(--text-muted); font-size: 14px; text-decoration: none; }
.page-header a:hover { color: var(--accent); }

h2 {
  font-family: var(--font-display);
  font-size: 16px;
  margin: 28px 0 10px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
h2 svg { width: 17px; height: 17px; color: var(--accent); flex-shrink: 0; }

/* ---------- Hero de bienvenida ---------- */
.hero-panel { margin-bottom: 26px; }
.hero-panel h1 { font-family: var(--font-display); font-size: 26px; margin: 0 0 6px; }
.hero-panel .hero-sub { color: var(--text-muted); font-size: 13px; margin: 0; }

/* ---------- Compartimientos (Ventas / Personal) ---------- */
.compartments {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 32px;
}
.compartment-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  padding: 24px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.compartment-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.compartment-icon {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(201, 162, 39, 0.12);
  color: var(--accent);
}
.compartment-icon svg { width: 22px; height: 22px; }
.compartment-title { font-family: var(--font-display); font-size: 18px; }
.compartment-desc { color: var(--text-muted); font-size: 13px; line-height: 1.45; }
.compartment-stat {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}
.compartment-stat svg { width: 14px; height: 14px; }

/* ---------- Botones ---------- */
.btn-primary {
  background: var(--accent);
  color: #1b1503;
  border: none;
  border-radius: 6px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  display: inline-block;
  cursor: pointer;
}
.btn-primary:hover { background: #dcb62d; }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-link-danger {
  background: none;
  border: none;
  color: #e39089;
  cursor: pointer;
  font-size: 13px;
  padding: 0;
}
.btn-link-danger:hover { text-decoration: underline; }

/* ---------- Buscador ---------- */
.search-bar { display: flex; gap: 8px; margin-bottom: 18px; }
.search-bar input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 9px 12px;
  color: var(--text);
}
.search-bar button {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 9px 16px;
  cursor: pointer;
}

/* ---------- Tablas ---------- */
.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
th { color: var(--text-muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
tr:last-child td { border-bottom: none; }
td.mono, .mono { font-family: var(--font-mono); }
td.empty, .empty { color: var(--text-muted); text-align: center; padding: 24px; }
.row-actions { display: flex; gap: 10px; align-items: center; }
.row-actions form { display: inline; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}
.badge-success { background: rgba(90, 168, 110, 0.15); color: #7fd396; }
.badge-warning { background: rgba(201, 162, 39, 0.15); color: var(--accent); }
.badge-danger  { background: rgba(193, 68, 60, 0.15); color: #e39089; }

/* ---------- Formularios de módulo ---------- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 20px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}
.form-grid.form-compact { grid-template-columns: 1fr 1fr 1fr; align-items: end; }
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.form-grid label.full { grid-column: 1 / -1; }
.form-grid input, .form-grid select, .form-grid textarea {
  background: var(--surface-2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-body);
  text-transform: none;
  letter-spacing: normal;
}
.form-grid input:focus-visible, .form-grid select:focus-visible, .form-grid textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.form-grid .hint { text-transform: none; font-size: 11px; opacity: 0.8; }
.form-grid button { grid-column: 1 / -1; justify-self: start; }
.file-link { font-size: 12px; color: var(--accent); text-decoration: none; margin-top: 2px; }

/* ---------- Resultado del mes (ganancia/pérdida) ---------- */
.resultado-banner {
  display: flex;
  align-items: center;
  gap: 18px;
  border-radius: var(--radius);
  padding: 22px 26px;
  margin-bottom: 24px;
  border: 1px solid transparent;
}
.resultado-banner.resultado-positivo { background: rgba(90, 168, 110, 0.1); border-color: rgba(90, 168, 110, 0.3); }
.resultado-banner.resultado-negativo { background: rgba(193, 68, 60, 0.1); border-color: rgba(193, 68, 60, 0.3); }
.resultado-icon {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  flex-shrink: 0;
}
.resultado-positivo .resultado-icon { background: rgba(90, 168, 110, 0.18); color: #7fd396; }
.resultado-negativo .resultado-icon { background: rgba(193, 68, 60, 0.18); color: #e39089; }
.resultado-icon svg { width: 28px; height: 28px; }
.resultado-texto { display: flex; flex-direction: column; }
.resultado-label { font-size: 13px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.resultado-monto { font-family: var(--font-display); font-size: 32px; line-height: 1.25; }
.resultado-positivo .resultado-monto { color: #7fd396; }
.resultado-negativo .resultado-monto { color: #e39089; }
.resultado-sub { font-size: 12px; color: var(--text-muted); }

/* ---------- Tarjetas de estadísticas ---------- */
.cards-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-decoration: none;
  color: inherit;
}
.stat-card.link-card:hover { border-color: var(--accent); }
.stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-family: var(--font-display); font-size: 26px; }
.stat-value.positive { color: #7fd396; }
.stat-value.negative { color: #e39089; }
.positive { color: #7fd396; }
.negative { color: #e39089; }

.quick-links { display: flex; gap: 12px; margin: 20px 0; flex-wrap: wrap; }
.quick-links a {
  color: var(--text);
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 14px;
}
.quick-links a:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Listas de alertas ---------- */
.alert-list { list-style: none; padding: 0; margin: 0 0 24px; display: flex; flex-direction: column; gap: 8px; }
.alert-list li { border-radius: 8px; padding: 10px 14px; font-size: 14px; border: 1px solid transparent; }
.alert-list .alert-warning { background: rgba(201, 162, 39, 0.08); border-color: rgba(201, 162, 39, 0.25); }
.alert-list .alert-danger { background: rgba(193, 68, 60, 0.08); border-color: rgba(193, 68, 60, 0.25); }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid.form-compact { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .topbar .mainnav { order: 3; width: 100%; }
  .compartments { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
