/* =====================================================================
   Quality Roofing — Intranet · Sistema de diseño (tema claro)
   Fondos claros · marca como acento — rojo #ef0000 · carbón #393432
   ===================================================================== */

:root {
  /* Marca */
  --qr-red:          #ef0000;
  --qr-red-dark:     #cc0000;
  --qr-red-soft:     rgba(239, 0, 0, .09);
  --qr-red-soft-2:   rgba(239, 0, 0, .04);
  --qr-charcoal:     #393432;
  --qr-charcoal-2:   #2b2725;
  --qr-ink:          #1f1d1c;
  --qr-gray:         #a8a8a9;

  /* UI claro */
  --qr-soft:         #6d6764;
  --qr-muted:        #9a9591;
  --qr-border:       #e8e8ea;
  --qr-border-2:     #f0f0f2;
  --qr-bg:           #f5f6f8;
  --qr-surface:      #ffffff;
  --qr-surface-2:    #fafafb;

  /* Estado */
  --qr-ok:           #1c7c1c;
  --qr-ok-soft:      #e9f7e9;
  --qr-warn:         #b34500;
  --qr-warn-soft:    #fff3e6;

  /* Métricas */
  --qr-sidebar-w:    256px;
  --qr-topbar-h:     58px;
  --qr-radius:       14px;
  --qr-radius-sm:    9px;
  --qr-shadow:       0 1px 2px rgba(17,17,26,.04), 0 3px 12px rgba(17,17,26,.05);
  --qr-shadow-lg:    0 14px 36px rgba(17,17,26,.14);
  --qr-font:         'Montserrat', system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }   /* respeta el atributo hidden aunque .btn fije display */

html, body { height: 100%; }
body {
  font-family: var(--qr-font);
  background: var(--qr-bg);
  color: var(--qr-ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
.qr-icon { width: 20px; height: 20px; flex-shrink: 0; }

/* =====================================================================
   SHELL  ·  sidebar + main  (alto de viewport, sin scroll de página)
   ===================================================================== */
.app-shell {
  display: grid;
  grid-template-columns: var(--qr-sidebar-w) 1fr;
  height: 100dvh;
  overflow: hidden;
}

/* ── Sidebar (carbón) ────────────────────────────────────────────── */
.sidebar {
  background: linear-gradient(180deg, var(--qr-charcoal) 0%, #211e1c 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  z-index: 50;
}
.sidebar__brand {
  display: flex;
  align-items: center;
  justify-content: center;          /* logo centrado */
  padding: 22px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.sidebar__brand img {
  height: 52px;                     /* logo más grande */
  width: auto; max-width: 100%;
  filter: brightness(0) invert(1);  /* blanco sobre fondo oscuro */
}

.sidebar__nav { flex: 1; overflow-y: auto; padding: 16px 12px 18px; }
.sidebar__group { margin-top: 20px; }
.sidebar__group:first-child { margin-top: 4px; }
.sidebar__group-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: rgba(255,255,255,.38);
  padding: 0 12px 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: rgba(255,255,255,.78); font-size: 13.5px; font-weight: 600;
  position: relative; transition: background .15s, color .15s;
}
.nav-item .qr-icon { color: rgba(255,255,255,.5); transition: color .15s; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item:hover .qr-icon { color: #fff; }
.nav-item--active { background: rgba(239,0,0,.16); color: #fff; }
.nav-item--active .qr-icon { color: var(--qr-red); }
.nav-item--active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--qr-red);
}

/* ── Sidebar footer (usuario) ────────────────────────────────────── */
.sidebar__user {
  border-top: 1px solid rgba(255,255,255,.08);
  padding: 12px 14px; display: flex; align-items: center; gap: 11px;
  flex-shrink: 0;
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--qr-red); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; flex-shrink: 0;
  background-size: cover; background-position: center; overflow: hidden;
}
.avatar--img { background-color: var(--qr-charcoal); }   /* respaldo si la imagen tarda */
.avatar--sm { width: 34px; height: 34px; font-size: 12px; }
.sidebar__user-meta { min-width: 0; flex: 1; }
.sidebar__user-name {
  font-size: 13px; font-weight: 700; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar__user-role { font-size: 11px; color: rgba(255,255,255,.45); text-transform: capitalize; }
.sidebar__logout {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 9px;
  color: rgba(255,255,255,.55); transition: background .15s, color .15s; flex-shrink: 0;
}
.sidebar__logout:hover { background: rgba(239,0,0,.22); color: #fff; }

/* ── Main column ─────────────────────────────────────────────────── */
.app-main {
  display: flex; flex-direction: column;
  min-width: 0; height: 100dvh; overflow: hidden;
}
.topbar {
  position: relative;
  height: var(--qr-topbar-h); flex-shrink: 0;
  background: var(--qr-surface);
  border-bottom: 1px solid var(--qr-border);
  display: flex; align-items: center; gap: 14px; padding: 0 18px;
}
.topbar__menu {
  display: none; background: none; border: none; cursor: pointer;
  color: var(--qr-charcoal); width: 38px; height: 38px;
  align-items: center; justify-content: center; border-radius: 9px;
  flex-shrink: 0; z-index: 1;
}
.topbar__menu:hover { background: var(--qr-bg); }
/* Título centrado absoluto: queda centrado sin importar menú/chip */
.topbar__brand-title {
  position: absolute; left: 0; right: 0;
  text-align: center; pointer-events: none;
  font-size: 15px; font-weight: 800; color: var(--qr-ink);
  letter-spacing: .01em;
}
.topbar__chip { display: flex; align-items: center; gap: 10px; margin-left: auto; z-index: 1; }
.topbar__chip-meta { text-align: right; line-height: 1.25; }
.topbar__chip-name { font-size: 13px; font-weight: 700; }
.topbar__chip-role { font-size: 11px; color: var(--qr-muted); text-transform: capitalize; }

/* área de trabajo: único elemento con scroll cuando hace falta */
.app-content { flex: 1; overflow-y: auto; padding: 24px; }
.container { max-width: 1180px; margin: 0 auto; }

.app-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--qr-border);
  padding: 10px 24px; background: var(--qr-surface);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 12px; color: var(--qr-muted);
}
.app-footer__copy strong { color: var(--qr-soft); font-weight: 700; }
.app-footer__nest {
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--qr-muted); font-weight: 600; white-space: nowrap;
  transition: color .15s;
}
.app-footer__nest img { height: 18px; width: auto; display: block; }
.app-footer__nest:hover { color: var(--qr-charcoal); }

/* ── Paneles SPA ─────────────────────────────────────────────────── */
.view-panel { display: none; animation: fade .18s ease; }
.view-panel.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* =====================================================================
   HERO  ·  bienvenida (claro, acento de marca)
   ===================================================================== */
.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(120deg, var(--qr-surface) 0%, #fdf1f1 100%);
  border: 1px solid var(--qr-border);
  border-radius: var(--qr-radius);
  padding: 22px 26px;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  box-shadow: var(--qr-shadow);
}
.hero::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--qr-red);
}
.hero__eyebrow {
  font-size: 11px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--qr-red); margin-bottom: 4px;
}
.hero__name { font-size: 24px; font-weight: 800; line-height: 1.1; color: var(--qr-ink); }
.hero__role { font-size: 13px; color: var(--qr-soft); margin-top: 5px; }
.hero__date { text-align: right; flex-shrink: 0; }
.hero__date-day { font-size: 34px; font-weight: 800; line-height: 1; color: var(--qr-red); }
.hero__date-rest { font-size: 12px; color: var(--qr-soft); text-transform: capitalize; margin-top: 4px; }
.hero__time { font-size: 12px; color: var(--qr-muted); margin-top: 2px; font-variant-numeric: tabular-nums; }

/* =====================================================================
   SECCIONES + GRID DE MÓDULOS
   ===================================================================== */
.section-label {
  font-size: 12px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--qr-muted);
  margin: 26px 2px 13px;
}
.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(244px, 1fr));
  gap: 16px;
}
.module-card {
  position: relative; background: var(--qr-surface);
  border: 1px solid var(--qr-border); border-radius: var(--qr-radius);
  padding: 20px 20px 18px; display: flex; flex-direction: column; gap: 11px;
  transition: transform .16s, box-shadow .16s, border-color .16s; overflow: hidden;
  cursor: pointer;
}
.module-card::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: var(--qr-red); transform: scaleX(0); transform-origin: left;
  transition: transform .2s;
}
.module-card:hover {
  transform: translateY(-3px); box-shadow: var(--qr-shadow-lg); border-color: transparent;
}
.module-card:hover::before { transform: scaleX(1); }
.module-card__icon {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--qr-red-soft); color: var(--qr-red);
  display: flex; align-items: center; justify-content: center;
}
.module-card__icon .qr-icon { width: 23px; height: 23px; }
.module-card__title { font-size: 15px; font-weight: 800; color: var(--qr-ink); }
.module-card__desc { font-size: 12.5px; color: var(--qr-soft); line-height: 1.5; flex: 1; }
.module-card__cta {
  font-size: 12.5px; font-weight: 700; color: var(--qr-red);
  display: inline-flex; align-items: center; gap: 6px; transition: gap .15s;
}
.module-card:hover .module-card__cta { gap: 10px; }

/* =====================================================================
   CARD + TABLA  (gestión de usuarios)
   ===================================================================== */
.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 21px; font-weight: 800; }
.page-head p { font-size: 13px; color: var(--qr-soft); margin-top: 4px; }

.card {
  background: var(--qr-surface); border: 1px solid var(--qr-border);
  border-radius: var(--qr-radius); box-shadow: var(--qr-shadow); overflow: hidden;
}
.card__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 20px; border-bottom: 1px solid var(--qr-border);
}
.card__head-title { font-size: 14px; font-weight: 800; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 540px; }
th {
  padding: 12px 16px; text-align: left; font-size: 11px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--qr-muted);
  background: var(--qr-surface-2); border-bottom: 1px solid var(--qr-border); white-space: nowrap;
}
td { padding: 13px 16px; border-bottom: 1px solid var(--qr-border-2); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover td { background: var(--qr-surface-2); }
.cell-strong { font-weight: 700; color: var(--qr-ink); }
.cell-soft { font-size: 12px; color: var(--qr-soft); }
.user-cell { display: inline-flex; align-items: center; gap: 10px; }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.badge--admin     { background: var(--qr-red-soft); color: var(--qr-red-dark); }
.badge--inspector { background: #e8f0ff; color: #1a3a8a; }
.badge--on        { background: var(--qr-ok-soft); color: var(--qr-ok); }
.badge--off       { background: #f1eeec; color: var(--qr-soft); }

/* =====================================================================
   BOTONES
   ===================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 16px; border: 1.5px solid transparent; border-radius: var(--qr-radius-sm);
  font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
}
.btn--primary { background: var(--qr-red); color: #fff; }
.btn--primary:hover { background: var(--qr-red-dark); box-shadow: 0 4px 14px rgba(239,0,0,.26); }
.btn--ghost { background: transparent; color: var(--qr-charcoal); border-color: var(--qr-border); }
.btn--ghost:hover { border-color: var(--qr-red); color: var(--qr-red); }
.btn--sm { padding: 8px 13px; font-size: 12px; }

.acts { display: flex; gap: 5px; align-items: center; }
.act-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border: none; border-radius: 9px;
  font-size: 14px; cursor: pointer; flex-shrink: 0; transition: background .15s, color .15s;
}
.act-btn--edit  { background: #f0f0f0; color: var(--qr-charcoal); }
.act-btn--edit:hover  { background: #e0e5ff; color: #2233aa; }
.act-btn--deact { background: var(--qr-warn-soft); color: var(--qr-warn); }
.act-btn--deact:hover { background: #ffe2c2; }
.act-btn--act   { background: var(--qr-ok-soft); color: var(--qr-ok); }
.act-btn--act:hover   { background: #c8efc8; }
.act-btn--del   { background: #fdecec; color: var(--qr-red); }
.act-btn--del:hover   { background: var(--qr-red); color: #fff; }
.you-tag { font-size: 10px; color: var(--qr-gray); white-space: nowrap; }
.empty { padding: 40px 20px; text-align: center; color: var(--qr-muted); font-size: 14px; }

/* =====================================================================
   MODAL
   ===================================================================== */
.modal-bg {
  display: none; position: fixed; inset: 0;
  background: rgba(33,30,28,.45); backdrop-filter: blur(2px);
  z-index: 200; align-items: center; justify-content: center; padding: 16px;
}
.modal-bg.open { display: flex; }
.modal-box {
  background: #fff; border-radius: 16px; width: 100%; max-width: 430px;
  padding: 26px; box-shadow: var(--qr-shadow-lg);
  max-height: calc(100dvh - 32px); overflow-y: auto;
}
.modal-box h2 { font-size: 17px; font-weight: 800; margin-bottom: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 15px; }
.field label { font-size: 12px; font-weight: 700; color: var(--qr-charcoal); }
.field input, .field select {
  padding: 12px 13px; border: 1.5px solid var(--qr-border); border-radius: var(--qr-radius-sm);
  font-family: inherit; font-size: 14px; color: var(--qr-ink); outline: none; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus { border-color: var(--qr-red); box-shadow: 0 0 0 3px var(--qr-red-soft); }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.error-msg { color: var(--qr-red); font-size: 12px; font-weight: 600; margin-bottom: 12px; display: none; }
.field .opt { color: var(--qr-muted); font-weight: 500; }

/* ── Uploaders (foto / firma) ────────────────────────────────────── */
.uploader { display: flex; align-items: center; gap: 14px; }
.uploader__body { min-width: 0; flex: 1; }
.uploader__btns { display: flex; gap: 8px; flex-wrap: wrap; }
.uploader__hint { font-size: 11px; color: var(--qr-muted); margin-top: 6px; line-height: 1.4; }
.avatar--lg { width: 60px; height: 60px; font-size: 20px; }
.firma-preview {
  width: 130px; height: 60px; flex-shrink: 0;
  border: 1.5px dashed var(--qr-border); border-radius: var(--qr-radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--qr-muted); text-align: center;
  background: var(--qr-surface-2);
  background-size: contain; background-position: center; background-repeat: no-repeat;
}
.firma-preview.has-img { border-style: solid; color: transparent; }

/* =====================================================================
   LOGIN  ·  split brand + form
   ===================================================================== */
.login-wrap { min-height: 100dvh; display: grid; grid-template-columns: 1.05fr .95fr; }
.login-brand {
  position: relative; overflow: hidden;
  background:
    radial-gradient(130% 120% at 90% 10%, rgba(239,0,0,.30) 0%, rgba(239,0,0,0) 50%),
    linear-gradient(150deg, var(--qr-charcoal) 0%, #211e1c 100%);
  color: #fff; padding: 56px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.login-brand__logo img { height: 40px; filter: brightness(0) invert(1); }
.login-brand__pitch { max-width: 420px; }
.login-brand__pitch h2 { font-size: 30px; font-weight: 800; line-height: 1.18; letter-spacing: -.01em; }
.login-brand__pitch p { font-size: 14px; color: rgba(255,255,255,.62); margin-top: 14px; line-height: 1.6; }
.login-brand__foot { font-size: 12px; color: rgba(255,255,255,.4); }
.login-brand__chevron {
  position: absolute; right: -60px; bottom: -60px; width: 0; height: 0;
  border-left: 150px solid transparent; border-right: 150px solid transparent;
  border-bottom: 120px solid rgba(239,0,0,.12);
}
.login-form-side { display: flex; align-items: center; justify-content: center; padding: 40px 28px; background: var(--qr-surface); }
.login-form { width: 100%; max-width: 360px; }
.login-form__mark { display: none; text-align: center; margin-bottom: 26px; }
.login-form__mark img { height: 40px; }
.login-form h1 { font-size: 22px; font-weight: 800; }
.login-form .subtitle { font-size: 13px; color: var(--qr-soft); margin: 4px 0 26px; }
.login-form label { display: block; font-size: 12.5px; font-weight: 700; color: var(--qr-charcoal); margin-bottom: 6px; }
.login-form input {
  width: 100%; padding: 13px 14px; border: 1.5px solid var(--qr-border);
  border-radius: var(--qr-radius-sm); font-family: inherit; font-size: 15px;
  color: var(--qr-ink); outline: none; margin-bottom: 18px;
  transition: border-color .15s, box-shadow .15s;
}
.login-form input:focus { border-color: var(--qr-red); box-shadow: 0 0 0 3px var(--qr-red-soft); }
.login-form .btn { width: 100%; padding: 14px; font-size: 15px; }
.error-box {
  background: #fdecec; border: 1.5px solid var(--qr-red); border-radius: var(--qr-radius-sm);
  padding: 11px 14px; font-size: 13px; font-weight: 600; color: var(--qr-red-dark); margin-bottom: 18px;
}

/* =====================================================================
   RESPONSIVE
   ===================================================================== */
.nav-scrim { display: none; }   /* fuera del flujo del grid en escritorio */

@media (max-width: 980px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-form__mark { display: block; }
}

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: var(--qr-sidebar-w);
    transform: translateX(-100%); transition: transform .25s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.25);
  }
  .app-shell.nav-open .sidebar { transform: translateX(0); }
  .nav-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 45; }
  .app-shell.nav-open .nav-scrim { display: block; }
  .topbar__menu { display: inline-flex; }
}

@media (max-width: 620px) {
  .app-content { padding: 16px; }
  .hero { flex-direction: column; align-items: flex-start; gap: 12px; padding: 20px; }
  .hero__date { text-align: left; }
  .hero__name { font-size: 20px; }
  .topbar { padding: 0 10px; }
  .topbar__chip-meta { display: none; }
  /* el título centrado deja espacio al menú (izq) y avatar (der) */
  .topbar__brand-title { left: 48px; right: 48px; font-size: 13.5px; }
  .modules-grid { grid-template-columns: 1fr; }
  .app-footer { flex-direction: column; gap: 6px; text-align: center; padding: 12px 16px; }
  .page-head h1 { font-size: 19px; }
}

@media (max-width: 400px) {
  .topbar__brand-title { font-size: 12px; }
}
