:root {
  --bg: #f3f7f1;
  --surface: #ffffff;
  --surface-2: #e8f0e4;
  --text: #22352b;
  --muted: #5f7467;
  --primary: #2f6e43;
  --primary-2: #3e8756;
  --danger: #9e2d2d;
  --line: #d8e2d3;
  --radius: 12px;
  --shadow: 0 8px 20px rgba(34, 53, 43, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top left, #e4efe0 0%, var(--bg) 40%, #eef4ec 100%);
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.login-card {
  width: min(420px, 100%);
  padding: 24px;
}

.topbar {
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 2;
}

.topbar h1 {
  margin: 0;
  font-size: 1.75rem;
  line-height: 1.1;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.menu-toggle {
  width: 40px;
  height: 40px;
  padding: 0;
  display: grid;
  place-items: center;
}

.menu-toggle-icon {
  width: 16px;
  height: 12px;
  border-top: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  position: relative;
}

.menu-toggle-icon::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 4px;
  border-top: 2px solid currentColor;
}

.layout {
  position: relative;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: calc(100vh - 74px);
  transition: grid-template-columns 0.25s ease;
}

.menu {
  width: 240px;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.menu button {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #f7fbf6;
  color: var(--text);
  transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease,
    transform 0.18s ease, box-shadow 0.18s ease;
}

.menu button:hover {
  background: #edf5ea;
  border-color: #bfd0c0;
  transform: translateX(2px);
}

.menu button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 6px 14px rgba(47, 110, 67, 0.22);
}

.content {
  padding: 10px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 1400px;
  width: 100%;
}

.panel {
  display: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
}

.panel.active {
  display: block;
  animation: panelEnter 180ms ease-out;
}

@keyframes panelEnter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

h2 {
  margin-top: 0;
  margin-bottom: 10px;
}

h3 {
  margin: 16px 0 10px;
  font-size: 1rem;
}

.grid-form {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: 14px;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.subpanel {
  border: 1px solid var(--line);
  background: #f8fbf7;
  border-radius: 10px;
  padding: 12px;
}

.subpanel h3 {
  margin-top: 0;
}

.form-actions {
  display: flex;
  gap: 8px;
  align-items: end;
}

.form-vertical {
  width: min(100%, 620px);
}

.grid-form.form-vertical {
  grid-template-columns: 1fr;
}

.inline-form.form-vertical {
  display: grid;
  grid-template-columns: 1fr;
  align-items: stretch;
}

.form-vertical .form-actions {
  align-items: center;
}

.form-vertical button[type="submit"] {
  width: 100%;
  min-height: 42px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
}

input,
select,
button {
  font: inherit;
  border-radius: 8px;
  border: 1px solid #cdd8c8;
  padding: 8px 10px;
  background: #fff;
}

button {
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

button:hover {
  background: var(--primary-2);
}

.btn.ghost,
button.ghost {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}

.topbar-exit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid #d7e1d6;
  background: #f5faf4;
  color: #2f6e43;
  font-weight: 700;
  text-decoration: none;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.topbar-exit:hover {
  background: #e8f4e9;
  border-color: #bfd6c2;
  color: #1f5f37;
}

.proof-open-btn {
  min-width: 34px;
  min-height: 30px;
  padding: 2px 8px;
  border-radius: 8px;
  border: 1px solid #c7d8ca;
  background: #f8fcf8;
  color: var(--primary);
  font-weight: 700;
}

.proof-open-btn:hover {
  background: #ecf6ee;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  font-size: 0.9rem;
}

th {
  background: var(--surface-2);
}

.rep-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: capitalize;
  border: 1px solid transparent;
}

.rep-principal {
  color: #0f4f2f;
  background: #dff3e8;
  border-color: #a9d8be;
}

.rep-secundario {
  color: #6a4a16;
  background: #f9f1df;
  border-color: #e8d1a6;
}

.toast-stack {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 20;
  display: grid;
  gap: 8px;
  width: min(92vw, 360px);
}

.proof-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 30;
}

.proof-modal.is-open {
  display: block;
}

.proof-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(13, 23, 18, 0.62);
}

.proof-modal__dialog {
  position: relative;
  z-index: 1;
  width: min(96vw, 1500px);
  height: min(92vh, 980px);
  margin: 3vh auto;
  background: #fff;
  border-radius: 12px;
  border: 1px solid #d8e2d3;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.25);
  padding: 12px;
  display: flex;
  flex-direction: column;
}

.proof-modal__close {
  align-self: flex-end;
  min-width: 36px;
  min-height: 36px;
  border-radius: 999px;
  border: 1px solid #d0dad2;
  background: #fff;
  color: #294638;
  font-size: 1.4rem;
  line-height: 1;
  padding: 0;
}

.proof-modal__content {
  flex: 1;
  display: grid;
  place-items: center;
  overflow: auto;
  border-radius: 10px;
  background: #f4f7f4;
}

.proof-modal__content img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.alert {
  border-radius: 10px;
  padding: 10px 12px;
  border: 1px solid transparent;
  box-shadow: 0 10px 24px rgba(20, 30, 24, 0.16);
  backdrop-filter: blur(2px);
}

.alert.success {
  background: #e6f5ea;
  color: #1f5e34;
  border-color: #add7b9;
}

.alert.error {
  background: #f9e8e8;
  color: #7f2222;
  border-color: #e7b7b7;
}

.alert.info {
  background: #e8f0fa;
  color: #1c4b7a;
  border-color: #b5ccea;
}

.alert.warning {
  background: #fbf4e6;
  color: #7c5b1e;
  border-color: #ecd9ac;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.8rem;
}

.stack {
  display: grid;
  gap: 12px;
}

.menu-backdrop {
  display: none;
}

body.sidebar-collapsed .layout {
  grid-template-columns: 0 minmax(0, 1fr);
}

body.sidebar-collapsed .menu {
  transform: translateX(-110%);
  opacity: 0;
  pointer-events: none;
}

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

  .menu {
    position: fixed;
    top: 74px;
    left: 0;
    bottom: 0;
    width: min(82vw, 320px);
    border-right: 1px solid var(--line);
    border-bottom: 0;
    z-index: 6;
    transform: translateX(-110%);
    opacity: 1;
    pointer-events: none;
    overflow-y: auto;
  }

  body.sidebar-mobile-open .menu {
    transform: translateX(0);
    pointer-events: auto;
  }

  .menu-backdrop {
    position: fixed;
    inset: 74px 0 0 0;
    background: rgba(20, 30, 24, 0.35);
    z-index: 5;
  }

  body.sidebar-mobile-open .menu-backdrop {
    display: block;
  }

  .topbar {
    align-items: flex-start;
    gap: 6px;
  }

  .topbar-left {
    width: 100%;
    justify-content: space-between;
  }

  .toast-stack {
    right: 10px;
    bottom: 10px;
    width: min(95vw, 320px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .panel.active {
    animation: none;
  }

  .menu,
  .layout {
    transition: none;
  }
}
