@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  color-scheme: light;
  --bg: #f4f7ff;
  --panel: #ffffff;
  --panel-alt: #eef3fb;
  --panel-strong: #072765;
  --text: #10293f;
  --muted: #62779f;
  --accent: #003b8e;
  --accent-soft: rgba(0, 59, 142, 0.14);
  --danger: #b33030;
  --danger-soft: rgba(179, 48, 48, 0.14);
  --border: rgba(15, 42, 98, 0.12);
  --shadow: 0 18px 42px rgba(15, 42, 98, 0.12);
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at top left, rgba(0, 93, 194, 0.12), transparent 28%),
              linear-gradient(180deg, #eef3fb 0%, #f7f9ff 100%);
  color: var(--text);
}

body {
  overflow: hidden;
}

button, input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: linear-gradient(180deg, #05255f, #0c356e 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  transition: width 0.24s ease;
  overflow: hidden;
}

.sidebar.collapsed {
  width: 72px;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  gap: 10px;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 80px;
  padding: 0 18px;
  background: rgba(100, 140, 200, 0.25);
  border-radius: 14px;
  overflow: hidden;
}

.logo {
  display: block;
  width: 100%;
  max-width: 225px;
}

.sidebar.collapsed .logo {
  max-width: 48px;
}


.tree-menu {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 10px 20px;
}

.tree-menu > ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tree-root,
.tree-submenu {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tree-item,
.tree-leaf {
  margin: 0;
}

.tree-toggle,
.tree-leaf button {
  width: 100%;
  border: none;
  background: transparent;
  color: #f7fbff;
  padding: 16px 18px;
  text-align: left;
  border-radius: 14px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  transition: background 0.18s ease;
}

.tree-toggle:hover,
.tree-leaf button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.tree-item.active > .tree-toggle,
.tree-leaf.active > button {
  background: rgba(36, 91, 173, 0.24);
  color: #fff;
}

.tree-item.has-children > .tree-toggle::after {
  content: "\25BE";
  transform: rotate(0deg);
  transition: transform 0.2s ease;
}

.tree-item.has-children.expanded > .tree-toggle::after {
  transform: rotate(-180deg);
}

.tree-item.has-children.expanded > .tree-submenu {
  display: block;
}

.tree-submenu .tree-leaf {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tree-submenu {
  margin-top: 6px;
  padding-left: 30px;
  display: none;
}

.tree-submenu .tree-leaf button {
  width: 100%;
  border: none;
  background: transparent;
  color: #d8e2f0;
  padding: 12px 18px;
  text-align: left;
  border-radius: 12px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.tree-submenu .tree-leaf button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.tree-submenu .tree-leaf.active button {
  background: rgba(36, 91, 173, 0.24);
  color: #fff;
  font-weight: 600;
}

/* --- User menu in sidebar header --- */
#menuContainer {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.menu-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.menu-header {
  padding: 10px 10px 4px;
  flex-shrink: 0;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4a6fa5, #245bad);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: #fff;
  flex-shrink: 0;
}

.user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #f7fbff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.45);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.3);
}

/* --- Menu footer / logout --- */
.menu-footer {
  padding: 8px 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.btn-logout {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  font-size: 0.8rem;
  font-family: inherit;
  transition: background 0.15s ease, color 0.15s ease;
}

.btn-logout:hover {
  background: rgba(255, 107, 107, 0.1);
  color: #ff6b6b;
  border-color: rgba(255, 107, 107, 0.2);
}

.logout-icon {
  font-size: 1rem;
}

/* --- Admin-only items (hidden by default) --- */
.admin-only.hidden {
  display: none !important;
}

.main-content {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: transparent;
}

.page-header {
  display: flex;
  align-items: center;
  min-height: 72px;
  padding: 0 30px;
  margin: 0 30px 18px;
  background: linear-gradient(180deg, #1d3a6e 0%, #0f2f5d 100%);
  border-radius: 24px;
  color: #eef3ff;
  box-shadow: 0 10px 30px rgba(22, 46, 87, 0.12);
}

.page-title {
  font-size: 2rem;
  font-weight: 700;
  color: #f7fbff;
}

.page-body {
  flex: 1;
  overflow: hidden;
  padding: 10px 30px 30px;
  min-height: 0;
}

.page-body.acuerdos-active {
  padding: 0;
}

.page-body.grid-active {
  padding: 5px;
}

.screen-screen {
  width: 100%;
  height: 100%;
}

.page-body.grid-active .screen-screen {
  height: 100%;
}

.page-body.grid-active .grid-panel {
  height: 100%;
}

.page-body.acuerdos-active #acuerdosScreen {
  height: 100%;
}

.page-body.acuerdos-active #acuerdosScreen .grid-panel {
  height: 100%;
}

.welcome-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: rgba(29, 63, 122, 1);
  border-radius: 24px;
}

.welcome-logo {
  width: min(320px, 100%);
  opacity: 0.5;
}

.hidden {
  display: none !important;
}

/* --- Activo toggle slider (global para grillas de Maestros) --- */
.activo-cell {
  text-align: center;
}

.activo-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 20px;
}

.activo-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.activo-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #4a5568;
  border-radius: 24px;
  transition: background-color 0.2s ease;
}

.activo-slider::before {
  content: "";
  position: absolute;
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: #ffffff;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.activo-toggle input:checked + .activo-slider {
  background-color: #4a6fa5;
}

.activo-toggle input:checked + .activo-slider::before {
  transform: translateX(20px);
}

.activo-toggle input:focus + .activo-slider {
  box-shadow: 0 0 0 2px rgba(74, 111, 165, 0.4);
}

.grid-panel {
  background: linear-gradient(180deg, #1d3a6e 0%, #0f2f5d 100%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 24px;
  box-shadow: 0 20px 40px rgba(12, 33, 69, 0.18);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.grid-container {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.grid-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
}

.toolbar-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: #ffffff;
}

.toolbar-actions {
  display: flex;
  gap: 12px;
}

.grid-actions-row {
  padding: 16px 24px 0;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.grid-actions-buttons {
  display: flex;
  gap: 12px;
}

.grid-actions-row label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: auto;
}

.grid-actions-row .search-label {
  width: 300px;
}

.grid-actions-row label {
  color: #ffffff;
  font-weight: 500;
}

.grid-actions-row input {
  width: 100%;
  max-width: 300px;
  background: rgba(244, 247, 255, 0.92);
  border: 1px solid rgba(15, 42, 98, 0.12);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
}

button.primary,
button.danger,
button.secondary {
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  color: #fff;
  font-weight: 600;
  transition: transform 0.15s ease, background 0.15s ease;
}

button.primary {
  background: #4a6fa5;
}

button.danger {
  background: #c47a7a;
}

button:hover {
  transform: translateY(-1px);
}

.table-wrapper {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 24px 24px;
}

.data-grid {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

.data-grid thead th {
  position: sticky;
  top: 0;
  background: #1d3a6e;
  color: #f7fbff;
  padding: 8px 10px;
  text-align: center;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  z-index: 10;
}

.data-grid thead th:last-child {
  border-right: none;
}

.data-grid tbody tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background 0.16s ease;
  background: transparent;
}

.data-grid tbody td {
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.data-grid tbody td:last-child {
  border-right: none;
}

.data-grid tbody tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background 0.16s ease;
  background: transparent;
}

.data-grid tbody tr:hover {
  background: rgba(255, 255, 255, 0.08);
}

.data-grid tbody td[data-field="Monto"],
.data-grid tbody td[data-field="Tasa"] {
  text-align: right;
}

.data-grid tbody td[data-field="Monto"] {
  font-variant-numeric: tabular-nums;
}

.data-grid tbody tr.selected {
  background: rgba(0, 101, 213, 0.16);
}

.data-grid td {
  padding: 8px 10px;
  color: #f4f7ff;
  line-height: 1.2;
  min-height: 28px;
  font-size: 0.9rem;
}

.data-grid td[contenteditable] {
  min-width: 120px;
  line-height: 1.2;
}

.data-grid thead th.select-col,
.data-grid td.select-col {
  width: 32px;
  text-align: center;
  padding: 8px 6px;
}

.data-grid td.select-col input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.data-grid td[contenteditable] {
  min-width: 130px;
}

.data-grid td:focus {
  outline: 2px solid rgba(0, 101, 213, 0.45);
  outline-offset: -2px;
}

.data-grid thead th.select-col,
.data-grid td.select-col {
  width: 40px;
  text-align: center;
  padding: 8px 8px;
}

.data-grid td.select-col input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

button.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.grid-footer {
  margin-top: auto;
  padding: 8px 24px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.875rem;
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(3, 8, 18, 0.6);
  z-index: 20;
}

.modal-content {
  background: #0d1e34;
  padding: 28px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  width: min(420px, calc(100% - 32px));
}

.date-picker-modal {
  width: min(340px, calc(100% - 32px));
}

.custom-calendar {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 16px;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.calendar-header span {
  color: #f7fbff;
  font-weight: 600;
  font-size: 0.95rem;
}

.calendar-nav {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #f7fbff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: background 0.15s ease;
}

.calendar-nav:hover {
  background: rgba(255, 255, 255, 0.2);
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}

.calendar-weekdays span {
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 0;
}

.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #f4f7ff;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  position: relative;
}

.calendar-day:hover:not(.disabled):not(.empty) {
  background: rgba(74, 111, 165, 0.4);
}

.calendar-day.selected {
  background: #4a6fa5;
  color: #fff;
  font-weight: 600;
}

.calendar-day.disabled {
  color: rgba(255, 255, 255, 0.2);
  cursor: not-allowed;
  text-decoration: line-through;
}

.calendar-day.disabled.weekend {
  color: rgba(196, 122, 122, 0.4);
}

.calendar-day.empty {
  cursor: default;
}

.calendar-day.today {
  border: 1px solid rgba(74, 111, 165, 0.6);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.modal h2 {
  margin-top: 0;
  margin-bottom: 14px;
  color: #ffffff;
}

.modal p {
  color: #f4f7ff;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 14px;
  margin-top: 22px;
}

.modal-actions button {
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 600;
  transition: transform 0.15s ease, background 0.15s ease;
  cursor: pointer;
}

.modal-actions button.secondary,
.modal-actions button:not(.danger) {
  background: #4a6a8a;
  color: #ffffff;
}

.modal-actions button:not(.danger):hover {
  transform: translateY(-1px);
  background: #5a7a9a;
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    width: 100%;
  }
}

@media (max-width: 700px) {
  .page-body {
    padding: 18px 18px 20px;
  }
  .grid-toolbar,
  .grid-actions-row,
  .table-wrapper,
  .grid-footer {
    padding-left: 16px;
    padding-right: 16px;
  }
}
