/* Segtronic Reportes — mobile-first.
   Base = celular (una columna, targets grandes); desde 760px se comporta como
   escritorio (tabla real, barra de acciones dentro del formulario). */

:root {
  --brand: #15558c;          /* azul Segtronic */
  --brand-dark: #0f3f6b;
  --accent: #e8442c;         /* rojo del logo */
  --ink: #16222c;
  --muted: #64748b;
  --line: #dfe5ea;
  --bg: #f2f5f8;
  --card: #ffffff;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --ok: #067647;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  padding: 0 0 104px;              /* espacio para la barra inferior fija */
  font-family: "Segoe UI", Roboto, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;                 /* 16px evita el zoom automático en iOS */
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

a { color: var(--brand); }
.muted { color: var(--muted); font-size: 13px; }

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: #fff; border-bottom: 1px solid var(--line);
}
.topbar .logo { height: 38px; width: auto; display: block; }
.topbar .brand {
  font-weight: 700; font-size: 15px; letter-spacing: .2px;
  border-left: 1px solid var(--line); padding-left: 10px;
}
.topbar .spacer { flex: 1; }
.topbar form { margin: 0; }
.user-email { color: var(--muted); font-size: 12px; max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.link { background: none; border: 0; padding: 0; color: var(--brand); cursor: pointer; font-size: 14px; text-decoration: underline; }
.btn-ghost {
  border: 1px solid var(--line); background: #fff; border-radius: 10px;
  padding: 10px 12px; font-size: 14px; cursor: pointer; color: var(--ink);
}

/* ------------------------------------------------------------- estructura */
.wrap { padding: 14px; display: flex; flex-direction: column; gap: 14px; max-width: 1100px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 15px; }
.card h2 { margin: 0 0 4px; font-size: 16px; }
.card-head { display: flex; align-items: baseline; gap: 8px; justify-content: space-between; margin-bottom: 10px; }
.step { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 12px; font-weight: 700; margin-right: 8px; }

/* --------------------------------------------------------------- búsqueda */
.search { display: flex; gap: 8px; }
.search input[type="search"] {
  flex: 1; min-width: 0; padding: 12px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
button.primary, .button-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px 16px; border: 0; border-radius: 12px;
  background: var(--brand); color: #fff; font-size: 16px; font-weight: 600;
  cursor: pointer; text-decoration: none;
}
button.primary:hover, .button-primary:hover { background: var(--brand-dark); }
.search .btn-ghost { flex: 0 0 auto; }

/* -------------------------------------------------------------- vehículos */
.devices { width: 100%; border-collapse: collapse; }
.devices thead { display: none; }               /* móvil: tarjetas, sin encabezado */
.devices tr {
  display: grid; grid-template-columns: 34px 1fr; gap: 2px 10px;
  align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--line);
}
.devices tr:last-child { border-bottom: 0; }
.devices td { padding: 0; border: 0; min-width: 0; }
.devices td.c-check { grid-row: span 2; display: flex; align-items: flex-start; justify-content: center; }
.devices td.c-check input { width: 22px; height: 22px; margin: 2px 0 0; }
.devices td.c-plate { font-weight: 700; font-size: 16px; }
.devices td.c-info { grid-column: 2; display: flex; flex-direction: column; gap: 1px; }
.devices td.c-info .info-owner { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.devices td.c-info .info-meta { font-size: 12px; color: #8a99a8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* las columnas de escritorio no se muestran en el celular */
.devices td.c-owner, .devices td.c-model, .devices td.c-name { display: none; }
.devices tr.selected { background: #eef6ff; }
.devices tr.selected td.c-plate { color: var(--brand-dark); }
.devices .empty { color: var(--muted); font-size: 14px; }

.list-scroll { max-height: 58vh; overflow: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 12px; }
.list-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; background: #f8fafc; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.list-head label { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.list-head input[type="checkbox"] { width: 20px; height: 20px; }
.badge-count { margin-left: auto; font-size: 13px; color: var(--brand-dark); font-weight: 600; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #eef2f6; color: var(--muted); font-size: 12px; }
.chip.ok { background: #e7f6ee; color: var(--ok); }
.chip.err { background: var(--danger-bg); color: var(--danger); }

/* -------------------------------------------------------------- formulario */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 13px; color: var(--muted); }
input[type="date"], input[type="time"], select {
  width: 100%; padding: 12px; font-size: 16px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.segmented { display: grid; gap: 8px; }
.segmented label {
  display: flex; align-items: center; gap: 10px; padding: 12px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer;
}
.segmented input { width: 20px; height: 20px; }
.segmented input:checked + span { font-weight: 600; color: var(--brand-dark); }

/* --------------------------------------------------------- barra inferior */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
  background: rgba(255, 255, 255, .97); border-top: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.actionbar .hint { display: block; text-align: center; font-size: 12px; color: var(--muted); margin-bottom: 6px; }

/* ------------------------------------------------------------------ avisos */
.alert { background: var(--danger-bg); border: 1px solid #fda29b; color: var(--danger); border-radius: 12px; padding: 12px; margin-bottom: 12px; font-size: 14px; }
.alert ul { margin: 6px 0 0 18px; }
.notice { background: #eef6ff; border: 1px solid #b6d4fe; color: var(--brand-dark); border-radius: 12px; padding: 12px; font-size: 14px; }

/* --------------------------------------------------------------- progreso */
.progress { height: 14px; border-radius: 999px; background: #e6edf1; overflow: hidden; margin: 14px 0 8px; }
.progress .bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--brand), #38bdf8); transition: width .5s ease; }
.files { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.file {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff;
  text-decoration: none; color: var(--ink);
}
.file .icon { font-size: 20px; }
.file .name { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file .dl { font-size: 13px; color: var(--brand); font-weight: 600; }
.file:hover { border-color: var(--brand); }

/* ----------------------------------------------------------------- recents */
.recent { display: flex; flex-direction: column; gap: 8px; }
.recent a { display: flex; gap: 10px; align-items: center; text-decoration: none; color: var(--ink); padding: 10px; border: 1px solid var(--line); border-radius: 10px; font-size: 13px; }
.recent a:hover { border-color: var(--brand); }
.recent .when { color: var(--muted); font-size: 12px; margin-left: auto; }

/* ------------------------------------------------------------------ footer */
.footer { text-align: center; font-size: 12px; color: var(--muted); padding: 18px 14px 8px; }
.footer a { color: var(--muted); text-decoration: underline; }

/* ------------------------------------------------------------------- login */
.login-body { display: flex; flex-direction: column; min-height: 100vh; padding: 0; }
.login-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 20px 16px; }
.login-card { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 24px; }
.login-card .logo { display: block; height: 92px; width: auto; margin: 0 auto 6px; }
.login-card h1 { font-size: 18px; text-align: center; margin: 0 0 2px; }
.login-card p.sub { text-align: center; color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.login-card .field { margin-bottom: 14px; }
.login-card input { width: 100%; padding: 13px 12px; font-size: 16px; border: 1px solid var(--line); border-radius: 10px; }

/* ---------------------------------------------------------------- escritorio */
@media (min-width: 760px) {
  body { padding-bottom: 40px; }
  .wrap { padding: 22px; gap: 18px; }
  .actionbar { position: static; padding: 0; background: none; border: 0; margin-top: 14px; backdrop-filter: none; }
  .actionbar .hint { display: none; }
  button.primary, .button-primary { width: auto; padding: 12px 22px; }
  .segmented { grid-template-columns: 1fr 1fr; }
  .list-scroll { max-height: 46vh; }

  .devices { display: table; }
  .devices thead { display: table-header-group; }
  .devices thead th {
    position: sticky; top: 0; background: #f6f9fb; text-align: left;
    padding: 10px 12px; font-size: 12px; text-transform: uppercase;
    letter-spacing: .4px; color: var(--muted); border-bottom: 1px solid var(--line);
  }
  .devices tr { display: table-row; }
  .devices tbody tr:nth-child(even) { background: #fbfdfe; }
  .devices tr:hover { background: #f4f9ff; }
  .devices td { display: table-cell; padding: 9px 12px; border-bottom: 1px solid #eef2f5; vertical-align: middle; }
  .devices td.c-info { display: none; }
  .devices td.c-owner, .devices td.c-model, .devices td.c-name { display: table-cell; font-size: 14px; color: var(--ink); white-space: normal; }
  .devices td.c-plate { font-weight: 600; font-size: 14px; }
  .devices td.c-check input { width: 18px; height: 18px; margin: 0; }
  .files { flex-direction: row; flex-wrap: wrap; }
  .file { flex: 0 1 320px; }
  .recent { flex-direction: row; flex-wrap: wrap; }
  .recent a { flex: 0 1 320px; }
}
