/* Factotal — tema claro / oscuro */
:root {
  --font-sans: "DM Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 24px rgba(15, 23, 42, 0.08);
  --transition: 0.2s ease;
}

/* Tema oscuro (verde bosque Factotal) */
[data-theme="dark"] {
  --bg: #0b120e;
  --bg-elevated: #101a13;
  --panel: #131f17;
  --panel-hover: #18271d;
  --text: #ecf5ee;
  --text-secondary: #95ab9c;
  --accent: #34b369;
  --accent-hover: #2d9e5c;
  --accent-muted: rgba(52, 179, 105, 0.14);
  --border: rgba(149, 171, 156, 0.14);
  --border-strong: rgba(149, 171, 156, 0.26);
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.1);
  --ok: #4ade80;
  --ok-bg: rgba(74, 222, 128, 0.1);
  --input-bg: #0a100c;
  --topbar-bg: rgba(16, 26, 19, 0.88);
  --gradient-body: linear-gradient(165deg, #070c09 0%, #0d1510 45%, #0b1310 100%);
  --logo-glow: rgba(52, 179, 105, 0.35);
}

/* Tema claro (marca Factotal: blanco + verdes; por defecto) */
[data-theme="light"],
:root:not([data-theme]) {
  --bg: #f3f8f4;
  --bg-elevated: #ffffff;
  --panel: #ffffff;
  --panel-hover: #f4faf6;
  --text: #102217;
  --text-secondary: #5b6f62;
  --accent: #1d8a4e;
  --accent-hover: #166e3d;
  --accent-muted: rgba(29, 138, 78, 0.09);
  --border: rgba(16, 34, 23, 0.09);
  --border-strong: rgba(16, 34, 23, 0.16);
  --danger: #dc2626;
  --danger-bg: rgba(220, 38, 38, 0.08);
  --ok: #15803d;
  --ok-bg: rgba(22, 163, 74, 0.1);
  --input-bg: #ffffff;
  --topbar-bg: rgba(255, 255, 255, 0.94);
  --gradient-body: linear-gradient(180deg, #e6f3ea 0%, #f1f8f3 40%, #fbfdfb 100%);
  --shadow-sm: 0 1px 3px rgba(16, 34, 23, 0.06);
  --shadow-md: 0 8px 30px rgba(16, 34, 23, 0.08);
  --logo-glow: rgba(29, 138, 78, 0.22);
}

* {
  box-sizing: border-box;
}

html[data-theme="dark"] {
  color-scheme: dark;
}

html[data-theme="light"],
html:not([data-theme]) {
  color-scheme: light;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: -0.01em;
  background: var(--gradient-body);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

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

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

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Barra superior */
.brand__logo-link {
  display: inline-flex;
  align-items: center;
}

.brand__logo {
  height: 36px;
  width: auto;
  display: block;
}

.brand__logo--dark {
  display: none;
}

[data-theme="dark"] .brand__logo--light {
  display: none;
}

[data-theme="dark"] .brand__logo--dark {
  display: block;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  /* Alineado con .container: 90% de ancho útil, centrado */
  padding: 0.65rem max(5%, calc((100% - 1800px) / 2));
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.brand__mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #1d8a4e 0%, #34b369 100%);
  border: 2px solid rgba(16, 34, 23, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: -0.02em;
  box-shadow: 0 2px 12px var(--logo-glow);
}

[data-theme="dark"] .brand__mark {
  border-color: rgba(236, 245, 238, 0.18);
}

.brand a {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  letter-spacing: -0.02em;
}

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

.brand__sub {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-left: 1px solid var(--border);
  padding-left: 0.65rem;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.2rem;
  align-items: center;
}

.nav a {
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}

.nav a:hover {
  background: var(--accent-muted);
  color: var(--accent);
  text-decoration: none;
}

.nav__meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: 0.5rem;
  padding-left: 0.75rem;
  border-left: 1px solid var(--border);
}

.nav .user {
  color: var(--text-secondary);
  font-size: 0.85rem;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Toggle tema */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.theme-toggle:hover {
  background: var(--panel-hover);
  color: var(--text);
  border-color: var(--border-strong);
}

.theme-toggle__icons {
  position: relative;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.theme-toggle__icons svg {
  position: absolute;
  inset: 0;
  opacity: 0.92;
}

/* En modo oscuro: mostrar sol (pasar a claro). En claro: luna (pasar a oscuro) */
html[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}
html[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}
html[data-theme="light"] .theme-toggle .icon-sun {
  display: none;
}
html[data-theme="light"] .theme-toggle .icon-moon {
  display: block;
}

.theme-toggle__label {
  display: none;
}

@media (min-width: 900px) {
  .theme-toggle__label {
    display: inline;
  }
}

.container {
  width: min(90%, 1800px);
  margin: 0 auto;
  padding: 1.75rem 0 3.5rem;
}

.page-header {
  margin-bottom: 1.5rem;
}

.dashboard-intro {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.dashboard-alerts {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 1.5rem;
}

.alert-tile {
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 0.92rem;
  line-height: 1.45;
}

.alert-tile a {
  font-weight: 600;
  margin-left: 0.35rem;
}

.alert-tile--warn {
  background: var(--danger-bg);
  border-color: rgba(248, 113, 113, 0.35);
  color: var(--danger);
}

[data-theme="light"] .alert-tile--warn {
  color: #b91c1c;
}

.alert-tile--info {
  background: var(--accent-muted);
  border-color: var(--border-strong);
  color: var(--text);
}

.dashboard-section {
  margin-bottom: 1.75rem;
}

/* ---- Ciclo mensual (inicio orientado a tareas) ---- */
.cycle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.cycle-step {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem 1.2rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.cycle-step__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--accent-muted);
  color: var(--accent);
  flex-shrink: 0;
}

.cycle-step__head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.cycle-step__head h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.cycle-step__body {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.45;
  flex: 1;
}

.cycle-step__body strong {
  color: var(--text);
}

.cycle-step .btn {
  align-self: flex-start;
  font-size: 0.84rem;
  padding: 0.45rem 0.9rem;
}

.cycle-step--done {
  border-color: rgba(52, 179, 105, 0.45);
}

.cycle-step--done .cycle-step__num {
  background: var(--accent);
  color: #fff;
}

.cycle-step--active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted), var(--shadow-sm);
}

.cycle-step__state {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cycle-step__state--done { color: var(--accent); }
.cycle-step__state--active { color: var(--accent-hover); }
.cycle-step__state--pending { color: var(--text-secondary); }

.progressbar {
  height: 8px;
  border-radius: 4px;
  background: var(--accent-muted);
  overflow: hidden;
  margin: 0.35rem 0;
}

.progressbar > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* ---- Selector tipo aporte/retiro (pills) ---- */
.pill-group {
  display: flex;
  gap: 0.5rem;
}

.pill-group input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.pill-group label.pill {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.7rem 0.9rem;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  transition: border-color var(--transition), background var(--transition);
}

.pill-group label.pill small {
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 0.76rem;
}

.pill-group input[type="radio"]:checked + label.pill {
  border-color: var(--accent);
  background: var(--accent-muted);
}

.pill-group input[type="radio"]:focus-visible + label.pill {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- Barra de acciones de liquidación ---- */
.liq-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.liq-toolbar form,
.liq-toolbar .liq-tool {
  flex: 1 1 200px;
  margin: 0;
}

.liq-tool {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.liq-tool h3 {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.liq-tool p {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
  flex: 1;
}

.liq-tool .btn {
  align-self: flex-start;
  font-size: 0.84rem;
  padding: 0.45rem 0.9rem;
}

.badge-estado {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-estado--borrador {
  background: var(--accent-muted);
  color: var(--accent-hover);
}

.badge-estado--cerrada {
  background: var(--accent);
  color: #fff;
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 30, 18, 0.5);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  z-index: 300;
  padding: 5vh 1rem;
  overflow-y: auto;
}

.modal-overlay.is-open {
  display: flex;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(10, 40, 22, 0.35);
  width: 100%;
  max-width: 680px;
  padding: 1.5rem 1.75rem 1.75rem;
  animation: modal-in 0.18s ease-out;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.modal__head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.modal__close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
}

.modal__close:hover {
  background: var(--accent-muted);
  color: var(--text);
}

/* ---- Drawer lateral (panel derecho) ---- */
.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: none;
  pointer-events: none;
}

.drawer-overlay.is-open {
  display: block;
  pointer-events: auto;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 30, 18, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  border: none;
  cursor: pointer;
  animation: fade-in 0.15s ease;
}

.drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: min(460px, 94vw);
  height: 100%;
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 40px rgba(10, 40, 22, 0.2);
  display: flex;
  flex-direction: column;
  animation: drawer-in 0.22s ease-out;
  overflow: hidden;
}

@keyframes drawer-in {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem 1.35rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.drawer__head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.35rem 1.5rem;
}

.drawer__foot {
  padding: 1rem 1.35rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.65rem;
  flex-shrink: 0;
  background: var(--bg-elevated);
}

/* ---- Pestañas de sección ---- */
.section-tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.section-tabs a {
  display: inline-block;
  padding: 0.55rem 1rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.section-tabs a:hover {
  color: var(--text);
  background: var(--accent-muted);
}

.section-tabs a.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.perm-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem 1rem;
  margin-top: 0.35rem;
}

.perm-grid label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
}

/* ---- Barra de filtros ---- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
}

.filter-bar .row {
  margin: 0;
  min-width: 150px;
  flex: 0 1 auto;
}

.filter-bar label {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.filter-bar .filter-bar__actions {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

/* ---- Layout movimientos: tabla principal + saldos ---- */
.mov-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 1.25rem;
  align-items: start;
}

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

.scroll-card {
  max-height: 600px;
  overflow-y: auto;
}

.scroll-card thead th {
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 2;
}

.list-search {
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 0.5rem;
}

/* Encabezado fijo en tablas largas */
.table-sticky thead th {
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 2;
  box-shadow: 0 1px 0 var(--border);
}

.dashboard-section__title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-secondary);
  margin: 0 0 0.75rem;
  font-weight: 700;
}

.dashboard-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.stat-card--accent {
  border-color: rgba(52, 179, 105, 0.4);
  background: linear-gradient(145deg, var(--panel) 0%, var(--accent-muted) 100%);
}

[data-theme="light"] .stat-card--accent {
  background: linear-gradient(145deg, #fff 0%, rgba(29, 138, 78, 0.07) 100%);
}

.stat-hint {
  margin: 0.5rem 0 0;
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.stat-hint a {
  font-weight: 600;
}

.dashboard-two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.25rem;
  align-items: start;
}

.dashboard-proyeccion__nums {
  display: grid;
  gap: 1rem;
  margin: 1rem 0;
}

@media (min-width: 520px) {
  .dashboard-proyeccion__nums {
    grid-template-columns: repeat(2, 1fr);
  }
}

.dashboard-proyeccion__highlight {
  grid-column: 1 / -1;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--accent-muted);
  border: 1px solid var(--border-strong);
}

.dashboard-proyeccion__label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.dashboard-proyeccion__val {
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  color: var(--text);
}

.muted-strong {
  color: var(--text) !important;
  opacity: 0.85;
}

.dashboard-breakdown {
  list-style: none;
  margin: 0;
  padding: 0;
}

.dashboard-breakdown li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}

.dashboard-breakdown li:last-child {
  border-bottom: none;
}

.dashboard-table {
  font-size: 0.86rem;
}

.dashboard-table th,
.dashboard-table td {
  padding: 0.55rem 0.85rem;
}

.dashboard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.dashboard-two-col--charts {
  align-items: stretch;
}

.chart-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chart-card__title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: 280px;
  max-height: min(40vh, 320px);
  min-height: 220px;
  margin: 0.25rem 0 0.75rem;
}

.chart-wrap--bar {
  height: 300px;
  max-height: min(42vh, 340px);
  min-height: 240px;
}

.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

.page-header h1 {
  margin: 0 0 0.35rem;
}

.footer {
  padding: 1.25rem 1rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}

.footer small {
  max-width: 560px;
  margin: 0 auto;
  display: inline-block;
  line-height: 1.5;
}

h1 {
  font-size: 1.65rem;
  margin: 0 0 1rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

h2 {
  font-size: 1.05rem;
  margin: 1.5rem 0 0.75rem;
  color: var(--text-secondary);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.alert {
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
  font-size: 0.95rem;
}

.alert-error {
  background: var(--danger-bg);
  border-color: rgba(248, 113, 113, 0.35);
  color: var(--danger);
}

[data-theme="light"] .alert-error {
  color: #b91c1c;
}

.alert-ok {
  background: var(--ok-bg);
  border-color: rgba(74, 222, 128, 0.3);
  color: var(--ok);
}

[data-theme="light"] .alert-ok {
  color: #166534;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem 1.4rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), border-color var(--transition);
}

[data-theme="light"] .card {
  box-shadow: var(--shadow-md);
}

.card:hover {
  border-color: var(--border-strong);
}

.grid2 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.1rem;
}

.stat-card h2 {
  margin-top: 0;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.stat-card .stat-value {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  margin: 0.25rem 0 0;
}

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--input-bg);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--text-secondary);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
  outline: none;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

.row {
  margin-bottom: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.15rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  transition: background var(--transition), transform 0.1s ease, box-shadow var(--transition);
}

.btn:hover {
  background: var(--accent-hover);
  text-decoration: none;
  color: #fff;
  box-shadow: 0 4px 14px rgba(29, 138, 78, 0.35);
}

.btn:active {
  transform: translateY(1px);
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
  box-shadow: none;
}

.btn-secondary:hover {
  background: var(--panel-hover);
  box-shadow: var(--shadow-sm);
  color: var(--text);
}

.btn-danger {
  background: #b91c1c;
  box-shadow: none;
}

.btn-danger:hover {
  background: #991b1b;
  box-shadow: 0 4px 14px rgba(185, 28, 28, 0.35);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

table.data th,
table.data td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

table.data th {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

table.data tbody tr {
  transition: background var(--transition);
}

table.data tbody tr:hover {
  background: var(--accent-muted);
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.actions {
  white-space: nowrap;
}

.login-box {
  max-width: 400px;
  margin: 3rem auto;
}

.login-hero {
  text-align: center;
  margin-bottom: 1.5rem;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

.login-hero .brand__mark {
  margin: 0 auto 1rem;
  width: 48px;
  height: 48px;
  font-size: 1.1rem;
}

.muted {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Barra mínima en login */
.login-top {
  display: flex;
  justify-content: flex-end;
  padding: 0.75rem 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 0.15em 0.4em;
  border-radius: 4px;
  background: var(--accent-muted);
  color: var(--accent);
}

[data-theme="light"] code {
  color: var(--accent-hover);
}

@media (max-width: 640px) {
  .container {
    width: auto;
    padding: 1.25rem 1rem 3rem;
  }

  .topbar {
    padding: 0.65rem 1rem;
  }

  .nav {
    width: 100%;
    justify-content: flex-start;
  }

  .nav__meta {
    width: 100%;
    margin-left: 0;
    padding-left: 0;
    border-left: none;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
    justify-content: space-between;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}

/* Si el script inicial no corre, asumir claro en iconos */
html:not([data-theme]) .theme-toggle .icon-sun {
  display: none;
}
html:not([data-theme]) .theme-toggle .icon-moon {
  display: block;
}
