:root {
  /* Identidad Limitless by Largotek */
  --navy: #031c3e;
  --navy-2: #2b405b;
  --teal: #25d2c8;
  --cream: #fdf8ec;

  --bg: #f7f1e1;
  --surface: #fdf8ec;
  --text: #031c3e;
  --muted: #5a6577;
  --border: #e4dcc6;
  --accent: #0b7e77;          /* teal oscuro: legible sobre crema */
  --accent-bg: #25d2c8;       /* botones primarios */
  --accent-text: #031c3e;
  --good: #15803d;
  --bad: #b91c1c;
  --warn: #b45309;
  --chip: #efe7d2;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #031c3e;
    --surface: #0a2750;
    --text: #fdf8ec;
    --muted: #a3aec0;
    --border: #1d3a63;
    --accent: #25d2c8;
    --good: #4ade80;
    --bad: #f87171;
    --warn: #fbbf24;
    --chip: #14325c;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font: 15px/1.5 "Outfit", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
main { max-width: 1100px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.4rem; margin: 0 0 12px; }
h2 { font-size: 1.05rem; margin: 0 0 10px; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; background: var(--navy); color: var(--cream); border-bottom: 1px solid rgb(37 210 200 / .25);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 36px; height: 36px; }
.brand .name { font-weight: 600; font-size: 1.2rem; line-height: 1; }
.brand .by { display: block; font-size: .7rem; opacity: .75; font-weight: 400; margin-top: 2px; }
.who { display: flex; gap: 10px; align-items: center; color: #c9d1dd; font-size: .9rem; }
.topbar button.ghost { color: var(--cream); border-color: rgb(253 248 236 / .35); }
.hero { text-align: center; margin: 32px auto 0; }
.hero img { width: 96px; height: 96px; }
.hero .name { font-size: 2rem; font-weight: 600; line-height: 1.1; margin-top: 6px; }
.hero .by { color: var(--muted); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
}
.narrow { max-width: 420px; margin: 24px auto 40px; }
.center { text-align: center; padding: 60px 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.end { justify-content: flex-end; }
.grid { display: grid; gap: 12px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.stat .label { color: var(--muted); font-size: .8rem; }
.stat .value { font-size: 1.35rem; font-weight: 650; font-variant-numeric: tabular-nums; }
button {
  font: inherit; border-radius: 8px; border: 1px solid var(--border); padding: 7px 12px;
  background: var(--surface); color: var(--text); cursor: pointer;
}
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--accent-bg); color: var(--accent-text); border-color: var(--accent-bg); font-weight: 600; }
button.ghost { background: transparent; }
button.good { border-color: var(--good); color: var(--good); }
button.bad { border-color: var(--bad); color: var(--bad); }
button.link { border: 0; background: none; color: var(--accent); padding: 4px 0; }
button.wide { width: 100%; }
label { display: block; margin-bottom: 10px; font-size: .9rem; color: var(--muted); }
input, select {
  display: block; width: 100%; margin-top: 4px; padding: 8px 10px; font: inherit;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text);
}
select { width: auto; display: inline-block; margin: 0; }
.sep { display: flex; align-items: center; gap: 8px; color: var(--muted); margin: 14px 0; font-size: .85rem; }
.sep::before, .sep::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.msg { min-height: 1.2em; color: var(--bad); font-size: .9rem; }
.tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; white-space: nowrap; }
.tabs button.active { border-bottom-color: var(--accent); color: var(--accent); }
.count { background: var(--bad); color: #fff; border-radius: 999px; padding: 0 7px; font-size: .75rem; }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; }
.pos { color: var(--good); }
.neg { color: var(--bad); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; background: var(--chip); }
.badge.sim { background: var(--warn); color: #fff; margin-left: 6px; }
.badge.ok { background: color-mix(in srgb, var(--good) 20%, transparent); color: var(--good); }
.badge.err { background: color-mix(in srgb, var(--bad) 20%, transparent); color: var(--bad); }
.badge.wait { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.opp { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.opp .why { color: var(--muted); font-size: .9rem; margin: 6px 0; }
.opp .nums { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 4px 12px; font-size: .9rem; }
.toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: var(--cream); border: 1px solid var(--teal); padding: 10px 16px; border-radius: 8px; max-width: 90vw;
}
dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); max-width: 420px; }
dialog::backdrop { background: rgb(3 28 62 / .55); }
.opp .actions { margin-top: 8px; }
.who #whoName { max-width: 28ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv dd { overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- celulares */
@media (max-width: 640px) {
  body { font-size: 15px; }
  main { padding: 12px 12px calc(24px + env(safe-area-inset-bottom)); }
  .narrow { margin: 16px auto; }
  .hero { margin-top: 20px; }
  .hero img { width: 72px; height: 72px; }
  .hero .name { font-size: 1.7rem; }

  .topbar { padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top)); }
  .brand img { width: 30px; height: 30px; }
  .brand .name { font-size: 1.05rem; }
  .brand .by { display: none; }
  .who #whoName { display: none; }

  /* Toques cómodos y sin zoom automático en iOS */
  button { min-height: 42px; padding: 8px 14px; }
  button.link { min-height: 0; }
  input, select { font-size: 16px; min-height: 42px; }

  .card { padding: 14px 12px; border-radius: 10px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat .value { font-size: 1.1rem; overflow-wrap: anywhere; }

  .tabs { position: sticky; top: calc(58px + env(safe-area-inset-top)); z-index: 4; background: var(--bg);
          margin: -12px -12px 12px; padding: 0 8px; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { padding: 12px 10px; }

  /* Botones de acción a lo ancho */
  .actions { width: 100%; flex-wrap: nowrap; }
  .actions button { flex: 1; }
  .row.between > h2 { margin-bottom: 4px; }

  .kv { grid-template-columns: 1fr; gap: 0; }
  .kv dt { font-size: .8rem; margin-top: 8px; }

  .opp .nums { grid-template-columns: 1fr 1fr; font-size: .85rem; }

  /* Tablas como tarjetas: cada fila es un bloque con etiqueta y valor */
  .scroll { overflow-x: visible; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tr { border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px; margin-bottom: 10px; background: var(--surface); }
  .card tr { background: transparent; }
  td { display: flex; justify-content: space-between; align-items: center; gap: 12px;
       border: 0; border-bottom: 1px dashed var(--border); padding: 6px 0; white-space: normal; text-align: right; }
  td:last-child { border-bottom: 0; }
  td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; text-align: left; flex: 0 0 auto; }
  td[data-label=""]::before { content: none; }
  td[data-label=""] { justify-content: flex-end; }
  td .v { min-width: 0; overflow-wrap: anywhere; }
  td:has(.v:empty) { display: none; }
  td select { width: auto; }

  .toast { bottom: calc(16px + env(safe-area-inset-bottom)); width: calc(100vw - 32px); text-align: center; }
  dialog { width: calc(100vw - 32px); }
  dialog .row.end button { flex: 1; }
}
