/* ==========================================================================
   base.css - Capa 2: fundacion (reset, tipografia, enlaces, topbar base,
   container, botones, tarjetas, tablas, status, listas, responsive).
   Fase 1: reglas movidas TAL CUAL desde el inicio de tqc.css (orden
   preservado => cascada identica). Depura/sub-divide en fases posteriores.
   ========================================================================== */
* { box-sizing: border-box; }
html { overflow-x: clip; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
a { color: var(--primary); text-decoration: none; font-weight: 700; }
a:hover { text-decoration: underline; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px; background: rgba(255,255,255,.96);
  backdrop-filter: blur(8px); box-shadow: 0 2px 16px rgba(16, 24, 40, .08);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 44px; height: 44px; border-radius: var(--radius-md);
  display: grid; place-items: center; background: var(--primary); color: var(--on-primary, #fff);
  font-weight: 700; letter-spacing: .5px;
}
.brand strong { display: block; font-size: var(--text-lg); }
.brand span { display: block; color: var(--muted); font-size: var(--text-sm); margin-top: 2px; }
.main-nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.main-nav a { color: var(--primary); }
.user-pill { padding: 8px 10px; background: var(--soft-blue); border-radius: var(--radius-pill); color: var(--primary); font-weight: 700; font-size: var(--text-sm); }
.container { width: 100%; max-width: 1280px; margin: 28px auto; padding: 0 18px 48px; flex: 1 0 auto; }
h1, h2 { margin: 0; }
h1 { font-size: clamp(28px, 4vw, 44px); letter-spacing: -1px; }
h1.page-title-compact { font-size: var(--text-2xl); line-height: 1.2; letter-spacing: -.025em; }
h2 { font-size: var(--text-xl); }
p { color: var(--muted); line-height: 1.5; }
.eyebrow { margin: 0 0 8px; color: var(--primary); text-transform: uppercase; letter-spacing: .09em; font-size: var(--text-xs); font-weight: 800; }
.hero, .page-heading, .profile-header {
  display: flex; justify-content: space-between; align-items: center; gap: 18px;
  background: linear-gradient(135deg, var(--card) 0%, var(--soft-blue) 100%);
  border: 1px solid var(--line); border-radius: var(--radius-2xl); padding: 26px; box-shadow: var(--shadow); margin-bottom: 20px;
}
button {
  border: 0; border-radius: var(--radius-md); padding: 11px 16px; font-weight: 700; cursor: pointer; white-space: nowrap;
  background: var(--primary); color: var(--on-primary, #fff);
}
.cards { display: grid; gap: 16px; margin: 18px 0; }

.summary-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-xl); padding: 20px; box-shadow: var(--shadow); }




.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.section-title span { color: var(--muted); font-size: var(--text-sm); font-weight: 700; }
.search-panel { display: grid; grid-template-columns: 1fr 200px auto auto; gap: 10px; margin: 18px 0; }
/* Relleno 9px: un campo suelto mide lo mismo que un botón (--control-h, 36px). Antes 12px = 43px y en una
   barra con botones no quedaban parejos. Los campos con alto propio (barras compactas) no cambian. */
input, select, textarea { width: 100%; padding: 9px 13px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--card); font-family: inherit; font-size: var(--text-md); }
/* Foco único de todos los campos (el de .form-field): borde y halo del color principal. Sin esto Chrome pinta
   su anillo blanco y negro, que en modo oscuro hace ver el campo como un hueco negro. :where() = sin peso,
   los módulos con foco propio (tablas editables, login) lo siguen mandando. */
:where(input, select, textarea):focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.result-info { color: var(--muted); font-size: var(--text-sm); font-weight: 700; margin: 8px 0 14px; }
.table-wrap { width: 100%; overflow: auto; background: var(--card); border-radius: var(--radius-lg); box-shadow: var(--shadow); border: 1px solid var(--line); }
.table-wrap.no-shadow { box-shadow: none; border-radius: var(--radius-md); }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--row-line); text-align: left; vertical-align: top; }
th { background: var(--table-head); color: var(--text-2); font-size: var(--text-sm); white-space: nowrap; }
td { font-size: var(--text-md); }
/* Valores en celdas sin negrilla: <strong> dentro de una celda es énfasis suave
   (columna que identifica la fila, totales), no negrilla plena. */
td :is(strong, b) { font-weight: 600; }
.compact th, .compact td { padding: 10px 12px; font-size: var(--text-sm); }
.empty { text-align: center; color: var(--muted); padding: 18px !important; }
.status { display: inline-flex; padding: 6px 10px; border-radius: var(--radius-pill); font-weight: 700; font-size: var(--text-xs); background: var(--sem-gris-bg); color: var(--text-2); }


.status-vencido, .status-suspendido { background: var(--warning-bg); color: var(--warning); }
.simple-list { list-style: none; margin: 0; padding: 0; }
.simple-list li { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.simple-list li:last-child { border-bottom: 0; }
.simple-list span { color: var(--muted); }
.simple-list strong { color: var(--primary); }
.profile-meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.profile-meta > span:not(.status) { color: var(--muted); font-weight: 700; }
.back-link { display: inline-block; margin-bottom: 12px; }
.current-contract { min-width: 250px; background: var(--primary); color: var(--on-primary, #fff); border-radius: var(--radius-xl); padding: 18px; }
.current-contract span, .current-contract small { display: block; opacity: .86; }
.current-contract strong { display: block; font-size: var(--text-3xl); margin: 8px 0; }
.detail-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; margin: 0; }
.detail-list div { padding: 10px 0; border-bottom: 1px solid var(--line); }
dt { color: var(--muted); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .06em; font-weight: 800; margin-bottom: 4px; }
dd { margin: 0; font-weight: 400; color: var(--text); }
.section-card { margin-top: 16px; }
.messages { margin-bottom: 16px; }
.message { padding: 12px 14px; border-radius: var(--radius-md); background: var(--soft-blue); border: 1px solid var(--line); }
.message.success { background: var(--success-bg); border-color: var(--success-line); color: var(--text); }
/* Notificaciones tipo toast (arriba a la derecha, auto-desaparecen). */
.tqc-toasts { position: fixed; top: 72px; right: 16px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; max-width: 360px; }
.tqc-toast { position: relative; background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--primary); border-radius: 10px; box-shadow: 0 12px 30px rgba(13,23,48,.16); padding: 12px 34px 12px 14px; font-size: var(--text-md); color: var(--text); animation: tqc-toast-in .2s ease; }
.tqc-toast.success { border-left-color: var(--success); }
.tqc-toast.error, .tqc-toast.danger { border-left-color: var(--danger); }
.tqc-toast.warning { border-left-color: var(--warning); }
/* Descargas en segundo plano (static/js/tqc-descargas.js): abajo a la derecha, como Drive. */
.tqc-descargas { position: fixed; right: 16px; bottom: 16px; z-index: 2000; width: min(360px, calc(100vw - 32px)); background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--primary); border-radius: 10px; box-shadow: 0 12px 30px rgba(13,23,48,.18); font-size: var(--text-md); color: var(--text); overflow: hidden; }
.tqc-descargas .tqc-desc-cab { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px 8px 14px; border-bottom: 1px solid var(--line); }
.tqc-descargas.min .tqc-desc-cab { border-bottom: 0; }
.tqc-descargas.min .tqc-desc-lista { max-height: 0; opacity: 0; overflow: hidden; }
.tqc-descargas .tqc-desc-min, .tqc-descargas .tqc-desc-x { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: var(--text-lg); line-height: 1; padding: 0 4px; min-height: 0; width: auto; }
.tqc-descargas .tqc-desc-lista { max-height: 260px; overflow-y: auto; transition: max-height .45s ease, opacity .35s ease; }
.tqc-descargas .tqc-desc-item { padding: 8px 12px 8px 14px; border-bottom: 1px solid var(--line); }
.tqc-descargas .tqc-desc-item:last-child { border-bottom: 0; }
.tqc-descargas .tqc-desc-nombre { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tqc-descargas .tqc-desc-barra { height: 5px; border-radius: 3px; background: var(--line); margin: 6px 0 4px; overflow: hidden; }
.tqc-descargas .tqc-desc-barra span { display: block; height: 100%; background: var(--primary); transition: width .3s ease; }
.tqc-descargas .tqc-desc-pie { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: var(--text-xs); color: var(--muted); }
.tqc-descargas .tqc-desc-pie > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tqc-descargas .tqc-desc-acc { display: inline-flex; align-items: center; gap: 4px; flex: none; }
.tqc-descargas .tqc-desc-btn { background: none; border: 0; color: var(--primary); font-weight: 700; cursor: pointer; padding: 2px 4px; font-size: var(--text-xs); min-height: 0; width: auto; }
.tqc-descargas .tqc-desc-item.listo .tqc-desc-pie > span:first-child { color: var(--success); font-weight: 700; }
.tqc-descargas .tqc-desc-item.error .tqc-desc-pie > span:first-child { color: var(--danger); }
.tqc-toast.fade { opacity: 0; transform: translateX(12px); transition: opacity .4s, transform .4s; }
.tqc-toast-x { position: absolute; top: 5px; right: 8px; border: 0; background: none; font-size: var(--text-xl); line-height: 1; cursor: pointer; color: var(--muted); }
@keyframes tqc-toast-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
@media (max-width: 560px){ .tqc-toasts { left: 12px; right: 12px; max-width: none; } }
@media (max-width: 900px) {
  .topbar, .hero, .page-heading, .profile-header { align-items: flex-start; flex-direction: column; }
  .grid-2 { grid-template-columns: 1fr; }
  .search-panel { grid-template-columns: 1fr; }
  .detail-list { grid-template-columns: 1fr; }
  .current-contract { width: 100%; }
}
