/* Portal empresas: menú lateral, módulos y tarjetas de analítica */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(120deg, var(--navy) 0%, var(--blue) 70%, #0B6E8A 100%); }
.login-card { width: min(420px, 100%); padding: 2rem; box-shadow: 0 30px 60px rgba(0,0,0,.25); }
.login-logo { width: 64px; height: 64px; background: #fff; border-radius: 16px; padding: 6px; margin-bottom: 1rem; }
.login-card h1 { font-size: 1.7rem; }
.login-sub { color: var(--muted); margin: .3rem 0 1.4rem; font-size: .95rem; }
.login-card .back { display: block; text-align: center; margin-top: 1.2rem; color: var(--muted); font-size: .9rem; }
.note { font-size: .85rem; color: var(--muted); margin: .6rem 0 0; }
.note.err { color: var(--danger); }
.sub { color: var(--muted); margin: .2rem 0 0; }

/* Estructura */
.app { display: grid; grid-template-columns: 260px minmax(0, 1fr); grid-template-rows: auto; align-content: start; min-height: 100vh; }
.mobile-bar { display: none; }
.side { background: linear-gradient(180deg, var(--navy), var(--blue)); color: #fff; padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 1rem; border-right: 3px solid var(--cyan); }
.side-brand { display: flex; gap: .7rem; align-items: center; padding: 0 8px 14px; border-bottom: 1px solid rgba(255,255,255,.14); }
.side-brand img { background: #fff; border-radius: 10px; padding: 3px; width: 40px; height: 40px; }
.side-brand b { display: block; font-family: 'Helvetica Neue', Arial, sans-serif; font-size: 1.05rem; }
.side-brand small { color: #B8CCE0; font-size: .8rem; }
.menu-side { display: grid; gap: .25rem; }
.menu-side .sec { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: #8FB0CC; margin: .9rem 8px .3rem; }
.menu-side a { color: #DCEAF5; text-decoration: none; padding: .65rem .8rem; border-radius: 12px; font-weight: 500; display: flex; align-items: center; gap: .5rem; }
.menu-side a:hover { background: rgba(255,255,255,.09); color: #fff; }
.menu-side a[aria-current="page"] { background: var(--cyan); color: var(--navy); font-weight: 700; }
.badge { margin-left: auto; background: var(--sun); color: var(--navy); border-radius: 999px; padding: 0 .5rem; font-size: .75rem; font-weight: 700; }
.side-out { margin-top: auto; background: transparent; color: #fff; border-color: rgba(255,255,255,.3); }
.content { padding: 28px clamp(16px, 3vw, 36px) 60px; min-width: 0; }
.mod { display: block; }
.mod[hidden] { display: none; }
.mod-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.mod-head h2 { font-size: clamp(1.7rem, 3vw, 2.2rem); }

/* Analítica */
.range { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.range button { border: 0; background: transparent; color: var(--muted); font: 600 .88rem 'Helvetica Neue', Arial, sans-serif; padding: .5rem .85rem; border-radius: 9px; cursor: pointer; }
.range button.on, .range button[aria-pressed="true"] { background: var(--navy); color: #fff; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .9rem; margin-bottom: 1rem; }
.kpi { padding: 1.1rem 1.2rem; border-radius: 14px; box-shadow: 0 8px 22px rgba(26,58,92,.06); background: var(--card); border: 1px solid var(--line); position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--c, var(--cyan)); }
.kpi small { color: var(--muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.kpi b { display: block; font-family: 'Helvetica Neue', Arial, sans-serif; font-weight: 700; color: var(--navy); font-size: 2.1rem; line-height: 1.1; margin-top: .3rem; }
.kpi .hint { font-size: .8rem; color: var(--muted); }
.panel { padding: 1.2rem 1.3rem; margin-bottom: 1rem; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .8rem; }
.panel-head small { color: var(--muted); }
.chart-box { position: relative; height: 280px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 900px) { .two { grid-template-columns: 1fr; } }
.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.rank li { display: grid; grid-template-columns: 1fr auto; gap: .4rem .8rem; align-items: center; font-size: .92rem; }
.rank .bar { grid-column: 1 / -1; height: 8px; background: var(--mint); border-radius: 999px; overflow: hidden; }
.rank .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan), var(--blue)); border-radius: 999px; }
.rank .n { font-weight: 700; color: var(--navy); }
.rank .empty { color: var(--muted); }

/* Tablas y listas */
.table-wrap { overflow-x: auto; border-radius: 18px; }
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: .8rem .9rem; border-bottom: 1px solid var(--line); font-size: .92rem; vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--bg); }
td .sm { color: var(--muted); font-size: .84rem; }
.actions { display: flex; gap: .35rem; flex-wrap: wrap; }
.chips { display: flex; gap: .45rem; flex-wrap: wrap; margin-bottom: 1rem; }
.chips button { border: 1.5px solid var(--line); background: var(--card); color: var(--text); border-radius: 999px; padding: .4rem .85rem; font: 600 .85rem 'Helvetica Neue', Arial, sans-serif; cursor: pointer; }
.chips button[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.chips .n { opacity: .75; margin-left: .25rem; }
.msg-cell { max-width: 420px; white-space: pre-wrap; }
.empty-box { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }

/* Política de datos */
.policy-editor { min-height: 420px; font-family: ui-monospace, Consolas, monospace; font-size: .88rem; line-height: 1.55; }
.policy-preview { background: #fff; color: #1A3A5C; border-radius: 14px; padding: 1.2rem 1.4rem; max-height: 520px; overflow: auto; line-height: 1.6; }
.policy-preview h2 { font-family: 'Helvetica Neue', Arial, sans-serif; font-size: 1.3rem; margin: 0 0 .6rem; }
.policy-preview h3 { font-family: 'Helvetica Neue', Arial, sans-serif; font-size: 1.1rem; margin: 1.2rem 0 .3rem; }
.policy-preview p { margin: .35rem 0; color: #2A3B4C; }
.policy-preview ul { margin: .3rem 0 .6rem 1.2rem; color: #2A3B4C; }
td.trace { min-width: 220px; line-height: 1.5; }

/* Empresas afiliadas */
.logo-prev { width: 72px; height: 56px; border-radius: 12px; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; }
.logo-prev img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-prev span { font-family: 'Helvetica Neue', Arial, sans-serif; font-weight: 700; color: var(--navy); }
#companyList input[type="file"] { font: inherit; font-size: .85rem; max-width: 220px; }

/* Códigos QR por empresa */
.inline { display: flex; gap: .5rem; } .inline .input { flex: 1; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }
.qr-layout { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 1rem; align-items: start; }
.qr-controls .field { margin-bottom: 1rem; }
.code-pill { font-family: ui-monospace, Consolas, monospace; background: var(--mint); color: var(--text); border-radius: 12px; padding: .65rem .9rem; font-weight: 700; letter-spacing: .08em; word-break: break-all; }
.code-pill.small { font-size: .82rem; font-weight: 500; letter-spacing: 0; }
.qr-preview-wrap { display: grid; place-items: center; background: #fff; }
#qrPoster { width: 100%; max-width: 480px; height: auto; border: 1px solid var(--line); border-radius: 12px; }
@media (max-width: 860px) { .qr-layout { grid-template-columns: 1fr; } }

/* Herramientas */
.qr-box { display: grid; place-items: center; background: #fff; border-radius: 14px; padding: 16px; min-height: 230px; border: 1px solid var(--line); }
.code { background: var(--navy); color: #DCEAF5; border-radius: 14px; padding: 14px; font-size: .8rem; overflow: auto; white-space: pre-wrap; word-break: break-all; }

/* Modal de vehículos usa el estilo de app.css */
.asu-only[hidden] { display: none !important; }

/* Móvil: el menú pasa arriba y se desplaza en horizontal */
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { min-width: 0; align-self: start; height: auto; min-height: 0; }
  .side .menu-side { min-width: 0; }
  .mobile-bar { display: flex; justify-content: space-between; align-items: center; height: 60px; position: sticky; top: 0; padding: 0 16px; }
  .side { position: static; height: auto; border-right: 0; border-bottom: 3px solid var(--cyan); padding: 10px 12px; gap: .5rem; }
  .side-brand { display: none; }
  .menu-side { display: flex; overflow-x: auto; gap: .3rem; padding-bottom: 4px; }
  .menu-side .sec { display: none; }
  .menu-side a { white-space: nowrap; padding: .5rem .7rem; font-size: .92rem; }
  .side-out { display: none; }
  .content { padding: 20px 16px 48px; }
  .mod-head .range { width: 100%; }
  .mod-head .range button { flex: 1; }
  .chart-box { height: 230px; }
}

.form-sec { margin: 1.1rem 0 .4rem; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--navy); }
.modal-wide { max-width: 760px; width: 100%; }
