/* =========================================================
   ULTRON · Panel de incidencias
   Usa los colores, tipografía y botones de landing.css
   ========================================================= */
:root {
  --navy-900: #0b1b33; --navy-800: #0f2747; --navy-700: #13305a;
  --teal-600: var(--orange-600); --teal-500: var(--orange); --cyan: #ff9a3c;
  --peach: #ffe3cc; --mint: var(--orange-50); --muted: #5a6880; --cream: #fff;
  --header-h: var(--nav-h); --grad: var(--orange);
}
.muted { color: var(--muted); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.panel-body { background: var(--mist); min-height: 100vh; }
.btn-line { border: 1.5px solid var(--line); background: #fff; color: var(--navy-800); }
.btn-line:hover { border-color: rgba(226, 104, 12, .45); }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .6; pointer-events: none; }

/* ---------- Encabezado ---------- */
.user-session { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.user-who {
  display: flex; align-items: center; gap: 10px; padding: 5px 14px 5px 5px; border: 1.5px solid var(--line); border-radius: 999px;
  background: #fff; color: var(--navy); font: inherit; cursor: pointer; text-align: left; transition: border-color .2s;
}
.user-who:hover { border-color: var(--orange); }
.user-text { display: grid; gap: 2px; min-width: 0; }
.user-who b { font-size: 14px; line-height: 1.2; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-who .role-pill { justify-self: start; font-size: 9.5px; padding: 2px 8px; }
.back-link { margin-left: auto; color: var(--navy); font-weight: 700; font-size: 14.5px; display: inline-flex; align-items: center; gap: 10px; }
.back-link:hover { color: var(--orange-600); }
.kicker-light { color: var(--cyan); }
.auth-umma { width: 200px; height: auto; margin: 6px 0 22px; opacity: .95; }

/* Fotos de perfil */
.user-pic, .user-av, .avatar-big {
  flex: none; display: grid; place-items: center; border-radius: 50%; overflow: hidden;
  background: var(--orange-50); color: var(--orange-600); font: 800 13px/1 var(--head);
}
.user-pic { width: 36px; height: 36px; }
.user-pic img, .user-av img, .avatar-big img { width: 100%; height: 100%; object-fit: cover; }
.avatar-edit { display: flex; align-items: center; gap: 18px; margin: 4px 0 6px; }
.avatar-big { width: 88px; height: 88px; font-size: 26px; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--orange); }
.avatar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.avatar-actions small { flex-basis: 100%; font-size: 12.5px; }
.avatar-upload { cursor: pointer; }
#msgFoto { margin-bottom: 14px; }

.role-pill {
  display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 99px; background: rgba(255, 255, 255, .14); color: #fff; white-space: nowrap;
}
.rol-admin { background: var(--peach); color: #8a3f05; }
.rol-visor { background: var(--mint); color: var(--teal-600); }
.rol-pendiente { background: #eef0f1; color: #65737a; }
.rol-propietario { background: var(--navy-800); color: #fff; }

/* ---------- Vistas ---------- */
.view { padding: 48px 0 80px; }
.view-center { min-height: calc(100vh - var(--header-h)); display: grid; place-items: center; padding: 40px 18px; }
.spinner {
  width: 42px; height: 42px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--teal-500);
  animation: girar .8s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }

/* ---------- Acceso ---------- */
.auth { min-height: calc(100vh - var(--header-h)); display: grid; place-items: center; padding: 40px 18px; }
.auth-card {
  width: 100%; max-width: 980px; display: grid; grid-template-columns: 0.95fr 1.05fr;
  background: #fff; border-radius: 28px; overflow: hidden; box-shadow: 0 40px 80px -40px rgba(11, 23, 48, .45);
  border: 1px solid var(--line);
}
.auth-side {
  position: relative; overflow: hidden; color: #fff; padding: 44px 40px;
  background: linear-gradient(150deg, var(--navy-900), var(--navy-700));
  display: flex; flex-direction: column; justify-content: center;
}
.auth-side::after {
  content: ""; position: absolute; right: -80px; bottom: -80px; width: 280px; height: 280px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 154, 60, .28), transparent 70%);
}
.auth-side img { width: 110px; margin-bottom: 22px; filter: drop-shadow(0 16px 26px rgba(0, 0, 0, .45)); position: relative; z-index: 1; }
.auth-side h1 { font-size: clamp(24px, 2.6vw, 32px); line-height: 1.15; position: relative; z-index: 1; }
.auth-side h1 span { color: var(--cyan); }
.auth-points { margin-top: 24px; display: grid; gap: 10px; position: relative; z-index: 1; }
.auth-points li { position: relative; padding-left: 28px; color: rgba(255, 255, 255, .82); font-size: 14.5px; }
.auth-points li::before { content: ""; position: absolute; left: 0; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--cyan); }
.auth-points li::after {
  content: ""; position: absolute; left: 5.5px; top: 8px; width: 6px; height: 3.5px;
  border-left: 2px solid var(--navy-900); border-bottom: 2px solid var(--navy-900); transform: rotate(-45deg);
}
.dots { position: absolute; width: 150px; height: 110px; pointer-events: none; background-size: 16px 16px; }
.dots-auth { right: 18px; top: 18px; opacity: .25; background-image: radial-gradient(#fff 1.3px, transparent 1.4px); }

.auth-main { padding: 40px 44px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; background: #f1f4f5; border-radius: 999px; padding: 5px; margin-bottom: 28px; }
.segmented button {
  border: 0; background: transparent; border-radius: 999px; padding: 11px 12px; cursor: pointer;
  font-family: inherit; font-weight: 700; font-size: 14px; color: var(--muted); transition: background .2s, color .2s, box-shadow .2s;
}
.segmented button.is-active { background: #fff; color: var(--navy-900); box-shadow: 0 4px 14px -6px rgba(16, 35, 66, .35); }

.auth-form { display: grid; gap: 16px; }
.auth-form h2 { font-size: 24px; }
.auth-form .muted { margin-top: -8px; font-size: 14.5px; }
.auth-form label { display: grid; gap: 7px; font-size: 13.5px; font-weight: 700; }
.auth-form small { font-weight: 500; color: var(--muted); font-size: 12.5px; }
.auth-form input, .filters input, .filters select, .role-select {
  width: 100%; font-family: inherit; font-size: 15px; color: var(--ink);
  background: var(--cream); border: 1.5px solid #e6ded6; border-radius: 12px; padding: 12px 14px;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.auth-form input:focus, .filters input:focus, .filters select:focus, .role-select:focus {
  outline: none; border-color: var(--teal-500); background: #fff; box-shadow: 0 0 0 4px rgba(242, 129, 29, .14);
}
.pass-wrap { position: relative; display: block; }
.pass-wrap input { padding-right: 64px; }
.pass-toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: transparent;
  font-family: inherit; font-weight: 700; font-size: 12.5px; color: var(--teal-600); cursor: pointer; padding: 6px 8px;
}
.form-msg { font-size: 14px; font-weight: 600; min-height: 0; }
.form-msg:empty { display: none; }
.form-msg.error { color: #b3261e; background: #fdecea; padding: 10px 14px; border-radius: 10px; }
.form-msg.ok { color: #146c43; background: #e6f6ee; padding: 10px 14px; border-radius: 10px; }
.link-btn {
  justify-self: center; border: 0; background: none; font-family: inherit; font-weight: 700; font-size: 14px;
  color: var(--teal-600); cursor: pointer; padding: 4px;
}
.link-btn:hover { text-decoration: underline; }
.config-warning { background: #fff4e5; color: #7a4100; border-radius: 12px; padding: 12px 14px; font-size: 14px; margin-bottom: 18px; }

/* ---------- Pendiente ---------- */
.pending-card {
  background: #fff; border-radius: 24px; padding: 44px 40px; max-width: 520px; text-align: center;
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.pending-icon { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--peach); margin-bottom: 18px; }
.pending-icon svg { width: 30px; height: 30px; fill: none; stroke: #a24d06; stroke-width: 1.8; stroke-linecap: round; }
.pending-card h1 { font-size: 26px; }
.pending-mail { margin-top: 14px; font-weight: 700; color: var(--navy-800); }
.pending-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 24px; }

/* ---------- Panel ---------- */
.dash-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 26px; }
.dash-head h1 { font-size: clamp(28px, 3.2vw, 38px); }
.tabs { display: flex; gap: 6px; background: #fff; padding: 5px; border-radius: 999px; border: 1px solid var(--line); }
.tabs button {
  border: 0; background: transparent; font-family: inherit; font-weight: 700; font-size: 14px; color: var(--muted);
  padding: 10px 18px; border-radius: 999px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
}
.tabs button.is-active { background: var(--navy-800); color: #fff; }
.tab-badge { background: var(--orange); color: #fff; font-size: 11px; font-weight: 800; border-radius: 99px; padding: 1px 7px; }

.kpis {
  display: grid; grid-template-columns: repeat(4, auto) 1fr; margin-bottom: 14px;
  background: #fff; border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
}
.kpi { display: flex; align-items: baseline; gap: 10px; padding: 12px 22px; min-width: 0; }
.kpi + .kpi { border-left: 1px solid var(--line); }
.kpi span { order: 2; font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.kpi b { order: 1; font: 800 22px/1 var(--head); color: var(--navy); }
.kpi-accent b { font-size: 15px; color: var(--orange-600); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-accent { justify-content: flex-end; }
.kpi-accent span { order: 0; }

.insights { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px; }
.insight { background: #fff; border-radius: 18px; padding: 20px 22px; border: 1px solid var(--line); min-width: 0; }
.insight h2 { font-size: 17px; margin: 0; }
.insight > .muted { font-size: 13px; margin: 4px 0 14px; }
.insight-empty { color: var(--muted); font-size: 14px; padding: 6px 0; }
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.bar-head { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; margin-bottom: 6px; }
.bar-head span { font-weight: 600; overflow-wrap: anywhere; }
.bar { display: block; height: 8px; border-radius: 99px; background: rgba(226, 104, 12, .1); position: relative; overflow: hidden; }
.bar::after { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--p); border-radius: inherit; background: linear-gradient(90deg, var(--teal-600, #c2560a), var(--cyan, #ff9a3c)); }
.repeat { list-style: none; margin: 0; padding: 0; display: grid; }
.repeat li { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.repeat li + li { border-top: 1px solid var(--line); }
.repeat li div { flex: 1; min-width: 0; }
.repeat b { display: block; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.repeat small { font-size: 12.5px; color: var(--muted); }
.repeat em { font-style: normal; font-size: 12.5px; font-weight: 700; color: #a24d06; background: var(--peach, #ffe3cc); padding: 4px 10px; border-radius: 99px; white-space: nowrap; }
.avatar-sm { width: 36px; height: 36px; font-size: 12.5px; flex: none; }
@media (max-width: 760px) { .insights { grid-template-columns: 1fr; } .insight { padding: 16px 18px; } }

.filters {
  display: grid; grid-template-columns: minmax(180px, 2fr) repeat(2, minmax(148px, 1fr)) repeat(2, minmax(118px, 1fr)) auto;
  gap: 12px; align-items: end;
  background: #fff; border-radius: 18px; padding: 16px; border: 1px solid var(--line);
}
.filters label { display: grid; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.filters input, .filters select { padding: 10px 12px; font-size: 14px; }
.f-search { position: relative; }
.f-search svg { position: absolute; left: 13px; bottom: 12px; width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.f-search input { padding-left: 40px; }
.f-actions { display: flex; gap: 8px; }

.result-count { margin: 20px 2px 14px; font-size: 14px; color: var(--muted); font-weight: 600; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card {
  background: #fff; border-radius: 18px; overflow: hidden; border: 1px solid var(--line); cursor: pointer;
  display: flex; flex-direction: column; text-align: left; font-family: inherit; padding: 0; color: inherit;
  transition: transform .25s var(--ease), box-shadow .25s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.card-photo { position: relative; aspect-ratio: 4 / 3; background: #dfe7ea; overflow: hidden; }
.card-photo img { width: 100%; height: 100%; object-fit: cover; }
.no-photo { width: 100%; height: 100%; display: grid; place-items: center; color: #8a9aa3; font-size: 13px; font-weight: 600; }
.card-badge {
  position: absolute; left: 12px; top: 12px; font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  background: rgba(11, 23, 48, .82); color: #fff; padding: 5px 10px; border-radius: 99px;
}
.card-badge.warn { background: var(--orange); }
.card-body { padding: 16px 18px 18px; display: grid; gap: 6px; }
.card-body h3 { font-size: 16.5px; font-weight: 800; }
.card-meta { font-size: 13.5px; color: var(--muted); }
.card-date { font-size: 13px; font-weight: 700; color: var(--teal-600); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip-epp { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 99px; background: #fdecea; color: #b3261e; }
.chip-epp.mal { background: #fff1e3; color: #9a4a06; }

.empty { text-align: center; background: #fff; border-radius: 20px; padding: 50px 24px; border: 1px dashed var(--line); }
.empty svg { width: 44px; height: 44px; fill: none; stroke: var(--teal-600); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; margin-bottom: 10px; }
.empty h2 { font-size: 20px; }
.more { display: flex; justify-content: center; margin-top: 26px; }

/* ---------- Detalle ---------- */
.detail {
  width: min(980px, calc(100% - 28px)); max-height: calc(100vh - 40px); padding: 0; border: 0; border-radius: 24px;
  overflow: auto; box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .55);
}
.detail::backdrop { background: rgba(6, 15, 34, .7); backdrop-filter: blur(3px); }
.detail-close {
  position: absolute; right: 14px; top: 12px; z-index: 2; width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: rgba(255, 255, 255, .92); font-size: 24px; line-height: 1; cursor: pointer; color: var(--navy-900);
}
.detail-grid { display: grid; grid-template-columns: 1.2fr 1fr; }
.detail-photo { background: #0b1730; display: grid; place-items: center; min-height: 360px; }
.detail-photo img { width: 100%; height: 100%; object-fit: contain; max-height: 80vh; }
.detail-info { padding: 30px 28px; display: grid; gap: 16px; align-content: start; }
.detail-info h2 { font-size: 22px; padding-right: 40px; }
.detail-info dl { display: grid; gap: 12px; }
.detail-info dt { font-size: 11.5px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--teal-600); }
.detail-info dd { margin-top: 2px; font-size: 15px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 6px; border-top: 1px solid var(--line); }
.btn-danger { background: #fdecea; color: #b3261e; }
.btn-danger:hover { background: #fbd9d5; }

/* ---------- Usuarios ---------- */
#panelUsuarios { background: #fff; border-radius: 20px; padding: 24px; border: 1px solid var(--line); }
.users-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; margin-bottom: 18px; }
.users-head h2 { font-size: 22px; }
.role-legend { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.role-legend li { display: flex; align-items: center; gap: 8px; }
.users { border-top: 1px solid var(--line); }
.user {
  display: grid; grid-template-columns: auto 1fr auto 180px; align-items: center; gap: 16px;
  padding: 16px 4px; border-bottom: 1px solid var(--line);
}
.user.is-pending { background: linear-gradient(90deg, rgba(253, 227, 204, .45), transparent 60%); border-radius: 12px; }
.user-av {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; font-size: 14px; background: var(--mint); color: var(--teal-600);
}
.user-name { min-width: 0; }
.user-name b { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-name span { font-size: 13.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.user-since { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.role-select { padding: 9px 12px; font-size: 14px; font-weight: 600; cursor: pointer; }
.role-fixed { justify-self: start; }

/* ---------- Aviso flotante ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100;
  background: var(--navy-900); color: #fff; padding: 12px 20px; border-radius: 12px; font-size: 14px; font-weight: 600;
  box-shadow: 0 16px 40px -16px rgba(0, 0, 0, .6); max-width: calc(100% - 32px);
}
.toast.error { background: #b3261e; }

/* ---------- Responsivo ---------- */
@media (max-width: 1000px) {
  .filters { grid-template-columns: 1fr 1fr 1fr; }
  .f-search { grid-column: 1 / -1; }
  .f-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .kpi-accent { grid-column: 1 / -1; justify-content: flex-start; border-left: 0 !important; border-top: 1px solid var(--line); }
}
@media (max-width: 820px) {
  .auth-card { grid-template-columns: 1fr; }
  .auth-side { padding: 32px 28px; }
  .auth-side img { width: 76px; margin-bottom: 14px; }
  .auth-points { display: none; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-photo { min-height: 240px; }
  .user { grid-template-columns: auto 1fr; }
  .user-since { grid-column: 2; }
  .user .role-select, .user .role-fixed { grid-column: 1 / -1; }
  .back-link span { display: none; }
}
@media (max-width: 640px) {
  .view { padding: 28px 0 60px; }
  .auth, .view-center { padding: 20px 14px; }
  .auth-main { padding: 26px 20px 30px; }
  .auth-side h1 { font-size: 22px; }
  .user-session { gap: 10px; margin-right: 10px; }
  .user-who b { display: none; }
  #volverSitio { display: none; }
  .filters { grid-template-columns: 1fr 1fr; padding: 14px; }
  .f-actions { justify-content: stretch; }
  .f-actions .btn { flex: 1; justify-content: center; }
  .kpi { padding: 10px 14px; flex-direction: column; gap: 4px; }
  .kpi span { font-size: 12px; white-space: normal; }
  .kpi b { font-size: 20px; }
  .kpi-accent { flex-direction: row; align-items: baseline; }
  .cards { grid-template-columns: 1fr; }
  #panelUsuarios { padding: 16px; }
  .pending-card { padding: 32px 22px; }
  .detail { width: calc(100% - 16px); border-radius: 20px; }
  .detail-info { padding: 22px 18px; }
}

/* ---------- Correcciones de celular ---------- */
.filters > *, .filters label, .filters input, .filters select { min-width: 0; }
.filters input[type="date"] { -webkit-appearance: none; appearance: none; min-height: 42px; }
.user-session .btn { white-space: nowrap; }
@media (max-width: 640px) {
  .nav-row:has(#sesion:not([hidden])) .cobrand-x,
  .nav-row:has(#sesion:not([hidden])) .cobrand-umma { display: none; }
  .user-text { display: none; }
  .user-who { padding: 4px; }
  .user-session { margin-left: auto; margin-right: 0; }
  .f-actions .btn { padding-left: 10px; padding-right: 10px; }
  .tabs { width: 100%; }
  .tabs button { flex: 1; justify-content: center; }
}

/* ---------- Mi perfil · Crear usuario · Contraseña ---------- */
.modal {
  width: min(460px, calc(100% - 24px)); max-height: calc(100vh - 32px); overflow: auto;
  padding: 30px 28px 28px; border: 0; border-radius: 24px; box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .55);
}
.modal::backdrop { background: rgba(6, 15, 34, .7); backdrop-filter: blur(3px); }
.modal h2 { font-size: 22px; padding-right: 44px; margin: 0; }
.modal > .muted { font-size: 14px; margin: 6px 0 18px; }
.modal-mail { overflow-wrap: anywhere; }
.modal .auth-form { display: grid; gap: 14px; }
.modal .auth-form .btn-sm { justify-self: start; }
.modal-sep { margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--line); }
.modal-sep h3 { font-size: 16px; margin: 0; }
.modal .role-select { width: 100%; }
.users-new { margin-top: 14px; }
.user { grid-template-columns: auto 1fr auto 180px 120px; }
.user-key { justify-content: center; padding-left: 12px; padding-right: 12px; }
@media (max-width: 900px) {
  .user { grid-template-columns: auto 1fr; }
  .user .user-key { grid-column: 1 / -1; }
  .user-key-empty { display: none; }
}
@media (max-width: 640px) {
  #btnPerfil { padding-left: 12px; padding-right: 12px; }
  .modal { padding: 24px 18px 22px; }
}
@media (max-width: 640px) {
  .user-session .role-pill { display: none; }
  .avatar-edit { align-items: flex-start; }
}
.auth-side h1, .pending-card h1 { font-family: var(--head); }
.auth-side h1 { color: #fff; }
.auth-side .auth-umma { width: 190px; height: auto; margin: 22px 0 0; filter: none; opacity: .9; }
@media (max-width: 640px) {
  .nav-row:has(#sesion:not([hidden])) .logo span { display: none; }
  .auth-side .auth-umma { width: 150px; margin-top: 14px; }
}

/* ---------- Análisis plegable y compacto ---------- */
.insights-box { background: #fff; border: 1px solid var(--line); border-radius: 18px; margin-bottom: 18px; }
.insights-box summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 14px 20px;
  font-weight: 700; color: var(--navy); user-select: none;
}
.insights-box summary::-webkit-details-marker { display: none; }
.insights-box summary small { font-weight: 500; color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.insights-box summary::after {
  content: ""; margin-left: auto; flex: none; width: 9px; height: 9px; border-right: 2px solid var(--orange); border-bottom: 2px solid var(--orange);
  transform: rotate(45deg); transition: transform .2s;
}
.insights-box[open] summary::after { transform: rotate(-135deg); }
.insights-box .insights { margin: 0; padding: 0 20px 16px; gap: 28px; }
.insights-box .insight { border: 0; padding: 0; border-radius: 0; }
.insights-box .insight h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 10px; }
.insights-box .bars { gap: 8px; }
.insights-box .bar-head { font-size: 13.5px; margin-bottom: 4px; }
.insights-box .bar { height: 6px; }
.insights-box .repeat li { padding: 7px 0; }
.insights-box .avatar-sm { width: 30px; height: 30px; font-size: 11px; }
@media (max-width: 760px) { .insights-box .insights { gap: 18px; } .insights-box summary small { display: none; } }

/* ---------- Lista de incidencias ---------- */
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.list-head .result-count { margin: 0; }
.view-toggle { display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.view-toggle button {
  display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; cursor: pointer;
  font: 600 13px/1 var(--body); color: var(--muted); padding: 7px 12px; border-radius: 999px;
}
.view-toggle button.is-active { background: var(--navy); color: #fff; }
.view-toggle svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.card-state { display: none; }

.cards.is-list { display: block; background: #fff; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.cards.is-list .card {
  display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; align-items: center; gap: 14px; width: 100%;
  border: 0; border-radius: 0; box-shadow: none; padding: 10px 16px; transform: none; text-align: left;
}
.cards.is-list .card + .card { border-top: 1px solid var(--line); }
.cards.is-list .card:hover { background: var(--orange-50); transform: none; box-shadow: none; }
.cards.is-list .card-photo { width: 52px; height: 52px; aspect-ratio: auto; border-radius: 12px; }
.cards.is-list .card-photo .no-photo { font-size: 9px; }
.cards.is-list .card-badge { display: none; }
.cards.is-list .card-body {
  padding: 0; display: grid; grid-template-columns: minmax(140px, 1.1fr) minmax(0, 1.4fr) auto; align-items: center; gap: 4px 18px;
}
.cards.is-list .card-body h3 { grid-column: 1; grid-row: 1; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cards.is-list .card-meta { grid-column: 1; grid-row: 2; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cards.is-list .chips { grid-column: 2; grid-row: 1 / span 2; margin: 0; }
.cards.is-list .card-date { grid-column: 3; grid-row: 1 / span 2; font-size: 12.5px; white-space: nowrap; color: var(--muted); font-weight: 600; }
.cards.is-list .card-state {
  display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px; background: var(--navy); color: #fff; white-space: nowrap;
}
.cards.is-list .card-state.warn { background: var(--orange); }
@media (max-width: 860px) {
  .cards.is-list .card-body { grid-template-columns: minmax(0, 1fr); }
  .cards.is-list .chips, .cards.is-list .card-date { grid-column: 1; grid-row: auto; }
  .cards.is-list .card { align-items: start; }
}
@media (max-width: 520px) {
  .cards.is-list .card { grid-template-columns: 44px minmax(0, 1fr); padding: 12px; gap: 12px; }
  .cards.is-list .card-photo { width: 44px; height: 44px; }
  .cards.is-list .card-state { display: none; }
  .view-toggle button { padding: 7px 10px; }
}

/* ---------- Botón de tema en el panel ---------- */
.panel-body .theme-toggle { order: 2; margin-left: auto; }
.panel-body .user-session { order: 3; margin-left: 12px; }
.panel-body .back-link { order: 3; margin-left: 14px; }

/* ---------- Modo oscuro del panel ---------- */
html[data-theme="dark"] { --muted: #93a2b8; --cream: #0f1b2e; --peach: rgba(244, 123, 32, .18); --surface: #13213a; --surface-2: #0f1b2e; }
html[data-theme="dark"] .panel-body { background: var(--white); }
html[data-theme="dark"] .auth-card,
html[data-theme="dark"] .pending-card,
html[data-theme="dark"] .tabs,
html[data-theme="dark"] .kpis,
html[data-theme="dark"] .insight,
html[data-theme="dark"] .insights-box,
html[data-theme="dark"] .filters,
html[data-theme="dark"] .card,
html[data-theme="dark"] .cards.is-list,
html[data-theme="dark"] .empty,
html[data-theme="dark"] #panelUsuarios,
html[data-theme="dark"] .view-toggle,
html[data-theme="dark"] .user-who,
html[data-theme="dark"] .btn-line,
html[data-theme="dark"] .modal,
html[data-theme="dark"] .detail { background: var(--surface); color: var(--text); }
html[data-theme="dark"] .modal, html[data-theme="dark"] .detail { border: 1px solid var(--line); }
html[data-theme="dark"] .detail-info { background: var(--surface); }
html[data-theme="dark"] .segmented { background: var(--surface-2); }
html[data-theme="dark"] .segmented button { color: var(--muted); }
html[data-theme="dark"] .segmented button.is-active { background: var(--surface); color: var(--ink); }
html[data-theme="dark"] .auth-form input,
html[data-theme="dark"] .filters input,
html[data-theme="dark"] .filters select,
html[data-theme="dark"] .role-select { background: var(--surface-2); border-color: var(--line); color: var(--ink); }
html[data-theme="dark"] .auth-form input:focus,
html[data-theme="dark"] .filters input:focus,
html[data-theme="dark"] .filters select:focus,
html[data-theme="dark"] .role-select:focus { background: var(--surface-2); }
html[data-theme="dark"] .auth-form label, html[data-theme="dark"] .filters label span { color: var(--ink); }
html[data-theme="dark"] .user-who,
html[data-theme="dark"] .back-link,
html[data-theme="dark"] .btn-line,
html[data-theme="dark"] .kpi b,
html[data-theme="dark"] .insights-box summary,
html[data-theme="dark"] .card-body h3,
html[data-theme="dark"] .user-name b,
html[data-theme="dark"] .repeat b,
html[data-theme="dark"] .detail-info dd,
html[data-theme="dark"] .result-count { color: var(--ink); }
html[data-theme="dark"] .tabs button { color: var(--muted); }
html[data-theme="dark"] .tabs button.is-active,
html[data-theme="dark"] .view-toggle button.is-active { background: var(--orange); color: #fff; }
html[data-theme="dark"] .cards.is-list .card:hover { background: rgba(244, 123, 32, .08); }
html[data-theme="dark"] .card-photo, html[data-theme="dark"] .detail-photo { background: #0b1626; }
html[data-theme="dark"] .no-photo { color: #6c7d95; }
html[data-theme="dark"] .chip-epp { background: rgba(224, 69, 47, .18); color: #ff9b8c; }
html[data-theme="dark"] .chip-epp.mal { background: rgba(244, 123, 32, .18); color: #ffb36b; }
html[data-theme="dark"] .card-state, html[data-theme="dark"] .card-badge { background: #2a4170; }
html[data-theme="dark"] .card-state.warn, html[data-theme="dark"] .card-badge.warn { background: var(--orange); }
html[data-theme="dark"] .bar { background: rgba(255, 255, 255, .08); }
html[data-theme="dark"] .user.is-pending { background: linear-gradient(90deg, rgba(244, 123, 32, .14), transparent 60%); }
html[data-theme="dark"] .rol-admin { color: #ffb36b; }
html[data-theme="dark"] .rol-visor { color: #ffb36b; background: rgba(244, 123, 32, .1); }
html[data-theme="dark"] .rol-pendiente { background: rgba(255, 255, 255, .08); color: var(--muted); }
html[data-theme="dark"] .rol-propietario { background: var(--orange); }
html[data-theme="dark"] .repeat em, html[data-theme="dark"] .team-list em { color: #ffb36b; }
html[data-theme="dark"] .form-msg.error, html[data-theme="dark"] .btn-danger { background: rgba(224, 69, 47, .16); color: #ff9b8c; }
html[data-theme="dark"] .form-msg.ok { background: rgba(31, 164, 99, .16); color: #6fdca4; }
html[data-theme="dark"] .config-warning { background: rgba(244, 123, 32, .14); color: #ffcf9f; }
html[data-theme="dark"] .detail-close { background: rgba(255, 255, 255, .12); color: var(--ink); }
html[data-theme="dark"] .modal-sep { border-color: var(--line); }
html[data-theme="dark"] .avatar-big { border-color: var(--surface); }
html[data-theme="dark"] .toast { background: #f2f5fa; color: var(--navy-900); }
html[data-theme="dark"] .modal::backdrop, html[data-theme="dark"] .detail::backdrop { background: rgba(0, 0, 0, .7); }
.nav-row .logo, .nav-row .logo img { flex: none; }

/* ---------- Estado del equipo ---------- */
.chip-epp.falta { background: #fdecea; color: #b3261e; }
.chip-epp.mal { background: #fff1e3; color: #9a4a06; }
.chip-epp.ok { background: #e6f6ee; color: #146c43; }
.epp-detail { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; }
.epp-group { display: grid; gap: 6px; }
.epp-group dt { font-size: 11.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.epp-group.ok dt { color: #146c43; }
.epp-group.falta dt { color: #b3261e; }
.epp-group.mal dt { color: #9a4a06; }
.epp-group dd { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.epp-none { font-size: 13px; color: var(--muted); }
html[data-theme="dark"] .chip-epp.falta { background: rgba(224, 69, 47, .18); color: #ff9b8c; }
html[data-theme="dark"] .chip-epp.ok { background: rgba(31, 164, 99, .18); color: #6fdca4; }
html[data-theme="dark"] .epp-group.ok dt { color: #6fdca4; }
html[data-theme="dark"] .epp-group.falta dt { color: #ff9b8c; }
html[data-theme="dark"] .epp-group.mal dt { color: #ffb36b; }

/* ---------- Accesos aprobados ---------- */
.kpi-ok b { color: #1f9a5c; }
.card-badge.ok, .cards.is-list .card-state.ok { background: #1f9a5c; }
html[data-theme="dark"] .kpi-ok b { color: #6fdca4; }
html[data-theme="dark"] .card-badge.ok, html[data-theme="dark"] .card-state.ok { background: #1f9a5c; }
.filters { grid-template-columns: minmax(180px, 1.6fr) repeat(5, minmax(0, 1fr)) auto; }
@media (max-width: 1180px) { .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); } .filters .f-search { grid-column: 1 / -1; } .f-actions { grid-column: 1 / -1; } }
@media (max-width: 640px) { .filters { grid-template-columns: 1fr 1fr; } }

.chip-epp.chip-todo { background: #1f9a5c; color: #fff; font-weight: 800; }
html[data-theme="dark"] .chip-epp.chip-todo { background: #1f9a5c; color: #fff; }

/* ---------- Listado en tabla: una fila por registro ---------- */
.card-epp, .card-when, .list-cols { display: none; }
.list-table.is-list { background: #fff; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.list-table.is-list .cards.is-list { border: 0; border-radius: 0; }
.list-table.is-list .list-cols,
.cards.is-list .card {
  display: grid; align-items: center; column-gap: 14px;
  grid-template-columns: 40px minmax(150px, 1.6fr) repeat(4, 64px) 150px 116px;
}
.list-table.is-list .list-cols {
  padding: 10px 16px; background: var(--mist); border-bottom: 1px solid var(--line);
  font-size: 11.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.list-cols span:nth-child(n+3):nth-child(-n+6) { text-align: center; }
.cards.is-list .card { padding: 8px 16px; min-height: 0; }
.cards.is-list .card-photo { width: 40px; height: 40px; border-radius: 10px; }
.cards.is-list .card-body { display: block; padding: 0; min-width: 0; }
.cards.is-list .card-body .chips, .cards.is-list .card-date { display: none; }
.cards.is-list .card-body h3 { font-size: 14.5px; }
.cards.is-list .card-meta { font-size: 12.5px; margin: 0; }
.cards.is-list .card-epp { display: contents; }
.cards.is-list .card-when { display: block; font-size: 13px; color: var(--muted); white-space: nowrap; }
.cards.is-list .card-state { justify-self: start; }
.epp-cell { display: grid; place-items: center; }
.epp-cell i {
  font-style: normal; font-weight: 800; font-size: 14px; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
}
.epp-cell small { display: none; }
.epp-cell.ok i { background: #e6f6ee; color: #146c43; }
.epp-cell.falta i { background: #fdecea; color: #b3261e; }
.epp-cell.mal i { background: #fff1e3; color: #9a4a06; }
html[data-theme="dark"] .list-table.is-list { background: var(--surface); }
html[data-theme="dark"] .list-table.is-list .list-cols { background: var(--surface-2); }
html[data-theme="dark"] .epp-cell.ok i { background: rgba(31, 164, 99, .18); color: #6fdca4; }
html[data-theme="dark"] .epp-cell.falta i { background: rgba(224, 69, 47, .18); color: #ff9b8c; }
html[data-theme="dark"] .epp-cell.mal i { background: rgba(244, 123, 32, .18); color: #ffb36b; }

/* Celular: nombre arriba, los 4 equipos en fila con su nombre, fecha y resultado */
@media (max-width: 860px) {
  .list-table.is-list .list-cols { display: none; }
  .cards.is-list .card {
    grid-template-columns: 40px minmax(0, 1fr) auto; grid-template-areas: "foto nombre estado" "epp epp epp" "fecha fecha fecha";
    row-gap: 8px; padding: 12px;
  }
  .cards.is-list .card-photo { grid-area: foto; }
  .cards.is-list .card-body { grid-area: nombre; }
  .cards.is-list .card-state { grid-area: estado; display: inline-block !important; justify-self: end; }
  .cards.is-list .card-epp { display: grid; grid-area: epp; grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .cards.is-list .card-when { grid-area: fecha; font-size: 12px; }
  .epp-cell { display: flex; gap: 6px; justify-content: flex-start; }
  .epp-cell i { width: 22px; height: 22px; font-size: 12px; flex: none; }
  .epp-cell small { display: inline; font-size: 12px; color: var(--muted); }
}

/* ---------- Confirmación ---------- */
.modal.confirm { width: min(400px, calc(100% - 24px)); text-align: center; padding: 28px 26px 24px; }
.modal.confirm h2 { padding-right: 0; font-size: 20px; }
.modal.confirm > .muted { margin: 8px 0 22px; font-size: 14.5px; line-height: 1.5; }
.confirm-icon {
  width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 50%; display: grid; place-items: center;
  background: var(--orange-50); color: var(--orange-600);
}
.confirm-icon svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.modal.confirm.is-danger .confirm-icon { background: #fdecea; color: #c0392b; }
.confirm-actions { display: flex; gap: 10px; justify-content: center; }
.confirm-actions .btn { min-width: 120px; }
.btn-danger-solid { background: #dc2626; color: #fff; box-shadow: 0 12px 24px -14px rgba(220, 38, 38, .9); }
.btn-danger-solid:hover { background: #b91c1c; }
html[data-theme="dark"] .modal.confirm.is-danger .confirm-icon { background: rgba(224, 69, 47, .18); color: #ff9b8c; }
html[data-theme="dark"] .confirm-icon { background: rgba(244, 123, 32, .16); color: #ffb36b; }
