:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #16181d;
  --muted: #5d6470;
  --border: #dde1e7;
  --primary: #1f5eff;
  --primary-ink: #ffffff;
  --primary-soft: #e6edff;
  --danger: #c62828;
  --danger-soft: #fdecec;
  --ok: #1b7f4a;
  --ok-soft: #e4f5ec;
  --warn: #a15c00;
  --warn-soft: #fff3e0;
  --info: #3b4bb8;
  --info-soft: #eceefe;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #1f232b;
    --text: #e8eaee;
    --muted: #9aa2ae;
    --border: #2b303a;
    --primary: #5b8cff;
    --primary-ink: #0b1020;
    --primary-soft: #1b2645;
    --danger: #ff6b6b;
    --danger-soft: #3a1c1c;
    --ok: #4cc38a;
    --ok-soft: #15301f;
    --warn: #f0a94b;
    --warn-soft: #3a2a12;
    --info: #9aa6ff;
    --info-soft: #1f2347;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 0.75rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
[hidden] { display: none !important; }

/* Layout */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.75rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; display: flex; align-items: center; gap: 0.5rem; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.topbar .user { display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; }
.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.narrow { max-width: 440px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; box-shadow: var(--shadow);
}
.stack > * + * { margin-top: 1rem; }
.row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }

/* Forms */
label { display: block; font-weight: 600; font-size: 0.88rem; margin-bottom: 0.3rem; }
.field { margin-bottom: 0.9rem; }
.hint { font-size: 0.8rem; color: var(--muted); margin-top: 0.25rem; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 0.55rem 0.7rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: transparent; }
textarea { min-height: 90px; resize: vertical; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  font: inherit; font-weight: 600; border-radius: 8px; padding: 0.55rem 1rem; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.small { padding: 0.3rem 0.65rem; font-size: 0.85rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Image picker */
.picker {
  border: 2px dashed var(--border); border-radius: 10px; padding: 0.75rem; text-align: center;
  cursor: pointer; background: var(--surface-2); position: relative; min-height: 120px;
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 0.35rem;
}
.picker:hover, .picker:focus-within { border-color: var(--primary); }
.picker input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.picker img { max-height: 140px; border-radius: 6px; object-fit: contain; }
.picker .ph { color: var(--muted); font-size: 0.85rem; }

/* Tabs */
.tabs { display: flex; gap: 0.25rem; background: var(--surface-2); padding: 0.25rem; border-radius: 10px; margin-bottom: 1rem; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 0.5rem; border-radius: 8px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* Badges & alerts */
.badge { display: inline-block; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.78rem; font-weight: 700; }
.badge.borrador { background: var(--surface-2); color: var(--muted); }
.badge.enviado { background: var(--info-soft); color: var(--info); }
.badge.observado { background: var(--warn-soft); color: var(--warn); }
.badge.aprobado { background: var(--ok-soft); color: var(--ok); }
.badge.rechazado { background: var(--danger-soft); color: var(--danger); }
.alert { border-radius: 10px; padding: 0.8rem 1rem; border: 1px solid transparent; }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.info { background: var(--info-soft); color: var(--info); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.error { background: var(--danger-soft); color: var(--danger); }
.form-error { color: var(--danger); font-size: 0.88rem; margin: 0.25rem 0 0.75rem; min-height: 1.2em; }

/* Team header */
.team-head { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.logo { width: 84px; height: 84px; border-radius: 14px; object-fit: cover; background: var(--surface-2); border: 1px solid var(--border); }
.logo.sm { width: 40px; height: 40px; border-radius: 8px; }
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); }

/* Participant card */
.pcard { display: flex; flex-direction: column; gap: 0.6rem; }
.pcard .docs { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.pcard .docs img, .thumb { width: 100%; aspect-ratio: 1.58; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); cursor: zoom-in; background: var(--surface-2); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 0.1rem 0.75rem; font-size: 0.88rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); border: 2px dashed var(--border); border-radius: var(--radius); }

/* Stats */
.stat { padding: 1rem; }
.stat .n { font-size: 1.6rem; font-weight: 800; }
.stat .l { color: var(--muted); font-size: 0.85rem; }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }
td .thumb { width: 90px; }

/* Dialog */
dialog {
  border: 1px solid var(--border); border-radius: 14px; padding: 0; background: var(--surface); color: var(--text);
  width: min(720px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
dialog.wide { width: min(1000px, calc(100vw - 2rem)); }
dialog::backdrop { background: rgba(10, 12, 16, 0.55); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.dlg-body { padding: 1.25rem; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 1rem 1.25rem; border-top: 1px solid var(--border); }
.icon-btn { border: 0; background: transparent; font-size: 1.4rem; line-height: 1; cursor: pointer; color: var(--muted); padding: 0.25rem 0.5rem; }
#viewer { background: transparent; border: 0; box-shadow: none; width: auto; max-width: 95vw; }
#viewer img { max-height: 88vh; max-width: 95vw; border-radius: 8px; }

/* Toast */
#toast {
  position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%); z-index: 100;
  padding: 0.7rem 1.1rem; border-radius: 10px; background: var(--text); color: var(--bg); font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); max-width: calc(100vw - 2rem);
}
#toast.error { background: var(--danger); color: #fff; }

.hero { text-align: center; margin: 2.5rem 0 1.5rem; }
.hero p { color: var(--muted); }

@media (max-width: 600px) {
  .topbar { padding: 0.6rem 1rem; }
  .topbar .user .who { display: none; }
  .hide-sm { display: none; }
}
