/* ═══════════════════════════════════════════════════
   UPMYS · Sistema de Diseño Institucional
   Paleta oficial
   ═══════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Google+Sans+Flex:opsz,wght@6..144,1..1000&family=IBM+Plex+Sans:ital,wght@0,100..700;1,100..700&family=Work+Sans:ital,wght@0,100..900;1,100..900&display=swap');

:root {
  /* Paleta oficial */
  --dark-blue:  #061856;
  --bold-blue:  #134074;
  --blue:       #0054A2;
  --light-blue: #5590FF;
  --light:      #F2F9FF;

  /* Derivados */
  --bg:         #F4F7FC;
  --surface:    #FFFFFF;
  --border:     #D3E2F4;
  --border-light: #E8F1FB;

  /* Texto */
  --text-primary:   #0D1B3E;
  --text-secondary: #4A5F80;
  --text-muted:     #8298B8;

  /* Estados */
  --success: #1A7F4B;
  --success-bg: #E8F5EE;
  --error:   #C0392B;
  --error-bg: #FAEAE8;
  --warning: #B7670A;
  --warning-bg: #FEF3E2;

  /* Layout */
  --header-h: 68px;
  --footer-h: 56px;
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;

  /* Sombras */
  --shadow-sm: 0 1px 4px rgba(6,24,86,.06), 0 1px 2px rgba(6,24,86,.04);
  --shadow:    0 2px 12px rgba(6,24,86,.08), 0 1px 4px rgba(6,24,86,.04);
  --shadow-lg: 0 8px 32px rgba(6,24,86,.12), 0 2px 8px rgba(6,24,86,.06);

  /* Transición */
  --ease: cubic-bezier(.4,0,.2,1);
  --t: 180ms;

  /* Tipografía */
  --font-ui:    'IBM Plex Sans', 'Work Sans', system-ui, sans-serif;
  --font-title: 'Google Sans Flex', 'IBM Plex Sans', system-ui, sans-serif;
  --font-data:  'IBM Plex Sans', system-ui, sans-serif;
}

/* ── Reset ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; }
body {
  font-family: var(--font-ui);
  font-weight: 400;
  font-feature-settings: "tnum" 1;
  letter-spacing: -.001em;
  color: var(--text-primary);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.55;
}

/* ── Scrollbar ──────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--light-blue); }

/* ══════════════════════════════════════════════════
   HEADER
   ══════════════════════════════════════════════════ */
.site-header {
  background: var(--dark-blue);
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
  display: flex;
  flex: 1 0 auto;
  width: 100%;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.header-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
  height: 72px;
  width: 70%;
  max-width: 90%;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  text-decoration: none;
  flex-shrink: 0;
}

.header-logo {
  width: 60px;
  height: 60px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: hidden;
}
.header-logo svg { width: 60px; height: auto; }

.header-brand-text { display: flex; flex-direction: column; gap: 2px; }
.header-brand-name {
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.005em;
  line-height: 1.25;
}
.header-brand-sub {
  font-size: 12px;
  font-weight: 400;
  color: rgba(255,255,255,.55);
  letter-spacing: .01em;
  line-height: 1.4;
}

.header-nav {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.header-link {
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: color var(--t) var(--ease);
  white-space: nowrap;
}
.header-link-bold {
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: .01em;
}
.header-link:hover { color: #fff; }

/* Breadcrumb sub-bar */
.header-breadcrumb-bar {
  background: rgba(0, 84, 162, 1);
  border-top: 1px solid rgba(255,255,255,.08);
  padding: 8px 40px;
  width: 100%;
}
.header-breadcrumb-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: var(--max-w);
}
.header-breadcrumb-inner a {
  color: rgba(255,255,255,.55);
  text-decoration: none;
  font-size: 13px;
  transition: color var(--t);
}
.header-breadcrumb-inner a:hover { color: rgba(255,255,255,.9); }
.header-breadcrumb-inner .sep { color: rgba(255,255,255,.25); font-size: 13px; }
.header-breadcrumb-inner .current {
  color: rgba(255,255,255,.85);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}

/* Legacy compat */
.header-divider { display: none; }
.header-breadcrumb { display: none; }
.header-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--t) var(--ease);
  border: none;
}

/* ══════════════════════════════════════════════════
   FOOTER
   ══════════════════════════════════════════════════ */
.site-footer {
  background: var(--dark-blue);
  margin-top: auto;
  flex-shrink: 0;
}

.footer-body {
  border-top: 1px solid rgba(255,255,255,.08);
  padding: 40px 40px 36px;
}
.footer-body-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 40px;
}

.footer-info-block { flex: 1; }

.footer-brand-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}
.footer-logo {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.footer-logo svg { width: 56px; height: auto; }
.footer-brand-text { display: flex; flex-direction: column; gap: 2px; }
.footer-brand-name {
  font-family: var(--font-title);
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.005em;
  line-height: 1.25;
}
.footer-brand-sub {
  font-size: 12px;
  color: rgba(255,255,255,.5);
}

.footer-desc {
  font-size: 13px;
  color: rgba(255,255,255,.65);
  line-height: 1.75;
  margin-bottom: 16px;
}
.footer-desc strong { color: rgba(255,255,255,.85); font-weight: 600; }

.footer-address {
  font-size: 13px;
  color: rgba(255,255,255,.55);
  line-height: 1.85;
}

.footer-nav {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  padding-top: 4px;
}
.footer-nav-link {
  color: rgba(255,255,255,.55);
  text-decoration: none;
  font-size: 13px;
  transition: color var(--t);
  white-space: nowrap;
}
.footer-nav-link-bold {
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: .01em;
}
.footer-nav-link:hover { color: #fff; }

.footer-bar {
  border-top: 1px solid rgba(255,255,255,.1);
  padding: 16px 40px;
}
.footer-bar-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  text-align: center;
  flex-direction: column;
}
.footer-bar-inner span {
  font-size: 12px;
  color: rgba(255,255,255,.4);
}
.footer-bar-link {
  color: rgba(255,255,255,.6);
  text-decoration: none;
  font-weight: 600;
  transition: color var(--t);
}
.footer-bar-link:hover { color: #fff; }

/* Legacy compat */
.footer-left, .footer-right { display: none; }

/* ══════════════════════════════════════════════════
   MAIN CONTENT
   ══════════════════════════════════════════════════ */
.page-main {
  flex: 1;
  padding: 40px 32px;
  max-width: calc(var(--max-w) + 64px);
  width: 100%;
  margin: 0 auto;
}

.page-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.page-title {
  font-family: var(--font-title);
  font-size: 26px;
  font-weight: 700;
  color: var(--dark-blue);
  letter-spacing: -.01em;
  line-height: 1.25;
}
.page-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.55;
}

/* ══════════════════════════════════════════════════
   BADGES / CHIPS
   ══════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge-blue   { background: var(--light); color: var(--blue); }
.badge-navy   { background: rgba(6,24,86,.08); color: var(--dark-blue); }
.badge-green  { background: var(--success-bg); color: var(--success); }
.badge-red    { background: var(--error-bg); color: var(--error); }
.badge-yellow { background: var(--warning-bg); color: var(--warning); }

/* ══════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-ui);
  letter-spacing: -.001em;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--t) var(--ease);
  border: none;
  line-height: 1;
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0,84,162,.25);
}

.btn-primary {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0,84,162,.2);
}
.btn-primary:hover:not(:disabled) {
  background: var(--bold-blue);
  box-shadow: 0 3px 10px rgba(0,84,162,.28);
}

.btn-secondary {
  background: var(--light);
  color: var(--blue);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--border-light); border-color: var(--light-blue); }

.btn-danger {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid rgba(192,57,43,.15);
}
.btn-danger:hover:not(:disabled) { background: #F5C6C0; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface);
  color: var(--text-primary);
  border-color: var(--blue);
}

.btn-sm { padding: 6px 14px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-lg { padding: 12px 28px; font-size: 15px; }
.btn-full { width: 100%; }

/* ══════════════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* ══════════════════════════════════════════════════
   FORM ELEMENTS
   ══════════════════════════════════════════════════ */
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -.001em;
  margin-bottom: 7px;
  line-height: 1.4;
}
.form-label .req { color: var(--error); margin-left: 3px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 5px; line-height: 1.5; }
.form-error { font-size: 12px; color: var(--error); margin-top: 5px; font-weight: 500; }

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-data);
  font-size: 14px;
  color: var(--text-primary);
  background: #fff;
  transition: border-color var(--t), box-shadow var(--t);
  outline: none;
  appearance: none;
}
.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-muted); }
.form-input:hover,
.form-select:hover,
.form-textarea:hover { border-color: var(--light-blue); }
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,84,162,.12);
}
.form-input.is-invalid,
.form-select.is-invalid,
.form-textarea.is-invalid {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(192,57,43,.1);
}
.form-textarea { resize: vertical; min-height: 96px; line-height: 1.65; }
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234A5F80' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

/* Radio / Checkbox option rows */
.opt-list { display: flex; flex-direction: column; gap: 8px; }
.opt-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--t) var(--ease);
  background: #fff;
}
.opt-item:hover { border-color: var(--light-blue); background: var(--light); }
.opt-item.is-selected { border-color: var(--blue); background: var(--light); box-shadow: 0 0 0 1px var(--blue) inset; }
.opt-item input[type="radio"],
.opt-item input[type="checkbox"] {
  accent-color: var(--blue);
  width: 16px; height: 16px;
  flex-shrink: 0;
  cursor: pointer;
}
.opt-item .opt-label { font-size: 14px; color: var(--text-primary); cursor: pointer; line-height: 1.4; }

/* ══════════════════════════════════════════════════
   TABLE
   ══════════════════════════════════════════════════ */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-data);
  font-size: 13px;
  background: var(--surface);
}
thead th {
  background: var(--dark-blue);
  color: rgba(255,255,255,.8);
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
  border-bottom: 1px solid var(--bold-blue);
}
thead th:first-child { border-radius: var(--radius-lg) 0 0 0; }
thead th:last-child  { border-radius: 0 var(--radius-lg) 0 0; }
tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  vertical-align: middle;
  font-feature-settings: "tnum" 1;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--t); }
tbody tr:hover td { background: var(--light); }
.td-muted { color: var(--text-muted); font-size: 12px; }

/* ══════════════════════════════════════════════════
   SPINNER / STATES
   ══════════════════════════════════════════════════ */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  color: var(--text-muted);
  gap: 12px;
  text-align: center;
}
.empty-state-icon {
  width: 56px; height: 56px;
  background: var(--light);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 24px;
}
.empty-state p { font-size: 14px; max-width: 280px; line-height: 1.6; }

/* ══════════════════════════════════════════════════
   ALERT
   ══════════════════════════════════════════════════ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.55;
}
.alert-error {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid rgba(192,57,43,.2);
}
.alert-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(26,127,75,.2);
}

/* ══════════════════════════════════════════════════
   MODAL / DRAWER
   ══════════════════════════════════════════════════ */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(6,24,86,.45);
  z-index: 200;
  backdrop-filter: blur(2px);
}
.overlay.is-open { display: flex; }

.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: 440px;
  max-width: 95vw;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  padding: 28px 28px 40px;
  animation: drawerIn .22s var(--ease);
  z-index: 201;
}
@keyframes drawerIn {
  from { transform: translateX(32px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px;
  width: 100%;
  max-width: 400px;
  margin: auto;
  animation: modalIn .2s var(--ease);
}
@keyframes modalIn {
  from { transform: scale(.96); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* ══════════════════════════════════════════════════
   UTILITIES
   ══════════════════════════════════════════════════ */
.flex   { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.mb-1   { margin-bottom: 4px; }
.mb-2   { margin-bottom: 8px; }
.mb-3   { margin-bottom: 12px; }
.mb-4   { margin-bottom: 16px; }
.mb-6   { margin-bottom: 24px; }
.mb-8   { margin-bottom: 32px; }
.mt-4   { margin-top: 16px; }
.mt-6   { margin-top: 24px; }
.text-sm   { font-size: 13px; }
.text-xs   { font-size: 12px; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }

/* ══════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .header-main {
    width: 100%;
    max-width: 100%;
    padding: 0 16px;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
  }
  .header-brand {
    gap: 10px;
    min-width: 0;
    flex-shrink: 1;
  }
  .header-logo {
    width: 44px;
    height: 44px;
  }
  .header-logo svg {
    width: 44px;
  }
  .header-brand-name {
    font-size: 15px;
  }
  .header-brand-sub {
    font-size: 11px;
  }
  .header-nav {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    flex-wrap: wrap;
  }
  .header-link, .header-link-bold {
    font-size: 13px;
    padding: 4px 0;
  }
  .header-breadcrumb-bar {
    padding: 8px 12px;
  }
}

@media (max-width: 640px) {
    .header-nav .header-link {
      display: none;
    }
  .header-main {
    padding: 0 8px;
    min-height: 68px;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
  }
  .header-brand-sub {
    display: block;
    font-size: 10px;
    max-width: 90vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: rgba(255,255,255,.55);
  }
  .header-brand {
    min-width: 0;
    flex-shrink: 1;
  }
  .header-logo {
    width: 36px;
    height: 36px;
  }
  .header-logo svg {
    width: 36px;
  }
  .header-brand-name {
    font-size: 13px;
  }
  .header-nav {
    gap: 4px;
    margin-left: auto;
    flex-wrap: wrap;
  }
  .header-breadcrumb-bar {
    padding: 6px 8px;
  }
  .page-main   { padding: 20px 6px; }
  .footer-body { padding: 24px 8px 18px; }
  .footer-body-inner { flex-direction: column; gap: 16px; }
  .footer-nav { align-items: flex-start; }
  .footer-bar { padding: 10px 8px; }
}