:root{
  --snte-orange:#f47b20;
  --ink:#0b0b0f;
  --paper:#ffffff;
  --muted:#6b7280;
  --border:#e5e7eb;
  --card:#ffffff;
  --shadow: 0 10px 24px rgba(0,0,0,.08);
  --radius: 14px;
  --font: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
}

*{ box-sizing:border-box; }
body{
  margin:0;
  font-family: var(--font);
  background: #f6f7fb;
  color: var(--ink);
}

.container{
  width: min(100% - 32px, 1640px);
  max-width: 1640px;
  margin: 0 auto;
  padding: 0;
}

.topbar{
  background: var(--paper);
  border-bottom: 1px solid var(--border);
}

.topbar .container{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 12px 0;
}

.brand{
  display:flex;
  gap:12px;
  align-items:center;
}
.brand-mark{
  width:10px;
  height:42px;
  border-radius: 999px;
  background: var(--snte-orange);
}
.brand-title{ font-weight:700; font-size: 16px; }
.brand-subtitle{ font-size: 12px; color: var(--muted); }

.nav a{
  text-decoration:none;
  color: var(--ink);
  font-weight:600;
  margin-left:14px;
}
.nav a:hover{ color: var(--snte-orange); }

.content{ padding: 14px 0 32px; }

main.py-3,
main.py-lg-4 {
  padding-top: 10px !important;
  padding-bottom: 10px !important;
}

.card{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 5px 16px rgba(0,0,0,.06);
  padding: 0;
}

.card .card-body {
  padding: 14px 16px;
}

.form-label {
  margin-bottom: .3rem;
}

.form-control,
.form-select,
.btn {
  border-radius: 6px;
}

.btn {
  padding: .4rem .75rem;
}

.btn-sm {
  padding: .25rem .55rem;
}

.row.g-3 {
  --bs-gutter-x: 1rem;
  --bs-gutter-y: .85rem;
}

.fs-4 {
  font-size: 1.35rem !important;
}

.flash-stack{ display:grid; gap:10px; margin: 12px 0; }
.flash{
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: var(--paper);
}
.flash-danger{ border-color: #fecaca; background:#fff1f2; }
.flash-warning{ border-color: #fde68a; background:#fffbeb; }
.flash-info{ border-color: #bfdbfe; background:#eff6ff; }
.flash-success{ border-color: #bbf7d0; background:#ecfdf5; }
.flash {
  opacity: 1;
  transform: translateY(0);
  transition: opacity .65s ease, transform .65s ease;
}
.flash-fading {
  opacity: 0;
  transform: translateY(-6px);
}

.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
}

.page-heading h2 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 750;
}

.page-heading p {
  margin: 4px 0 0;
  color: var(--muted);
}

.module-card {
  box-shadow: 0 4px 14px rgba(15, 23, 42, .06);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.module-card:hover {
  transform: translateY(-2px);
  border-color: rgba(244, 123, 32, .35);
  box-shadow: 0 10px 26px rgba(15, 23, 42, .09);
}

.module-card-agenda {
  border-color: rgba(249, 115, 22, .45);
}

.module-card-agenda .module-mark {
  background: #f97316;
  color: #fff;
  box-shadow: 0 8px 18px rgba(249, 115, 22, .28);
}

.module-card-agenda:hover {
  border-color: rgba(249, 115, 22, .7);
  box-shadow: 0 12px 28px rgba(249, 115, 22, .16);
}

.module-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  font-weight: 800;
  line-height: 1;
  box-shadow: inset 4px 0 0 var(--snte-orange);
}

.dashboard-metric {
  border-color: rgba(17, 24, 39, .08);
}

.dashboard-metric .card-body {
  padding: 14px 16px;
}

.dashboard-metric .fs-3 {
  line-height: 1.1;
}

.permission-matrix th,
.permission-matrix td {
  text-align: center;
}

.permission-matrix th:first-child,
.permission-matrix td:first-child {
  text-align: left;
}

.perm-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 78px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
}

.perm-yes {
  background: #dcfce7;
  color: #166534;
}

.perm-no {
  background: #e5e7eb;
  color: #4b5563;
}

.permission-tree {
  display: grid;
  gap: 12px;
}

.permission-node {
  overflow: hidden;
}

.permission-switch-table th,
.permission-switch-table td {
  text-align: center;
}

.permission-switch-table th:first-child,
.permission-switch-table td:first-child {
  min-width: 240px;
  text-align: left;
}

.permission-switch {
  display: inline-flex;
  justify-content: center;
  min-width: 48px;
}

.permission-switch .form-check-input {
  cursor: pointer;
}

.permission-subtree {
  display: grid;
  gap: 10px;
}

.permission-section {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfbfc;
  padding: 10px 12px;
}

.permission-section summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}

.sticky-save-bar {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 -8px 24px rgba(15, 23, 42, .08);
}

.footer{
  border-top: 1px solid var(--border);
  background: var(--paper);
  padding: 16px 0;
  color: var(--muted);
}

/* ==========================
   Acceso
   ========================== */

.login-shell {
  position: relative;
  display: grid;
  place-items: center;
  min-height: calc(100vh - 126px);
  padding: 34px 16px;
  overflow: hidden;
  isolation: isolate;
}

.login-shell::before {
  content: "";
  position: absolute;
  inset: -30%;
  z-index: -2;
  background-image: url("/static/img/logo_coordinacion.png");
  background-size: 230px auto;
  background-repeat: repeat;
  opacity: .5;
  transform: rotate(-8deg);
  animation: loginLogoDrift 64s linear infinite;
}

.login-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 50% 22%, rgba(244, 123, 32, .08), transparent 30%),
    linear-gradient(180deg, rgba(246, 247, 251, .52), rgba(246, 247, 251, .82));
}

.login-card {
  width: min(100%, 430px);
  padding: 24px;
  border: 1px solid rgba(229, 231, 235, .92);
  border-radius: 10px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 22px 54px rgba(15, 23, 42, .14);
  backdrop-filter: blur(6px);
}

.login-logo-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.login-logo {
  width: min(100%, 285px);
  height: auto;
  object-fit: contain;
}

.login-card h2 {
  margin: 0 0 6px;
  font-size: 1.35rem;
  font-weight: 760;
  text-align: center;
}

.login-card p {
  margin: 0 0 18px;
  color: var(--muted);
  text-align: center;
}

.login-institutional-phrase {
  max-width: 340px;
  margin: -6px auto 16px !important;
  color: #4b5563 !important;
  font-size: .92rem;
  line-height: 1.35;
}

.login-label {
  display: block;
  margin-bottom: 6px;
  color: #374151;
  font-size: .92rem;
  font-weight: 650;
}

.login-input {
  width: 100%;
  margin-bottom: 14px;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.login-input:focus {
  border-color: rgba(244, 123, 32, .62);
  box-shadow: 0 0 0 3px rgba(244, 123, 32, .13);
}

.login-submit,
.login-dev-button {
  width: 100%;
  padding: 10px 12px;
  border-radius: 7px;
  font-weight: 750;
}

.login-dev-form {
  margin-top: 12px;
}

.login-submit {
  border: 0;
  background: #111827;
  color: #fff;
}

.login-submit:hover {
  background: #000;
}

.login-dev-button {
  border: 1px solid var(--border);
  background: #f3f4f6;
  color: var(--ink);
}

@keyframes loginLogoDrift {
  from { background-position: 0 0; }
  to { background-position: 460px 0; }
}

@media (prefers-reduced-motion: reduce) {
  .login-shell::before,
  .module-card {
    animation: none;
    transition: none;
  }

  .module-card:hover {
    transform: none;
  }
}

/* ==========================
   Alertas institucionales
   ========================== */

.alert-cr {
  background-color: #f8f9fa;      /* gris claro */
  border: 1px solid #dee2e6;
  border-left: 5px solid #f57c00; /* naranja SNTE */
  color: #212529;
}

/* ==========================
   Botones institucionales
   ========================== */

.btn-cr-primary {
  background-color: #212529; /* negro */
  color: #fff;
  border: none;
}

.btn-cr-primary:hover {
  background-color: #000;
}

.btn-cr-outline {
  border: 1px solid #212529;
  color: #212529;
  background: transparent;
}

.btn-cr-outline:hover {
  background-color: #212529;
  color: #fff;
}

.btn-cr-warning {
  border: 1px solid #f57c00;
  color: #f57c00;
  background: transparent;
}

.btn-cr-warning:hover {
  background-color: #f57c00;
  color: #fff;
}

.btn-snte{
  background: #f36f21 !important;
  border-color: #f36f21 !important;
  color: #fff !important;
  font-weight: 600;
}

.btn-snte:hover,
.btn-snte:focus{
  background: #d85f1c !important;
  border-color: #d85f1c !important;
  color: #fff !important;
}

.data-table-scroll {
  max-height: 70vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--paper);
}

.membresia-table-scroll {
  width: calc(100% - 24px);
  max-height: 58vh;
  margin-inline: 12px;
}

.data-table-scroll table {
  margin-bottom: 0;
  min-width: max-content;
}

.data-table-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8f9fa;
  box-shadow: inset 0 -1px 0 var(--border);
}

.data-table-scroll th,
.data-table-scroll td {
  white-space: nowrap;
  vertical-align: middle;
  padding: 6px 8px;
}

.compact-card {
  max-width: 980px;
}

.stat-card .card-body {
  min-height: 78px;
}

.data-table-scroll tr.duplicate-warning > *,
.data-table-scroll tr.membresia-color-warning > * {
  background-color: #ffd59e !important;
}

.data-table-scroll tr.duplicate-budget-key > *,
.data-table-scroll tr.membresia-color-budget_key > * {
  background-color: #111111 !important;
  color: #ffffff !important;
  font-weight: 700;
}

.data-table-scroll tr.duplicate-exact > *,
.data-table-scroll tr.membresia-color-exact > * {
  background-color: #f87171 !important;
  font-weight: 700;
}

.data-table-scroll tr.membresia-color-educacion_fisica > * {
  background-color: #9cc3e6 !important;
}

.data-table-scroll td.nombramiento-color-interino,
.legend-swatch.nombramiento-color-interino {
  background-color: #6d28d9 !important;
  color: #ffffff !important;
  font-weight: 700;
}

.data-table-scroll td.nombramiento-color-contrato,
.legend-swatch.nombramiento-color-contrato {
  background-color: #0f766e !important;
  color: #ffffff !important;
  font-weight: 700;
}

.data-table-scroll td.nombramiento-color-beca_comision,
.legend-swatch.nombramiento-color-beca_comision {
  background-color: #b45309 !important;
  color: #ffffff !important;
  font-weight: 700;
}

.data-table-scroll td.nombramiento-color-permiso_sin_goce,
.legend-swatch.nombramiento-color-permiso_sin_goce {
  background-color: #9d174d !important;
  color: #ffffff !important;
  font-weight: 700;
}

.data-table-scroll td.nombramiento-color-prejubilatorio,
.legend-swatch.nombramiento-color-prejubilatorio {
  background-color: #334155 !important;
  color: #ffffff !important;
  font-weight: 700;
}

.data-table-scroll td.nombramiento-color-acuerdo_presidencial,
.legend-swatch.nombramiento-color-acuerdo_presidencial {
  background-color: #7c2d12 !important;
  color: #ffffff !important;
  font-weight: 700;
}

.data-table-scroll td.nombramiento-color-otro,
.legend-swatch.nombramiento-color-otro {
  background-color: #525252 !important;
  color: #ffffff !important;
  font-weight: 700;
}

.duplicate-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  color: var(--muted);
  font-size: 0.875rem;
}

.duplicate-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  display: inline-block;
  width: 18px;
  height: 12px;
  border: 1px solid rgba(0, 0, 0, .18);
  border-radius: 2px;
}

.nombramiento-swatch {
  border-color: rgba(255, 255, 255, .35);
}

.legend-claves {
  background: #fff3cd;
}

.legend-budget-key {
  background: #111111;
}

.legend-warning {
  background: #ffd59e;
}

.legend-exact {
  background: #f87171;
}

.legend-educacion-fisica {
  background: #9cc3e6;
}

.bajas-context-menu {
  position: absolute;
  z-index: 1080;
  min-width: 260px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.bajas-context-menu button {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 10px 12px;
  text-align: left;
  font: inherit;
}

.bajas-context-menu button:hover {
  background: #f8f9fa;
}

.estructura-table {
  width: calc(100% - 96px);
  max-height: 68vh;
  margin-inline: 48px;
  overflow: auto;
  overscroll-behavior-x: contain;
  padding-bottom: 10px;
}

.estructura-table table {
  min-width: 1560px;
}

.estructura-group-cell {
  background: #f8f9fa !important;
  border-right: 2px solid var(--border);
  vertical-align: middle !important;
  white-space: normal !important;
  min-width: 160px;
}

.estructura-inline-field {
  width: 100%;
  min-width: 155px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  padding: 3px 5px;
}

.estructura-phone {
  min-width: 105px;
}

.estructura-email {
  min-width: 175px;
}

.estructura-inline-field[readonly] {
  cursor: default;
}

.estructura-inline-field:not([readonly]),
.estructura-inline-field.is-editing {
  background: #fff;
  border-color: var(--snte-orange);
  box-shadow: 0 0 0 2px rgba(244, 123, 32, .12);
  outline: none;
}

.estructura-line-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  margin-top: 4px;
}

.estructura-line-label:first-child {
  margin-top: 0;
}

.estructura-line-spacer {
  height: 19px;
  margin-top: 4px;
}

.agenda-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  font-size: 13px;
}

.agenda-dot {
  border-radius: 999px;
  display: inline-block;
  height: 10px;
  margin-right: 6px;
  width: 10px;
}

.agenda-grid {
  display: grid;
  gap: 12px;
}

.agenda-grid-dia {
  grid-template-columns: minmax(0, 1fr);
}

.agenda-grid-semana {
  grid-template-columns: repeat(7, minmax(150px, 1fr));
  overflow-x: auto;
}

.agenda-grid-mes {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.agenda-day {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 130px;
  overflow: hidden;
}

.agenda-day.is-today {
  border-color: #f97316;
  box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.12);
}

.agenda-day-header {
  align-items: center;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  padding: 8px 10px;
}

.agenda-day-body {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.agenda-card {
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-left-width: 5px;
  border-radius: 6px;
  cursor: pointer;
  padding: 8px 10px;
}

.agenda-card-time,
.agenda-card-meta,
.agenda-card-status {
  color: var(--muted);
  font-size: 12px;
}

.agenda-card-title {
  font-weight: 650;
  line-height: 1.25;
  margin: 3px 0;
}

.agenda-red {
  background: #fee2e2;
  border-left-color: #dc2626;
}

.agenda-yellow {
  background: #fef9c3;
  border-left-color: #eab308;
}

.agenda-orange {
  background: #ffedd5;
  border-left-color: #f97316;
}

.agenda-blue {
  background: #dbeafe;
  border-left-color: #2563eb;
}

.agenda-green {
  background: #dcfce7;
  border-left-color: #16a34a;
}

.agenda-gray {
  background: #f1f5f9;
  border-left-color: #64748b;
}

.pagination-scroll {
  max-width: 100%;
  overflow-x: auto;
  padding-bottom: 2px;
}

.pagination-scroll .pagination {
  flex-wrap: nowrap;
  width: max-content;
}

@media (max-width: 768px) {
  .container {
    width: calc(100% - 20px);
    max-width: 100%;
    padding: 0;
  }

  .topbar .container {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
  }

  .brand-mark {
    height: 34px;
  }

  .brand-title {
    font-size: 15px;
  }

  .brand-subtitle {
    font-size: 11px;
  }

  .nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }

  .nav a,
  .nav span {
    margin-left: 0;
    font-size: 13px;
  }

  .content {
    padding: 10px 10px 28px;
  }

  main.py-3,
  main.py-lg-4 {
    padding-top: 8px !important;
    padding-bottom: 8px !important;
  }

  h1,
  h2 {
    font-size: 1.35rem;
  }

  .card {
    border-radius: 8px;
    padding: 0;
  }

  .card .card-body {
    padding: 12px;
  }

  .btn {
    white-space: normal;
  }

  .data-table-scroll {
    max-height: 62vh;
    border-radius: 6px;
    -webkit-overflow-scrolling: touch;
  }

  .data-table-scroll table {
    font-size: 12px;
  }

  .data-table-scroll th,
  .data-table-scroll td {
    padding: 6px 8px;
  }

  .estructura-table {
    width: calc(100% - 28px);
    max-height: 62vh;
    margin-inline: 14px;
    overflow: auto;
  }

  .duplicate-legend {
    display: grid;
    gap: 8px;
    font-size: 12px;
  }

  .modal-dialog {
    margin: 0;
    max-width: 100%;
  }

  .modal-content {
    min-height: 100vh;
    border-radius: 0;
  }

  .modal-body {
    max-height: calc(100vh - 132px) !important;
  }

  .modal-footer {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .modal-footer .btn {
    width: 100%;
  }

  .pagination-scroll {
    width: 100%;
  }

  .estructura-inline-field {
    min-width: 150px;
  }
}

@media (max-width: 480px) {
  .d-flex.align-items-start.justify-content-between {
    flex-direction: column;
  }

  .d-flex.align-items-start.justify-content-between > .d-flex {
    width: 100%;
  }

  .d-flex.align-items-start.justify-content-between > .d-flex .btn {
    flex: 1 1 0;
  }

  .form-label,
  .form-check-label {
    font-size: 13px;
  }

  .form-control,
  .form-select {
    font-size: 14px;
  }
}
