/* ─── TOKENS ────────────────────────────────────────────────────────────── */
:root {
  --bg:              #F8FAFC;
  --bg-accent:       #F1F5F9;
  --surface:         #FFFFFF;
  --surface-strong:  #FFFFFF;
  --surface-muted:   #F8FAFC;
  --sidebar-bg:      #F8FAFC;
  --sidebar-border:  #E2E8F0;

  --text:            #0F172A;
  --text-soft:       #64748B;
  --line:            #E2E8F0;

  --primary:         #475569;
  --primary-strong:  #0F172A;
  --primary-soft:    #F1F5F9;

  --accent:          #14B8A6;

  --success:         #16A34A;
  --success-soft:    #DCFCE7;
  --danger:          #DC2626;
  --danger-soft:     #FEE2E2;

  --shadow-lg:       0 4px 24px rgba(15, 23, 42, 0.08);
  --shadow-md:       0 2px 12px rgba(15, 23, 42, 0.06);

  --radius-xl:       12px;

  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
}

/* ─── RESET ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button, input, select { font: inherit; }
h1, h2, h3, h4 { margin: 0; color: var(--primary-strong); }
p { margin: 0; }

/* ─── SHELL ──────────────────────────────────────────────────────────────── */
.panel-shell {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  min-height: 100vh;
}

/* ─── SIDEBAR ────────────────────────────────────────────────────────────── */
.panel-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 18px;
  border-bottom: 1px solid var(--line);
}

.sidebar-logo-mark {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  display: grid;
  place-items: center;
}

.sidebar-logo-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary-strong);
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 12px;
}

.nav-group:first-child { padding-top: 4px; }

.nav-group-label {
  display: block;
  padding: 0 10px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, color 0.12s;
}

.nav-link:hover {
  background: var(--bg-accent);
  color: var(--primary-strong);
}

.nav-link.active {
  background: var(--primary-strong);
  color: #fff;
}

.nav-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

.nav-label {
  font-size: 13px;
  font-weight: 500;
}

.sidebar-footer {
  padding: 12px 8px 16px;
  border-top: 1px solid var(--line);
}

.sidebar-client {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg-accent);
}

.sidebar-client-avatar {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.sidebar-client-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-strong);
}

/* ─── CONTENT AREA ───────────────────────────────────────────────────────── */
.panel-content {
  min-width: 0;
  background: var(--bg);
}

/* ─── SECTIONS ───────────────────────────────────────────────────────────── */
.panel-section {
  display: none;
  padding: 28px 32px 48px;
}

.panel-section.is-active { display: block; }

/* ─── PAGE HEADER ────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.page-header-main { min-width: 0; }

.page-breadcrumb {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin-bottom: 6px;
}

.page-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary-strong);
  line-height: 1.15;
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-soft);
  line-height: 1.5;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  padding-top: 4px;
}

/* ─── BUTTONS ────────────────────────────────────────────────────────────── */
.btn-primary,
.btn-save,
.btn-outline,
.ghost-btn,
.soft-btn,
.run-btn,
.picker-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, box-shadow 0.12s;
  white-space: nowrap;
}

.btn-primary, .run-btn {
  border: 0;
  background: var(--primary-strong);
  color: #fff;
}

.btn-primary:hover, .run-btn:hover {
  background: #1e293b;
}

.btn-save {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--primary-strong);
}

.btn-save:hover { background: var(--bg-accent); }

.btn-outline {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-soft);
}

.btn-outline:hover { color: var(--primary-strong); background: var(--bg-accent); }

.ghost-btn, .picker-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--primary-strong);
}

.ghost-btn:hover, .picker-btn:hover { background: var(--bg-accent); }

.soft-btn {
  border: 1px solid #fca5a5;
  background: #fff5f5;
  color: #dc2626;
}

.soft-btn:hover { background: #fee2e2; }

.btn-primary:disabled, .ghost-btn:disabled, .soft-btn:disabled, .btn-save:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.icon-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.icon-action-btn--edit {
  color: var(--primary-strong);
}

.icon-action-btn--edit:hover {
  background: var(--bg-accent);
}

.icon-action-btn--delete {
  color: var(--danger);
}

.icon-action-btn--delete:hover {
  background: var(--danger-soft);
}

/* ─── CARDS ──────────────────────────────────────────────────────────────── */
.panel-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 24px;
  margin-bottom: 20px;
}

.panel-card:last-child { margin-bottom: 0; }

/* ─── CLIENT BADGE (sidebar footer) ─────────────────────────────────────── */
.client-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--primary-strong);
  margin-bottom: 6px;
}

.client-badge-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.client-badge-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: 8px;
  border: 1px solid var(--sidebar-border);
  background: var(--surface);
  min-width: 0;
}
.sidebar-user[hidden] { display: none; }
.sidebar-user-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
  background: #e8f0fc; color: #1c5cab; font-size: 11px; font-weight: 700;
}
.sidebar-user-text { display: grid; min-width: 0; }
.sidebar-user-name { font-size: 13px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-role { font-size: 11px; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── SIDEBAR LOGOUT ─────────────────────────────────────────────────────── */
.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #ef4444;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s;
}

.sidebar-logout:hover { background: #fef2f2; }

/* ─── DASHBOARD ──────────────────────────────────────────────────────────── */
.dashboard-group {
  margin-bottom: 32px;
}

.dashboard-group-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary-strong);
  margin: 0 0 14px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.dashboard-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  text-align: left;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.dashboard-card:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-md);
}

.dashboard-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
}

.dashboard-card-icon svg { width: 20px; height: 20px; }

.dashboard-card-icon--accesos     { background: #f0f9ff; color: #0284c7; }
.dashboard-card-icon--disponibilidad { background: #fdf4ff; color: #9333ea; }
.dashboard-card-icon--replica     { background: #fff7ed; color: #ea580c; }
.dashboard-card-icon--config      { background: #f1f5f9; color: #475569; }

.dashboard-card-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--primary-strong);
  margin: 0;
}

.dashboard-card-desc {
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.5;
  flex: 1;
}

.dashboard-card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.dashboard-card-cta {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

/* ─── SUMMARY CARDS ──────────────────────────────────────────────────────── */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.summary-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 18px 20px;
}

.summary-card span {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-soft);
  margin-bottom: 8px;
}

.summary-card strong {
  display: block;
  font-size: 26px;
  font-weight: 700;
  color: var(--primary-strong);
  line-height: 1;
}

/* ─── SECTION HEAD ───────────────────────────────────────────────────────── */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.section-head h3 {
  font-size: 17px;
  font-weight: 700;
}

.section-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* ─── EYEBROW ────────────────────────────────────────────────────────────── */
.eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin-bottom: 4px;
}

/* ─── FORM ELEMENTS ──────────────────────────────────────────────────────── */
.form-grid,
.toolbar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.toolbar-grid { margin-bottom: 20px; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
}

input,
select {
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  transition: border-color 0.12s, box-shadow 0.12s;
}

input:focus,
select:focus {
  outline: none;
  border-color: #94a3b8;
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.06);
}

/* ─── STATUS ─────────────────────────────────────────────────────────────── */
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--line);
}

.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 16px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.status-chip.success {
  background: var(--success-soft);
  color: var(--success);
}

.status-chip.off {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ─── BADGES ─────────────────────────────────────────────────────────────── */
.chip, .badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  color: var(--primary-strong);
}

.chip.danger, .badge.warn {
  background: var(--danger-soft);
  border-color: #fca5a5;
  color: var(--danger);
}

.badge.success {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--success-soft);
  border-color: #86efac;
  color: var(--success);
}

.badge.success::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.badge.warn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.badge.warn::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
  flex-shrink: 0;
}

/* ─── TABLES ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

th {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
}

td {
  padding: 12px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  color: var(--text);
  font-size: 13px;
}

tr:last-child td { border-bottom: 0; }

/* ─── ENTITY CELL ────────────────────────────────────────────────────────── */
.entity-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.entity-avatar {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--primary-strong);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.entity-title {
  display: block;
  font-weight: 600;
  color: var(--primary-strong);
  font-size: 13px;
}

.entity-meta {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-soft);
}

/* ─── MESSAGE BOX ────────────────────────────────────────────────────────── */
.message-box {
  padding: 14px 18px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-muted);
  font-size: 13px;
  color: var(--text-soft);
  margin-bottom: 16px;
}

.message-box strong {
  display: block;
  margin-bottom: 6px;
  color: var(--primary-strong);
}

.message-box.error {
  border-color: #fca5a5;
  background: var(--danger-soft);
  color: var(--danger);
}

.message-box.success {
  border-color: #86efac;
  background: var(--success-soft);
  color: var(--success);
}

/* ─── UPLOAD CARD (collapsible) ──────────────────────────────────────────── */
.upload-card { margin-bottom: 20px; }

.upload-card summary { list-style: none; }
.upload-card summary::-webkit-details-marker { display: none; }

.upload-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
  user-select: none;
  padding: 2px 0;
}

.upload-toggle:hover .upload-chevron { color: var(--primary-strong); }

.upload-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-strong);
  margin: 0;
}

.upload-subtitle {
  font-size: 13px;
  color: var(--text-soft);
  margin: 3px 0 0;
}

.upload-chevron {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: var(--text-soft);
  transition: transform 0.2s ease, color 0.12s;
}

details[open] .upload-chevron { transform: rotate(180deg); }

.upload-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.upload-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ─── FORM HELPERS ───────────────────────────────────────────────────────── */
.req  { color: #dc2626; font-size: 12px; }
.opt  { font-size: 12px; color: var(--text-soft); font-style: normal; }
.field-label { font-size: 12px; font-weight: 600; color: var(--text-soft); }
.sr-only { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* ─── LIST HEADER (toolbar de tabla con buscador) ────────────────────────── */
.list-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 16px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.list-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.list-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-strong);
  margin: 0;
}

.list-count {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--bg-accent);
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-soft);
}

.list-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.list-search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.list-search svg { flex-shrink: 0; width: 14px; height: 14px; color: var(--text-soft); }

.list-search-input {
  border: 0;
  background: transparent;
  min-height: 32px;
  padding: 0;
  font-size: 13px;
  color: var(--text);
  width: 200px;
}

.list-search-input:focus { outline: none; }

/* ─── REPLICA ────────────────────────────────────────────────────────────── */
.replica-summary-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.replica-workspace { margin-top: 0; }

.replica-workspace-head { margin-bottom: 20px; }

.replica-layout { display: grid; gap: 16px; }

.replica-toolbar {
  padding: 20px;
  background: var(--surface);
}

.replica-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.replica-hint {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--text-soft);
}

.replica-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr);
  gap: 16px;
}

.replica-panel { padding: 20px; }

.replica-panel-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.replica-panel-head h3 {
  font-size: 17px;
  font-weight: 700;
}

.replica-panel-head p {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-soft);
}

.replica-logbox {
  margin: 0;
  min-height: 420px;
  padding: 18px;
  border-radius: 8px;
  background: #0f172a;
  color: #e2e8f0;
  overflow: auto;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.replica-logs { display: grid; gap: 10px; }

.replica-logitem {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
}

.replica-loghead {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.replica-loghead strong {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--primary-strong);
}

.replica-loghead span {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-soft);
}

.replica-logactions { display: flex; justify-content: flex-end; }

.replica-empty {
  padding: 20px 16px;
  border-radius: 10px;
  background: var(--surface-muted);
  color: var(--text-soft);
  font-size: 13px;
}

/* ─── UTILITIES ──────────────────────────────────────────────────────────── */
.is-hidden  { display: none !important; }
.negative   { color: var(--danger) !important; }
.success    { color: var(--success) !important; }

.empty-copy { color: var(--text-soft); font-size: 13px; display: block; margin-top: 4px; }

/* ─── DIRECTORIO AGENTES/CLIENTES (fila editable inline) ─────────────────── */
.compact-field { min-width: 170px; }
.compact-field input { min-height: 42px; }

.status-toggle-btn { min-width: 110px; }

.status-toggle-btn.is-enabled {
  background: var(--success-soft);
  color: var(--success);
  border-color: #cbe6d6;
}

.status-toggle-btn.is-disabled {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #f0cbc5;
}

/* Picker de "Tarifas visibles" por agente. La tabla de Agentes necesita overflow:visible
   (ver mas abajo) para que este dropdown flotante no quede recortado por .table-wrap,
   igual que CotoBlau necesita ese mismo ajuste en sus tablas con selectores similares. */
.tarifas-multiselect { position: relative; }

.tarifas-btn {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.tarifas-btn:hover { border-color: #94a3b8; }

.tarifas-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  display: grid;
  gap: 8px;
  width: max-content;
  min-width: 240px;
  max-height: 280px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

/* El atributo [hidden] pierde contra el display:grid de arriba si no se refuerza aqui -
   sin esto, TODOS los desplegables de tarifa se ven abiertos a la vez, uno debajo de otro. */
.tarifas-dropdown[hidden] { display: none; }

.tarifas-search-wrap { position: sticky; top: 0; }

.tarifas-search-input {
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--text);
  font-size: 13px;
}

.tarifas-options-list {
  display: grid;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
  padding-right: 2px;
}

.tarifas-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  padding: 4px;
  border-radius: 6px;
}

.tarifas-option[hidden] { display: none; }

.tarifas-option:hover { background: var(--bg-accent); }

.tarifas-option input { width: 15px; height: 15px; flex-shrink: 0; }

/* Deja que el dropdown se salga del contenedor con scroll horizontal de la tabla. */
#agentes .table-wrap,
#agentes .table-wrap table,
#agentes .table-wrap tbody,
#agentes .table-wrap tr,
#agentes .table-wrap td,
#familias .table-wrap,
#familias .table-wrap table,
#familias .table-wrap tbody,
#familias .table-wrap tr,
#familias .table-wrap td,
#marcas .table-wrap,
#marcas .table-wrap table,
#marcas .table-wrap tbody,
#marcas .table-wrap tr,
#marcas .table-wrap td {
  overflow: visible;
}

/* Selector de "agentes con acceso" en Marcas/Familias - mismo componente que
   .tarifas-multiselect, solo que lista agentes reales en vez de tarifas. */
.access-multiselect { position: relative; }

.access-btn {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.access-btn:hover { border-color: #94a3b8; }

.access-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  display: grid;
  gap: 8px;
  width: max-content;
  min-width: 240px;
  max-height: 280px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.access-dropdown[hidden] { display: none; }

.access-search-wrap { position: sticky; top: 0; }

.access-search-input {
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--text);
  font-size: 13px;
}

.access-options-list {
  display: grid;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
  padding-right: 2px;
}

.access-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  padding: 4px;
  border-radius: 6px;
}

.access-option[hidden] { display: none; }

.access-option:hover { background: var(--bg-accent); }

.access-option input { width: 15px; height: 15px; flex-shrink: 0; }

/* ─── FILE ZONE (banners + documentos) ──────────────────────────────────── */
.file-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 22px 16px;
  border: 1.5px dashed var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.12s, background 0.12s;
}

.file-zone:hover { border-color: #94a3b8; background: var(--bg-accent); }

.file-zone.is-dragover {
  border-color: var(--accent);
  background: #ecfeff;
}

.file-zone svg { width: 22px; height: 22px; color: var(--text-soft); margin-bottom: 6px; }

.file-zone-cta { font-size: 13px; font-weight: 600; color: var(--primary-strong); }

.file-zone-sub { font-size: 12px; color: var(--text-soft); }

.file-zone--lg { padding: 32px 24px; }

/* ─── BANNERS ────────────────────────────────────────────────────────────── */
.banner-form-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 24px;
  align-items: start;
}

.banner-form-fields {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.banner-preview-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.banner-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.banner-cell img {
  width: 56px;
  height: 36px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface-muted);
}

/* Picker de articulos sueltos (buscar + resultados + chips seleccionados) */
.banner-articles-picker { position: relative; }

.banner-articles-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 10;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.banner-article-result {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: 0;
  background: none;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

.banner-article-result:hover { background: var(--bg-accent); }

.banner-articles-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.banner-article-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 4px 6px 4px 10px;
  border-radius: 999px;
  background: var(--bg-accent);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 12px;
}

.banner-article-chip button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
}

.banner-article-chip button:hover { background: var(--danger-soft); color: var(--danger); }

/* ─── DOCUMENTOS ─────────────────────────────────────────────────────────── */
.doc-delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #dc2626;
  cursor: pointer;
  transition: background 0.12s;
}

.doc-delete-btn:hover { background: var(--danger-soft); }

/* ─── MODAL (detalle de pedido) ──────────────────────────────────────────── */
.stats-modal-shell {
  position: fixed;
  inset: 0;
  z-index: 100;
}

.stats-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(3px);
}

.stats-modal {
  position: relative;
  width: min(760px, calc(100vw - 40px));
  max-height: calc(100vh - 64px);
  overflow: auto;
  margin: 32px auto;
  padding: 20px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.2);
}

.stats-modal-close {
  position: sticky;
  top: 0;
  margin-left: auto;
  display: block;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--primary-strong);
  font-size: 18px;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  z-index: 1;
}

.stats-modal-layout { display: grid; gap: 14px; }

.stats-modal-header { display: flex; align-items: center; gap: 12px; }

.stats-modal-header h3 { margin: 0; color: var(--primary-strong); }

/* ─── RESPONSIVE ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  /* minmax(0, 1fr) y no 1fr: con 1fr la columna crece hasta el ancho minimo de su contenido
     (tablas, graficos) y la pagina se sale por la derecha en el movil */
  .panel-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .panel-sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding-bottom: 8px;
  }

  .sidebar-logo { border-bottom: 0; }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 8px;
    gap: 4px;
  }

  .nav-group {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding-top: 0;
    gap: 2px;
  }

  .nav-group-label { display: none; }

  .sidebar-footer { display: none; }

  .panel-section { padding: 20px 16px 40px; }

  .page-header { flex-direction: column; }

  .replica-grid { grid-template-columns: 1fr; }

  .replica-summary-grid { grid-template-columns: 1fr 1fr; }

  .list-header { flex-wrap: wrap; }
  .list-header-right { flex-wrap: wrap; width: 100%; }
  .list-search-input { width: 140px; }

  .banner-form-layout { grid-template-columns: 1fr; }
}

/* ─── TICKETS (soporte DAAP) ─────────────────────────────────────────────────
   Adaptado de panel/public/tickets.css de Pielsa. Ojo: no hay clase .hidden generica en este
   panel, cada overlay tiene su propia regla. */
.nav-badge {
  margin-left: auto;
  background: #e11d48;
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  border-radius: 999px;
  padding: 1px 7px;
  min-width: 18px;
  text-align: center;
  line-height: 1.5;
}
.nav-badge.hidden { display: none; }

.unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: #e11d48;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.tickets-table tbody tr.ticket-row { cursor: pointer; }
.tickets-table tbody tr.ticket-row:hover { background: var(--surface-muted); }
.tickets-table tbody tr.row-unread { background: #fff8f8; }
.tickets-table tbody tr.row-unread td:nth-child(3) { font-weight: 700; }
.ticket-actions { white-space: nowrap; }
.ticket-actions .btn-outline { margin-left: 4px; }
.ticket-adjunto-badge { margin-left: 6px; font-size: 11px; color: var(--text-soft); }

.status-chip.warn { background: #fef3c7; color: #92400e; }
.status-chip.neutral { background: var(--bg-accent); color: var(--text-soft); }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
}
.modal-overlay.hidden { display: none; }

.modal-card {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#ticketDetailModal .modal-card { max-width: 640px; }

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--line);
}
.modal-header h3 { font-size: 18px; font-weight: 700; margin: 4px 0 0; }
.modal-close-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-muted);
  color: var(--text-soft);
  cursor: pointer;
}
.modal-close-btn:hover { background: var(--danger-soft); color: var(--danger); }
.modal-body { padding: 20px 24px; overflow-y: auto; max-height: 65vh; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  background: var(--surface-muted);
}

.ticket-form { display: grid; gap: 16px; }
.ticket-form label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-soft); }
.ticket-form input,
.ticket-form select,
.ticket-form textarea {
  font-family: inherit;
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--surface);
}
.ticket-form textarea { resize: vertical; }
.ticket-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.ticket-modulo-opciones { display: flex; flex-wrap: wrap; gap: 8px; }
.ticket-form label.ticket-modulo-pastilla {
  position: relative;
  display: inline-flex;
  align-items: center;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.ticket-modulo-pastilla input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.ticket-form label.ticket-modulo-pastilla:has(input:checked) { background: var(--accent); border-color: var(--accent); color: #fff; }
.ticket-fotos-info { margin: -4px 0 0; font-size: 12px; color: var(--text-soft); }
@media (max-width: 640px) { .ticket-form-row { grid-template-columns: 1fr; } }

.ticket-detail-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.ticket-detail-meta div { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--text-soft); }
.ticket-detail-meta strong { font-size: 13px; color: var(--text); font-weight: 600; }
.ticket-detail-desc {
  white-space: pre-wrap;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  margin: 0 0 12px;
}
.ticket-detail-adjuntos { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.ticket-detail-adjuntos img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  cursor: zoom-in;
}
.ticket-detail-subtitle {
  margin: 18px 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-soft);
}
.ticket-comentarios { display: grid; gap: 8px; max-height: 220px; overflow-y: auto; margin-bottom: 10px; }
.ticket-comentarios-empty { font-size: 12px; color: var(--text-soft); margin: 0; }
.ticket-comentario {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  font-size: 13px;
}
.ticket-comentario.es-daap { background: #f0fdfa; border-color: #ccfbf1; }
.ticket-comentario-header { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-soft); margin-bottom: 4px; }
.ticket-comentario-form { display: grid; gap: 8px; }
.ticket-comentario-form textarea {
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  resize: vertical;
}

.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(10, 12, 18, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.lightbox-overlay.hidden { display: none; }
.lightbox-overlay img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.lightbox-close {
  position: fixed;
  top: 20px;
  right: 24px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  cursor: pointer;
}

/* Selector de dia del log de replicas + ultima ejecucion de cada bloque/job */
.replica-log-date {
  width: auto;
  min-width: 170px;
}

.replica-lastrun {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-soft);
}

.replica-lastrun.is-fail {
  color: var(--danger);
}

/* ─── DASHBOARD DE USO DEL B2B (Inicio) ──────────────────────────────────
   Panel propio y bien separado del resto de Inicio (cabecera "B2B"), con pestañas para no
   enseñarlo todo a la vez. Paleta validada (dataviz validate_palette.js, light, fondo #FFFFFF):
   agente = azul #2a78d6, cliente = naranja #eb6834; año anterior = gris de contexto. */
.b2b {
  --dash-agente: #2a78d6;
  --dash-cliente: #eb6834;
  --dash-actual: #2a78d6;
  --dash-anterior: #a8a29e;
  --dash-track: #dbe8f8;
  --dash-grid: #eeece9;
  --dash-up: #006300;
  --dash-down: #d03b3b;
  --dash-warn: #b45309;
  --b2b-ink: #0f172a;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  margin-bottom: 32px;
  overflow: hidden;
}
.b2b-head {
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 18px 22px; background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%); border-bottom: 1px solid var(--line);
}
.b2b-brand { display: flex; align-items: center; gap: 14px; }
.b2b-badge {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 12px;
  background: var(--b2b-ink); color: #fff; font-weight: 700; font-size: 14px; letter-spacing: 0.04em;
}
.b2b-title { margin: 0; font-size: 18px; font-weight: 650; color: var(--text); }
.b2b-sub { margin: 2px 0 0; font-size: 13px; color: var(--text-soft); }
.b2b-tools { display: flex; align-items: center; gap: 10px; }
.b2b-year { width: auto; min-width: 92px; }
.b2b-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 5px 10px; border-radius: 999px; white-space: nowrap; }
.b2b-status.is-ok { background: #e7f5e9; color: var(--dash-up); }
.b2b-status.is-warn { background: #fef3c7; color: var(--dash-warn); }
.b2b-tabs { display: flex; gap: 4px; padding: 0 16px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.b2b-tab {
  appearance: none; border: 0; background: none; padding: 12px 12px 10px; font-size: 13px; font-weight: 500;
  color: var(--text-soft); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap;
}
.b2b-tab:hover { color: var(--text); }
.b2b-tab.is-active { color: var(--text); border-bottom-color: var(--b2b-ink); font-weight: 600; }
.b2b-body { padding: 20px 22px 22px; }
.b2b-note { margin: 0 0 16px; font-size: 12px; color: var(--text-soft); }
.b2b-panel[hidden] { display: none; }

/* Resumen: cifra protagonista + 3 datos */
.b2b-hero-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 2fr); gap: 16px; align-items: stretch; }
.b2b-hero { background: var(--b2b-ink); color: #fff; border-radius: 14px; padding: 20px 22px; }
.b2b-hero-label { font-size: 13px; opacity: 0.75; }
.b2b-hero-value { font-size: 40px; font-weight: 700; letter-spacing: -0.02em; margin: 6px 0 8px; line-height: 1.05; }
.b2b-hero-delta { font-size: 13px; opacity: 0.9; }
.b2b-hero-delta .is-up { color: #86efac; }
.b2b-hero-delta .is-down { color: #fca5a5; }
.b2b-minis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.b2b-mini { border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; display: flex; flex-direction: column; justify-content: center; }
.b2b-mini-label { font-size: 12px; color: var(--text-soft); }
.b2b-mini-value { font-size: 24px; font-weight: 650; color: var(--text); margin: 4px 0; }
.b2b-delta { font-size: 12px; color: var(--text-soft); }
.b2b-delta b { font-weight: 600; white-space: nowrap; }
.b2b-delta .is-up { color: var(--dash-up); }
.b2b-delta .is-down { color: var(--dash-down); }
.b2b-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; margin-top: 16px; }
.b2b-block { border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; min-width: 0; }
.b2b-block-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.b2b-block-head h3 { margin: 0; font-size: 14px; font-weight: 600; color: var(--text); }

/* ¿Quien hace los pedidos? */
.b2b-who { display: grid; gap: 14px; }
.b2b-who-item { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: center; }
.b2b-who-dot { width: 12px; height: 12px; border-radius: 50%; }
.b2b-who-name { font-size: 14px; font-weight: 600; color: var(--text); }
.b2b-who-pct { font-size: 26px; font-weight: 700; color: var(--text); text-align: right; }
.b2b-who-meta { grid-column: 2 / -1; font-size: 12px; color: var(--text-soft); }
.b2b-who-bar { display: flex; height: 10px; gap: 2px; border-radius: 5px; overflow: hidden; margin-top: 4px; }
.b2b-who-bar span { display: block; height: 100%; }
.b2b-who-foot { font-size: 12px; color: var(--text-soft); margin-top: 2px; }

/* Agentes / Clientes */
.b2b-adopt { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 20px; align-items: center; padding: 4px 0 18px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.b2b-ring { width: 96px; height: 96px; }
.b2b-adopt-title { font-size: 20px; font-weight: 650; color: var(--text); margin: 0; }
.b2b-adopt-sub { font-size: 13px; color: var(--text-soft); margin: 4px 0 0; }
.b2b-list-title { font-size: 12px; font-weight: 600; color: var(--text-soft); margin: 0 0 8px; text-transform: uppercase; letter-spacing: 0.05em; }
.b2b-rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.b2b-rank li { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 2px 12px; align-items: center; }
.b2b-avatar { grid-row: span 3; width: 36px; height: 36px; border-radius: 10px; background: var(--primary-soft); color: var(--text); font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.b2b-rank-pos .b2b-avatar { background: var(--b2b-ink); color: #fff; }
.b2b-rank-name { font-size: 13px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b2b-rank-val { font-size: 13px; font-weight: 600; color: var(--text); text-align: right; white-space: nowrap; }
.b2b-rank-bar { grid-column: 2 / -1; height: 6px; border-radius: 3px; background: var(--dash-track); overflow: hidden; }
.b2b-rank-bar span { display: block; height: 100%; border-radius: 3px; background: var(--dash-actual); }
.b2b-rank-meta { grid-column: 2 / -1; font-size: 11px; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b2b-more { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.b2b-more summary { cursor: pointer; font-size: 13px; color: var(--text-soft); }
.b2b-more[open] summary { margin-bottom: 12px; }
.b2b-more .b2b-rank-bar span { background: var(--dash-anterior); }

/* Productos */
.b2b-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.b2b-bars li { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; }
.b2b-bars .b2b-pos { grid-row: span 2; font-size: 13px; font-weight: 700; color: var(--text-soft); text-align: center; }
.b2b-bars .b2b-bars-name { font-size: 13px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b2b-bars .b2b-bars-val { font-size: 13px; font-weight: 600; color: var(--text); text-align: right; white-space: nowrap; }
.b2b-bars .b2b-bars-track { grid-column: 2 / -1; height: 8px; border-radius: 4px; background: var(--dash-track); overflow: hidden; }
.b2b-bars .b2b-bars-track span { display: block; height: 100%; border-radius: 4px; background: var(--dash-actual); }
.b2b-bars .b2b-bars-meta { grid-column: 2 / -1; font-size: 11px; color: var(--text-soft); }

/* Actividad */
.b2b-cols { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; }
.b2b-feed { list-style: none; margin: 0; padding: 0; }
.b2b-feed li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.b2b-feed li:first-child { border-top: 0; padding-top: 0; }
.b2b-feed-icon { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 11px; font-weight: 700; }
.b2b-feed-main { min-width: 0; }
.b2b-feed-title { font-size: 13px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b2b-feed-meta { font-size: 11px; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b2b-feed-val { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; }
.b2b-empty { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--text-soft); background: var(--surface-muted); border: 1px dashed var(--line); border-radius: 12px; padding: 12px 14px; }

/* Graficos (compartido) */
.dash-legend { display: flex; gap: 12px; font-size: 12px; color: var(--text-soft); }
.dash-key { display: inline-flex; align-items: center; gap: 6px; }
.dash-key i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.dash-key i.is-line { height: 2px; width: 14px; border-radius: 1px; }
.dash-chart { position: relative; height: 230px; }
.dash-chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.dash-chart .dash-hit { fill: transparent; }
.dash-chart .dash-band.is-hover { fill: rgba(15, 23, 42, 0.04); }
.dash-tip {
  position: absolute; pointer-events: none; z-index: 5; background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: var(--shadow-md); padding: 8px 10px; font-size: 12px; color: var(--text-soft); min-width: 150px;
}
.dash-tip strong { color: var(--text); font-weight: 600; }
.dash-tip-row { display: flex; align-items: center; gap: 6px; justify-content: space-between; margin-top: 3px; }
.dash-tip-row span:first-child { display: inline-flex; align-items: center; gap: 6px; }
.dash-tip-row i { display: inline-block; width: 12px; height: 2px; border-radius: 1px; }
.dash-table-toggle { margin-top: 8px; font-size: 12px; color: var(--text-soft); }
.dash-table-toggle summary { cursor: pointer; }
.dash-table-toggle table { width: 100%; margin-top: 8px; font-size: 12px; }
.dash-table-toggle td, .dash-table-toggle th { padding: 4px 6px; text-align: right; font-variant-numeric: tabular-nums; }
.dash-table-toggle td:first-child, .dash-table-toggle th:first-child { text-align: left; }
.b2b.is-loading .b2b-body { opacity: 0.55; transition: opacity 0.15s; }

@media (max-width: 1100px) {
  .b2b-hero-row, .b2b-row, .b2b-cols { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .b2b-minis { grid-template-columns: 1fr; }
  .b2b-hero-value { font-size: 32px; }
  .b2b-body { padding: 16px; }
  .b2b-adopt { grid-template-columns: 1fr; }
}

/* Comparacion con el año anterior en pestañas del dashboard B2B */
.b2b-chip { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--primary-soft); color: var(--text-soft); white-space: nowrap; vertical-align: 1px; }
.b2b-chip.is-up { background: #e7f5e9; color: var(--dash-up); }
.b2b-chip.is-down { background: #fdecec; color: var(--dash-down); }
.b2b-chip.is-new { background: #e8f0fc; color: #1c5cab; }
.b2b-stats { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 10px; }
.b2b-stat { font-size: 12px; color: var(--text-soft); display: inline-flex; align-items: center; gap: 6px; }
.b2b-stat b { color: var(--text); font-size: 14px; }
.b2b-who-meta b.is-up { color: var(--dash-up); }
.b2b-who-meta b.is-down { color: var(--dash-down); }

/* Clientes que entran en la web B2B pero todavia no compran (pestaña Clientes).
   Embudo en rampa ordinal azul validada (#1c5cab -> #2a78d6 -> #6da7ec, --ordinal PASS). */
.b2b-web {
  position: relative; border-radius: 16px; padding: 20px 22px; margin-bottom: 22px;
  background: linear-gradient(135deg, #fff6f1 0%, #ffffff 55%); border: 1px solid #f6d9cb; overflow: hidden;
}
.b2b-web::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--dash-cliente); }
.b2b-web-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 18px; }
.b2b-web-kicker { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #b4471b; }
.b2b-web-kicker i { width: 6px; height: 6px; border-radius: 50%; background: var(--dash-cliente); box-shadow: 0 0 0 4px rgba(235, 104, 52, 0.15); }
.b2b-web-title { margin: 6px 0 4px; font-size: 20px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.b2b-web-sub { margin: 0; font-size: 13px; color: var(--text-soft); max-width: 640px; }
.b2b-web-big { text-align: right; }
.b2b-web-big strong { display: block; font-size: 44px; line-height: 1; font-weight: 800; color: var(--text); letter-spacing: -0.03em; }
.b2b-web-big span { font-size: 12px; color: var(--text-soft); }

.b2b-funnel { display: grid; gap: 8px; margin-bottom: 20px; }
.b2b-funnel-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 64px; gap: 12px; align-items: center; }
.b2b-funnel-label { font-size: 13px; color: var(--text); font-weight: 500; }
.b2b-funnel-track { height: 26px; border-radius: 8px; background: rgba(15, 23, 42, 0.04); overflow: hidden; }
.b2b-funnel-fill { display: block; height: 100%; border-radius: 8px; transition: width 0.4s ease; }
.b2b-funnel-val { font-size: 13px; font-weight: 700; color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }
.b2b-funnel-step { grid-column: 2 / -1; font-size: 11px; color: var(--text-soft); margin: -4px 0 2px 2px; }

.b2b-leads { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.b2b-lead {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px;
  display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 4px 10px; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.b2b-lead:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.b2b-lead-avatar {
  grid-row: span 2; width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800; color: #b4471b; background: #fde8dd;
}
.b2b-lead-name { font-size: 14px; font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b2b-lead-place { grid-column: 2 / -1; font-size: 12px; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b2b-lead-when { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; white-space: nowrap; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 12px; color: var(--text-soft); }
.b2b-lead-when b { color: var(--text); font-variant-numeric: tabular-nums; }
.b2b-lead-pill { align-self: start; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #fde8dd; color: #b4471b; white-space: nowrap; }
.b2b-lead-pill.is-fresh { background: #e8f0fc; color: #1c5cab; }
.b2b-lead-foot { grid-column: 1 / -1; font-size: 11px; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b2b-lead-foot b { color: var(--text); font-weight: 600; }
.b2b-web-more { margin-top: 12px; }
.b2b-web-more summary { cursor: pointer; font-size: 13px; color: var(--text-soft); }
.b2b-web-more[open] summary { margin-bottom: 12px; }

.b2b-web-empty { display: flex; gap: 16px; align-items: center; padding: 18px; border-radius: 14px; background: rgba(255, 255, 255, 0.8); border: 1px dashed #f0c3ad; }
.b2b-web-empty-icon { flex: none; width: 48px; height: 48px; border-radius: 14px; background: #fde8dd; color: #b4471b; display: flex; align-items: center; justify-content: center; }
.b2b-web-empty strong { display: block; font-size: 14px; color: var(--text); margin-bottom: 2px; }
.b2b-web-empty span { font-size: 13px; color: var(--text-soft); }
@media (max-width: 640px) {
  .b2b-funnel-row { grid-template-columns: 110px minmax(0, 1fr) 48px; }
  .b2b-web-big { text-align: left; }
}

/* ─── ESTADISTICAS DE VENTAS ─────────────────────────────────────────────
   Facturas de Etendo (Power BI), mismas pestañas que Natural. Reutiliza el .b2b del dashboard de
   Inicio (misma paleta validada: año analizado = azul #2a78d6, comparado = gris de contexto) y
   añade filtros, KPIs, tarjetas pulsables con detalle en ventana, barras dobles por agente y el
   reparto en barras 100 % (rampa ordinal azul por puesto + gris para el resto). */
.st [hidden], .st-chips[hidden], #stEmpty[hidden], #stModal [hidden] { display: none !important; }
.st-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.is-up { color: var(--dash-up, #006300); }
.is-down { color: var(--dash-down, #d03b3b); }
.st-hint { font-size: 12px; color: var(--text-soft); margin: 8px 0 0; }
.st-hint b { color: var(--text); }
.st-block-gap { margin-top: 16px; }

/* Filtros */
.st-filters {
  display: grid; grid-template-columns: 110px 130px minmax(0, 1fr) minmax(0, 1.3fr); gap: 12px; align-items: end;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px;
  box-shadow: var(--shadow-md); margin-bottom: 12px;
}
.st-filter { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.st-filter > span { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-soft); }
.st-filter select { width: 100%; }
.st-client { position: relative; }
.st-client-box {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 0 10px;
  background: var(--surface); height: 38px;
}
.st-client-box:focus-within { border-color: #2a78d6; box-shadow: 0 0 0 3px rgba(42, 120, 214, 0.15); }
.st-client-box svg { width: 15px; height: 15px; color: var(--text-soft); flex: none; }
.st-client-box input { border: 0; outline: 0; background: none; width: 100%; font-size: 13px; color: var(--text); padding: 0; }
.st-client-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 20; list-style: none; margin: 0; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); max-height: 320px; overflow: auto;
}
.st-client-list li { padding: 8px 10px; border-radius: 8px; cursor: pointer; display: grid; gap: 1px; }
.st-client-list li b { font-size: 13px; color: var(--text); font-weight: 600; }
.st-client-list li span { font-size: 11px; color: var(--text-soft); }
.st-client-list li:hover, .st-client-list li[aria-selected="true"] { background: #eef4fc; }
.st-client-list .st-client-none { cursor: default; font-size: 13px; color: var(--text-soft); }
.st-client-list .st-client-none:hover { background: none; }
.st-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 12px; }
.st-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-soft);
  background: #e8f0fc; border: 1px solid #cfe0f7; border-radius: 999px; padding: 4px 6px 4px 12px;
}
.st-chip b { color: #1c5cab; font-weight: 600; }
.st-chip button {
  appearance: none; border: 0; width: 20px; height: 20px; border-radius: 50%; background: rgba(28, 92, 171, 0.12);
  color: #1c5cab; font-size: 14px; line-height: 1; cursor: pointer;
}
.st-chip button:hover { background: rgba(28, 92, 171, 0.22); }
.st-chip-clear { appearance: none; border: 0; background: none; font-size: 12px; color: var(--text-soft); text-decoration: underline; cursor: pointer; }

/* Agentes: KPIs + destacados */
.st-kpis { display: grid; grid-template-columns: 1.3fr repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.st-kpi { border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; display: grid; gap: 4px; align-content: center; background: var(--surface); }
.st-kpi > span { font-size: 12px; color: var(--text-soft); }
.st-kpi > b { font-size: 26px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.st-kpi > small { font-size: 12px; color: var(--text-soft); }
.st-kpi.is-hero { background: linear-gradient(135deg, #0f172a 0%, #17325c 60%, #1c5cab 130%); border-color: transparent; color: #fff; position: relative; overflow: hidden; }
.st-kpi.is-hero::after {
  content: ""; position: absolute; right: -40px; bottom: -70px; width: 190px; height: 190px; border-radius: 50%;
  background: radial-gradient(circle, rgba(109, 167, 236, 0.35) 0%, rgba(109, 167, 236, 0) 70%); pointer-events: none;
}
.st-kpi.is-hero > span, .st-kpi.is-hero > small { color: rgba(255, 255, 255, 0.8); }
.st-kpi.is-hero > b { color: #fff; font-size: 30px; }
.st-kpi.is-hero .is-up { color: #86efac; }
.st-kpi.is-hero .is-down { color: #fca5a5; }
.st-highs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.st-high {
  position: relative; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px 12px 18px; display: grid; gap: 2px;
  background: linear-gradient(180deg, #fbfcfe 0%, #ffffff 100%); overflow: hidden; min-width: 0;
}
.st-high::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: #2a78d6; }
.st-high.is-good::before { background: var(--dash-up); }
.st-high.is-new::before { background: #6da7ec; }
.st-high.is-bad::before { background: var(--dash-down); }
.st-high > span { font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-soft); }
.st-high > b { font-size: 14px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-high > small { font-size: 13px; font-weight: 600; color: var(--text); }
.st-high.is-good > small { color: var(--dash-up); }
.st-high.is-bad > small { color: var(--dash-down); }

.st-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; font-size: 12px; color: var(--text-soft); }
.st-agents { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.st-agent {
  appearance: none; width: 100%; border: 0; background: none; text-align: left; font: inherit; color: inherit; cursor: pointer;
  display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 4px 12px; align-items: center;
  padding: 10px 12px; border-radius: 12px; transition: background 0.15s ease;
}
.st-agent:hover:not([disabled]), .st-agent:focus-visible { background: #f3f7fd; outline: none; }
.st-agent[disabled] { cursor: default; }
.st-agent .b2b-avatar { grid-row: span 3; }
.b2b-avatar.is-top { background: var(--b2b-ink); color: #fff; }
.st-agent-name { font-size: 13px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-agent-name small { font-weight: 400; font-size: 11px; color: var(--text-soft); margin-left: 8px; }
.st-agent-val { font-size: 14px; font-weight: 700; color: var(--text); white-space: nowrap; text-align: right; }
.st-pair { grid-column: 2 / -1; display: grid; gap: 2px; }
.st-pair span { display: block; border-radius: 0 4px 4px 0; }
.st-pair-a { height: 8px; background: var(--dash-actual); }
.st-pair-b { height: 4px; background: var(--dash-anterior); }
.st-agent-meta, .st-meta-wrap { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11px; color: var(--text-soft); white-space: normal; }
.st-agent-meta b { color: var(--text); font-weight: 600; }
.st-tag { font-weight: 600; padding: 0 6px; border-radius: 999px; }
.st-tag.is-up { background: #e7f5e9; }
.st-tag.is-down { background: #fdecec; }
.st-expand {
  appearance: none; display: block; width: 100%; margin-top: 10px; padding: 9px; border: 1px dashed var(--line); border-radius: 10px;
  background: var(--surface-muted); color: var(--text-soft); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
}
.st-expand:hover { color: #1c5cab; border-color: #cfe0f7; background: #f3f7fd; }
.st-table-wrap { overflow-x: auto; }
.st-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.st-table th { text-align: right; font-weight: 600; color: var(--text-soft); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.st-table td { text-align: right; padding: 9px 10px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text); }
.st-table th:first-child, .st-table td:first-child { text-align: left; white-space: normal; }
.st-table tbody tr:hover td { background: #f8fafd; }
.st-td-sub { display: block; font-size: 11px; color: var(--text-soft); }
.st-rank li { grid-template-columns: 36px minmax(0, 1fr) auto; }
.st-link {
  appearance: none; border: 0; background: none; padding: 0; font: inherit; text-align: left; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--text);
}
.st-link:hover, .st-link:focus-visible { color: #1c5cab; text-decoration: underline; outline: none; }
.st-badge { display: inline-flex; align-items: center; font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--primary-soft); color: var(--text-soft); white-space: nowrap; }
.st-badge.is-good { background: #e7f5e9; color: var(--dash-up); }
.st-badge.is-new { background: #e8f0fc; color: #1c5cab; }
.st-diff { font-weight: 600; white-space: nowrap; }

/* Ventas / Articulos: tarjetas pulsables */
.st-cards { display: grid; grid-template-columns: minmax(0, 1.25fr) repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.st-card {
  border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; background: var(--surface); cursor: pointer; min-width: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.st-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: #cfe0f7; }
.st-card-head { display: grid; grid-template-columns: 1fr auto; gap: 0 8px; align-items: baseline; margin-bottom: 12px; }
.st-eyebrow { grid-column: 1; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #1c5cab; }
.st-card-title { grid-column: 1; font-size: 16px; font-weight: 700; color: var(--text); }
.st-card-more {
  grid-column: 2; grid-row: 1 / span 2; align-self: center; appearance: none; border: 0; background: #eef4fc; color: #1c5cab;
  font: inherit; font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 999px; cursor: pointer; white-space: nowrap;
}
.st-bill { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.st-bill-panel { border-radius: 12px; padding: 12px; background: var(--surface-muted); border: 1px solid var(--line); display: grid; gap: 4px; min-width: 0; }
.st-bill-panel.is-current { background: #0f172a; border-color: #0f172a; color: #fff; }
.st-bill-year { font-size: 12px; font-weight: 700; color: var(--text-soft); display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.st-bill-panel.is-current .st-bill-year { color: rgba(255, 255, 255, 0.75); }
.st-bill-amount { font-size: 20px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.st-bill-panel.is-current .st-bill-amount { color: #fff; }
.st-bill-row { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--text-soft); }
.st-bill-row b { color: var(--text); white-space: nowrap; margin-left: auto; }
.st-bill-row { flex-wrap: wrap; }
.st-bill-panel.is-current .st-bill-row { color: rgba(255, 255, 255, 0.7); }
.st-bill-panel.is-current .st-bill-row b { color: #fff; }
.st-bill-panel.is-current .st-diff.is-up { color: #86efac; }
.st-bill-panel.is-current .st-diff.is-down { color: #fca5a5; }
.st-progress-line { height: 6px; border-radius: 3px; background: var(--dash-track); margin-top: 14px; overflow: hidden; }
.st-progress-line span { display: block; height: 100%; background: var(--dash-actual); border-radius: 3px; }
.st-big { display: flex; align-items: baseline; gap: 8px; }
.st-big b { font-size: 34px; font-weight: 800; letter-spacing: -0.03em; color: var(--text); line-height: 1.1; }
.st-big span { font-size: 13px; color: var(--text-soft); }
.st-inline { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.st-metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-bottom: 12px; }
.st-metric { background: var(--surface-muted); border-radius: 10px; padding: 8px 10px; display: grid; gap: 2px; min-width: 0; }
.st-metric span { font-size: 11px; color: var(--text-soft); }
.st-metric b { font-size: 14px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-list-title { font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-soft); margin: 12px 0 6px; }
.st-mini-list { list-style: none; margin: 0; padding: 0; display: grid; }
.st-mini-list li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.st-mini-list li:first-child { border-top: 0; }
.st-pos { width: 24px; height: 24px; border-radius: 8px; background: var(--primary-soft); color: var(--text); font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.st-mini-main { display: grid; min-width: 0; }
.st-mini-main b, .st-mini-amount b { font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-mini-main small, .st-mini-amount small { font-size: 11px; color: var(--text-soft); }
.st-mini-amount { display: grid; text-align: right; }
.st-thumb { width: 40px; height: 40px; border-radius: 10px; object-fit: contain; background: #f4f6f9; border: 1px solid var(--line); flex: none; }
.st-thumb.is-big { width: 56px; height: 56px; border-radius: 12px; }
.st-thumb.is-none { display: inline-block; background: repeating-linear-gradient(45deg, #f1f5f9 0 6px, #e8edf3 6px 12px); }

/* Reparto */
.st-rp-toolbar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 12px; align-items: end; margin-bottom: 14px; }
.st-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.st-seg button { appearance: none; border: 0; background: none; font: inherit; font-size: 13px; padding: 8px 12px; color: var(--text-soft); cursor: pointer; }
.st-seg button + button { border-left: 1px solid var(--line); }
.st-seg button.is-active { background: #0f172a; color: #fff; font-weight: 600; }
.st-rp-bar { display: grid; grid-template-columns: 150px minmax(0, 1fr) 120px; gap: 12px; align-items: center; margin: 10px 0; }
.st-rp-year { font-size: 12px; font-weight: 600; color: var(--text-soft); }
.st-rp-bar > b { font-size: 13px; text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
.st-rp-track { display: flex; gap: 2px; height: 22px; border-radius: 6px; overflow: hidden; background: var(--dash-track); }
.st-rp-track span { display: block; height: 100%; }
.st-rp-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 12px; color: var(--text-soft); margin-top: 8px; }
.st-rp-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.st-rp-row {
  appearance: none; width: 100%; font: inherit; text-align: left; cursor: pointer; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px;
  display: grid; grid-template-columns: 12px minmax(0, 1fr) repeat(2, 110px) 72px; gap: 12px; align-items: center;
}
.st-rp-row:hover { border-color: #cfe0f7; background: #f8fbff; }
.st-rp-dot { width: 12px; height: 12px; border-radius: 4px; }
.st-rp-name { display: grid; min-width: 0; }
.st-rp-name b { font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-rp-name small, .st-rp-cell small { font-size: 11px; color: var(--text-soft); }
.st-rp-cell { display: grid; text-align: right; }
.st-rp-cell b { font-size: 14px; color: var(--text); }
.st-rp-row .b2b-chip { justify-self: end; }

/* Web vs facturacion */
.st-info { font-size: 12px; color: #1e3a5f; background: #eef4fc; border: 1px solid #cfe0f7; border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; }
.st-web-agents { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.st-web-agents li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; }
.st-web-name { display: grid; min-width: 0; }
.st-web-name b { font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-web-name small, .st-web-meta { font-size: 11px; color: var(--text-soft); }
.st-web-meta b { color: var(--text); font-weight: 600; }
.st-web-pct { font-size: 18px; font-weight: 700; color: var(--text); text-align: right; display: grid; line-height: 1.1; }
.st-web-pct small { font-size: 11px; font-weight: 600; }
.st-web-bars { grid-column: 1 / -1; position: relative; height: 12px; }
.st-web-fact { position: absolute; left: 0; top: 0; height: 12px; border-radius: 0 4px 4px 0; background: #c3daf7; }
.st-web-web { position: absolute; left: 0; top: 3px; height: 6px; border-radius: 0 3px 3px 0; background: #2a78d6; box-shadow: 0 0 0 2px #fff; }
.st-web-cols { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.st-web-cols .b2b-block { min-width: 0; }
.st-hint-top { margin: -4px 0 8px; }
.st-cli-row { cursor: pointer; border-radius: 8px; }
.st-cli-row:hover, .st-cli-row:focus-visible { background: #f3f7fd; outline: none; }

/* Ventana de detalle */
.st-modal-card { max-width: 980px; }
.st-modal-body { max-height: 75vh; }
.st-search { width: 100%; height: 40px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; font-size: 13px; margin-bottom: 10px; }
.st-search:focus { outline: none; border-color: #2a78d6; box-shadow: 0 0 0 3px rgba(42, 120, 214, 0.15); }
.st-chipbar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.st-fchip { appearance: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 12px; color: var(--text-soft); cursor: pointer; }
.st-fchip.is-active { background: #0f172a; border-color: #0f172a; color: #fff; font-weight: 600; }
.st-details { display: grid; gap: 8px; margin-top: 10px; }
.st-detail {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 12px; cursor: pointer; transition: border-color 0.15s ease, background 0.15s ease;
}
.st-detail:hover { border-color: #cfe0f7; background: #f8fbff; }
.st-detail-main { display: grid; gap: 2px; min-width: 0; }
.st-detail-main b { font-size: 14px; color: var(--text); }
.st-detail-main small { font-size: 12px; color: var(--text-soft); }
.st-detail-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.st-detail-nums { display: grid; text-align: right; align-content: start; gap: 2px; font-size: 12px; }
.st-detail-nums b { font-size: 15px; color: var(--text); }
.st-detail-nums small { color: var(--text-soft); }
.st-compare-head { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 4px 0 8px; font-size: 12px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-soft); }
.st-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.st-compare-empty { grid-column: 1 / -1; }
.st-art-list { display: grid; gap: 8px; }
.st-art {
  appearance: none; font: inherit; text-align: left; cursor: pointer; width: 100%; min-width: 0;
  display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; gap: 12px; align-items: center;
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--surface);
}
.st-art-list .st-art { grid-template-columns: auto minmax(0, 1fr) auto; }
.st-art:hover { border-color: #cfe0f7; background: #f8fbff; }
.st-art.is-empty { border-style: dashed; background: none; cursor: default; min-height: 78px; }
.st-art-pos { font-size: 13px; font-weight: 700; color: var(--text-soft); min-width: 22px; text-align: center; }
.st-art-main { display: grid; gap: 1px; min-width: 0; }
.st-art-main b { font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-art-main small { font-size: 11px; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-art-val { font-size: 14px; font-weight: 700; color: var(--text); white-space: nowrap; display: grid; text-align: right; }
.st-art-val small { font-size: 11px; font-weight: 400; color: var(--text-soft); }
.st-back { appearance: none; border: 0; background: none; font: inherit; font-size: 13px; color: #1c5cab; cursor: pointer; padding: 0; margin-bottom: 10px; }
.st-art-head { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; align-items: start; margin-bottom: 14px; }
.st-art-head > div > b { display: block; font-size: 16px; color: var(--text); }
.st-art-head > div > small { display: block; font-size: 12px; color: var(--text-soft); margin-bottom: 8px; }
.st-modal-chart .dash-chart { height: 240px; }

/* Sin datos */
.st-empty {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; margin-bottom: 16px;
  border: 1px dashed #f0d58a; border-radius: 14px; background: #fffbeb;
}
.st-empty > span:last-child { display: grid; gap: 2px; }
.st-empty-icon { flex: none; width: 44px; height: 44px; border-radius: 12px; background: #fef3c7; color: #b45309; display: flex; align-items: center; justify-content: center; }
.st-empty-icon svg { width: 22px; height: 22px; }
.st-empty strong { font-size: 14px; color: var(--text); }
.st-empty span span { font-size: 13px; color: var(--text-soft); }

@media (max-width: 1200px) {
  .st-cards { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 1100px) {
  .st-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .st-kpis, .st-highs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .st-rp-toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .st-cards, .st-compare, .st-compare-head, .st-web-cols { grid-template-columns: 1fr; }
  .st-rp-bar { grid-template-columns: 1fr; gap: 4px; }
  .st-rp-bar > b { text-align: left; }
  .st-rp-row { grid-template-columns: 12px minmax(0, 1fr) 90px; }
  .st-rp-row .st-rp-cell:first-of-type, .st-rp-row .b2b-chip { display: none; }
}
@media (max-width: 640px) {
  .st-filters, .st-kpis, .st-highs, .st-rp-toolbar { grid-template-columns: 1fr; }
  .st-bill { grid-template-columns: 1fr; }
}

/* Clientes: tarifa asignada en Etendo que ya ha terminado (routes/usuarios.js#directorio/clientes) */
.tarifa-terminada {
  display: inline-block; margin-top: 3px; font-size: 11px; font-weight: 600; color: #b45309;
  background: #fef3c7; border-radius: 999px; padding: 1px 8px;
}
.tarifa-aviso-box {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin: 0 0 14px; padding: 12px 14px; border-radius: 12px; background: #fffbeb; border: 1px solid #f0d58a;
}
.tarifa-aviso-box strong { display: block; font-size: 13px; color: var(--text); }
.tarifa-aviso-box span { font-size: 12px; color: var(--text-soft); }

/* Agentes / Clientes: filtro por acceso al B2B */
.d-estado { width: auto; min-width: 190px; }

/* ── Documentos (panel CLENAPAL) ─────────────────────────────────────── */
.doc-agente { margin-bottom: 14px; }
.doc-inactivos-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-soft); cursor: pointer; }
.doc-inactivos-toggle input { width: auto; height: auto; min-height: 0; margin: 0; }
.doc-inactivo td { color: var(--text-soft); }
.doc-fichero { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; word-break: break-all; }
.doc-tamano { color: var(--text-soft); white-space: nowrap; }
.doc-error { font-size: 12px; color: var(--danger); margin: 4px 0; max-width: 260px; }
.btn-outline.btn-sm { padding: 4px 10px; font-size: 12px; min-height: 0; }
.doc-agentes { display: grid; gap: 8px; }
.doc-agentes-lista { max-height: 240px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 6px; display: grid; gap: 2px; }
.ticket-form label.doc-agente-item { display: flex; flex-direction: row; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; font-weight: 400; cursor: pointer; }
.ticket-form label.doc-agente-item:hover { background: var(--bg-accent); }
.ticket-form label.doc-agente-item input { width: auto; min-height: 0; }
.ticket-form label.doc-activo { display: flex; flex-direction: row; align-items: center; gap: 8px; }
.ticket-form label.doc-activo input { width: auto; min-height: 0; }
.ticket-form label.doc-activo[hidden] { display: none; }

/* Imagenes adjuntas a un comentario (pendientes de enviar) */
.ticket-comentario-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.ticket-comentario-adjuntar { cursor: pointer; }
.ticket-comentario-pendientes { display: flex; flex-wrap: wrap; gap: 8px; }
.ticket-comentario-pendientes:empty { display: none; }
.ticket-comentario-pendiente { position: relative; }
.ticket-comentario-pendiente img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); display: block; }
.ticket-comentario-pendiente button { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; border: none; background: #1f2937; color: #fff; font-size: 13px; line-height: 20px; padding: 0; cursor: pointer; }
