/* BE Detailing OS — identidad: negro y dorado del logo. Panel de trabajo claro para leer bien al sol, barra negra como el logo. */
:root {
  --ink: #000000;
  --page: #ededeb;
  --panel: #ffffff;
  --text: #121212;
  --muted: #66665f;
  --line: #d9d9d4;
  --gold: #cca040;
  --gold-deep: #7d5f16;      /* dorado legible como texto sobre blanco */
  --on-ink: #f4f2ec;
  --ok: #2f7a55;
  --bad: #b3413a;
  --radius: 6px;
  --font: "Bahnschrift", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.45; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }

/* ── Estructura ── */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--ink); color: var(--on-ink); padding: 22px 16px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px; overflow-y: auto; }
.side .brand { display: block; padding: 4px 8px 8px; }
.side .brand img { width: 150px; height: auto; display: block; margin: 0 auto; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 12px; border-radius: var(--radius); text-decoration: none; color: #c9c7c0; border-left: 3px solid transparent; }
.nav a:hover { background: #161616; color: #fff; }
.nav a[aria-current="page"] { color: #fff; background: #151515; border-left-color: var(--gold); font-weight: 600; }
.nav .soon { font-size: 11px; color: #85837c; border: 1px solid #2c2c2c; border-radius: 10px; padding: 0 7px; }
.nav .group { margin: 14px 12px 4px; font-size: 12px; color: #85837c; }
.side .foot { margin-top: auto; font-size: 12px; color: #85837c; padding: 0 8px; }
.topbar { display: none; }
.main { padding: 26px 32px 60px; max-width: 1240px; width: 100%; }

/* ── Encabezado ── */
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.head h1 { margin: 0; font-size: 30px; line-height: 1.1; font-weight: 700; letter-spacing: -0.01em; }
.head .date { color: var(--muted); margin-top: 4px; text-transform: capitalize; }
.demo { border: 1px solid var(--gold); color: var(--gold-deep); background: #fbf5e6; border-radius: var(--radius); padding: 6px 10px; font-size: 13px; max-width: 360px; }
h2 { font-size: 18px; margin: 34px 0 12px; font-weight: 700; }
h2 small { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 8px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }

/* ── Flujo de trabajo (lo primero que se ve) ── */
.flow { background: var(--ink); color: var(--on-ink); border-radius: var(--radius); padding: 14px 16px 16px; }
.flow-title { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 14px; color: #b9b7b0; margin-bottom: 10px; }
.flow-title b { color: #fff; font-weight: 600; }
.stages { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.stage { appearance: none; border: 0; text-align: left; font: inherit; color: inherit; cursor: pointer; text-decoration: none; display: block;
  background: linear-gradient(90deg, #1a1a1a, #101010); border-radius: 4px; padding: 12px 12px 10px; border-bottom: 3px solid #2a2a2a; }
.stage:hover { background: linear-gradient(90deg, #232323, #161616); }
.stage .count { font-size: 34px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.stage .label { font-size: 13px; color: #b9b7b0; margin-top: 6px; }
.stage.is-on { background: linear-gradient(90deg, #4a3a12, #1a1509 75%); border-bottom-color: var(--gold); }
.stage.is-on .count { color: var(--gold); }
.stage.is-zero .count { color: #6a6862; }

/* ── Marcador de cifras (hoy / mes) ── */
.score { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.stat { padding: 16px 18px; border-left: 1px solid var(--line); min-width: 0; }
.stat:first-child { border-left: 0; }
.stat-label { color: var(--muted); font-size: 14px; }
.stat { container-type: inline-size; }
.stat-value { font-size: clamp(17px, 12cqi, 30px); font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; white-space: nowrap; }
.stat-note { color: var(--muted); font-size: 13px; margin-top: 2px; }
.stat.is-due .stat-value { color: var(--gold-deep); }
.insight { margin-top: 10px; padding: 12px 16px; border-left: 4px solid var(--gold); background: var(--panel); border-radius: 0 var(--radius) var(--radius) 0; border-top: 1px solid var(--line); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }

/* ── Resumen: por cobrar / comprometido ── */
.trio { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 14px; margin-top: 14px; }
.tile { padding: 16px 18px; display: block; text-decoration: none; }
a.tile:hover { border-color: var(--gold); }
.tile .k { color: var(--muted); font-size: 14px; }
.tile { container-type: inline-size; }
.tile .v { font-size: clamp(18px, 10cqi, 28px); font-weight: 700; margin: 2px 0 6px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tile .n { color: var(--muted); font-size: 13px; }
.aging { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: #ececE8; margin: 10px 0 8px; }
.aging i { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; background: var(--c); }

/* ── Tablas ── */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip { appearance: none; font: inherit; font-size: 13.5px; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 5px 12px; border-radius: 16px; cursor: pointer; text-decoration: none; display: inline-block; }
.chip:hover { border-color: var(--gold); }
.chip.is-on { background: var(--ink); color: #fff; border-color: var(--ink); }
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 13px; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fafaf8; }
td { padding: 10px 12px; border-bottom: 1px solid #ececE8; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfaf5; }
th.r, td.r { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { white-space: normal; min-width: 200px; }
.plate { font-weight: 700; letter-spacing: 0.04em; }
.muted { color: var(--muted); }
.due { color: var(--gold-deep); font-weight: 600; }
.late { color: var(--bad); font-weight: 600; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c, #999); }
.empty { padding: 22px; color: var(--muted); }
tr[hidden] { display: none; }

/* ── Gráfico ── */
.controls { display: flex; flex-wrap: wrap; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); align-items: center; }
.controls label { color: var(--muted); font-size: 13.5px; display: flex; gap: 8px; align-items: center; }
select { font: inherit; font-size: 14px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; color: var(--text); }
#chart { padding: 10px 14px 4px; }
#chart svg { width: 100%; height: auto; display: block; }
#chart text { font-family: var(--font); font-size: 11.5px; fill: var(--muted); }
.note { color: var(--muted); font-size: 13px; padding: 8px 14px 14px; }

/* ── Página próximamente ── */
.soon-box { padding: 26px; max-width: 640px; }
.soon-box h1 { margin: 0 0 8px; font-size: 26px; }

/* ── Móvil ── */
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 56px 0 0 0; height: auto; z-index: 20; display: none; padding-top: 12px; }
  .side.open { display: flex; }
  .side .brand { display: none; }
  .topbar { display: flex; position: sticky; top: 0; z-index: 30; height: 56px; align-items: center; justify-content: space-between; padding: 0 14px; background: var(--ink); color: #fff; }
  .topbar .t { display: flex; align-items: center; gap: 10px; font-weight: 700; }
  .topbar img { width: 30px; height: 30px; }
  .menu-btn { appearance: none; border: 1px solid #333; background: #111; color: #fff; font: inherit; padding: 8px 14px; border-radius: var(--radius); min-height: 40px; }
  .main { padding: 16px 14px 48px; }
  .head h1 { font-size: 26px; }
  .stages { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stage .count { font-size: 28px; }
  .score { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
  .stat-value { font-size: clamp(17px, 9cqi, 24px); }
  .trio { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: no-preference) { .stage, .chip, .nav a { transition: background-color .15s, border-color .15s; } }

/* ── Formulario: nueva orden ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 20px 22px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid .f { display: flex; flex-direction: column; gap: 6px; }
.form-grid label { font-size: 13.5px; color: var(--muted); font-weight: 600; }
.form-grid input, .form-grid select, .form-grid textarea { font: inherit; font-size: 15px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; color: var(--text); min-height: 44px; }
.form-grid textarea { min-height: 64px; resize: vertical; }
.svc-groups { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.svc-group { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px 12px; }
.svc-group legend { font-size: 13px; font-weight: 700; color: var(--muted); padding: 0 4px; }
.svc-row { display: flex; align-items: center; gap: 8px; padding: 7px 2px; font-size: 14px; cursor: pointer; }
.svc-row input { width: 18px; height: 18px; min-height: auto; flex-shrink: 0; }
.svc-row span { flex: 1; }
.svc-row .svc-price { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; font-size: 13px; }
.quote-box { padding: 16px 20px; border: 1px solid var(--line); }
.quote-line { display: flex; justify-content: space-between; padding: 5px 0; font-size: 14.5px; }
.quote-line b { font-variant-numeric: tabular-nums; }
.quote-total { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 10px; font-size: 19px; font-weight: 700; }
@media (max-width: 960px) { .form-grid { grid-template-columns: 1fr; padding: 16px; } .svc-groups { grid-template-columns: 1fr; } }

/* ── Formulario: precio editable por línea ── */
.svc-row { justify-content: space-between; }
.svc-row .svc-price-input { width: 100px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; min-height: 36px; padding: 6px 8px; }
.svc-row input[type="checkbox"]:not(:checked) ~ .svc-price-input { opacity: .45; }

/* ── Botón de WhatsApp (color oficial de la marca) ── */
.chip-whatsapp { background: #25D366; border-color: #25D366; color: #fff; font-weight: 600; }
.chip-whatsapp:hover { background: #1ebe5a; border-color: #1ebe5a; }

/* ── Texto libre del cliente (Detalle servicio y comentario): que nunca se salga de la pantalla,
   incluso si alguien escribe una palabra o un texto muy largo sin espacios. ── */
.wrap-anywhere { overflow-wrap: anywhere; word-break: break-word; }

/* Pantallas de acceso */
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; padding: 24px 16px; background: var(--bg, #faf8f3); }
.auth-logo { width: 160px; max-width: 50vw; height: auto; }
.auth-card { width: 100%; max-width: 420px; grid-template-columns: 1fr !important; }

/* Edición de precios */
.price-in { width: 104px; max-width: 100%; text-align: right; font: inherit; font-variant-numeric: tabular-nums; font-weight: 600; padding: 6px 8px; min-height: 40px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; color: var(--text); }
.vis { display: inline-flex; align-items: center; gap: 4px; margin-left: 10px; font-size: 12.5px; color: var(--muted); font-weight: 400; }
