/* ====== Variables de color ====== */
:root {
  --bg: #f9fafb;          /* gris muy claro */
  --card: #ffffff;        /* blanco puro para tarjetas */
  --text: #1f2937;        /* gris oscuro para texto */
  --muted: #6b7280;       /* gris medio */
  --line: #e5e7eb;        /* gris claro para bordes */
  --primary: #d5001c;     /* rojo Toyota */
  --primary-dark: #a60015;
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 10px;
  --shadow: 0 2px 6px rgba(0,0,0,.08);
}

/* ====== Reset básico ====== */
* { box-sizing: border-box; }
html, body { height: 100%; margin:0; padding:0; font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--text); }
a { text-decoration:none; color: var(--primary); }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 6px 10px; text-align: left; }

/* ====== Layout ====== */
.container {
  max-width: 75%;
  margin: 0 auto;
  padding: 16px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.header h1 {
  font-size: 1.4rem;
  font-weight: 700;
}

/* ====== Cards ====== */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

/* ====== Botones ====== */
.btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .2s;
}
.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* ====== Tablas ====== */
.mini-table th {
  background: var(--bg);
  border-bottom: 2px solid var(--line);
  font-weight: 600;
}
.mini-table td {
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

/* ====== Formularios ====== */
input, select, textarea {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 14px;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

textarea { resize: vertical; }

/* ====== Utilidades ====== */
.flex { display: flex; }
.gap-2 { gap: 8px; }
.grid2 { display:grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mt-2 { margin-top: 8px; }

/* ====== Badges ====== */
.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  margin-right: 4px;
  color: #fff;
}
.badge.ok { background: var(--ok); }
.badge.warn { background: var(--warn); }
.badge.bad { background: var(--bad); }


/* ====== DEALERS ROW en admin/users ====== */
.dealerRow {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
}

.dealerRow input[type="checkbox"] {
  flex: 0 0 20px;   /* ancho fijo pequeño */
  margin: 0;
}

.dealerName {
  flex: 1;          /* ocupa todo el espacio sobrante */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis; /* si es muy largo, añade … */
}

.tree { --line:#e5e7eb; --muted:#6b7280; }
.tree .group { border:1px solid var(--line); border-radius:10px; margin-bottom:8px; }
.tree .group > summary { cursor:pointer; list-style:none; padding:10px 12px; display:flex; align-items:center; gap:8px; }
.tree .group > summary::-webkit-details-marker { display:none; }
.tree .chips { display:flex; gap:6px; flex-wrap:wrap; }
.tree .chip { font-size:11px; background:#f3f4f6; border:1px solid var(--line); border-radius:999px; padding:2px 8px; color:#111; }
.tree .chip.warn { background:#fff7ed; border-color:#fdba74; color:#9a3412; }
.tree .list { padding:8px 12px 12px; border-top:1px solid var(--line); display:grid; grid-template-columns:repeat(2, minmax(0,1fr)); gap:6px; }
.tree label { display:flex; align-items:center; gap:8px; padding:6px 8px; border:1px solid var(--line); border-radius:8px; background:#fff; }
.tree .right { margin-left:auto; font-size:12px; color:var(--muted); display:flex; gap:8px; align-items:center; }
.tree .badge { padding:2px 6px; border-radius:999px; border:1px solid var(--line); background:#f9fafb; }
.tree .badge.pending { background:#fef2f2; border-color:#fecaca; color:#991b1b; }
.tree .badge.zero { background:#f0fdf4; border-color:#bbf7d0; color:#166534; }
.tree .conflict { font-size:11px; color:#b91c1c; }


/* --- modo compacto árbol --- */
.tree.compact { --gap:6px; --pad:6px; --font:13px; --font-mini:11px; }
.tree.compact details.group{ margin:4px 0; border-radius:6px; }
.tree.compact details.group>summary{
  padding:4px 8px; gap:8px; font-size:var(--font);
}
.tree.compact .dealer-row{
  padding:2px 8px; gap:8px; align-items:center;
}
.tree.compact .dealer-row .name{
  font-size:var(--font); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.tree.compact .counts{ margin-left:auto; display:flex; gap:6px; align-items:center; }
.tree.compact .badge{ font-size:var(--font-mini); padding:1px 6px; border-radius:999px; }
.tree.compact .pill{ font-size:var(--font-mini); padding:1px 6px; }

.tree.compact input[type="checkbox"]{
  inline-size:14px; block-size:14px;
  margin:0 4px 0 0; transform:scale(.9); accent-color:#111;
}
