/* ==========================================================================
   Konversa — Paneles de gestión (Agencia y Super-admin)
   ========================================================================== */

.panel-app { display: grid; grid-template-columns: 252px 1fr; height: 100vh; overflow: hidden; }

/* ---------- Sidebar ---------- */
.panel-side { background: var(--ink); color: #aeb7c9; display: flex; flex-direction: column; padding: 20px 14px; }
.panel-side .brand { color: #fff; font-size: 21px; padding: 6px 10px 18px; }
.panel-side .brand svg { width: 26px; height: 26px; }
.side-role { font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: #6b7689; padding: 0 12px 10px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px;
  color: #aeb7c9; font-weight: 600; font-size: 15px; cursor: pointer; margin-bottom: 3px; transition: .14s; border: none; background: none; width: 100%; text-align: left; font-family: inherit;
}
.nav-item svg { width: 20px; height: 20px; flex: none; }
.nav-item:hover { background: #1b2537; color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(91,61,245,.35); }
.side-spacer { flex: 1; }
.side-foot { border-top: 1px solid #26324a; padding: 14px 12px 4px; }
.side-user { display: flex; align-items: center; gap: 10px; }
.side-user .avatar { width: 38px; height: 38px; font-size: 15px; }
.side-user .info { min-width: 0; }
.side-user .info .n { color: #fff; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .info .r { font-size: 12px; color: #6b7689; }

/* ---------- Main ---------- */
.panel-main { overflow-y: auto; background: var(--soft-2); }
.panel-top {
  position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.9); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line); padding: 16px 30px; display: flex; align-items: center; gap: 16px;
}
.panel-top h1 { font-size: 21px; font-weight: 800; letter-spacing: -.5px; }
.panel-top .sub { color: var(--muted); font-size: 13px; }
.top-spacer { flex: 1; }
.top-search { position: relative; }
.top-search input { padding: 9px 14px 9px 36px; border: 1.5px solid var(--line); border-radius: 999px; font-family: inherit; font-size: 14px; width: 220px; }
.top-search input:focus { outline: none; border-color: var(--brand); }
.top-search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.top-btn { background: var(--grad); color: #fff; border: none; font-weight: 700; font-size: 14px; padding: 10px 18px; border-radius: 11px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; box-shadow: 0 6px 16px rgba(91,61,245,.28); transition: .15s; }
.top-btn:hover { filter: brightness(1.06); transform: translateY(-1px); }

.panel-body { padding: 26px 30px 50px; max-width: 1240px; }
.section { display: none; }
.section.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px) } to { opacity: 1; transform: none } }

/* ---------- KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 20px; }
.kpi .top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi .ic { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; color: #fff; }
.kpi .val { font-size: 30px; font-weight: 800; letter-spacing: -1px; }
.kpi .delta { font-size: 13px; font-weight: 700; margin-top: 4px; }
.kpi .delta.up { color: var(--ok); } .kpi .delta.down { color: var(--danger); }

/* ---------- Cards ---------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 22px; margin-bottom: 22px; }
.card h3 { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.card .card-sub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 22px; align-items: start; }

/* ---------- Bar chart ---------- */
.bars { display: flex; align-items: flex-end; gap: 12px; height: 180px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.bar { width: 100%; max-width: 42px; border-radius: 8px 8px 4px 4px; background: var(--grad); transition: height .5s ease; position: relative; }
.bar .bv { position: absolute; top: -20px; left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.bar-col .bl { font-size: 12px; color: var(--muted); font-weight: 600; }

/* ---------- Tabla ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th { text-align: left; color: var(--muted); font-size: 12px; letter-spacing: .5px; text-transform: uppercase; font-weight: 700; padding: 10px 14px; border-bottom: 2px solid var(--line); white-space: nowrap; }
table.tbl td { padding: 13px 14px; border-bottom: 1px solid var(--soft); white-space: nowrap; }
table.tbl tr:hover td { background: var(--soft-2); }
.cell-user { display: flex; align-items: center; gap: 10px; }
.cell-user .avatar { width: 36px; height: 36px; font-size: 14px; }
.cell-user .nm { font-weight: 600; }
.cell-user .sc { font-size: 12px; color: var(--muted); }
.pill-state { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.pill-state .d { width: 7px; height: 7px; border-radius: 50%; }
.pill-state.on { background: #dcfce7; color: #15803d; } .pill-state.on .d { background: var(--ok); }
.pill-state.off { background: #f1f5f9; color: #64748b; } .pill-state.off .d { background: #94a3b8; }
.pill-state.wait { background: #fef3c7; color: #b45309; } .pill-state.wait .d { background: var(--warn); }
.pill-state.approved { background: #dcfce7; color: #15803d; } .pill-state.approved .d { background: var(--ok); }
.money { font-weight: 700; }
.act-btn { border: 1.5px solid var(--line); background: #fff; border-radius: 9px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; color: var(--ink); transition: .12s; }
.act-btn:hover { border-color: var(--brand); color: var(--brand); }
.act-btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.act-btn.primary:hover { filter: brightness(1.08); color: #fff; }
.act-btn.danger:hover { border-color: var(--danger); color: var(--danger); }

/* ---------- Ranking ---------- */
.rank-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--soft); }
.rank-item:last-child { border-bottom: none; }
.rank-num { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; font-size: 13px; background: var(--soft); color: var(--brand-2); flex: none; }
.rank-item.top1 .rank-num { background: #fde68a; color: #b45309; }
.rank-item .avatar { width: 38px; height: 38px; font-size: 14px; }
.rank-item .info { flex: 1; min-width: 0; }
.rank-item .info .n { font-weight: 600; font-size: 14px; }
.rank-item .info .s { font-size: 12px; color: var(--muted); }
.rank-item .amt { font-weight: 700; color: var(--brand); }

/* ---------- Reparto de ingresos (split) ---------- */
.split-visual { display: flex; height: 46px; border-radius: 12px; overflow: hidden; margin: 14px 0 8px; font-size: 13px; font-weight: 700; color: #fff; }
.split-visual > div { display: grid; place-items: center; transition: width .3s ease; min-width: 40px; }
.sp-plat { background: var(--brand); } .sp-agency { background: var(--accent); } .sp-model { background: #10b981; }
.split-legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; }
.split-legend span { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); }
.split-legend .sw { width: 12px; height: 12px; border-radius: 4px; }
.split-inputs { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; margin: 18px 0; }
.split-inputs label { font-size: 13px; font-weight: 600; color: var(--muted); display: block; margin-bottom: 6px; }
.split-inputs .inp { display: flex; align-items: center; border: 1.5px solid var(--line); border-radius: 11px; padding: 8px 12px; }
.split-inputs input { border: none; width: 100%; font-family: inherit; font-size: 18px; font-weight: 700; }
.split-inputs input:focus { outline: none; }
.split-inputs .pct { color: var(--muted); font-weight: 700; }
.split-warn { color: var(--danger); font-size: 13px; font-weight: 600; min-height: 18px; }
.split-sim { background: var(--soft); border-radius: 12px; padding: 16px; margin-top: 6px; }
.split-sim .row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; }
.split-sim .row.tot { border-top: 1px solid #ddd6ff; margin-top: 6px; padding-top: 10px; font-weight: 700; }

/* ---------- Precios de créditos ---------- */
.price-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 14px; }
.price-card { border: 1.5px solid var(--line); border-radius: 14px; padding: 16px; }
.price-card .a { font-size: 20px; font-weight: 800; color: var(--brand); margin-bottom: 8px; }
.price-card label { font-size: 12px; color: var(--muted); font-weight: 600; }
.price-card .inp { display: flex; align-items: center; border: 1.5px solid var(--line); border-radius: 9px; padding: 6px 10px; margin-top: 4px; }
.price-card .inp span { color: var(--muted); font-weight: 700; }
.price-card input { border: none; width: 100%; font-family: inherit; font-weight: 700; font-size: 15px; }
.price-card input:focus { outline: none; }

/* ---------- Modal simple (reutiliza .modal-backdrop de discover.css si está) ---------- */
.pmodal-back { position: fixed; inset: 0; background: rgba(15,23,41,.55); z-index: 80; display: none; align-items: center; justify-content: center; padding: 20px; }
.pmodal-back.show { display: flex; }
.pmodal { background: #fff; border-radius: 20px; width: 440px; max-width: 100%; box-shadow: var(--shadow); animation: fade .2s; }
.pmodal .h { padding: 22px 24px 4px; position: relative; }
.pmodal .h h3 { font-size: 19px; font-weight: 800; }
.pmodal .h .x { position: absolute; top: 16px; right: 18px; border: none; background: var(--soft); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; color: var(--muted); font-size: 18px; }
.pmodal .b { padding: 12px 24px 22px; }
.pmodal .field { margin-bottom: 14px; }
.pmodal .field label { font-size: 13px; font-weight: 600; display: block; margin-bottom: 6px; }
.pmodal .field input { width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 11px; font-family: inherit; font-size: 15px; }
.pmodal .field input:focus { outline: none; border-color: var(--brand); }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 13px 22px; border-radius: 12px; font-size: 14px; font-weight: 600; z-index: 100; opacity: 0; transition: .25s; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.avatar { border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; flex: none; }

/* ---------- IDs y código de agencia ---------- */
.id-chip { display: inline-block; font-family: 'Consolas', monospace; font-size: 11.5px; font-weight: 700; color: var(--muted); background: var(--soft-2); border: 1px solid var(--line); border-radius: 7px; padding: 3px 8px; letter-spacing: .3px; }
.agency-code { margin-top: 10px; font-size: 12px; color: #6b7689; background: #1b2537; border-radius: 10px; padding: 9px 12px; }
.agency-code b { color: #fff; font-family: 'Consolas', monospace; letter-spacing: 1px; }

/* ---------- Modal grande (ficha de modelo) ---------- */
.pmodal-lg { width: 620px; max-height: 92vh; overflow-y: auto; }
.pmodal .pm-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.form-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pmodal .field select, .pmodal .field textarea { width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 11px; font-family: inherit; font-size: 15px; background: #fff; resize: vertical; }
.pmodal .field select:focus, .pmodal .field textarea:focus { outline: none; border-color: var(--brand); }
.pmodal .field .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.pmodal .form-msg { min-height: 20px; font-size: 13.5px; font-weight: 600; text-align: center; margin-bottom: 10px; }
.pmodal .form-msg.err { color: var(--danger); }
.pmodal .form-msg.ok { color: var(--ok); }

/* Slots de fotos */
.photo-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.photo-slot { aspect-ratio: 3/4; border: 2px dashed var(--line); border-radius: 13px; background: var(--soft-2); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-family: inherit; transition: .15s; position: relative; overflow: hidden; }
.photo-slot:hover { border-color: var(--brand); }
.photo-slot .ps-ic { font-size: 22px; }
.photo-slot .ps-lbl { font-size: 11px; font-weight: 600; color: var(--muted); text-align: center; padding: 0 4px; }
.photo-slot.filled { border-style: solid; border-color: var(--ok); }
.photo-slot.filled .ps-fill { position: absolute; inset: 0; display: grid; place-items: center; font-size: 26px; color: #fff; }
.photo-slot.filled .ps-check { position: absolute; top: 6px; right: 6px; background: var(--ok); color: #fff; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; }

/* ---------- Ficha de aprobación (admin) ---------- */
.approve-card { border: 1.5px solid var(--line); border-radius: 16px; padding: 18px; margin-bottom: 16px; display: grid; grid-template-columns: 150px 1fr auto; gap: 18px; align-items: start; }
.approve-card .ph-mini { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.approve-card .ph-mini > div { aspect-ratio: 3/4; border-radius: 8px; display: grid; place-items: center; color: #fff; font-size: 15px; }
.approve-card h4 { font-size: 16.5px; font-weight: 800; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.approve-card .meta-row { color: var(--muted); font-size: 13.5px; margin: 3px 0 8px; }
.approve-card .desc { font-size: 14px; margin-bottom: 6px; }
.approve-card .obs { font-size: 13px; color: var(--muted); background: var(--soft-2); border-radius: 9px; padding: 8px 11px; }
.approve-card .obs b { color: var(--ink); }
.approve-actions { display: flex; flex-direction: column; gap: 8px; min-width: 120px; }
.btn-approve { background: #16a34a; color: #fff; border: none; border-radius: 10px; padding: 10px 16px; font-weight: 700; font-size: 14px; cursor: pointer; font-family: inherit; }
.btn-approve:hover { filter: brightness(1.08); }
.btn-reject { background: #fff; color: var(--danger); border: 1.5px solid #fecaca; border-radius: 10px; padding: 10px 16px; font-weight: 700; font-size: 14px; cursor: pointer; font-family: inherit; }
.btn-reject:hover { background: #fef2f2; }
.nav-badge { background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; min-width: 19px; height: 19px; border-radius: 999px; display: inline-grid; place-items: center; padding: 0 5px; margin-left: auto; }

@media (max-width: 700px) { .form-cols { grid-template-columns: 1fr; } .photo-grid { grid-template-columns: 1fr 1fr; } .approve-card { grid-template-columns: 1fr; } }

/* ---------- Seguridad / roles ---------- */
.side-user .icon-btn { flex: none; }
.role-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 4px 11px; border-radius: 999px; color: #fff; }
.caps-list { display: flex; flex-wrap: wrap; gap: 5px; }
.cap-tag { background: var(--soft); color: var(--brand-2); font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 6px; }
.cap-tag.ro { background: #f1f5f9; color: #64748b; }

.role-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.role-info { border: 1.5px solid var(--line); border-radius: 14px; padding: 16px; }
.role-info .rh { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.role-info .rh .ric { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-size: 18px; color: #fff; }
.role-info .rh .rn { font-weight: 800; font-size: 15px; }
.role-info p { font-size: 13px; color: var(--muted); line-height: 1.5; }

/* Banner solo-lectura */
.ro-banner { position: fixed; top: 0; left: 252px; right: 0; z-index: 30; background: linear-gradient(90deg,#64748b,#0f1729); color: #fff; text-align: center; font-size: 13px; font-weight: 600; padding: 8px; display: none; }
.ro-banner.show { display: block; }
body.ro .panel-main { padding-top: 34px; }
@media (max-width: 900px) { .ro-banner { left: 0; } }

/* Elementos deshabilitados por permiso */
.locked { opacity: .45; pointer-events: none; filter: grayscale(.4); }
.nav-item[hidden] { display: none; }

/* ---------- Operadores (asignar modelos) ---------- */
.op-models { display: flex; flex-wrap: wrap; gap: 8px; }
.op-pick { display: inline-flex; align-items: center; gap: 8px; border: 1.5px solid var(--line); border-radius: 999px; padding: 6px 13px 6px 6px; cursor: pointer; font-family: inherit; font-size: 13.5px; font-weight: 600; background: #fff; transition: .12s; }
.op-pick:hover { border-color: var(--brand); }
.op-pick.on { border-color: var(--brand); background: var(--soft); color: var(--brand-2); }
.op-pick .op-av { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 12px; }
.op-pick .op-check { margin-left: 2px; opacity: 0; font-weight: 800; }
.op-pick.on .op-check { opacity: 1; color: var(--brand); }
.op-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.op-chip { background: var(--soft); color: var(--brand-2); font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; }

/* ---------- Quejas / PQR ---------- */
.chip-f { border: 1.5px solid var(--line); background: #fff; color: var(--muted); font-weight: 600; font-size: 13px; padding: 7px 14px; border-radius: 999px; cursor: pointer; font-family: inherit; }
.chip-f.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.cx-card { border: 1.5px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 14px; }
.cx-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.cx-type { font-weight: 800; font-size: 15px; }
.cx-meta { color: var(--muted); font-size: 12.5px; margin-left: auto; }
.cx-subject { font-weight: 700; font-size: 14.5px; margin-bottom: 4px; }
.cx-msg { font-size: 14px; color: #374151; background: var(--soft-2); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.cx-ids { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.cx-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.cx-reply-in { flex: 1; min-width: 180px; padding: 9px 12px; border: 1.5px solid var(--line); border-radius: 10px; font-family: inherit; font-size: 14px; }
.cx-reply-in:focus { outline: none; border-color: var(--brand); }
.cx-reply-shown { font-size: 13px; color: var(--ok); background: #f0fdf4; border-radius: 9px; padding: 8px 11px; margin-bottom: 10px; }
.cx-reply-shown b { color: #15803d; }

/* Ocultar controles de acción según capacidad ausente del rol */
body.no-handleComplaints .cx-actions { display: none; }
body.no-addAgency #addAgencyBtn { display: none; }
body.no-toggleAgency [data-toggle] { display: none; }
body.no-approveWithdraw [data-pay] { display: none; }
body.no-approve .approve-actions { display: none; }
body.no-approve .approve-card::after { content: '🔒 Sin permiso para decidir (solo lectura)'; align-self: center; font-size: 12px; color: var(--muted); font-weight: 600; }
/* Inputs bloqueados: aspecto deshabilitado */
input:disabled { background: var(--soft-2); color: var(--muted); cursor: not-allowed; }

@media (max-width: 900px) {
  .panel-app { grid-template-columns: 1fr; }
  .panel-side { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
}
