/* Olimpo — sistema visual mínimo compartido por todos los módulos.
   Paleta Moldeamos: #1A0F2E · #3B1B4F · #7A2E6F · #D6598F · #F4D7D4 · #FF6B6B.
   Lienzo blanco; el ciruela (#7A2E6F) es el único acento de acción; el coral avisa. */
:root {
  --bg: #ffffff;
  --surface: #faf7f9;
  --ink: #1A0F2E;
  --ink-2: #3B1B4F;
  --ink-3: #8f7f9c;
  --line: #ece3ea;
  --accent: #7A2E6F;
  --accent-ink: #ffffff;
  --accent-soft: #F4D7D4;
  --accent-2: #D6598F;
  --deep: #1A0F2E;
  --ok: #7A2E6F;
  --warn: #D6598F;
  --danger: #FF6B6B;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px -16px rgba(0,0,0,.18);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; }
.muted { color: var(--ink-2); }
.tiny { font-size: .8rem; color: var(--ink-3); }

/* Barra superior común */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.brand .crumb { color: var(--ink-3); font-weight: 400; }
.topbar nav { display: flex; gap: 6px; }
.topbar nav a { padding: 6px 10px; border-radius: 8px; color: var(--ink-2); }
.topbar nav a.active, .topbar nav a:hover { background: var(--surface); color: var(--ink); }

.wrap { max-width: 1100px; margin: 0 auto; padding: 24px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 860px) { .grid.cols-4, .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 540px) { .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; } .wrap { padding: 16px; } }

.card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card.soft { background: var(--surface); box-shadow: none; }
.card h3 { margin-bottom: 6px; }

/* Botones */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; min-height: 40px; }
.btn:hover { background: var(--surface); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(.95); }
.btn.danger { color: #d94f4f; border-color: #ffd0d0; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.sm { padding: 6px 10px; min-height: 32px; font-size: .9rem; }

/* Formularios */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: .85rem; color: var(--ink-2); }
.field input, .field select, .field textarea { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: 16px; /* 16px evita zoom en iOS */ }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.field .hint { font-size: .78rem; color: var(--ink-3); }
.field.prefilled input, .field.prefilled textarea { background: #fbeeec; }
fieldset { border: 0; padding: 0; margin: 0 0 22px; }
legend { font-weight: 600; margin-bottom: 12px; padding: 0; display: flex; align-items: center; gap: 10px; }
legend .n { width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: #fff; font-size: .8rem; display: inline-flex; align-items: center; justify-content: center; }
.check { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.check input { width: 18px; height: 18px; }

/* Chips / estados */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .8rem; border: 1px solid var(--line); background: var(--surface); white-space: nowrap; }
.chip.no_iniciado { color: var(--ink-2); }
.chip.disenado { background: #F4D7D4; border-color: #ecc3c0; color: #7A2E6F; }
.chip.producido { background: #fbe6ef; border-color: #f2c3d6; color: #b83f73; }
.chip.enviado { background: #7A2E6F; border-color: #7A2E6F; color: #fff; }
.chip.facturado { background: #1A0F2E; color: #fff; border-color: #1A0F2E; }
.chip.no_facturado { color: var(--ink-3); }
.chip.revisar { background: #fff0ee; border-color: #ffc9c4; color: #d94f4f; }

/* Tablero de conteos */
.stat { display: flex; flex-direction: column; gap: 4px; cursor: pointer; transition: transform .08s ease; }
.stat:hover { transform: translateY(-1px); }
.stat .num { font-size: 2rem; font-weight: 600; letter-spacing: -0.02em; }
.stat .lbl { color: var(--ink-2); font-size: .9rem; }
.stat.active { outline: 2px solid var(--accent); }

/* Tabla */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; color: var(--ink-3); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
tr.row:hover td { background: var(--surface); cursor: pointer; }
@media (max-width: 700px) { .hide-sm { display: none; } }

/* Mensajes */
.alert { padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); }
.alert.error { background: #fff0ee; border-color: #ffc9c4; color: #c94444; }
.alert.ok { background: var(--accent-soft); border-color: #ecc3c0; color: var(--accent); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: .9rem; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 50; }
.toast.show { opacity: 1; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(20,20,20,.35); display: none; align-items: center; justify-content: center; padding: 16px; z-index: 40; }
.modal-bg.open { display: flex; }
.modal { background: var(--bg); border-radius: var(--radius); max-width: 560px; width: 100%; padding: 22px; max-height: 90vh; overflow: auto; }

/* Línea de tiempo (historial) */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 8px 0 8px 18px; border-left: 2px solid var(--line); position: relative; font-size: .9rem; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 14px; width: 10px; height: 10px; border-radius: 50%; background: var(--ink-3); }

/* Pasos de estado */
.steps { display: flex; gap: 6px; flex-wrap: wrap; }
.steps .step { flex: 1; min-width: 110px; padding: 10px; border-radius: 10px; border: 1px solid var(--line); text-align: center; font-size: .9rem; color: var(--ink-3); }
.steps .step.done { background: var(--surface); color: var(--ink-2); }
.steps .step.current { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.steps .step.done { background: var(--surface); color: var(--ink-2); border-color: #e3d3e0; }
