@charset "UTF-8";
/* Seguimiento TB — hoja de estilos única.
   Enfoque mobile-first: lo que ves acá es el teléfono; los @media agrandan a tablet y escritorio. */

/* ------------------------------------------------------------------ tokens */

:root {
  --ink: #17292c;
  --muted: #5d6f73;
  --line: #dce7e5;
  --canvas: #f4f8f7;
  --surface: #ffffff;
  --teal: #087b73;
  --teal-dark: #05645e;
  --teal-deep: #103b3c;
  --pale: #e4f2f0;
  --amber: #a86500;
  --red: #b5322d;
  --green: #1c6d3f;
  --grey: #667377;
  --focus: #0b9c91;
  --radius: 12px;
  --tap: 44px;
  --shadow: 0 1px 2px rgba(16, 59, 60, .06), 0 6px 20px rgba(16, 59, 60, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8f1f0;
    --muted: #9bb0b3;
    --line: #26403f;
    --canvas: #0e1a1b;
    --surface: #152525;
    --teal: #2fa89c;
    --teal-dark: #47c0b3;
    --teal-deep: #0b1f20;
    --pale: #16302f;
    --amber: #e0a24a;
    --red: #ef7c76;
    --green: #63c88d;
    --grey: #90a3a6;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 1.5rem; letter-spacing: -.02em; margin: 0; }
h2 { font-size: 1.125rem; letter-spacing: -.01em; margin: 0; }
h3 { font-size: 1rem; margin: 0; }
p { margin: 0 0 .75rem; }
p:last-child { margin-bottom: 0; }
a { color: var(--teal); }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--teal); color: #fff; padding: 12px 18px; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

.eyebrow {
  color: var(--muted); font-size: .7rem; letter-spacing: .09em;
  margin: 0 0 .25rem; text-transform: uppercase; font-weight: 600;
}
.subtitle { color: var(--muted); font-size: .875rem; margin: .4rem 0 0; }
.muted { color: var(--muted); }
.helper { color: var(--muted); font-size: .875rem; }
.hint { color: var(--muted); font-size: .8rem; display: block; margin-top: .3rem; font-weight: 400; }
.empty { color: var(--muted); padding: 1.25rem 0; text-align: center; }

/* ------------------------------------------------------------------ marca */

.brand { display: flex; align-items: center; gap: .625rem; font-size: .95rem; line-height: 1.1; }
.brand strong { font-size: 1.35rem; }
.brand-mark {
  display: grid; place-items: center; flex: none;
  width: 30px; height: 30px; border-radius: 8px;
  background: #35bfae; color: #103b3c; font-size: 1.5rem; font-weight: 700;
}

/* --------------------------------------------------- barra superior móvil */

.appbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: .75rem;
  padding: .5rem max(.75rem, env(safe-area-inset-right)) .5rem max(.75rem, env(safe-area-inset-left));
  padding-top: max(.5rem, env(safe-area-inset-top));
  background: var(--teal-deep); color: #eaf6f4;
}
.appbar-brand { display: flex; align-items: center; gap: .5rem; font-size: .95rem; flex: 1; }
.appbar-brand .brand-mark { width: 26px; height: 26px; font-size: 1.25rem; }
.appbar-menu {
  display: grid; place-items: center;
  width: var(--tap); height: var(--tap); min-width: var(--tap);
  background: transparent; border: 0; border-radius: 10px; cursor: pointer; color: inherit;
}
.appbar-menu:hover { background: rgba(255, 255, 255, .1); }
.burger, .burger::before, .burger::after {
  display: block; width: 20px; height: 2px; background: currentColor; border-radius: 2px;
  transition: transform .18s ease, opacity .18s ease;
}
.burger { position: relative; }
.burger::before, .burger::after { content: ""; position: absolute; left: 0; }
.burger::before { top: -6px; }
.burger::after { top: 6px; }
[aria-expanded="true"] .burger { background: transparent; }
[aria-expanded="true"] .burger::before { transform: translateY(6px) rotate(45deg); }
[aria-expanded="true"] .burger::after { transform: translateY(-6px) rotate(-45deg); }
.appbar-logout .text-btn { color: #bfe3de; }

/* ------------------------------------------------------------- estructura */

.shell { position: relative; }

main {
  padding: 1rem max(1rem, env(safe-area-inset-right)) 3rem max(1rem, env(safe-area-inset-left));
  max-width: 1320px;
}

.scrim {
  position: fixed; inset: 0; z-index: 39;
  background: rgba(6, 24, 25, .5);
  backdrop-filter: blur(2px);
}

/* Cajón lateral: fuera de pantalla en móvil, fijo en escritorio. */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 40;
  width: min(82vw, 280px);
  display: flex; flex-direction: column; gap: 1.5rem;
  padding: 1.5rem 1rem calc(1.5rem + env(safe-area-inset-bottom));
  background: var(--teal-deep); color: #d9eeeb;
  transform: translateX(-101%);
  transition: transform .22s ease;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0, 0, 0, .4); }
.sidebar .brand { color: #fff; padding: 0 .5rem; }

.sidebar nav { display: grid; gap: .25rem; }
.nav-item {
  display: flex; align-items: center; min-height: var(--tap);
  padding: .625rem .75rem; border-radius: 9px;
  color: #c9dedc; text-decoration: none; font-size: .95rem;
}
.nav-item:hover { background: #1d5250; color: #fff; }
.nav-item.active { background: #24605e; color: #fff; font-weight: 600; }

.sidebar-foot { margin-top: auto; border-top: 1px solid #2c5b5b; padding-top: 1rem; }
.sidebar-user { font-size: .85rem; color: #d9eeeb; }
.sidebar-foot .text-btn { color: #7fd6c9; }   /* contraste suficiente sobre el verde oscuro */
.sidebar-foot .text-btn:hover { color: #fff; }
.sidebar-note { color: #a8c6c3; font-size: .75rem; line-height: 1.45; margin-top: .75rem; }

/* ----------------------------------------------------------- encabezados */

.page-head {
  display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between;
  gap: .75rem; margin-bottom: 1.25rem;
}
.head-actions { display: flex; flex-wrap: wrap; gap: .5rem; width: 100%; }
.head-actions > * { flex: 1 1 auto; }
.page-head > .primary-btn { width: 100%; }

/* --------------------------------------------------------------- botones */

.primary-btn, .secondary-btn, .danger-btn, .action-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap); padding: .625rem 1rem;
  border: 0; border-radius: 10px; cursor: pointer;
  font: inherit; font-size: .9rem; font-weight: 600; text-decoration: none;
  transition: background .15s ease;
}
.primary-btn { background: var(--teal); color: #fff; }
.primary-btn:hover { background: var(--teal-dark); }
.secondary-btn { background: var(--pale); color: var(--ink); }
.secondary-btn:hover { background: var(--line); }
.danger-btn { background: var(--red); color: #fff; }
.danger-btn:hover { filter: brightness(.92); }
.action-btn {
  background: var(--pale); color: var(--teal-dark);
  min-height: 38px; padding: .4rem .75rem; font-size: .8rem;
}
.action-btn:hover { background: var(--line); }
.action-btn.danger { background: transparent; color: var(--red); }
.action-btn.danger:hover { background: rgba(181, 50, 45, .12); }

.text-btn, .link-btn {
  display: inline-flex; align-items: center; min-height: var(--tap);
  background: transparent; border: 0; padding: 0;
  color: var(--teal); cursor: pointer;
  font: inherit; font-size: .875rem; font-weight: 600; text-decoration: none;
}
.link-btn:hover, .text-btn:hover { text-decoration: underline; }

/* --------------------------------------------------------------- avisos */

.flash {
  border-radius: 10px; padding: .75rem 1rem; margin-bottom: 1rem;
  font-size: .9rem; border-left: 4px solid var(--green); background: var(--surface);
  box-shadow: var(--shadow);
}
.flash.error { border-left-color: var(--red); }
.notice {
  background: var(--pale); border-radius: 10px; padding: .75rem 1rem;
  font-size: .875rem; color: var(--ink);
}
.auth-error, .field-error {
  color: var(--red); font-size: .825rem; font-weight: 600;
  display: block; margin-top: .35rem;
}

/* --------------------------------------------------------------- tarjetas */

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: .75rem; padding: 1rem 1rem .5rem;
}
.card-header form { margin: 0; }

/* --------------------------------------------------------------- métricas */

.grid-metrics { display: grid; gap: .75rem; grid-template-columns: repeat(2, 1fr); margin-bottom: 1.25rem; }
.metric {
  display: flex; flex-direction: column; gap: .15rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .875rem; text-decoration: none; color: inherit; box-shadow: var(--shadow);
}
a.metric:hover { border-color: var(--teal); }
.metric.alarm { border-left: 4px solid var(--red); }
.metric-label { color: var(--muted); font-size: .8rem; }
.metric-value { font-size: 1.9rem; font-weight: 700; letter-spacing: -.03em; }
.metric-detail { color: var(--muted); font-size: .72rem; line-height: 1.35; }

/* ---------------------------------------------------------------- listas */

.content-grid, .detail-grid { display: grid; gap: 1rem; }
.list { padding: 0 .5rem .5rem; }

.row {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem;
  border-top: 1px solid var(--line); padding: .75rem .5rem;
  text-decoration: none; color: inherit;
}
.list > .row:first-child { border-top: 0; }
a.row:hover { background: var(--pale); border-radius: 8px; }
.row-main { flex: 1 1 60%; min-width: 0; }
.row-main strong { display: block; font-size: .95rem; }
.row-main span { display: block; color: var(--muted); font-size: .8rem; }
.row-actions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.row-actions form { margin: 0; }

.alert-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.alert-dot.is-red { background: var(--red); }
.alert-dot.is-amber { background: var(--amber); }

/* --------------------------------------------------------------- píldoras */

.pill {
  display: inline-block; border-radius: 99px; padding: .28rem .6rem;
  font-size: .7rem; font-weight: 700; white-space: nowrap;
  background: #e7ebec; color: #3f4c4f;
}
.pill.green { background: #dff1e5; color: #14572f; }
.pill.yellow { background: #fdf0cf; color: #6d4c07; }
.pill.orange { background: #fbe3d2; color: #8a3d09; }
.pill.red { background: #fbdedc; color: #8d2723; }
.pill.grey { background: #e7ebec; color: #3f4c4f; }

@media (prefers-color-scheme: dark) {
  .pill { background: #24393a; color: #cfe0e0; }
  .pill.green { background: #17402a; color: #93dcae; }
  .pill.yellow { background: #423414; color: #f0d08a; }
  .pill.orange { background: #47280f; color: #f3b183; }
  .pill.red { background: #48211f; color: #f4a9a4; }
  .pill.grey { background: #24393a; color: #cfe0e0; }
}

.masked {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  letter-spacing: .12em; color: var(--muted);
}

/* ------------------------------------------------------- tabla → tarjetas */

.tabs { display: flex; gap: .5rem; margin-bottom: 1rem; overflow-x: auto; }
.tab {
  padding: .5rem .9rem; border-radius: 99px; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--muted); text-decoration: none; font-size: .875rem; font-weight: 600;
  min-height: 38px; display: inline-flex; align-items: center;
}
.tab.active { background: var(--teal); border-color: var(--teal); color: #fff; }

.search-form { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; align-items: center; }
.search {
  flex: 1 1 220px; min-height: var(--tap);
  border: 1px solid var(--line); border-radius: 10px; padding: .625rem .875rem;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 16px;
}

.table-card { overflow: hidden; }
.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.data-table small { display: block; color: var(--muted); font-size: .75rem; }
.case-link { font-weight: 600; color: var(--teal-dark); text-decoration: none; }
.case-link:hover { text-decoration: underline; }

/* En móvil cada fila se muestra como una tarjeta con etiquetas propias. */
@media (max-width: 767px) {
  .data-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .data-table tr { display: block; border-bottom: 1px solid var(--line); padding: .875rem 1rem; }
  .data-table tr:last-child { border-bottom: 0; }
  .data-table td { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .2rem 0; border: 0; }
  .data-table td::before {
    content: attr(data-label);
    color: var(--muted); font-size: .75rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .05em; flex: none;
  }
  .data-table td[data-label=""]::before, .data-table td:not([data-label])::before { content: none; }
  .data-table td[data-label="Persona"], .data-table td[data-label="Contacto"] { display: block; margin-bottom: .35rem; }
  .data-table td[data-label="Persona"]::before, .data-table td[data-label="Contacto"]::before { content: none; }
  .data-table td[data-label="Persona"] .case-link, .data-table td[data-label="Contacto"] strong { font-size: 1rem; }
  .data-table td.row-actions { justify-content: stretch; margin-top: .6rem; }
  .data-table td.row-actions .action-btn { flex: 1; }
  .data-table td.empty { display: block; text-align: center; }
}

/* ------------------------------------------------------------ formularios */

.form-card { padding: 1rem; }
.form-card.narrow { max-width: 560px; }
.danger-card { border-left: 4px solid var(--red); }

.form-grid { display: grid; gap: 1rem; }

label {
  display: block; font-size: .85rem; font-weight: 600; color: var(--ink);
}
input, select, textarea {
  display: block; width: 100%; margin-top: .35rem;
  min-height: var(--tap);
  padding: .625rem .75rem;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink);
  font: inherit;
  font-size: 16px;              /* evita el zoom automático de iOS al enfocar */
  font-weight: 400;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); }
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2.25rem;
}

.form-actions {
  display: flex; flex-wrap: wrap; gap: .625rem; margin-top: 1.25rem;
}
.form-actions .primary-btn, .form-actions .danger-btn { flex: 1 1 auto; }
.form-actions .secondary-btn { flex: 1 1 auto; }

/* --------------------------------------------------------------- detalle */

.detail-list { display: grid; gap: .75rem; margin: 0; padding: 0 1rem 1rem; }
.detail-list > div { display: grid; gap: .1rem; }
.detail-list dt { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.detail-list dd { margin: 0; font-size: .95rem; }

.timeline { display: grid; gap: .25rem; padding: 0 1rem 1rem; }
.timeline-item { border-top: 1px solid var(--line); padding: .875rem 0; }
.timeline-item:first-child { border-top: 0; }
.timeline-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .35rem; }
.timeline-head span { font-size: .85rem; }

/* ------------------------------------------------------------ exportación */

.export-grid { display: grid; gap: 1rem; }
.export-card { padding: 1.25rem; }
.export-card h2 { margin-bottom: .5rem; }
.export-card form { margin-top: 1rem; }
.export-card.safe { border-left: 4px solid var(--green); }
code {
  background: var(--pale); border-radius: 4px; padding: .1rem .35rem;
  font-family: ui-monospace, Menlo, monospace; font-size: .85em;
}

/* ---------------------------------------------------------------- acceso */

.auth-body {
  display: grid; place-items: center; min-height: 100vh; min-height: 100dvh;
  padding: 1.25rem; background: linear-gradient(150deg, #103b3c, #1d6260);
}
.auth-card {
  width: min(100%, 420px);
  background: var(--surface); border-radius: 16px;
  padding: 1.75rem 1.5rem calc(1.75rem + env(safe-area-inset-bottom));
  box-shadow: 0 20px 60px rgba(8, 43, 43, .45);
}
.auth-brand { padding-bottom: 1.5rem; }
.auth-copy { color: var(--muted); font-size: .9rem; margin: .5rem 0 1.25rem; }
.auth-card form { display: grid; gap: 1rem; }
.auth-card .primary-btn { width: 100%; margin-top: .25rem; }
.auth-card .helper { margin-top: 1.25rem; font-size: .8rem; }

/* ============================== tablet ============================== */

@media (min-width: 600px) {
  .grid-metrics { grid-template-columns: repeat(4, 1fr); }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .wide { grid-column: 1 / -1; }
  .form-actions { justify-content: flex-end; }
  .form-actions .primary-btn, .form-actions .secondary-btn, .form-actions .danger-btn { flex: 0 0 auto; }
  .detail-list { grid-template-columns: 1fr 1fr; }
  .detail-list .wide { grid-column: 1 / -1; }
  .head-actions { width: auto; }
  .head-actions > * { flex: 0 0 auto; }
  .page-head > .primary-btn { width: auto; }
  main { padding: 1.5rem 2rem 4rem; }
}

/* ============================= escritorio ============================= */

@media (min-width: 900px) {
  .appbar { display: none; }
  .scrim { display: none !important; }

  .shell { display: grid; grid-template-columns: 244px minmax(0, 1fr); }

  .sidebar {
    position: sticky; top: 0; height: 100vh;
    width: auto; transform: none; box-shadow: none;
    padding: 1.75rem .875rem;
  }

  main { padding: 2rem 2.5rem 4rem; }

  h1 { font-size: 1.75rem; }
  .content-grid { grid-template-columns: 1.35fr .9fr; }
  .detail-grid { grid-template-columns: 1.25fr .9fr; }
  .detail-grid .wide { grid-column: 1 / -1; }

  .data-table thead th {
    text-align: left; padding: .875rem 1rem;
    font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); border-bottom: 1px solid var(--line);
  }
  .data-table td { padding: .875rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
  .data-table tbody tr:last-child td { border-bottom: 0; }
  .data-table tbody tr:hover { background: var(--pale); }
  .row-actions { justify-content: flex-end; }
}

@media (min-width: 1200px) {
  .export-grid { grid-template-columns: 1fr 1fr; }
}

/* --------------------------------------------------------- preferencias */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

@media print {
  .appbar, .sidebar, .scrim, .form-actions, .row-actions, .head-actions { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #ccc; }
}

/* --------------------------------------------------------------- marca --- */

img.brand-mark { border-radius: 8px; background: none; display: block; }
.brand small { display: block; color: #a8c6c3; font-size: .7rem; font-weight: 400; letter-spacing: .02em; margin-top: .15rem; }
.auth-logo { display: block; width: min(260px, 78%); height: auto; margin: 0 0 1.5rem; }

/* Credito del desarrollador. Discreto: no debe competir con el contenido. */
.site-foot {
  text-align: center; font-size: .75rem; color: var(--muted);
  padding: 1.25rem 1rem calc(1.25rem + env(safe-area-inset-bottom));
}
.site-foot a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.site-foot a:hover { color: var(--teal); }
/* Sobre el degradado oscuro de las pantallas de acceso. */
.auth-body > .site-foot { color: #a8c6c3; padding-top: 1rem; }
.auth-body > .site-foot a:hover { color: #ffffff; }
