* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: #f7f7f8; color: #111; }
a { color: inherit; text-decoration: none; }

.header { background: #fff; border-bottom: 1px solid #e5e7eb; position: sticky; top: 0; z-index: 10; }
.header-inner { max-width: 1100px; margin: 0 auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.brand { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand h1 { font-size: 18px; margin: 0; letter-spacing: 0.5px; }
.brand small { color: #6b7280; font-size: 12px; display: block; }
.nav { display: flex; gap: 4px; overflow-x: auto; }
.nav a { padding: 10px 14px; border-radius: 8px; font-size: 14px; font-weight: 500; color: #6b7280; white-space: nowrap; }
.nav a.active { background: #111; color: #fff; }

.main { max-width: 1100px; margin: 0 auto; padding: 16px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 22px; }
.page-head .sub { color: #6b7280; font-size: 13px; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; border-radius: 8px; border: 1px solid #111; background: #111; color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn.secondary { background: #fff; color: #111; }
.btn.ghost { background: transparent; border-color: transparent; color: #6b7280; }
.btn.danger { background: #dc2626; border-color: #dc2626; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 6px 10px; font-size: 13px; }

.card { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 16px; margin-bottom: 12px; }
.card h3 { margin: 0 0 12px; font-size: 16px; display: flex; justify-content: space-between; align-items: center; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #f3f4f6; color: #374151; font-size: 12px; font-weight: 500; }
.badge.red { background: #fee2e2; color: #991b1b; }
.badge.green { background: #dcfce7; color: #166534; }
.badge.blue { background: #dbeafe; color: #1e40af; }

.kanban { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 768px) { .kanban { grid-template-columns: 1fr 1fr 1fr; } }
.col { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 12px; min-height: 200px; }
.col h3 { font-size: 14px; margin: 0 0 12px; text-transform: uppercase; letter-spacing: 0.5px; color: #6b7280; }
.ticket { background: #fafafa; border: 1px solid #e5e7eb; border-radius: 8px; padding: 10px; margin-bottom: 8px; }
.ticket p { margin: 0 0 6px; font-size: 14px; }
.ticket .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.ticket .actions { display: flex; gap: 6px; justify-content: flex-end; }

.row { display: grid; grid-template-columns: 1fr; gap: 8px; padding: 12px 0; border-bottom: 1px solid #f3f4f6; }
.row:last-child { border-bottom: none; }
.row .name { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 500; }
.row .stocks { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.row .stocks label { font-size: 11px; color: #6b7280; display: block; margin-bottom: 2px; text-transform: uppercase; }
.row input[type=number], .row input[type=text], .row select { width: 100%; padding: 6px 8px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; background: #fff; }
.row .ro { padding: 6px 8px; background: #f3f4f6; border-radius: 6px; font-family: ui-monospace, monospace; font-size: 14px; }

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: none; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal-bg.open { display: flex; }
.modal { background: #fff; border-radius: 12px; padding: 20px; width: 100%; max-width: 420px; }
.modal h3 { margin: 0 0 12px; }
.modal label { display: block; font-size: 13px; margin: 10px 0 4px; color: #374151; }
.modal input, .modal select, .modal textarea { width: 100%; padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; font-family: inherit; }
.modal .pin { text-align: center; letter-spacing: 0.5em; font-size: 22px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.empty { color: #6b7280; font-size: 14px; padding: 12px 0; text-align: center; }
.error { color: #dc2626; font-size: 13px; margin-top: 6px; }

pre.shopping { background: #f3f4f6; padding: 12px; border-radius: 8px; font-family: ui-monospace, monospace; font-size: 13px; white-space: pre-wrap; }

/* === v2: kanban color edges, dnd, comments, inventory search === */
.ticket { position: relative; padding-left: 14px; cursor: grab; }
.ticket.dragging { opacity: 0.4; }
.ticket::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; border-radius: 8px 0 0 8px; background: #9ca3af; }
.ticket.status-todo::before  { background: #ef4444; }
.ticket.status-doing::before { background: #f97316; }
.ticket.status-done::before  { background: #22c55e; }

.col h3 .dot { display: inline-block; width: 8px; height: 8px; border-radius: 999px; vertical-align: middle; margin-right: 6px; }
.dot-todo  { background: #ef4444; }
.dot-doing { background: #f97316; }
.dot-done  { background: #22c55e; }
.col.drag-over { background: #f0f9ff; border-color: #93c5fd; }

.comments-list { max-height: 240px; overflow-y: auto; margin: 8px 0 12px; }
.comment { background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; }
.comment-date { font-size: 11px; color: #6b7280; margin-bottom: 2px; }
.comment p { margin: 0; font-size: 14px; }

.search-bar { margin-bottom: 12px; }
.search-bar input { width: 100%; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px; background: #fff; }

.totals { display: inline-flex; gap: 6px; align-items: center; }
.empty { color: #9ca3af; font-size: 13px; text-align: center; padding: 14px 0; }

/* Proveedor selector en filas de inventario */
.proveedor-row { display:flex; align-items:center; gap:8px; margin-top:6px; }
.proveedor-row label { font-size:12px; color:#6b7280; min-width:70px; }
.proveedor-row select {
  flex:1; padding:6px 8px; border:1px solid #e5e7eb;
  border-radius:6px; background:#fff; font-size:14px;
}
.supplier-items .row { padding:6px 0; border-bottom:1px solid #f3f4f6; }
.supplier-items .row:last-child { border-bottom:none; }

/* === v4: Análisis === */
.filters { display:flex; flex-wrap:wrap; gap:12px; align-items:center; justify-content:space-between; margin-bottom:12px; }
.filters .presets { display:flex; gap:6px; flex-wrap:wrap; }
.filters .range-form { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.filters .range-form label { font-size:12px; color:#6b7280; display:flex; flex-direction:column; gap:2px; }
.filters .range-form input { padding:6px 8px; border:1px solid #d1d5db; border-radius:6px; font-size:14px; }
.summary { display:flex; gap:8px; flex-wrap:wrap; margin-top:8px; }
.analisis-row .name { display:flex; justify-content:space-between; align-items:center; }
