/* ===== Botones ===== */
.btn {
  font: inherit;
  font-weight: 600;
  padding: 8px 16px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn--primary { background: var(--c-primary); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--c-primary-600); }

.btn--secondary { background: var(--c-surface); color: var(--c-primary); border-color: var(--c-border-strong); }
.btn--secondary:hover:not(:disabled) { border-color: var(--c-primary); }

.btn--ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.45); }
.btn--ghost:hover:not(:disabled) { background: rgba(255,255,255,.12); }

.btn--sm { padding: 4px 10px; font-size: 12px; }

/* ===== Paneles del sidebar ===== */
.panel { border-bottom: 1px solid var(--c-border); }
.panel__title {
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--c-primary);
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border);
}
.panel__body { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }

.metric { font-size: 13px; color: var(--c-text-muted); }
.metric span { font-size: 22px; font-weight: 700; color: var(--c-primary); margin-right: 4px; }

/* ===== Formularios ===== */
.field { display: flex; flex-direction: column; gap: 4px; }
.field__label { font-size: 12px; font-weight: 600; color: var(--c-text-muted); }

.input, .select {
  font: inherit;
  padding: 7px 10px;
  color: var(--c-text);
  background: var(--c-surface);
  border: 1px solid var(--c-border-strong);
  width: 100%;
}
.input:focus, .select:focus { border-color: var(--c-accent); outline: none; }
.input:disabled, .select:disabled { background: var(--c-bg); color: var(--c-text-muted); }

/* ===== Estado de datos (barra superior) ===== */
.status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: rgba(255,255,255,.85); }
.status__dot { width: 9px; height: 9px; background: var(--c-warn); }       /* cuadrado: sin curvas */
.status--ok .status__dot       { background: var(--c-ok); }
.status--error .status__dot    { background: var(--c-error); }
.status--updating .status__dot { background: var(--c-warn); animation: pulse 1.2s infinite; }

@keyframes pulse { 50% { opacity: .25; } }

/* ===== Tarjeta (contenedor de cada gráfica) ===== */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
}
.card__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-bg);
}
.card__title  { font-size: 14px; color: var(--c-primary); }
.card__body   { padding: 14px; flex: 1; }

/* ===== Estado vacío ===== */
.empty {
  grid-column: 1 / -1;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 64px 24px;
  text-align: center;
  background: var(--c-surface);
  border: 1px dashed var(--c-border-strong);
}
.empty__icon { height: 48px; opacity: .85; margin-bottom: 8px; }
.empty h3 { color: var(--c-primary); }

/* ===== Notificaciones ===== */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  min-width: 260px; max-width: 380px;
  padding: 10px 14px;
  background: var(--c-surface);
  border: 1px solid var(--c-border-strong);
  border-left: 4px solid var(--c-primary);
}
.toast--error { border-left-color: var(--c-error); }
.toast--ok    { border-left-color: var(--c-ok); }

/* ===== Carga (esqueleto) ===== */
.skeleton {
  background: linear-gradient(90deg, var(--c-bg) 25%, var(--c-primary-50) 50%, var(--c-bg) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  min-height: 16px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ===== Listas y selección (Tarea 10) ===== */
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check input, .ent input { accent-color: var(--c-primary); width: 15px; height: 15px; margin: 0; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.inline  { display: flex; gap: 8px; }
.inline .input { flex: 1; min-width: 0; }

.counter { font-size: 12px; color: var(--c-text-muted); }
.counter strong { color: var(--c-primary); font-size: 14px; }

.list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--c-border); background: var(--c-surface); }
.list--scroll { max-height: 340px; overflow-y: auto; }
.list__item { border-bottom: 1px solid var(--c-border); }
.list__item:last-child { border-bottom: 0; }
.list__empty { padding: 12px; font-size: 13px; color: var(--c-text-muted); }

.ent {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; font-size: 13px; cursor: pointer;
  border-left: 3px solid transparent;
}
.ent:hover { background: var(--c-primary-50); }
.ent--selected { background: var(--c-primary-50); border-left-color: var(--c-primary); }
.ent__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tag {
  font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  padding: 1px 6px; color: var(--c-text-muted); border: 1px solid var(--c-border-strong);
}

.grp { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.grp__head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.grp__name { font-weight: 600; color: var(--c-primary); }
.grp__meta { font-size: 12px; color: var(--c-text-muted); cursor: help; }
.grp__actions { display: flex; gap: 6px; flex-wrap: wrap; }

.btn--danger { background: var(--c-surface); color: var(--c-error); border-color: var(--c-border-strong); }
.btn--danger:hover:not(:disabled) { border-color: var(--c-error); background: #FDF2F1; }

/* ===== Muestra de color (Tarea 11) ===== */
.swatch {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; padding: 0; flex: none;
  border: 1px solid var(--c-border-strong);
  background: none; cursor: pointer;
}
.swatch::-webkit-color-swatch-wrapper { padding: 0; }
.swatch::-webkit-color-swatch { border: 0; }
.swatch::-moz-color-swatch { border: 0; }
.grp__head { align-items: center; justify-content: flex-start; }
.grp__meta { margin-left: auto; }

/* ===== Modal y formulario del constructor (Tarea 13) ===== */
.modal {
  border: 1px solid var(--c-border-strong);
  padding: 0;
  width: min(880px, 94vw);
  max-height: 90vh;
  background: var(--c-surface);
  color: var(--c-text);
}
.modal[open] { display: flex; flex-direction: column; }
.modal::backdrop { background: rgba(43, 20, 89, .5); }

.modal__head, .modal__foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; background: var(--c-bg); flex: none;
}
.modal__head { border-bottom: 1px solid var(--c-border); }
.modal__head h2 { font-size: 16px; color: var(--c-primary); }
.modal__foot { border-top: 1px solid var(--c-border); justify-content: flex-end; gap: 8px; }
.modal__body { padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

.fs { border: 1px solid var(--c-border); margin: 0; padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.fs legend { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--c-primary); padding: 0 6px; }
.fs .check input[type="radio"] { accent-color: var(--c-primary); }

.cl { display: flex; flex-direction: column; gap: 8px; }
.cl .list--scroll { max-height: 220px; }
.opts { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; }

.dot { width: 10px; height: 10px; display: inline-block; flex: none; }
.form-error { padding: 8px 12px; color: var(--c-error); border: 1px solid var(--c-error); background: #FDF2F1; }

.card__actions { display: flex; gap: 6px; }
.chart__msg { padding: 48px 16px; text-align: center; }

@media (max-width: 700px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
}

/* ===== Tablero personalizable (Tarea 14) ===== */
.card__header { gap: 12px; }
.card__title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card__actions { flex-wrap: wrap; justify-content: flex-end; }
.card__header--drag { cursor: grab; }
.card__header--drag:active { cursor: grabbing; }

.card--dragging { opacity: .4; }
.card--over-before { box-shadow: inset 4px 0 0 var(--c-accent); }
.card--over-after  { box-shadow: inset -4px 0 0 var(--c-accent); }

.templates { margin-top: 20px; display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; width: 100%; }
.templates .field__label { width: 100%; text-align: center; }
.tpl {
  font: inherit; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 4px;
  width: 280px; padding: 12px 14px;
  background: var(--c-surface); color: var(--c-text);
  border: 1px solid var(--c-border-strong);
  border-left: 4px solid var(--c-primary);
}
.tpl:hover { background: var(--c-primary-50); border-color: var(--c-primary); }
.tpl strong { color: var(--c-primary); }
.tpl .muted { font-size: 12px; }

/* ===== Tablas de ranking (Tarea 15) ===== */
.tbl-wrap { display: flex; flex-direction: column; gap: 20px; }
.tbl-block__head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px; flex-wrap: wrap; }
.tbl-block__title { font-weight: 600; color: var(--c-primary-900); }
.tbl-scroll { overflow: auto; max-height: 520px; border: 1px solid var(--c-border); }

.tbl { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: 7px 12px; border-bottom: 1px solid var(--c-border); text-align: right; white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--c-bg); color: var(--c-primary);
  font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  cursor: pointer; user-select: none;
  border-bottom: 2px solid var(--c-primary);
}
.tbl thead th:hover { background: var(--c-primary-50); }
.tbl tbody tr:hover { background: var(--c-primary-50); }
.tbl .row--grupo td { background: #FBFAFE; font-weight: 600; }
.tbl tfoot td { background: var(--c-bg); font-weight: 600; color: var(--c-primary-900); }
.tbl tfoot tr:first-child td { border-top: 2px solid var(--c-border-strong); }
.tbl .name { display: inline-flex; align-items: center; gap: 8px; }
.tbl .pos { color: var(--c-ok); }
.tbl .neg { color: var(--c-error); }