:root {
  --az: #0E4D64;
  --az2: #126B79;
  --vd: #1D9E75;
  --vd2: #E1F5EE;
  --rj: #E24B4A;
  --am: #EF9F27;
  --bg: #F0F4F7;
  --white: #fff;
  --txt: #1A2B35;
  --txt2: #5B7280;
  --bd: #DCE8EE;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: Segoe UI, system-ui, sans-serif;
  background: var(--bg);
  color: var(--txt);
  font-size: 14px;
  line-height: 1.5;
}

.hdr {
  background: var(--az);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.hdr-brand { display: flex; align-items: center; gap: 12px; }

.logo {
  background: rgba(255,255,255,.16);
  border-radius: 10px;
  padding: 8px 13px;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
}

.hdr-info .title { color: #fff; font-size: 16px; font-weight: 600; }
.hdr-info .sub { color: rgba(255,255,255,.6); font-size: 11px; margin-top: 1px; }

.hdr-nav { display: flex; gap: 8px; flex-wrap: wrap; }

.hdr-nav a {
  background: rgba(255,255,255,.13);
  color: #fff;
  font-size: 11px;
  padding: 6px 12px;
  border-radius: 20px;
  text-decoration: none;
  font-weight: 500;
}

.hdr-nav a:hover, .hdr-nav a.active { background: rgba(255,255,255,.28); }

.body { padding: 16px 20px 32px; max-width: 1400px; margin: 0 auto; }

.mg {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.mc {
  background: var(--white);
  border: 1px solid var(--bd);
  border-radius: 10px;
  padding: 12px 14px;
}

.mc-l {
  font-size: 10px;
  color: var(--txt2);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 4px;
}

.mc-v { font-size: 24px; font-weight: 700; color: var(--az); }
.mc-s { font-size: 11px; color: var(--txt2); margin-top: 3px; }

.card {
  background: var(--white);
  border: 1px solid var(--bd);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
}

.ct { font-size: 13px; font-weight: 600; color: var(--az); margin-bottom: 2px; }
.cs { font-size: 11px; color: var(--txt2); margin-bottom: 12px; }

.alert {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 14px;
  font-size: 13px;
}

.alert.ok { background: var(--vd2); border: 1px solid #9FE1CB; color: #0F6E56; }
.alert.err { background: #FCEBEB; border: 1px solid #F7C1C1; color: #A32D2D; }
.alert.info { background: #FFF5D8; border: 1px solid #FAC775; color: #854F0B; }

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 10px;
}

.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--txt2);
  margin-bottom: 4px;
}

.form-group input,
.form-group select {
  padding: 7px 10px;
  border: 1px solid var(--bd);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  min-width: 160px;
}

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}

.btn-primary { background: var(--az); color: #fff; }
.btn-primary:hover { background: var(--az2); }
.btn-secondary { background: #fff; color: var(--txt2); border: 1px solid var(--bd); }
.btn-secondary:hover { background: var(--bg); }

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: linear-gradient(135deg, #c93b3b, #e24b4a);
  color: #fff;
  box-shadow: 0 4px 14px rgba(226, 75, 74, 0.22);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-danger:hover:not(:disabled) {
  background: linear-gradient(135deg, #b53434, #d04342);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(226, 75, 74, 0.3);
}

.btn-danger-soft {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #fff;
  color: #c93b3b;
  border: 1px solid #f5d0d0;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  transition: all 0.18s ease;
}

.btn-danger-soft .btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.btn-danger-soft .btn-icon svg {
  display: block;
  width: 16px;
  height: 16px;
  stroke: currentColor;
}

.btn-danger-soft:hover {
  background: #fff8f8;
  border-color: #e8a0a0;
  color: #b53434;
  box-shadow: 0 4px 12px rgba(226, 75, 74, 0.12);
}

.btn-danger svg {
  display: block;
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  stroke: currentColor;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.fin-formula-note {
  margin-bottom: 0;
  padding-top: 8px;
  border-top: 1px solid var(--bd);
}

.card-danger-soft {
  padding: 0;
  overflow: hidden;
  border-color: #f5e0e0;
}

.danger-zone {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  background: linear-gradient(135deg, #fffbfa 0%, #fff 55%, #fafcfd 100%);
}

.danger-zone-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, #fff0f0, #ffe8e8);
  color: #d64545;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid #fad4d4;
}

.danger-zone-content {
  flex: 1;
  min-width: 0;
}

.danger-zone-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--txt);
  margin-bottom: 4px;
}

.danger-zone-text {
  font-size: 12px;
  color: var(--txt2);
  line-height: 1.55;
  max-width: 520px;
}

.fin-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  max-width: min(440px, calc(100vw - 48px));
  padding: 14px 18px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  background: var(--az);
  box-shadow: 0 16px 40px rgba(14, 77, 100, 0.28);
  z-index: 1200;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  transition: opacity 0.32s ease, transform 0.32s cubic-bezier(0.34, 1.4, 0.64, 1);
  pointer-events: none;
}

.fin-toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.fin-toast.ok {
  background: linear-gradient(135deg, #0f6e56, #1d9e75);
  box-shadow: 0 16px 40px rgba(29, 158, 117, 0.28);
}

.fin-toast.err {
  background: linear-gradient(135deg, #b53434, #e24b4a);
  box-shadow: 0 16px 40px rgba(226, 75, 74, 0.28);
}

.fin-toast-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 700;
}

.fin-toast-text {
  line-height: 1.45;
  padding-top: 4px;
}

.fin-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.fin-modal.open {
  opacity: 1;
  visibility: visible;
}

.fin-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(14, 43, 53, 0.45);
  backdrop-filter: blur(6px);
}

.fin-modal-panel {
  position: relative;
  width: min(520px, 100%);
  background: #fff;
  border-radius: 20px;
  border: 1px solid var(--bd);
  box-shadow: 0 32px 64px rgba(14, 77, 100, 0.18);
  overflow: hidden;
  transform: scale(0.94) translateY(16px);
  transition: transform 0.28s cubic-bezier(0.34, 1.2, 0.64, 1);
}

.fin-modal.open .fin-modal-panel {
  transform: scale(1) translateY(0);
}

.fin-modal-topbar {
  height: 4px;
  background: linear-gradient(90deg, #e24b4a, #ef9f27, #e24b4a);
  background-size: 200% 100%;
}

.fin-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f4f8fb;
  border: 1px solid var(--bd);
  border-radius: 10px;
  color: var(--txt2);
  cursor: pointer;
  transition: all 0.15s ease;
}

.fin-modal-close:hover {
  background: #fff;
  border-color: var(--az);
  color: var(--az);
}

.fin-modal-header {
  text-align: center;
  padding: 28px 28px 8px;
}

.fin-modal-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 16px;
  background: linear-gradient(135deg, #fff5e6, #fff0f0);
  color: #d97706;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #fde8c8;
}

.fin-modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--txt);
  margin-bottom: 8px;
}

.fin-modal-sub {
  font-size: 13px;
  color: var(--txt2);
  line-height: 1.55;
  max-width: 380px;
  margin: 0 auto;
}

.fin-modal-sub strong {
  color: #c93b3b;
}

.fin-modal-body {
  padding: 20px 28px 8px;
}

.fin-modal-steps {
  background: #f8fbfd;
  border: 1px solid #e3eef4;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 18px;
}

.fin-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 12px;
  color: var(--txt2);
  line-height: 1.45;
  padding: 5px 0;
}

.fin-step + .fin-step {
  border-top: 1px dashed #dce8ee;
  margin-top: 4px;
  padding-top: 9px;
}

.fin-step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--az);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.fin-modal-field label {
  font-size: 11px;
  font-weight: 700;
  color: var(--txt2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.fin-modal-field-last {
  margin-bottom: 0;
}

.fin-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--bd);
  border-radius: 10px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.fin-input:focus {
  outline: none;
  border-color: var(--az);
  box-shadow: 0 0 0 3px rgba(14, 77, 100, 0.1);
}

.fin-input-confirm {
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.fin-input-confirm.fin-input-valid {
  border-color: #1d9e75;
  background: #f8fdfb;
  box-shadow: 0 0 0 3px rgba(29, 158, 117, 0.12);
}

.fin-input-hint {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: #8aa3b0;
}

.fin-modal-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  background: linear-gradient(135deg, #eef7fb, #f5fafc);
  border: 1px solid #cde1eb;
  margin-bottom: 16px;
}

.fin-modal-stats-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--txt2);
}

.fin-modal-stats-value {
  text-align: right;
}

.fin-modal-stats-value span {
  display: block;
  font-size: 26px;
  font-weight: 700;
  color: var(--az);
  line-height: 1;
}

.fin-modal-stats-value small {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--txt2);
}

.fin-modal-stats-value small strong {
  color: var(--txt);
}

.fin-modal-check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid #e8eef2;
  background: #fafcfd;
  margin-bottom: 16px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.fin-modal-check:hover {
  border-color: #cde1eb;
  background: #f4f9fc;
}

.fin-modal-check input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.fin-check-box {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 2px solid #c5d8e2;
  background: #fff;
  flex-shrink: 0;
  margin-top: 1px;
  position: relative;
  transition: all 0.15s ease;
}

.fin-modal-check input:checked + .fin-check-box {
  background: var(--az);
  border-color: var(--az);
}

.fin-modal-check input:checked + .fin-check-box::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.fin-check-text {
  font-size: 12px;
  color: var(--txt2);
  line-height: 1.5;
}

.fin-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 16px 28px 24px;
  background: #fafcfd;
  border-top: 1px solid #eef3f6;
}

body.fin-modal-open {
  overflow: hidden;
}

@media (max-width: 680px) {
  .danger-zone {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .danger-zone-icon {
    margin: 0 auto;
  }

  .btn-danger-soft {
    justify-content: center;
    width: 100%;
  }

  .fin-modal-header,
  .fin-modal-body {
    padding-left: 20px;
    padding-right: 20px;
  }

  .fin-modal-actions {
    flex-direction: column-reverse;
    padding: 16px 20px 20px;
  }

  .fin-modal-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .fin-toast {
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-width: none;
  }
}

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

.data-tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.data-tbl th {
  background: #F0F4F7;
  text-align: left;
  padding: 9px 10px;
  font-weight: 600;
  font-size: 11px;
  color: var(--txt2);
  border-bottom: 1px solid var(--bd);
  white-space: nowrap;
}

.data-tbl td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--bd);
  vertical-align: middle;
}

.data-tbl tr:hover td { background: #FAFCFD; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
}

.badge-ok { background: var(--vd2); color: #0F6E56; }
.badge-warn { background: #FAEEDA; color: #854F0B; }
.badge-muted { background: #F0F4F7; color: var(--txt2); }

.pagination {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  margin-top: 14px;
  flex-wrap: wrap;
}

.pagination a, .pagination span {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  text-decoration: none;
  border: 1px solid var(--bd);
  color: var(--txt2);
  background: #fff;
}

.pagination a:hover { border-color: var(--az); color: var(--az); }
.pagination .current { background: var(--az); color: #fff; border-color: var(--az); }

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--txt2);
}

.fin-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 14px;
  align-items: start;
}

.fin-sidebar {
  background: var(--white);
  border: 1px solid var(--bd);
  border-radius: 14px;
  padding: 12px;
  position: sticky;
  top: 14px;
  box-shadow: 0 10px 24px rgba(14, 77, 100, 0.06);
}

.fin-sidebar .ct {
  background: linear-gradient(135deg, #0E4D64, #126B79);
  color: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  font-size: 12px;
  letter-spacing: .01em;
}

.fin-side-item {
  display: block;
  padding: 10px 12px;
  margin-bottom: 6px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--txt2);
  border: 1px solid #edf3f7;
  font-size: 12px;
  font-weight: 600;
  transition: .18s ease;
}

.fin-side-item:hover {
  background: #f3f9fc;
  border-color: #cfe2ec;
  color: var(--az);
  transform: translateX(2px);
}

.fin-side-item.active {
  background: linear-gradient(135deg, #e8f3f7, #edf8fb);
  border-color: #b7d4e1;
  color: var(--az);
  box-shadow: inset 3px 0 0 var(--az);
}

.fin-content {
  min-width: 0;
}

.fin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  background: #f4f8fb;
  border: 1px solid #dbe9f0;
  border-radius: 12px;
  padding: 8px;
}

.fin-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid #d3e4ec;
  color: var(--txt2);
  background: #fff;
  transition: .18s ease;
}

.fin-tab-name {
  line-height: 1;
}

.fin-tab-meta {
  font-size: 10px;
  font-weight: 600;
  color: #6b8795;
  background: #eef5f9;
  border-radius: 999px;
  padding: 2px 7px;
  line-height: 1.2;
}

.fin-tab:hover {
  border-color: #aacbda;
  color: var(--az);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(14, 77, 100, 0.09);
}

.fin-tab.positive {
  border-color: #c9e8dd;
}

.fin-tab.negative {
  border-color: #f2d9d7;
}

.fin-tab.active {
  background: linear-gradient(135deg, #0E4D64, #126B79);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 18px rgba(14, 77, 100, 0.24);
}

.fin-tab.active .fin-tab-meta {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.data-tbl tr.fin-mov-egreso td {
  background: rgba(220, 53, 69, 0.06);
}

.data-tbl tr.fin-mov-egreso td:first-child .sede-state {
  font-size: 11px;
}

.card .ct {
  letter-spacing: .01em;
}

.card .cs strong {
  color: #0f5f7d;
}

.sede-card {
  border: 1px solid #d3e6ef;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 6px 18px rgba(14, 77, 100, 0.06);
}

.sede-card-summary {
  padding: 14px;
  border-radius: 12px;
}

.sede-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sede-state {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  padding: 3px 8px;
}

.sede-state.excelente {
  color: #0f6e56;
  background: #e1f5ee;
  border: 1px solid #b8e7d5;
}

.sede-state.bueno {
  color: #0f6e56;
  background: #e7f7f1;
  border: 1px solid #c4eadb;
}

.sede-state.regular {
  color: #8b680d;
  background: #fff4d8;
  border: 1px solid #f4d58f;
}

.sede-state.bajo {
  color: #9a5610;
  background: #ffe9d4;
  border: 1px solid #f4c79e;
}

.sede-state.negativo {
  color: #9b3f3f;
  background: #fae6e6;
  border: 1px solid #f0c2c2;
}

.sede-hint {
  margin-top: 6px;
  font-size: 11px;
  color: #6d8793;
}

.sede-card-body {
  border-top: 1px solid #e6eff4;
  padding: 12px 14px 14px;
  background: linear-gradient(180deg, #fcfeff 0%, #f8fbfd 100%);
  border-radius: 0 0 12px 12px;
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.calc-card {
  border-radius: 10px;
  border: 1px solid #d8e7ef;
  padding: 10px;
  background: #fff;
}

.calc-card.ingresos {
  border-left: 4px solid #1d9e75;
}

.calc-card.egresos {
  border-left: 4px solid #e24b4a;
}

.calc-title {
  font-size: 11px;
  font-weight: 700;
  color: #35525f;
  text-transform: uppercase;
  letter-spacing: .03em;
  margin-bottom: 8px;
}

.calc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  margin-bottom: 6px;
  color: #486575;
}

.calc-row strong {
  color: #133f52;
}

.calc-total {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed #d6e5ec;
  color: #134358;
  font-size: 12px;
}

.calc-note {
  margin-top: 8px;
  font-size: 11px;
  color: #738e9c;
}

.operacion-box {
  margin-top: 10px;
  border-radius: 10px;
  border: 1px solid #cde1eb;
  padding: 10px 12px;
  background: #eff7fb;
}

.operacion-title {
  font-size: 11px;
  font-weight: 700;
  color: #35525f;
  text-transform: uppercase;
  letter-spacing: .03em;
  margin-bottom: 6px;
}

.operacion-formula {
  font-size: 14px;
  color: #134358;
}

.operacion-formula strong {
  font-size: 16px;
  color: #0e4d64;
}

.operacion-extra {
  margin-top: 5px;
  font-size: 11px;
  color: #5a7889;
}

.resumen-global {
  background: linear-gradient(180deg, #ffffff 0%, #f7fbfd 100%);
}

@media (max-width: 680px) {
  .mg { grid-template-columns: 1fr 1fr; }
  .form-row { flex-direction: column; align-items: stretch; }
}

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

  .fin-sidebar {
    position: static;
  }

  .calc-grid {
    grid-template-columns: 1fr;
  }
}
