:root { --bg:#0b1220; --card:#0f1827; --line:#1f2a3a; --fg:#e6edf3; --mut:#9fb0c3; --acc:#2ecc71; --err:#ff6b6b; }
* { box-sizing: border-box; }
body { margin:0; min-height:100vh; background:var(--bg); color:var(--fg);
  font-family:system-ui,Segoe UI,Roboto,Arial,sans-serif; display:flex; align-items:center; justify-content:center; padding:1rem; }
.card { width:100%; max-width:420px; background:var(--card); border:1px solid var(--line); border-radius:16px; padding:1.75rem; }
h1 { margin:0 0 .25rem; font-size:1.4rem; }
.sub { color:var(--mut); font-size:.9rem; margin:0 0 1.25rem; }
label { display:block; font-size:.8rem; color:var(--mut); margin:.6rem 0 .25rem; }
input, select { width:100%; padding:.6rem .7rem; border:1px solid var(--line); border-radius:10px;
  background:#0b1320; color:var(--fg); font-size:1rem; }
button { width:100%; margin-top:1rem; padding:.7rem; border:0; border-radius:10px; background:var(--acc);
  color:#04210f; font-weight:700; font-size:1rem; cursor:pointer; }
button:disabled { opacity:.6; cursor:default; }
.msg { margin-top:.9rem; font-size:.9rem; min-height:1.2em; }
.msg.err { color:var(--err); }
.msg.ok { color:var(--acc); }
.hidden { display:none; }
.row { display:flex; gap:.5rem; }
.row > * { flex:1; }
.nav { margin-top:1.25rem; font-size:.95rem; text-align:center; }
.nav a { color:var(--acc); text-decoration:none; font-weight:700; }
.nav a:hover { text-decoration:underline; }
table { width:100%; border-collapse:collapse; margin-top:1rem; }
td { padding:.4rem 0; border-bottom:1px solid var(--line); font-size:.95rem; }
td:last-child { text-align:right; color:var(--acc); font-weight:600; }
.dot { display:inline-block; width:9px; height:9px; border-radius:50%; background:var(--acc); margin-right:6px; }
.brand-logo { display:block; margin:0 auto .75rem; width:72px; height:72px; border-radius:18px; }

/* ---- Language toggle ---- */
.lang-toggle {
  position: fixed; top: 10px; right: 12px; z-index: 999;
  display: flex; align-items: center; gap: 2px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 8px; padding: 3px 6px; font-size: .8rem; font-weight: 700;
  user-select: none;
}
.lang-toggle span {
  cursor: pointer; padding: 2px 5px; border-radius: 5px; color: var(--mut);
  transition: background .15s, color .15s;
}
.lang-toggle span.active { background: var(--acc); color: #04210f; }
.lang-toggle .sep { color: var(--line); font-weight: 400; cursor: default; }

/* ---- Country picker row ---- */
.phone-row { display: flex; gap: .4rem; align-items: flex-end; }
.phone-row select#country { flex: 0 0 96px; width: 96px; }
.phone-row input#phone { flex: 1 1 auto; min-width: 0; }

/* ---- Admin layout ---- */
body.admin-layout { align-items: flex-start; justify-content: flex-start; padding: 0; }
.admin-wrap { width: 100%; max-width: 1100px; margin: 0 auto; padding: 1rem 1.25rem 4rem; }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 0; border-bottom: 1px solid var(--line); margin-bottom: 1rem;
  flex-wrap: wrap; gap: .5rem;
}
.topbar-brand { display: flex; align-items: center; gap: .25rem; }
.topbar-brand h1 { margin: 0; font-size: 1.2rem; font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

/* Search input in topbar */
.search-input {
  width: auto; min-width: 220px; padding: .4rem .7rem;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--fg); font-size: .88rem;
  outline: none; margin-top: 0;
}
.search-input:focus { border-color: var(--acc); }
.search-input::placeholder { color: var(--mut); }

/* Topbar button overrides */
.topbar-actions button,
.topbar-actions .btn-outline { width: auto; margin-top: 0; padding: .4rem .85rem; font-size: .88rem; border-radius: 8px; }

/* Outline button variant */
.btn-outline { background: transparent; border: 1px solid var(--line); color: var(--fg); font-weight: 600; }
.btn-outline:hover { border-color: var(--acc); color: var(--acc); }
.btn-outline.active { border-color: var(--acc); color: var(--acc); }
.btn-danger { border-color: var(--err) !important; color: var(--err) !important; }
.btn-danger:hover { background: var(--err) !important; color: #1a0000 !important; }

/* Resend-OTP button (secondary, under the main action) */
.btn-resend { margin-top: .55rem; font-size: .92rem; }
.btn-resend:disabled { opacity: .5; cursor: default; }
.btn-resend:disabled:hover { border-color: var(--line); color: var(--fg); }

/* Loading/empty state */
.loading-state {
  text-align: center; padding: 2.5rem 1rem; color: var(--mut); font-size: .95rem;
}
.loading-state.err { color: var(--err); }
.text-muted { color: var(--mut); }

/* ---- Number group cards ---- */
.number-group {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  margin-bottom: .75rem; overflow: hidden;
}

.number-group-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .7rem 1rem; border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.02);
}
.number-group-info { display: flex; align-items: center; gap: .6rem; }
.number-display { font-size: .95rem; font-weight: 700; letter-spacing: .01em; }
.number-badge {
  font-size: .72rem; color: var(--mut); background: rgba(255,255,255,.06);
  border: 1px solid var(--line); border-radius: 20px;
  padding: .15rem .55rem; font-weight: 600;
}

/* Message-number button */
.btn-msg-number {
  width: auto; margin: 0; padding: .3rem .7rem;
  font-size: .8rem; font-weight: 600; border-radius: 6px;
  background: transparent; border: 1px solid var(--line); color: var(--mut);
  cursor: pointer; white-space: nowrap; transition: border-color .15s, color .15s;
}
.btn-msg-number:hover { border-color: var(--acc); color: var(--acc); }

/* Operator list inside a card */
.op-list { padding: 0; }

/* Single operator row */
.op-row {
  border-bottom: 1px solid var(--line); cursor: pointer;
  transition: background .12s;
}
.op-row:last-child { border-bottom: none; }
.op-row:hover { background: rgba(255,255,255,.03); }
.op-row.op-row-open > .op-row-main { background: rgba(46,204,113,.04); }

.op-row-main {
  display: flex; align-items: center; gap: .55rem;
  padding: .6rem 1rem; user-select: none;
}

/* Status dot */
.status-dot {
  flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%; display: inline-block;
}
.status-active   { background: var(--acc); }
.status-inactive { background: var(--mut); opacity: .6; }

/* Op row text */
.op-alias  { font-weight: 600; font-size: .9rem; flex-shrink: 0; }
.op-name   { color: var(--mut); font-size: .8rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.op-team   { font-size: .75rem; color: var(--mut); background: rgba(255,255,255,.06); border: 1px solid var(--line); border-radius: 4px; padding: .1rem .35rem; white-space: nowrap; }

/* Live operational metrics strip on the operator row */
.op-metrics { display: flex; align-items: center; gap: .35rem; flex-shrink: 0; }
.op-metric {
  font-size: .68rem; font-weight: 600; white-space: nowrap;
  color: var(--mut); background: rgba(255,255,255,.04);
  border: 1px solid var(--line); border-radius: 20px; padding: .1rem .45rem;
}
.op-metric-idle { opacity: .55; }
.op-live {
  font-size: .68rem; font-weight: 700; white-space: nowrap;
  color: var(--acc); background: rgba(46,204,113,.12);
  border: 1px solid rgba(46,204,113,.4); border-radius: 20px; padding: .1rem .45rem;
  animation: op-live-pulse 1.6s ease-in-out infinite;
}
@keyframes op-live-pulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }

.op-chevron { color: var(--mut); font-size: .9rem; margin-left: auto; flex-shrink: 0; transition: transform .2s; }
.op-row.op-row-open .op-chevron { transform: rotate(90deg); }

/* Expanded detail panel */
.op-detail {
  margin: 0 .75rem .75rem; padding: .9rem 1rem;
  background: rgba(0,0,0,.18); border: 1px solid var(--line);
  border-radius: 8px;
}
.detail-loading { color: var(--mut); font-size: .85rem; }

/* Stats grid inside detail */
.detail-stats {
  display: flex; flex-wrap: wrap; gap: .4rem .6rem; margin-bottom: .85rem;
}
.stat-item {
  background: rgba(255,255,255,.04); border: 1px solid var(--line);
  border-radius: 6px; padding: .4rem .65rem; min-width: 90px;
}
.stat-label { font-size: .7rem; color: var(--mut); margin-bottom: .15rem; }
.stat-value { font-size: .9rem; font-weight: 600; }

/* Earnings row */
.detail-earnings {
  display: flex; align-items: center; justify-content: space-between;
  padding: .55rem .65rem; background: rgba(46,204,113,.07);
  border: 1px solid rgba(46,204,113,.2); border-radius: 6px; margin-bottom: .75rem;
}
.detail-earnings-label { font-size: .8rem; color: var(--mut); }
.detail-earnings-value { font-size: 1.05rem; font-weight: 700; color: var(--acc); }

/* Payment info */
.detail-payment { margin-bottom: .75rem; }
.detail-payment-label { font-size: .72rem; color: var(--mut); text-transform: uppercase; letter-spacing: .05em; margin-bottom: .3rem; }
.detail-payment-body { font-size: .85rem; line-height: 1.7; display: flex; flex-wrap: wrap; gap: .2rem .75rem; }
.pay-method { font-weight: 700; color: var(--fg); }
.pay-field  { color: var(--mut); }
.pay-key    { color: var(--fg); font-weight: 600; }

/* Detail action buttons */
.detail-actions { display: flex; gap: .5rem; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: .65rem; margin-top: .25rem; }
.btn-detail-action {
  width: auto; margin: 0; padding: .3rem .7rem;
  font-size: .78rem; font-weight: 600; border-radius: 6px;
  background: transparent; border: 1px solid var(--line); color: var(--mut);
  cursor: pointer; transition: border-color .15s, color .15s;
}
.btn-detail-action:hover { border-color: var(--acc); color: var(--acc); }
.btn-detail-danger { color: var(--err); border-color: transparent; }
.btn-detail-danger:hover { border-color: var(--err); background: rgba(255,107,107,.08); color: var(--err); }

/* ---- Billing view ---- */
.billing-group {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  margin-bottom: .75rem; overflow: hidden;
}
.billing-group-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .65rem 1rem; border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.02);
}
.billing-subtotal { font-size: .85rem; color: var(--mut); }
.billing-subtotal strong { color: var(--acc); }
.billing-rows { padding: 0; }
.billing-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: .55rem 1rem; border-bottom: 1px solid var(--line); font-size: .88rem;
  transition: background .12s;
}
.billing-row:last-child { border-bottom: none; }
.billing-row:hover { background: rgba(255,255,255,.02); }
.billing-op-info { display: flex; flex-direction: column; gap: .1rem; }
.billing-alias   { font-weight: 600; }
.billing-opname  { font-size: .76rem; color: var(--mut); }
.billing-op-nums { display: flex; align-items: center; gap: .9rem; }
.billing-minutes { font-size: .82rem; color: var(--mut); }
.billing-earnings { font-weight: 600; min-width: 70px; text-align: right; }
.billing-pay-icon { width: 20px; text-align: center; }
.pay-check  { color: var(--acc); font-weight: 700; }
.pay-missing { color: var(--mut); }

.billing-grand-total {
  display: flex; align-items: center; justify-content: space-between;
  padding: .85rem 1rem; margin-top: .5rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  font-size: 1rem;
}
.billing-grand-total strong { font-size: 1.1rem; color: var(--acc); }

/* ---- "Sin uso" / usage badges on operator rows ---- */
.op-badge-unused {
  font-size: .68rem; font-weight: 700; white-space: nowrap;
  color: var(--err); background: rgba(255,107,107,.12);
  border: 1px solid rgba(255,107,107,.35); border-radius: 20px;
  padding: .1rem .45rem; flex-shrink: 0;
}
.op-badge-used {
  font-size: .68rem; font-weight: 600; white-space: nowrap;
  color: var(--mut); background: rgba(255,255,255,.04);
  border: 1px solid var(--line); border-radius: 20px;
  padding: .1rem .45rem; flex-shrink: 0;
}

/* "Sin uso" badge in number-group header */
.number-badge-unused {
  font-size: .72rem; color: var(--err); background: rgba(255,107,107,.1);
  border: 1px solid rgba(255,107,107,.3); border-radius: 20px;
  padding: .15rem .55rem; font-weight: 700;
}

/* Operator row checkbox */
.op-checkbox {
  flex-shrink: 0;
  width: 15px; height: 15px;
  margin: 0; padding: 0;
  cursor: pointer;
  accent-color: var(--err);
  /* Prevent the default input styling from breaking the layout */
  display: inline-block; vertical-align: middle;
}

/* Override global input width rule so the checkbox isn't 100% wide */
.op-row-main input[type="checkbox"].op-checkbox {
  width: 15px;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 0;
  margin-top: 0;
}

/* ---- Historical usage block inside expanded detail ---- */
.detail-lifetime {
  margin-bottom: .75rem;
  padding: .55rem .65rem;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--line); border-radius: 6px;
}
.detail-lifetime-label {
  font-size: .7rem; color: var(--mut); text-transform: uppercase;
  letter-spacing: .05em; margin-bottom: .35rem;
}
.detail-lifetime-row {
  display: flex; gap: .5rem; font-size: .85rem; line-height: 1.7;
}
.detail-lifetime-key { color: var(--fg); font-weight: 600; }
.detail-lifetime-val { color: var(--mut); }

/* ===========================================================================
   Operators dashboard: KPI bar + sortable performance table
   =========================================================================== */

/* Performance color tiers (shared) */
.m-good { color: var(--acc); }
.m-mid  { color: #f1b24a; }
.m-bad  { color: var(--err); }
.m-idle { color: var(--mut); opacity: .5; }

/* ---- KPI summary bar ---- */
.kpi-bar {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: .6rem; margin: .25rem 0 1.1rem;
}
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: .7rem .85rem; border-left: 3px solid var(--line);
}
.kpi-value { font-size: 1.5rem; font-weight: 800; line-height: 1.1; letter-spacing: -.02em; }
.kpi-label { font-size: .68rem; color: var(--mut); text-transform: uppercase; letter-spacing: .06em; margin-top: .2rem; }
.kpi-good { border-left-color: var(--acc); }
.kpi-good .kpi-value { color: var(--acc); }
.kpi-mid  { border-left-color: #f1b24a; }
.kpi-mid  .kpi-value { color: #f1b24a; }
.kpi-bad  { border-left-color: var(--err); }
.kpi-bad  .kpi-value { color: var(--err); }
.kpi-live { border-left-color: var(--acc); animation: op-live-pulse 1.6s ease-in-out infinite; }
.kpi-live .kpi-value { color: var(--acc); }

/* ---- Table ---- */
.table-wrap {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  overflow: auto;
}
.ops-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.ops-table thead th {
  position: sticky; top: 0; z-index: 2;
  background: #0c1525; color: var(--mut);
  font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700;
  text-align: left; padding: .65rem .7rem; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.ops-table thead th.num { text-align: right; }
.ops-table th.th-sort { cursor: pointer; user-select: none; }
.ops-table th.th-sort:hover { color: var(--fg); }
.ops-table th.th-active { color: var(--acc); }

.ops-table tbody td {
  padding: .55rem .7rem; border-bottom: 1px solid var(--line); vertical-align: middle;
}
.ops-table tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
.ops-table tr.op-row { cursor: pointer; transition: background .12s; }
.ops-table tr.op-row:hover > td { background: rgba(255,255,255,.03); }
.ops-table tr.op-row-open > td { background: rgba(46,204,113,.05); }

/* Underperformer highlight */
.ops-table tr.op-row-bad > td { background: rgba(255,107,107,.06); }
.ops-table tr.op-row-bad > td:first-child { box-shadow: inset 3px 0 0 var(--err); }
.ops-table tr.op-row-bad:hover > td { background: rgba(255,107,107,.1); }
.flag-bad { color: var(--err); font-weight: 700; }

/* Operator name cell */
.col-op .op-alias { font-weight: 600; }
.col-op .op-name  { color: var(--mut); font-size: .76rem; margin-left: .45rem; }
.col-op .status-dot { margin-right: .45rem; }
.col-num { color: var(--mut); font-size: .82rem; white-space: nowrap; }
.num-shared {
  font-size: .68rem; color: #f1b24a; border: 1px solid rgba(241,178,74,.4);
  border-radius: 10px; padding: 0 .3rem; margin-left: .15rem;
}
.cell-live { color: var(--acc); font-weight: 700; white-space: nowrap; }
.badge-unused {
  font-size: .68rem; font-weight: 700; color: var(--err);
  background: rgba(255,107,107,.12); border: 1px solid rgba(255,107,107,.35);
  border-radius: 20px; padding: .05rem .4rem;
}
.metric { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Column widths / alignment */
.ops-table .col-chk  { width: 34px; text-align: center; }
.ops-table .col-chev { width: 28px; text-align: center; }
.ops-table tr.op-row .op-chevron { display: inline-block; transition: transform .2s; }
.ops-table tr.op-row-open .op-chevron { transform: rotate(90deg); }

/* Detail row inside the table */
.ops-table tr.op-detail-row > td { padding: 0; background: rgba(0,0,0,.18); }
.ops-table tr.op-detail-row .op-detail {
  margin: 0; padding: .9rem 1rem; border: none; border-radius: 0; background: transparent;
}

/* Responsive */
@media (max-width: 600px) {
  .search-input { min-width: 140px; }
  .op-team { display: none; }
  .billing-op-nums { gap: .5rem; }
  .billing-minutes { display: none; }
  .op-badge-used { display: none; }
  .op-metric-sec { display: none; }
  .col-op .op-name { display: none; }
  .kpi-value { font-size: 1.25rem; }
}

/* ===== Panel de reportes del operador (consumo por día) ===== */
.rep-wrap { align-self:flex-start; width:100%; max-width:720px; margin:0 auto; padding:.5rem .25rem 4rem; }
.rep-head { display:flex; align-items:center; gap:.85rem; margin-bottom:1rem; }
.rep-head .brand-logo { margin:0; width:56px; height:56px; flex:0 0 auto; }
.rep-head-txt { flex:1; min-width:0; }
.rep-head-txt h1 { margin:0; font-size:1.3rem; }
.rep-head-txt .sub { margin:.15rem 0 0; }
.rep-head .btn-outline { width:auto; margin:0; padding:.45rem .9rem; font-size:.85rem; border-radius:8px;
  background:transparent; border:1px solid var(--line); color:var(--mut); cursor:pointer; }
.rep-head .btn-outline:hover { color:var(--fg); border-color:var(--mut); }
.rep-controls { margin-bottom:1.25rem; }
.rep-h2 { font-size:1rem; margin:1.5rem 0 .6rem; color:var(--fg); border-bottom:1px solid var(--line); padding-bottom:.4rem; }
.rep-h3 { font-size:.82rem; text-transform:uppercase; letter-spacing:.04em; color:var(--mut); margin:1rem 0 .4rem; }

/* KPIs del día */
.kpi-row { display:grid; grid-template-columns:repeat(5,1fr); gap:.5rem; }
.kpi { background:#0b1320; border:1px solid var(--line); border-radius:12px; padding:.7rem .4rem; text-align:center; }
.kpi-val { display:block; font-size:1.35rem; font-weight:700; color:var(--acc); line-height:1.1; }
.kpi-lbl { display:block; font-size:.66rem; color:var(--mut); margin-top:.3rem; line-height:1.15; }

/* Tabla diaria (reutiliza .ops-table) */
.rep-table-wrap { overflow-x:auto; }
.rep-daily-table { font-size:.85rem; }
.rep-daily-table td, .rep-daily-table th { padding:.45rem .55rem; border-bottom:1px solid var(--line); }
.rep-daily-table td:first-child { white-space:nowrap; text-transform:capitalize; }
.rep-daily-table td.num, .rep-daily-table th.num { text-align:right; font-variant-numeric:tabular-nums; }
.rep-daily-table tbody tr.rep-dim td { color:var(--mut); opacity:.55; }
.rep-daily-table tfoot .rep-tot td { font-weight:700; color:var(--fg); border-top:2px solid var(--line); border-bottom:0; }
.rep-empty { color:var(--mut); font-size:.85rem; padding:.6rem 0; }

@media (max-width:560px) {
  .kpi-row { grid-template-columns:repeat(3,1fr); }
  .kpi-val { font-size:1.15rem; }
}

/* Bloque "consumo por día" dentro del detalle del operador (admin) */
.detail-daily { margin: .85rem 0 .25rem; }
.detail-daily-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--mut); margin-bottom: .5rem; }
.detail-daily .rep-h3 { margin: .7rem 0 .35rem; }
.detail-daily .rep-daily-table { font-size: .8rem; }
.detail-daily .rep-table-wrap { overflow-x: auto; }
