/* TXF Inspecciones — mobile first */
:root {
  --navy: #1B2A6B;
  --navy-dark: #121A4A;
  --navy-soft: #E8ECF8;
  --red: #C8102E;
  --accent: #C8102E;
  --bg: #F3F5F9;
  --card: #ffffff;
  --text: #1C1C1C;
  --muted: #5C6578;
  --line: #D5DAE3;
  --ok: #1B7F4E;
  --ok-bg: #E6F6EE;
  --warn: #8A5A00;
  --warn-bg: #FFF4D6;
  --err: #9B1C1C;
  --err-bg: #FDECEC;
  --shadow: 0 8px 24px rgba(18, 26, 74, 0.08);
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-size: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }
a { color: var(--navy); }
.boot { padding: 4rem 1.5rem; text-align: center; color: var(--muted); }

/* Login */
.login {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: calc(24px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
  background: linear-gradient(180deg, var(--navy-dark) 0%, var(--navy) 55%, #2a3c8a 100%);
}
.login-card {
  background: var(--card);
  border-radius: 20px;
  padding: 28px 22px 24px;
  box-shadow: var(--shadow);
  max-width: 420px;
  width: 100%;
  margin: 0 auto;
}
.login-logo { width: 200px; height: auto; margin: 0 auto 8px; }
.login h1 { margin: 8px 0 4px; font-size: 1.25rem; color: var(--navy); text-align: center; }
.login .sub { margin: 0 0 22px; color: var(--muted); text-align: center; font-size: 0.95rem; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 6px; color: #333; }
.field input, .field textarea, .field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fff;
  color: var(--text);
  outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(27,42,107,.15); }
.field textarea { min-height: 120px; resize: vertical; line-height: 1.45; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; border: 0; border-radius: 12px; padding: 13px 16px;
  font-weight: 700; letter-spacing: .01em;
  min-height: 48px;
}
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:not([disabled]):active { background: var(--navy-dark); }
.btn-ghost { background: transparent; color: var(--navy); border: 1px solid var(--line); }
.btn-danger { background: var(--err-bg); color: var(--err); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { width: auto; flex: 1; }
.btn-sm { min-height: 40px; padding: 8px 12px; width: auto; font-size: 0.9rem; }

/* App chrome */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--navy);
  color: #fff;
  padding: calc(10px + var(--safe-top)) 14px 10px;
  display: flex; align-items: center; gap: 8px;
}
.topbar h1 { font-size: 1rem; margin: 0; font-weight: 700; flex: 1; }
.topbar .icon-btn {
  background: transparent; border: 0; color: #fff; padding: 8px; min-width: 40px; min-height: 40px;
  border-radius: 10px;
}
.topbar .icon-btn:active { background: rgba(255,255,255,.12); }
.wrap { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(118px + var(--safe-bottom)); }

.hello { margin: 4px 0 16px; }
.hello h2 { margin: 0 0 4px; font-size: 1.35rem; color: var(--navy); }
.hello p { margin: 0; color: var(--muted); }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}
.card h3 { margin: 0 0 10px; font-size: 1rem; color: var(--navy); }

.list { display: flex; flex-direction: column; gap: 10px; }
.report-item {
  display: block; background: var(--card); border-radius: 14px;
  padding: 14px 16px; box-shadow: var(--shadow); text-decoration: none; color: inherit;
  border: 1px solid transparent;
}
.report-item:active { border-color: var(--navy); }
.report-item .title { font-weight: 700; color: var(--navy); }
.report-item .meta { color: var(--muted); font-size: 0.88rem; margin-top: 4px; }

.badge {
  display: inline-block; font-size: 0.72rem; font-weight: 700;
  padding: 3px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em;
}
.badge-campo { background: var(--navy-soft); color: var(--navy); }
.badge-revision { background: var(--warn-bg); color: var(--warn); }
.badge-pdf { background: var(--ok-bg); color: var(--ok); }

.steps {
  display: flex; gap: 4px; padding: 10px 12px 0;
  background: var(--bg);
}
.step {
  flex: 1; text-align: center; font-size: 0.72rem; font-weight: 700;
  color: var(--muted); padding-bottom: 8px; border-bottom: 3px solid var(--line);
}
.step.on { color: var(--navy); border-bottom-color: var(--navy); }
.step.done { color: var(--ok); border-bottom-color: var(--ok); }

.table-edit { width: 100%; border-collapse: collapse; }
.table-edit th {
  text-align: left; font-size: 0.78rem; color: var(--navy);
  background: #D9E3F3; padding: 8px;
}
.table-edit td { padding: 6px 4px; vertical-align: top; border-bottom: 1px solid var(--line); }
.table-edit input {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 8px;
  background: #fff;
}
.row-del { background: none; border: 0; color: var(--err); font-size: 1.2rem; padding: 8px; }

.photo-slot { margin-bottom: 16px; }
.photo-preview {
  width: 100%; aspect-ratio: 4/3; object-fit: cover;
  border-radius: 12px; background: #e9edf4; border: 1px solid var(--line);
}
.photo-empty {
  width: 100%; aspect-ratio: 4/3; border-radius: 12px;
  border: 2px dashed var(--line); display: flex; align-items: center; justify-content: center;
  color: var(--muted); text-align: center; padding: 16px;
  background: #fafbfe;
}
.file-btn { position: relative; overflow: hidden; }
.file-btn input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 2rem;
}

.rec-wrap { text-align: center; padding: 8px 0 16px; }
.rec-btn {
  width: 92px; height: 92px; border-radius: 50%; border: 0;
  background: var(--red); color: #fff; font-weight: 800; font-size: 0.85rem;
  box-shadow: 0 8px 20px rgba(200,16,46,.35);
}
.rec-btn.on { animation: pulse 1.1s ease-in-out infinite; background: #8e0b20; }
@keyframes pulse { 50% { transform: scale(1.05); } }
.timer { font-variant-numeric: tabular-nums; font-size: 1.4rem; margin: 10px 0; color: var(--navy); }
audio { width: 100%; margin-top: 10px; }

.banner {
  border-radius: 12px; padding: 10px 12px; margin: 0 0 14px; font-size: 0.92rem;
}
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.ok { background: var(--ok-bg); color: var(--ok); }
.banner.err { background: var(--err-bg); color: var(--err); }
.banner.info { background: var(--navy-soft); color: var(--navy); }

.install-hint {
  margin-top: 18px; font-size: 0.85rem; color: #d9def0; text-align: center;
}

.sticky-actions {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  max-width: 720px; margin: 0 auto;
  background: var(--bg);
  border-top: 1px solid var(--line);
  padding: 12px 16px calc(14px + var(--safe-bottom));
  display: flex; gap: 10px;
}
.hint { color: var(--muted); font-size: 0.88rem; margin: 8px 0 14px; }
.pdf-frame {
  width: 100%; min-height: 70vh; border: 1px solid var(--line); border-radius: 12px; background: #fff;
}
.empty { color: var(--muted); text-align: center; padding: 24px 8px; }
.hidden { display: none !important; }
.sr-only { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0,0,0,0); }

@media (max-width: 620px) {
  .table-edit thead { display: none; }
  .table-edit, .table-edit tbody { display: block; width: 100%; }
  .table-edit tr {
    display: block;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 8px 8px 4px;
    margin: 0 0 10px;
    background: #fafbfe;
  }
  .table-edit td {
    display: block;
    width: 100%;
    border: 0;
    padding: 4px 0;
  }
  .table-edit td:last-child { text-align: right; width: auto; }
}
