:root {
  --fondo: #f6f7f9;
  --panel: #ffffff;
  --texto: #1c1f24;
  --suave: #6b7280;
  --linea: #e3e6ea;
  --marca: #1f2937;
  --acento: #e8590c;
  --ok: #2b8a3e;
  --mal: #c92a2a;
  --radio: 8px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--fondo); color: var(--texto); }
a { color: inherit; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 24px 0 8px; }
.cargando { padding: 40px; text-align: center; color: var(--suave); }

/* barra superior */
.barra { display: flex; align-items: center; gap: 16px; padding: 0 20px; height: 56px; background: var(--marca); color: #fff; position: sticky; top: 0; z-index: 10; }
.barra select { width: auto; max-width: 220px; flex: none; background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 6px; padding: 6px 8px; font-weight: 600; }
.barra select option { color: #000; }
.barra nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.barra nav a { color: #d1d5db; text-decoration: none; padding: 6px 10px; border-radius: 6px; white-space: nowrap; }
.barra nav a.activo, .barra nav a:hover { background: rgba(255,255,255,.14); color: #fff; }
.barra .yo { font-size: 13px; color: #d1d5db; white-space: nowrap; }
.barra .yo a { margin-left: 10px; }

main { max-width: 1180px; margin: 0 auto; padding: 24px 20px 80px; }
.encabezado { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.filtros { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.filtros input[type=search] { min-width: 260px; }

.panel { background: var(--panel); border: 1px solid var(--linea); border-radius: var(--radio); padding: 16px; }
.tabla { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--linea); border-radius: var(--radio); overflow: hidden; }
.tabla th { text-align: left; font-weight: 600; font-size: 12px; color: var(--suave); text-transform: uppercase; letter-spacing: .03em; padding: 10px 12px; border-bottom: 1px solid var(--linea); background: #fafbfc; }
.tabla td { padding: 10px 12px; border-bottom: 1px solid var(--linea); vertical-align: top; }
.tabla tr:last-child td { border-bottom: 0; }
.tabla tr.clic { cursor: pointer; }
.tabla tr.clic:hover td { background: #f8fafc; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.suave { color: var(--suave); }
.pie-tabla { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; color: var(--suave); font-size: 13px; }

.estado { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: #eef0f3; color: #374151; text-transform: capitalize; }
.estado.enviada, .estado.enviado { background: #e7f0fd; color: #1c4f9c; }
.estado.aceptada, .estado.pagado { background: #e3f6e8; color: #1e6b33; }
.estado.rechazada, .estado.anulado { background: #fdecec; color: #9b2222; }

/* formularios */
label { display: block; font-size: 12px; font-weight: 600; color: var(--suave); margin-bottom: 4px; }
input, select, textarea { font: inherit; color: inherit; border: 1px solid #cfd4da; border-radius: 6px; padding: 7px 9px; background: #fff; width: 100%; }
textarea { resize: vertical; min-height: 38px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9ec5fe; border-color: #6ea8fe; }
.campos { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.campo { margin-bottom: 12px; }
.ancho { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 6px; font-weight: 400; color: var(--texto); font-size: 14px; }
.check input { width: auto; }

button, .boton { font: inherit; border: 1px solid #cfd4da; background: #fff; color: var(--texto); border-radius: 6px; padding: 7px 12px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
button:hover, .boton:hover { background: #f3f4f6; }
button.principal, .boton.principal { background: var(--acento); border-color: var(--acento); color: #fff; font-weight: 600; }
button.principal:hover { filter: brightness(.95); }
button.peligro { color: var(--mal); }
button:disabled { opacity: .55; cursor: default; }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; }

/* editor de documento */
.editor-lineas { width: 100%; border-collapse: collapse; margin-top: 8px; }
.editor-lineas th { font-size: 12px; color: var(--suave); text-align: left; padding: 6px; border-bottom: 1px solid var(--linea); }
.editor-lineas td { padding: 6px; vertical-align: top; border-bottom: 1px solid var(--linea); }
.editor-lineas td.importe { padding-top: 14px; }
.editor-lineas .col-prod { width: 22%; }
.editor-lineas .col-num { width: 100px; }
.editor-lineas .col-desc textarea { min-height: 60px; }
.editor-lineas .quitar { border: 0; color: var(--suave); padding: 4px 6px; margin-top: 4px; }
.totales { margin-left: auto; width: 320px; margin-top: 12px; }
.totales div { display: flex; justify-content: space-between; padding: 4px 0; }
.totales .total { font-weight: 700; font-size: 16px; border-top: 1px solid var(--linea); padding-top: 8px; margin-top: 4px; }
.impuestos-lista { display: flex; gap: 14px; flex-wrap: wrap; }
.historial { font-size: 13px; color: var(--suave); }
.historial li { margin-bottom: 4px; }

/* centrado (login) */
.centro { max-width: 380px; margin: 10vh auto; }
.centro .panel { padding: 24px; }
.centro h1 { margin-bottom: 16px; }

/* modal */
.fondo-modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 560px; padding: 20px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal h2 { margin-top: 0; }
.modal .acciones { justify-content: flex-end; margin-top: 8px; }

.aviso { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 100; max-width: 90vw; }
.aviso.error { background: var(--mal); }
.logo-prev { max-height: 60px; max-width: 220px; display: block; margin-bottom: 8px; border: 1px solid var(--linea); padding: 4px; background: #fff; }
.enlace-copiar { display: flex; gap: 8px; }
.vacio { padding: 40px; text-align: center; color: var(--suave); background: var(--panel); border: 1px dashed var(--linea); border-radius: var(--radio); }

@media (max-width: 760px) {
  .barra { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 8px; }
  .barra nav { order: 3; flex: 1 0 100%; }
  main { padding: 16px 12px 60px; }
  .tabla .ocultar-movil { display: none; }
  .editor-lineas thead { display: none; }
  .editor-lineas tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; border-bottom: 1px solid var(--linea); padding: 8px 0; }
  .editor-lineas td { border: 0; padding: 0; }
  .editor-lineas .col-prod, .editor-lineas .col-desc { grid-column: 1 / -1; width: auto; }
  .editor-lineas .col-num { width: auto; }
  .totales { width: 100%; }
  .filtros input[type=search] { min-width: 0; flex: 1; }
}
