:root {
  --jm-negro: #0d0d0d;
  --jm-amarillo: #ffd200;
  --jm-amarillo-oscuro: #e6bc00;
  --jm-blanco: #ffffff;
  --jm-fondo: #f0f2f5;
  --jm-texto: #1a1a1a;
  --jm-card: #ffffff;
  --jm-borde: #e2e5ea;
  --jm-sombra: 0 6px 20px rgba(0, 0, 0, 0.08);
  --jm-radio: 12px;
  --jm-sidebar-w: min(268px, 88vw);
  --jm-top-h: 3.75rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Montserrat, "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--jm-texto);
  background: var(--jm-fondo);
  font-size: 15px;
  line-height: 1.55;
}

h1,
h2 {
  font-family: Oswald, "Segoe UI Semibold", sans-serif;
  font-weight: 700;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  padding: 0.5rem 1rem;
  background: var(--jm-amarillo);
}
.skip-link:focus {
  left: 0.75rem;
  top: 0.75rem;
  z-index: 99;
}

/* Auth */
.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 20% 20%, rgba(255, 210, 0, 0.18), transparent 40%),
    radial-gradient(circle at 80% 0%, rgba(0, 0, 0, 0.06), transparent 42%),
    var(--jm-fondo);
  padding: 1.25rem;
}
.auth-wrap {
  width: min(420px, 100%);
}
.auth-card.card {
  padding: 2rem;
}
.auth-brand {
  font-family: Oswald, sans-serif;
  font-weight: 700;
  letter-spacing: 0.06em;
  font-size: 1.65rem;
  text-transform: uppercase;
  border-bottom: 3px solid var(--jm-amarillo);
  padding-bottom: 0.35rem;
  margin-bottom: 0.5rem;
  display: inline-block;
}
.auth-lead {
  margin: 0 0 1rem;
  color: #555;
  font-weight: 600;
  font-size: 0.9rem;
}

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

.sidebar {
  width: var(--jm-sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--jm-negro) 0%, #151515 100%);
  color: rgba(255, 255, 255, 0.88);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  z-index: 40;
  border-right: 2px solid var(--jm-amarillo);
}
.sidebar-brand {
  padding: 1.25rem 1.35rem;
  border-bottom: 1px solid rgba(255, 210, 0, 0.25);
}
.sidebar-title {
  display: block;
  font-family: Oswald, sans-serif;
  font-weight: 700;
  letter-spacing: 0.06em;
  font-size: 1.08rem;
  text-transform: uppercase;
}
.sidebar-sub {
  font-size: 0.76rem;
  opacity: 0.75;
  font-weight: 600;
}
.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 0.75rem;
  gap: 0.2rem;
  flex: 1;
}
.nav-item {
  display: block;
  padding: 0.62rem 0.95rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.78);
}
.nav-item:hover {
  background: rgba(255, 210, 0, 0.12);
  color: var(--jm-blanco);
}
.nav-item.is-active {
  background: var(--jm-amarillo);
  color: var(--jm-negro);
}
.sidebar-user {
  padding: 1rem 1.2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}
.sidebar-user .muted {
  display: block;
  font-size: 0.8rem;
  opacity: 0.75;
  margin-bottom: 0.65rem;
  text-transform: capitalize;
}

.app-main-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--jm-top-h);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  background: var(--jm-card);
  border-bottom: 1px solid var(--jm-borde);
  box-shadow: var(--jm-sombra);
}
.menu-toggle {
  display: none;
}
.topbar-title {
  margin: 0;
  font-size: 1.25rem;
  flex: 1;
}

.main-content {
  flex: 1;
  padding: 1rem 1.1rem 1.75rem;
  width: min(1280px, 100%);
  margin: 0 auto;
}

.app-footer {
  padding: 0.75rem 1.25rem 1rem;
  text-align: center;
  border-top: 1px solid var(--jm-borde);
  font-size: 0.76rem;
  color: #666;
}

/* Cards grid */
.grid {
  display: grid;
  gap: 1rem;
}
.two-col {
  grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr));
}
.kpis {
  grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
}
.mt-lg {
  margin-top: 1.5rem;
}
.mb-md {
  margin-bottom: 1rem;
}
.mb-sm {
  margin-bottom: 0.65rem;
}
.pt-sm {
  padding-top: 0.65rem;
}
.gap-lg {
  gap: 1.25rem !important;
}

.card {
  background: var(--jm-card);
  border-radius: var(--jm-radio);
  border: 1px solid var(--jm-borde);
  box-shadow: var(--jm-sombra);
  padding: 1.1rem 1.2rem 1.3rem;
}
.kpi-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  opacity: 0.55;
}
.kpi-value {
  display: block;
  margin-top: 0.35rem;
  font-size: 1.35rem;
  font-weight: 800;
}

.section-title {
  margin: 0 0 0.85rem;
  font-size: 1.1rem;
  border-left: 4px solid var(--jm-amarillo);
  padding-left: 0.55rem;
}
.chart-wrap {
  position: relative;
  min-height: 260px;
}
.muted {
  color: #5c5f65;
}
.muted.small,
.small {
  font-size: 0.82rem;
}
.stack > * + * {
  margin-top: 0.75rem;
}

/* Forms */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.65rem;
}
.toolbar label,
.inline-form label,
.inline {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-weight: 600;
  font-size: 0.82rem;
}
.label {
  font-weight: 600;
}
.input,
textarea.input,
select.input {
  padding: 0.55rem 0.72rem;
  border-radius: 8px;
  border: 1px solid var(--jm-borde);
  font-family: inherit;
  font-weight: 500;
  background: var(--jm-blanco);
  width: 100%;
}
.input:focus-visible,
select.input:focus-visible,
textarea.input:focus-visible {
  outline: 2px solid var(--jm-amarillo);
  outline-offset: 2px;
  border-color: var(--jm-amarillo-oscuro);
}
.form-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
}
.form-two .full {
  grid-column: 1 / -1;
}
fieldset {
  margin: 0;
  padding: 0;
  border: none;
}

.btn-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 0.55rem 1.05rem;
  border-radius: 999px;
  border: none;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  text-decoration: none;
  gap: 0.35rem;
}
.btn:focus-visible {
  outline: 2px solid var(--jm-amarillo);
  outline-offset: 3px;
}
.btn-primary {
  background: var(--jm-amarillo);
  color: var(--jm-negro);
}
.btn-primary:hover {
  background: var(--jm-amarillo-oscuro);
}
.btn-accent {
  background: var(--jm-negro);
  color: var(--jm-blanco);
}
.btn-accent:hover {
  opacity: 0.9;
}
.btn-outline {
  border: 1px solid currentColor;
  background: transparent;
  color: var(--jm-texto);
}
.sidebar .btn-outline {
  color: var(--jm-blanco);
  border-color: rgba(255, 255, 255, 0.35);
  width: 100%;
}
.btn-block {
  width: 100%;
}
.btn-sm {
  padding: 0.38rem 0.72rem;
  font-size: 0.8rem;
}

.icon-btn.menu-toggle {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--jm-borde);
  background: var(--jm-blanco);
  font-weight: 800;
}

.inline-form {
  display: inline-flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.input-inline {
  width: auto;
  min-width: 120px;
  max-width: 160px;
}

/* Alerts */
.alert {
  border-radius: 10px;
  padding: 0.65rem 0.95rem;
  font-weight: 600;
}
.alert-success {
  background: #e9fae8;
  color: #1c4c1f;
}
.alert-error {
  background: #feeaea;
  color: #6b1c16;
}

/* Tables */
.overflow-x {
  overflow-x: auto;
}
.table-scroll {
  overflow-x: auto;
  max-height: min(560px, 70vh);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}
.table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #5c5f65;
}
.table th,
.table td {
  border-bottom: 1px solid var(--jm-borde);
  padding: 0.62rem 0.52rem;
  text-align: left;
  vertical-align: top;
}
.table .numeric {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.row-hilite {
  outline: 1px dashed var(--jm-amarillo-oscuro);
}
.row-warn td {
  background: #fff9e9;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
}
.badge-success {
  background: #d8fbe0;
}
.badge-warn {
  background: #fde6c9;
}
.badge-muted {
  background: #e9ecef;
}

.def-list dl,
.def-list div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem;
  align-items: baseline;
  margin-bottom: 0.45rem;
}
.def-list dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.sep {
  border: none;
  border-top: 1px solid var(--jm-borde);
  margin: 1.35rem 0;
}

.report-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.report-list li {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--jm-borde);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.report-actions a {
  font-weight: 700;
  color: inherit;
}
.report-actions a + a::before {
  content: ' · ';
  font-weight: 400;
}

.link-edit {
  font-weight: 700;
}

/* Responsive sidebar */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .sidebar.is-open {
    transform: translateX(0);
  }
  .menu-toggle {
    display: inline-flex;
  }
  .kpis .kpi-alt {
    order: unset;
  }
}

@media print {
  .sidebar,
  .topbar,
  .app-footer,
  .menu-toggle {
    display: none !important;
  }
}
