:root {
  --bg: #060806;
  --bg-glow: #0d1a11;
  --panel: #0d120e;
  --panel-2: #121a14;
  --line: #1e2c22;
  --line-soft: #182219;
  --text: #e9f5ec;
  --muted: #7f9187;
  --accent: #22c55e;
  --accent-2: #16a34a;
  --accent-soft: rgba(34, 197, 94, .14);
  --green: #22c55e;
  --green-light: #4ade80;
  --red: #ef4444;
  --amber: #f59e0b;
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(900px 520px at 78% -8%, rgba(34, 197, 94, .09) 0%, transparent 62%),
    radial-gradient(700px 420px at 8% 4%, rgba(34, 197, 94, .06) 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font: 14px/1.55 "Segoe UI", system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.center { text-align: center; }
h1 { font-size: 23px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 12px; letter-spacing: .2px; }
a { color: var(--green-light); }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
code { background: rgba(34, 197, 94, .12); padding: 1px 5px; border-radius: 5px; color: var(--green-light); }

/* ============ ICONOS (SVG propios, sin CDN) ============ */
svg.i { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.22em; }
h2 { display: flex; align-items: center; gap: 9px; }
h2 svg.i, .card-head h2 svg.i { color: var(--accent); width: 17px; height: 17px; }
button, a.ghost, .quick-btn b, .chip, .mode, .side span, .target-list label, .badge { display: inline-flex; align-items: center; gap: 7px; }
button.block, a.block { justify-content: center; }
.nav-item .ico { display: inline-flex; align-items: center; justify-content: center; }
.nav-item .ico svg.i { width: 18px; height: 18px; }
.nav-item.active .ico { color: var(--accent); }
.kpi .badge-ico svg.i { width: 21px; height: 21px; }
.tg-logo svg.i { width: 40px; height: 40px; color: #fff; }
.chip svg.i, .kpi .delta svg.i { width: 14px; height: 14px; }
.chip .txt { font-weight: 600; color: var(--text); }
.small-btn svg.i { width: 14px; height: 14px; }
td svg.i, .badge svg.i, .signal-item .head svg.i { width: 14px; height: 14px; }

/* icono de cada evento en la actividad */
.fico {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none;
  background: rgba(34, 197, 94, .12); color: var(--green-light); border: 1px solid rgba(34, 197, 94, .25);
}
.fico svg.i { width: 15px; height: 15px; }
.fico.loss, .fico.kick { background: rgba(239, 68, 68, .12); color: #f87171; border-color: rgba(239, 68, 68, .28); }
.fico.payment { background: rgba(245, 158, 11, .12); color: #fbbf24; border-color: rgba(245, 158, 11, .28); }
.fico.member { background: rgba(56, 189, 248, .12); color: #38bdf8; border-color: rgba(56, 189, 248, .28); }

/* ============ LOGIN ============ */
.login { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card { width: 100%; max-width: 380px; text-align: center; }
.login-card label { text-align: left; }

.logo {
  width: 42px; height: 42px; border-radius: 12px; overflow: hidden; flex: none;
  display: grid; place-items: center; background: linear-gradient(145deg, #12351f, #0b1a11);
  border: 1px solid rgba(34, 197, 94, .35); box-shadow: 0 0 18px rgba(34, 197, 94, .18);
}
.logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.logo-fallback { display: none; font-weight: 800; font-size: 15px; color: var(--green-light); letter-spacing: .5px; }
.logo.big { width: 60px; height: 60px; margin: 0 auto 14px; }

/* ============ ESTRUCTURA ============ */
.shell { display: grid; grid-template-columns: 266px 1fr; min-height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, #0c110d 0%, #080b09 100%);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 14px; gap: 18px;
  position: sticky; top: 0; height: 100vh;
}
.side-brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px 16px; border-bottom: 1px solid var(--line); }
.side-brand strong { display: block; font-size: 14.5px; letter-spacing: .6px; line-height: 1.25; }
.side-brand small { color: var(--muted); font-size: 11.5px; }

.side-nav { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: transparent; border: 1px solid transparent; color: var(--muted);
  padding: 11px 13px; border-radius: 11px; cursor: pointer; font: inherit; text-align: left;
}
.nav-item:hover { color: var(--text); background: var(--panel-2); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(34, 197, 94, .2), rgba(34, 197, 94, .04));
  border-color: rgba(34, 197, 94, .38); color: #fff;
  box-shadow: inset 2px 0 0 var(--accent);
}
.nav-item .ico { width: 18px; text-align: center; }
.pill { margin-left: auto; background: var(--accent-2); color: #04120a; font-weight: 700; border-radius: 999px; padding: 1px 8px; font-size: 11px; }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.user-card {
  display: flex; align-items: flex-start; gap: 11px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px;
}
.user-card strong { display: block; font-size: 13px; }
.user-card small { color: var(--muted); font-size: 11.5px; display: block; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(34, 197, 94, .12); border: 1px solid rgba(34, 197, 94, .4);
  font-size: 12px; font-weight: 700; color: var(--green-light); flex: none;
}
.tag { background: rgba(34, 197, 94, .18); color: var(--green-light); font-size: 10px; padding: 1px 6px; border-radius: 5px; border: 1px solid rgba(34,197,94,.3); }
.online { display: inline-flex; align-items: center; gap: 6px; color: var(--green-light); font-size: 11.5px; margin-top: 5px; }
.online::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }

.content { min-width: 0; }
.topbar { display: flex; align-items: flex-start; gap: 18px; padding: 24px 26px 8px; flex-wrap: wrap; }
.topbar .muted { font-size: 13px; margin: 5px 0 0; }
.chips { margin-left: auto; display: flex; gap: 9px; flex-wrap: wrap; }
.chip {
  background: var(--panel); border: 1px solid var(--line); border-radius: 11px;
  padding: 9px 13px; font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 8px;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); }
.chip.icon-chip b { background: var(--accent-2); color: #04120a; border-radius: 999px; padding: 0 6px; font-size: 11px; }

.tab-panel { display: none; padding: 18px 26px 40px; }
.tab-panel.active { display: block; }

/* ============ TARJETAS ============ */
.card {
  background: linear-gradient(180deg, var(--panel) 0%, #0a0f0b 100%);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }

.cols { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 16px; align-items: start; margin-bottom: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
@media (max-width: 1100px) { .cols { grid-template-columns: 1fr; } }
@media (max-width: 860px) { .shell { grid-template-columns: 1fr; } .sidebar { position: static; height: auto; } }

/* ============ KPIs ============ */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(232px, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi {
  background: linear-gradient(180deg, var(--panel) 0%, #0a0f0b 100%);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
}
.kpi:hover { border-color: rgba(34, 197, 94, .35); }
.kpi .top { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.kpi .badge-ico {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 18px;
  background: linear-gradient(145deg, var(--accent), var(--accent-2)); color: #04120a; flex: none;
}
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 27px; font-weight: 700; letter-spacing: .3px; }
.kpi .foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.kpi .delta { font-size: 12px; color: var(--muted); }
.kpi .delta.up { color: var(--green-light); }
.kpi .delta.down { color: #f87171; }
.spark { width: 124px; height: 36px; }

/* ============ TABLA ============ */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px; }
.table th {
  text-align: left; color: var(--muted); font-weight: 600; font-size: 11px; letter-spacing: .7px;
  padding: 8px 10px; border-bottom: 1px solid var(--line);
}
.table td { padding: 12px 10px; border-bottom: 1px solid var(--line-soft); }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: rgba(34, 197, 94, .04); }
.tag-long { background: rgba(34, 197, 94, .16); color: var(--green-light); padding: 4px 12px; border-radius: 8px; font-size: 11.5px; font-weight: 700; }
.tag-short { background: rgba(239, 68, 68, .16); color: #f87171; padding: 4px 12px; border-radius: 8px; font-size: 11.5px; font-weight: 700; }

/* ============ BOT ============ */
.bot-box { display: flex; gap: 16px; align-items: center; }
.tg-logo {
  width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; font-size: 38px;
  background: radial-gradient(circle at 32% 28%, #35a9f0, #1a72c0); flex: none;
  border: 2px solid rgba(34, 197, 94, .55); box-shadow: 0 0 22px rgba(34, 197, 94, .25);
}
.kv { margin: 0; flex: 1; display: grid; grid-template-columns: auto auto; gap: 7px 10px; font-size: 12.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 600; }

/* ============ FEED ============ */
.feed { display: flex; flex-direction: column; gap: 2px; max-height: 330px; overflow-y: auto; }
.feed-item { display: flex; gap: 11px; align-items: flex-start; padding: 10px 4px; border-bottom: 1px solid var(--line-soft); }
.feed-item:last-child { border-bottom: 0; }
.feed-item .fdot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--accent); box-shadow: 0 0 8px rgba(34,197,94,.6); }
.feed-item .fdot.win { background: var(--green); }
.feed-item .fdot.loss { background: var(--red); box-shadow: 0 0 8px rgba(239,68,68,.5); }
.feed-item .fdot.payment { background: var(--amber); box-shadow: 0 0 8px rgba(245,158,11,.5); }
.feed-item .fdot.member { background: #38bdf8; box-shadow: 0 0 8px rgba(56,189,248,.5); }
.feed-item .fdot.kick { background: var(--red); box-shadow: none; }
.feed-item .ftxt { flex: 1; font-size: 13px; }
.feed-item .ftxt small { display: block; color: var(--green-light); font-size: 12px; }
.feed-item .fwhen { color: var(--muted); font-size: 11.5px; white-space: nowrap; }

/* ============ GRAFICOS ============ */
.chart svg, .donut-wrap svg { display: block; width: 100%; height: auto; }
.donut-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.donut-wrap > div:first-child { width: 175px; flex: none; }
.legend { display: flex; flex-direction: column; gap: 12px; font-size: 13px; }
.legend .li { display: flex; align-items: center; gap: 9px; }
.legend .sw { width: 10px; height: 10px; border-radius: 50%; }
.legend small { display: block; color: var(--muted); }

/* ============ ACCIONES RAPIDAS ============ */
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(196px, 1fr)); gap: 12px; }
.quick-btn {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 15px;
  text-align: left; color: var(--text); cursor: pointer; font: inherit;
}
.quick-btn:hover { border-color: var(--accent); background: rgba(34, 197, 94, .07); }
.quick-btn b { display: block; font-size: 13.5px; margin-bottom: 3px; }
.quick-btn small { color: var(--muted); font-size: 12px; }

/* ============ ENVIO RAPIDO ============ */
.mode-switch { display: flex; gap: 8px; margin-bottom: 16px; }
.mode { background: var(--panel); border: 1px solid var(--line); color: var(--muted); padding: 9px 16px; border-radius: 11px; cursor: pointer; font: inherit; }
.mode.active {
  background: linear-gradient(90deg, rgba(34, 197, 94, .22), rgba(34, 197, 94, .06));
  border-color: rgba(34, 197, 94, .45); color: #fff;
}
#quick-text { font: 15px/1.6 ui-monospace, Consolas, "Segoe UI", monospace; min-height: 210px; margin-bottom: 12px; }
.drop {
  border: 1.5px dashed var(--line); border-radius: 12px; padding: 18px; text-align: center;
  color: var(--muted); font-size: 13px; margin-bottom: 12px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.drop.over, .drop:hover { border-color: var(--accent); background: rgba(34, 197, 94, .07); color: var(--text); }
.link-file { display: inline; margin: 0; color: var(--green-light); cursor: pointer; text-decoration: underline; }
button.big { padding: 13px 26px; font-size: 15px; }

/* ============ FORMULARIOS ============ */
label { display: block; margin-bottom: 12px; font-size: 12.5px; color: var(--muted); }
input, select, textarea {
  width: 100%; margin-top: 5px; background: #0a0f0b; border: 1px solid var(--line);
  color: var(--text); border-radius: 10px; padding: 10px 12px; font: inherit; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34, 197, 94, .12); }
input[type=file] { padding: 8px; color: var(--muted); }
textarea { resize: vertical; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > label { flex: 0 0 auto; }
.row > .grow { flex: 1 1 130px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
.check input { width: auto; margin: 0; accent-color: var(--accent); }
.search { width: 175px; margin: 0; }

.side-toggle { display: flex; gap: 10px; margin-bottom: 14px; }
.side {
  flex: 1; margin: 0; cursor: pointer; text-align: center; border: 1px solid var(--line);
  border-radius: 11px; padding: 11px; background: var(--panel-2); color: var(--text);
}
.side input { display: none; }
.side.long:has(input:checked) { border-color: var(--green); background: rgba(34, 197, 94, .12); }
.side.short:has(input:checked) { border-color: var(--red); background: rgba(239, 68, 68, .12); }

fieldset.targets { border: 1px solid var(--line); border-radius: 11px; padding: 12px; margin: 0 0 14px; }
fieldset.targets legend { color: var(--muted); font-size: 12.5px; padding: 0 6px; }
.target-list { display: flex; flex-wrap: wrap; gap: 8px; }
.target-list label {
  margin: 0; display: flex; align-items: center; gap: 7px; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 13px; cursor: pointer; font-size: 12.5px;
}
.target-list label:has(input:checked) { border-color: rgba(34, 197, 94, .5); background: rgba(34, 197, 94, .1); }
.target-list input { width: auto; margin: 0; accent-color: var(--accent); }

.photo-preview { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.photo-preview img { max-width: 190px; max-height: 130px; border-radius: 10px; border: 1px solid var(--line); }

.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
button { border-radius: 10px; padding: 10px 16px; font: inherit; cursor: pointer; border: 1px solid var(--line); }
button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: 0; color: #04120a; font-weight: 700;
  box-shadow: 0 4px 16px rgba(34, 197, 94, .22);
}
button.primary:disabled { opacity: .55; cursor: progress; box-shadow: none; }
button.ghost, a.ghost {
  background: transparent; color: var(--muted); text-decoration: none; display: inline-block;
}
button.ghost:hover, a.ghost:hover { color: var(--green-light); border-color: var(--accent); background: rgba(34, 197, 94, .06); }
button.danger { background: transparent; color: #f87171; border-color: #43222a; }
button.danger:hover { background: rgba(239, 68, 68, .08); }
button.block, a.block { width: 100%; }
.small-btn { padding: 6px 11px; font-size: 12.5px; }
.btn-link { padding: 6px 11px; font-size: 12.5px; border: 1px solid var(--line); border-radius: 10px; }

.result { margin: 10px 0 0; font-size: 12.5px; min-height: 16px; }
.result.ok { color: var(--green-light); }
.result.error, .error { color: #f87171; }

/* ============ VISTA PREVIA TELEGRAM ============ */
.phone { background: #0a0f0b; border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.bubble {
  background: #16241a; border-radius: 12px 12px 12px 4px; padding: 12px 14px;
  white-space: pre-wrap; word-break: break-word; font-size: 13.5px; line-height: 1.55;
}

/* ============ LISTAS ============ */
.group-list, .signal-list, .discovered, .member-list, .payment-list { display: flex; flex-direction: column; gap: 10px; }
.discovered:not(:empty) { margin: 12px 0; }
.group-item, .signal-item, .disc-item, .member-item, .pay-item {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px;
}
.group-item:hover, .signal-item:hover, .member-item:hover, .pay-item:hover { border-color: rgba(34, 197, 94, .3); }
.group-item, .disc-item, .pay-item { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.group-item .name, .disc-item .name, .pay-item .name, .member-item .name { font-weight: 600; }
.group-item .cid, .disc-item .cid { color: var(--muted); font-size: 12px; font-family: ui-monospace, Consolas, monospace; }
.group-item .spacer, .disc-item .spacer { margin-left: auto; }
.group-info, .member-info { flex-basis: 100%; color: var(--muted); font-size: 12.5px; }
.group-info:not(:empty), .member-info:not(:empty) { margin-top: 8px; }
.pay-item .amount { font-weight: 700; color: var(--green-light); }

.badge { font-size: 11px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.badge.on { color: var(--green-light); border-color: rgba(34, 197, 94, .35); background: rgba(34, 197, 94, .12); }
.badge.off { color: #f87171; border-color: #43222a; background: rgba(239, 68, 68, .1); }
.badge.warn { color: #fbbf24; border-color: #4d3a12; background: rgba(245, 158, 11, .1); }

.signal-item .head, .member-item .head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 6px; }
.signal-item .pair { font-weight: 700; font-size: 14.5px; }
.signal-item .side-long { color: var(--green-light); }
.signal-item .side-short { color: #f87171; }
.signal-item .meta, .member-item .meta { color: var(--muted); font-size: 12px; }
.signal-item .deliveries { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.signal-item .updates { color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 15px; }
.stat .k { display: block; font-size: 21px; font-weight: 700; color: var(--green-light); }
.stat .v { color: var(--muted); font-size: 12px; }
.stat.warn .k { color: #fbbf24; }
.stat.bad .k { color: #f87171; }

ul.help { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
ul.help li { margin-bottom: 8px; }

/* ============ MODALES ============ */
.modal { position: fixed; inset: 0; background: rgba(3, 6, 4, .78); display: grid; place-items: center; padding: 20px; z-index: 30; }
.modal-card { width: 100%; max-width: 440px; max-height: 92vh; overflow-y: auto; border-color: rgba(34, 197, 94, .3); }

.side.long svg.i { color: var(--green); }
.side.short svg.i { color: var(--red); }
.signal-item .side-long svg.i, .signal-item .side-short svg.i { width: 14px; height: 14px; }
