/* Estilos generales + responsive (VNET). */

/* =========================
   Variables (tema claro)
   ========================= */
:root {
  --sidebar-width: 280px;

  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --primary-50: #eff6ff;

  --secondary: #f4f6f8;
  --bg: #ffffff;

  --text: #1f2937;
  --muted: #6b7280;

  --border: #e5e7eb;

  --success: #16a34a;
  --success-bg: #dcfce7;

  --error: #dc2626;
  --error-bg: #fee2e2;

  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.06);
  --shadow-md: 0 14px 40px rgba(17, 24, 39, 0.12);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;

  --transition: 180ms ease;
}

/* =========================
   Reset básico
   ========================= */

*,
*::before,
*::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--secondary);
  color: var(--text);
}

a { color: inherit; }

.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 56px 1fr;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-areas:
    "topbar topbar"
    "sidebar content";
}

.topbar {
  grid-area: topbar;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 60;
}

.topbar__title {
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--primary);
}

.topbar__brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--primary);
}

.topbar__logo {
  height: 28px;
  width: auto;
  display: block;
}

.topbar__user {
  color: var(--muted);
  font-size: 14px;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 999px;
  background: var(--secondary);
  border: 1px solid var(--border);
}

.user-chip__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
}

.user-chip__name {
  color: var(--text);
  font-weight: 600;
}

.user-menu {
  position: relative;
}

.user-menu__btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 999px;
  background: var(--secondary);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
}

.user-menu__btn:hover {
  background: rgba(37, 99, 235, 0.08);
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-50);
  color: var(--primary);
  border: 1px solid rgba(37, 99, 235, 0.25);
  font-weight: 800;
  font-size: 13px;
  line-height: 1;
}

.user-menu__name {
  font-weight: 700;
  color: var(--text);
  font-size: 14px;
}

.user-menu__chev {
  color: var(--muted);
  display: inline-flex;
}

.user-menu__dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  min-width: 220px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: 80;
}

.user-menu__item {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
}

.user-menu__item:hover {
  background: rgba(37, 99, 235, 0.08);
}

.user-menu__item--danger {
  color: var(--error);
}

.topbar__burger {
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.topbar__burger:hover {
  background: rgba(37, 99, 235, 0.08);
}

.burger {
  width: 20px;
  height: 2px;
  background: var(--text);
  display: block;
  position: relative;
}

.burger::before,
.burger::after {
  content: "";
  position: absolute;
  left: 0;
  width: 20px;
  height: 2px;
  background: var(--text);
}

.burger::before { top: -6px; }
.burger::after { top: 6px; }

.sidebar {
  grid-area: sidebar;
  width: var(--sidebar-width);
  background: var(--bg);
  border-right: 1px solid var(--border);
  box-shadow: 6px 0 24px rgba(17, 24, 39, 0.06);
  padding: 16px;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow: auto;
}

.sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.sidebar__close {
  border: 0;
  background: rgba(37, 99, 235, 0.10);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: none;
}

.sidebar__brand {
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 0;
  color: var(--primary);
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav__link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  position: relative;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  transition: background var(--transition), border-color var(--transition);
}

.nav__link:hover {
  background: var(--secondary);
  border-color: var(--border);
}

.nav__icon {
  width: 20px;
  display: inline-flex;
  justify-content: center;
}

.nav__icon svg {
  width: 18px;
  height: 18px;
  display: block;
}

.nav__link.is-active {
  background: var(--primary-50);
  border-color: rgba(37, 99, 235, 0.25);
  color: var(--primary);
}

.nav__link.is-active::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 8px;
  bottom: 8px;
  width: 4px;
  border-radius: 999px;
  background: var(--primary);
}

.sidebar__footer {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.content {
  grid-area: content;
  flex: 1;
  padding: 20px;
  background: var(--secondary);
}

.footer {
  margin-top: 24px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
}

.footer__link {
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
}

.footer__link:hover,
.footer__link:focus {
  text-decoration: underline;
}

.footer {
  color: var(--muted);
  font-size: 13px;
}

.page__header {
  margin-bottom: 16px;
}

.page__header--with-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.page__actions {
  display: inline-flex;
  gap: 10px;
  flex-wrap: wrap;
}

.page__title {
  margin: 0 0 6px;
}

.page__subtitle {
  margin: 0;
  color: var(--muted);
}

.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.card__icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-50);
  color: var(--primary);
  font-size: 22px;
}

.card__icon svg {
  width: 22px;
  height: 22px;
  display: block;
}

.card__label {
  color: var(--muted);
  font-size: 13px;
}

.card__value {
  font-size: 32px;
  font-weight: 800;
  margin-top: 8px;
}

/* Panel / Formularios / Tablas */

.panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.form-grid--filters {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.table-wrap {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table thead th {
  text-align: left;
  font-size: 12px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--secondary);
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

 .table thead th.th-right {
   text-align: right;
 }

.table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table__thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--secondary);
  display: block;
}

.form-thumb {
  margin: 8px 0;
}

.table tbody tr:hover td {
  background: rgba(37, 99, 235, 0.03);
}

.th-right,
.td-right {
  text-align: right;
}

.td-muted {
  color: var(--muted);
}

.td-actions {
  white-space: nowrap;
}

form.inline {
  display: inline;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge--success {
  background: var(--success-bg);
  color: var(--success);
}

.badge--muted {
  background: var(--secondary);
  color: var(--muted);
  border: 1px solid var(--border);
}

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.35);
  z-index: 55;
}

.backdrop[hidden] { display: none; }

.page {
  max-width: 1100px;
}

.page h1 {
  margin: 0 0 8px;
}

.page p {
  margin: 0;
  color: var(--muted);
}

.dash-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.dash-header__meta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.dash-chip {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.8);
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
}

.kpi-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.kpi {
  border-radius: var(--radius-lg);
  padding: 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  box-shadow: var(--shadow-sm);
  min-height: 132px;
}

.kpi__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.kpi__icon {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.55);
}

.kpi__label {
  font-weight: 700;
  letter-spacing: 0.3px;
  font-size: 13px;
}

.kpi__value {
  font-size: 30px;
  font-weight: 900;
  line-height: 1.05;
}

.kpi__sub {
  font-size: 12px;
  color: var(--muted);
}

.kpi--primary {
  background: linear-gradient(180deg, rgba(37,99,235,0.10), rgba(255,255,255,1));
}

.kpi--primary .kpi__icon { color: var(--primary); }

.kpi--success {
  background: linear-gradient(180deg, rgba(22,163,74,0.10), rgba(255,255,255,1));
}

.kpi--success .kpi__icon { color: var(--success); }

.kpi--warn {
  background: linear-gradient(180deg, rgba(245,158,11,0.14), rgba(255,255,255,1));
}

.kpi--warn .kpi__icon { color: #b45309; }

.kpi--neutral {
  background: linear-gradient(180deg, rgba(17,24,39,0.06), rgba(255,255,255,1));
}

.kpi--neutral .kpi__icon { color: var(--text); }

.dash-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.dash-panel {
  padding: 14px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-head__title {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
}

.panel-head__subtitle {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.dash-chart {
  height: 220px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(37,99,235,0.04), rgba(255,255,255,1));
  position: relative;
  overflow: hidden;
  padding: 14px 12px 10px;
}

.dash-chart__empty {
  color: var(--muted);
  font-size: 13px;
}

.dash-chart__bars {
  height: 100%;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  align-items: end;
}

.dash-chart__group {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
}

.dash-chart__bar {
  width: 100%;
  border-radius: 10px;
  min-height: 2px;
}

.dash-chart__bar--in {
  background: rgba(22, 163, 74, 0.85);
}

.dash-chart__bar--out {
  background: rgba(37, 99, 235, 0.75);
  margin-top: 6px;
}

.dash-chart__label {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

.dash-legend {
  display: flex;
  gap: 14px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.dash-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.dot--in { background: rgba(22, 163, 74, 0.85); }
.dot--out { background: rgba(37, 99, 235, 0.75); }

.dash-list {
  display: grid;
  gap: 10px;
}

.dash-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.7);
}

.dash-item__title {
  font-weight: 800;
  font-size: 12px;
  margin-top: 6px;
}

.dash-item__meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.dash-item__right {
  text-align: right;
  min-width: 88px;
}

.dash-item__qty {
  font-weight: 900;
  font-size: 18px;
}

.dash-item__when {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.dash-two {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.dash-mini__title {
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  margin-bottom: 10px;
}

.dash-mini__row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  margin-bottom: 10px;
}

.dash-mini__name {
  font-weight: 800;
  font-size: 12px;
}

.dash-mini__meta {
  color: var(--muted);
  font-size: 11px;
  margin-top: 4px;
}

.dash-mini__qty {
  align-self: center;
  font-weight: 900;
  font-size: 18px;
  color: var(--error);
}

.dash-mini__row:hover {
  border-color: rgba(37, 99, 235, 0.25);
  background: rgba(37, 99, 235, 0.04);
}

@media (max-width: 900px) {
  .app {
    grid-template-rows: 56px 1fr;
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "content";
  }

  .topbar__burger {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    transform: translateX(-105%);
    transition: transform var(--transition);
    z-index: 60;
  }

  .sidebar__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  body.sidebar-open {
    overflow: hidden;
  }

  body.sidebar-open .backdrop {
    display: block;
  }

  .content {
    padding: 16px;
  }
}

@media (min-width: 901px) {
  .topbar__burger {
    display: none;
  }

  .kpi-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .dash-grid {
    grid-template-columns: 1.4fr 0.9fr;
    align-items: stretch;
  }

  .dash-panel--wide {
    grid-column: 1 / -1;
  }

  .dash-two {
    grid-template-columns: 1fr 1fr;
  }

  .cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid--filters {
    grid-template-columns: 1.5fr 1fr 0.8fr;
  }
}

@media (max-width: 720px) {
  .page__header--with-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .table thead {
    display: none;
  }

  .table,
  .table tbody,
  .table tr,
  .table td {
    display: block;
    width: 100%;
  }

  .table tbody {
    padding: 10px;
  }

  .table tr {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg);
    overflow: hidden;
    margin-bottom: 10px;
  }

  .table td {
    display: grid;
    grid-template-columns: minmax(110px, 40%) 1fr;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    overflow-wrap: anywhere;
  }

  .table tr td:last-child {
    border-bottom: 0;
  }

  .table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
  }

  .table__thumb {
    width: 52px;
    height: 52px;
    border-radius: 12px;
  }

  .td-actions {
    white-space: normal;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    align-items: center;
    justify-items: stretch;
  }

  .td-actions::before {
    grid-column: 1 / -1;
    margin-right: 0;
  }

  .td-actions form.inline {
    display: block;
    width: 100%;
    margin: 0;
  }

  .td-actions .btn {
    width: 100%;
    justify-content: center;
    font-size: 12px;
    padding: 8px 8px;
  }
}

/* Login (sin layout) */

body.auth {
  min-height: 100vh;
  background: linear-gradient(rgba(15, 23, 42, 0.55), rgba(15, 23, 42, 0.55)),
    url('../img/fondo.png') center/cover no-repeat fixed;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.auth__container {
  width: 100%;
  max-width: 460px;
}

.auth__card {
  width: 100%;
  max-width: 420px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-md);
}

.auth__logo {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
}

.auth__logo img {
  max-width: 160px;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.auth__brand {
  font-weight: 800;
  letter-spacing: 0.6px;
  color: var(--primary);
  margin-bottom: 6px;
}

.auth__title {
  margin: 0 0 16px;
  font-size: 22px;
  text-align: center;
}

.auth__subtitle {
  margin: -10px 0 16px;
  color: var(--muted);
  font-size: 14px;
}

.auth__form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field__password {
  display: flex;
  align-items: center;
  gap: 6px;
}

.field__password .field__input {
  flex: 1;
}

.password-toggle {
  border: 1px solid var(--border);
  background: var(--secondary);
  color: var(--muted);
  border-radius: var(--radius-sm);
  width: 44px;
  height: 44px;
  cursor: pointer;
  font-size: 18px;
  transition: background var(--transition), color var(--transition);
}

.password-toggle:hover {
  background: var(--primary-50);
  color: var(--primary);
}

.password-toggle__icon {
  display: block;
  color: currentColor;
}

.password-toggle__icon--hide {
  display: none;
}

.password-toggle.is-visible .password-toggle__icon--show {
  display: none;
}

.password-toggle.is-visible .password-toggle__icon--hide {
  display: block;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field__label {
  font-size: 13px;
  color: var(--muted);
}

.field__input {
  width: 100%;
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  outline: none;
}

.field__input:focus {
  border-color: rgba(37, 99, 235, 0.55);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: none;
  font-weight: 600;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover,
.btn:focus,
.btn:active,
.btn:visited {
  text-decoration: none;
}

.btn--block { width: 100%; }

.btn--primary {
  background: var(--primary);
  color: #ffffff;
}

.btn--primary:hover {
  background: var(--primary-600);
}

.btn--secondary {
  background: var(--secondary);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn--secondary:hover {
  border-color: rgba(37, 99, 235, 0.25);
}

.btn--danger {
  background: var(--error);
  color: #ffffff;
}

.btn--danger:hover {
  filter: brightness(0.95);
}

.btn--sm {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.alert {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.alert--error {
  border-color: rgba(220, 38, 38, 0.25);
  background: var(--error-bg);
  color: var(--error);
}

.alert--success {
  border-color: rgba(22, 163, 74, 0.25);
  background: var(--success-bg);
  color: var(--success);
}

.alert__list {
  margin: 8px 0 0;
  padding-left: 18px;
}

.auth__hint {
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted);
}

@media (min-width: 900px) {
  .auth__card {
    padding: 24px;
  }
}
