/* Repositorio ITFIP — estilos globales */
:root {
  --color-bg: #f0f4f8;
  --color-surface: #ffffff;
  --color-text: #0f172a;
  --color-muted: #64748b;
  --color-border: #e2e8f0;
  --color-primary: #1d4ed8;
  --color-primary-hover: #1e40af;
  --color-primary-soft: #eff6ff;
  --color-danger: #b91c1c;
  --color-danger-soft: #fef2f2;
  --color-success-bg: #ecfdf5;
  --color-success-border: #6ee7b7;
  --color-error-bg: #fef2f2;
  --color-error-border: #fca5a5;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.1);
  --font: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --header-h: 56px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ——— Cabecera ——— */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 50;
}

.site-header__inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 1rem;
  min-height: var(--header-h);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--color-text);
  letter-spacing: -0.02em;
}

.brand:hover {
  color: var(--color-primary);
  text-decoration: none;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
  flex: 1;
}

.nav-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
}

.nav-group__label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted);
  width: 100%;
  margin: 0.25rem 0 0;
}

@media (min-width: 768px) {
  .nav-group {
    flex-direction: row;
    align-items: center;
    gap: 0.35rem;
  }

  .nav-group__label {
    width: auto;
    margin: 0 0.35rem 0 0;
    padding-right: 0.35rem;
    border-right: 1px solid var(--color-border);
  }
}

.nav-link {
  display: inline-block;
  padding: 0.4rem 0.65rem;
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
}

.nav-link:hover {
  background: var(--color-bg);
  text-decoration: none;
}

.nav-link.is-active {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.site-user {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.user-chip {
  font-size: 0.8rem;
  color: var(--color-muted);
}

.user-chip strong {
  color: var(--color-text);
  font-weight: 600;
}

/* ——— Contenido ——— */
.app-shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2.5rem;
}

body.layout-auth .app-shell {
  max-width: none;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
}

body.layout-auth {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ——— Tipografía de página ——— */
.page-title {
  margin: 0 0 0.35rem;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.page-lead {
  margin: 0 0 1.25rem;
  color: var(--color-muted);
  font-size: 0.95rem;
  max-width: 52ch;
}

/* ——— Alertas ——— */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin: 0 0 1rem;
  font-size: 0.9rem;
  border: 1px solid transparent;
}

.alert-success {
  background: var(--color-success-bg);
  border-color: var(--color-success-border);
  color: #065f46;
}

.alert-error {
  background: var(--color-error-bg);
  border-color: var(--color-error-border);
  color: #991b1b;
}

/* ——— Tarjetas ——— */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  margin: 0 0 1rem;
  box-shadow: var(--shadow);
}

.card h2,
.card h3 {
  margin-top: 0;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.card h2 {
  font-size: 1.2rem;
}

.empty-state {
  margin: 0;
  color: var(--color-muted);
  font-size: 0.95rem;
}

/* ——— Formularios ——— */
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem 1rem;
}

@media (max-width: 640px) {
  .grid {
    grid-template-columns: 1fr;
  }
}

.grid-login {
  grid-template-columns: 1fr;
}

label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
  color: var(--color-text);
}

input,
select,
textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font: inherit;
  background: var(--color-surface);
  color: var(--color-text);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.2);
}

button {
  cursor: pointer;
  font: inherit;
}

/* ——— Botones ——— */
button[type="submit"],
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  width: auto;
  min-height: 2.5rem;
}

button[type="submit"]:not(.btn-danger):not(.btn-ghost),
.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

button[type="submit"]:not(.btn-danger):not(.btn-ghost):hover,
.btn-primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  text-decoration: none;
}

.btn-danger {
  background: var(--color-danger);
  color: #fff;
  border-color: var(--color-danger);
}

.btn-danger:hover {
  filter: brightness(1.08);
  text-decoration: none;
}

.btn-ghost {
  background: transparent;
  color: var(--color-muted);
  border-color: var(--color-border);
}

.btn-ghost:hover {
  background: var(--color-bg);
  color: var(--color-text);
  text-decoration: none;
}

a.btn-primary,
a.btn-ghost {
  text-decoration: none;
}

a.btn-primary:hover,
a.btn-ghost:hover {
  text-decoration: none;
}

.btn-block {
  width: 100%;
}

/* Formularios que fueron 100% width en inputs: botón principal ancho completo en cards */
.card > form > button[type="submit"]:last-child {
  margin-top: 0.5rem;
  width: 100%;
}

form.card > button[type="submit"] {
  width: 100%;
}

.form-work > button[type="submit"] {
  margin-top: 0.75rem;
  width: 100%;
}

/* ——— Enlaces de acción (tablas / listados) ——— */
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.actions a {
  font-weight: 500;
}

.link-inline {
  font-weight: 600;
}

/* ——— Tablas ——— */
.table-wrap {
  overflow-x: auto;
  margin: 0.5rem 0 0;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  border: 1px solid var(--color-border);
  padding: 0.6rem 0.75rem;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f8fafc;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-muted);
}

tbody tr:nth-child(even) {
  background: #fafbfc;
}

tbody tr:hover {
  background: var(--color-primary-soft);
}

.small {
  font-size: 0.85rem;
  color: var(--color-muted);
}

/* ——— Paginación ——— */
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-top: 1rem;
  padding: 0.75rem 0;
  font-size: 0.9rem;
  color: var(--color-muted);
}

.pager a {
  font-weight: 600;
}

/* ——— Login ——— */
.auth-card {
  width: 100%;
  max-width: 420px;
}

.auth-card .page-title {
  text-align: center;
}

.auth-card .page-lead {
  text-align: center;
  margin-left: auto;
  margin-right: auto;
}

.auth-switch {
  margin: 1.25rem 0 0;
  text-align: center;
  font-size: 0.9rem;
  color: var(--color-muted);
}

.auth-switch a {
  font-weight: 600;
}

/* ——— Vista previa PDF ——— */
.embed-pdf {
  display: block;
  width: 100%;
  min-height: 480px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #f1f5f9;
}
