:root {
  --bg: #F7F8FA;
  --surface: #FFFFFF;
  --ink: #1A2B3C;
  --ink-soft: #475467;
  --ink-faint: #8B92A0;
  --line: #E4E7EC;
  --line-strong: #D0D5DD;

  --blue: #2E86AB;
  --blue-hover: #256E8C;
  --blue-soft: #EAF3F8;
  --orange: #D9622B;
  --orange-soft: #FCEEE6;

  --green: #1D7A4C;
  --green-bg: #E1F3E9;
  --amber: #B76B00;
  --amber-bg: #FCEFD9;
  --danger: #C2372A;
  --danger-bg: #FBE7E4;

  --radius-s: 6px;
  --radius-m: 8px;
  --radius-l: 10px;
  --shadow-card: 0 1px 2px rgba(17,19,24,0.05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
h1, h2, h3 { letter-spacing: -0.01em; margin: 0; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
input, select, textarea {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-m);
  padding: 10px 13px;
  color: var(--ink);
  width: 100%;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft);
}
button { cursor: pointer; font-weight: 600; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
a { color: var(--blue); }

.btn-primary {
  background: var(--blue); color: #fff; border: none; border-radius: var(--radius-m);
  padding: 10px 18px; font-size: 14px; display: inline-flex; align-items: center; gap: 8px;
}
.btn-primary:hover { background: var(--blue-hover); }
.btn-primary:disabled { opacity: .5; cursor: default; }
.btn-secondary {
  background: #fff; border: 1px solid var(--line-strong); color: var(--ink); border-radius: var(--radius-m);
  padding: 10px 16px; font-size: 14px; display: inline-flex; align-items: center; gap: 8px;
}
.btn-secondary:hover { border-color: var(--ink-faint); }
.btn-text { background: none; border: none; color: var(--blue); font-size: 13px; font-weight: 600; padding: 0; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l);
  padding: 20px; box-shadow: var(--shadow-card);
}

.badge { font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.red { background: var(--danger-bg); color: var(--danger); }

.semaforo { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; flex-shrink: 0; }
.semaforo.en_analisis { background: var(--amber); }
.semaforo.ganado { background: var(--green); }
.semaforo.perdido { background: var(--danger); }
.semaforo.borrador { background: var(--ink-faint); }

.estado-select { border: 1px solid var(--line-strong); border-radius: var(--radius-s); padding: 6px 8px; font-size: 12.5px; background: #fff; }

.stat-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.stat-tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 16px 18px; }
.stat-tile .n { font-size: 22px; font-weight: 800; }
.stat-tile .lbl { font-size: 12px; color: var(--ink-soft); font-weight: 600; margin-top: 2px; }
.stat-tile .sum { font-size: 12.5px; color: var(--ink-faint); margin-top: 4px; }
.stat-tile.ganado .n { color: var(--green); }
.stat-tile.perdido .n { color: var(--danger); }
.stat-tile.en_analisis .n { color: var(--amber); }

input[type="text"], input[type="tel"] { -webkit-appearance: none; }
input.no-arrows::-webkit-outer-spin-button, input.no-arrows::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input.no-arrows { -moz-appearance: textfield; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; padding: 10px 12px; color: var(--ink-soft); font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.4px; border-bottom: 1px solid var(--line); background: var(--bg);
}
tbody td { padding: 12px; border-bottom: 1px solid #F0F2F5; }
tbody tr:last-child td { border-bottom: none; }

/* ---------- App shell ---------- */
header.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner { padding: 14px 28px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand .mark { display: flex; align-items: baseline; font-weight: 800; font-size: 19px; }
.brand .mark .c { color: var(--blue); }
.brand .mark .m { color: var(--orange); }
.brand .name { font-size: 14px; font-weight: 700; line-height: 1.1; }
.brand .sub { font-size: 11px; color: var(--ink-faint); }
.whoami { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.logout-btn { background: none; border: 1px solid var(--line-strong); border-radius: var(--radius-m); color: var(--ink-soft); font-size: 12.5px; padding: 6px 12px; }

nav.tabbar { padding: 0 28px; display: flex; gap: 24px; border-top: 1px solid #F0F2F5; overflow-x: auto; }
nav.tabbar button {
  background: none; border: none; padding: 10px 2px; font-weight: 500; font-size: 14px; color: var(--ink-faint);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
nav.tabbar button.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--blue); }

.app-shell { max-width: 1100px; margin: 0 auto; padding: 24px 28px 72px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 19px; font-weight: 700; }
.page-head .sub { font-size: 13px; color: var(--ink-faint); margin-top: 2px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field-grid .span-2 { grid-column: 1 / -1; }
.section-title { font-size: 14px; font-weight: 700; margin-bottom: 10px; }
.hint { font-size: 13px; color: var(--ink-faint); }

.chip-toggle { display: inline-flex; background: #F0F2F5; border-radius: var(--radius-m); padding: 3px; }
.chip-toggle button { background: none; border: none; padding: 7px 18px; border-radius: 6px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.chip-toggle button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.checkbox-pill { display: flex; align-items: center; gap: 8px; background: var(--blue-soft); border: 1px solid var(--blue); border-radius: 999px; padding: 8px 14px; font-size: 13px; }
.checkbox-pill.off { background: #fff; border-color: var(--line-strong); color: var(--ink-faint); }

.search-results { margin-top: 6px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; box-shadow: var(--shadow-card); }
.search-results .row { padding: 10px 14px; border-bottom: 1px solid #F0F2F5; font-size: 14px; cursor: pointer; }
.search-results .row:last-child { border-bottom: none; }
.search-results .row:hover { background: var(--bg); }

.total-box { display: flex; justify-content: space-between; padding: 12px 16px; background: var(--ink); border-radius: var(--radius-m); color: #fff; }
.total-box .label { color: #C4CBD4; font-size: 14px; font-weight: 600; }
.total-box .value { font-size: 19px; font-weight: 700; }

.dropzone { border: 1.5px dashed var(--line-strong); border-radius: var(--radius-m); padding: 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.file-chip { background: #F0F2F5; border-radius: 6px; padding: 6px 12px; font-size: 12px; display: flex; align-items: center; gap: 6px; }

.social-row { display: flex; align-items: center; justify-content: center; gap: 22px; padding-top: 4px; flex-wrap: wrap; font-size: 13px; color: var(--ink-soft); }
.social-row .item { display: flex; align-items: center; gap: 8px; }
.social-row svg { width: 20px; height: 20px; color: var(--blue); }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 40px 36px; box-shadow: 0 1px 2px rgba(17,19,24,.04); }
.login-card .mark { justify-content: center; font-size: 30px; margin-bottom: 4px; }
.login-card h1 { font-size: 16px; text-align: center; }
.login-card p.hint { text-align: center; margin: 2px 0 22px; }
.empty-state { border: 1px dashed var(--line-strong); border-radius: var(--radius-l); padding: 40px 18px; text-align: center; color: var(--ink-faint); font-size: 13.5px; background: #fff; }
.form-status { font-size: 13px; margin-top: 10px; }
.form-status.error { color: var(--danger); }
.form-status.ok { color: var(--green); }

@media (max-width: 640px) {
  .field-grid { grid-template-columns: 1fr; }
  .app-shell { padding: 18px 16px 56px; }
  .topbar-inner { padding: 12px 16px; }
  nav.tabbar { padding: 0 16px; }
}
