:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #dc2626;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.5;
}

/* Header */
.header {
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}
.header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
}
.header h1 span { color: var(--primary); }

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: .5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--gray-200);
    padding-bottom: 0;
}
.tab {
    padding: .75rem 1.25rem;
    cursor: pointer;
    border: none;
    background: none;
    font-size: .9rem;
    font-weight: 500;
    color: var(--gray-500);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all .2s;
}
.tab:hover { color: var(--gray-700); }
.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Cards */
.card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    text-align: center;
}
.stat-card .value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}
.stat-card .label {
    font-size: .8rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: .05em;
}

/* Filters bar */
.filters-bar {
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 1.5rem;
}
.filters-bar select,
.filters-bar input {
    padding: .5rem .75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: .875rem;
    background: #fff;
}

/* Incidencia list */
.inc-list { display: flex; flex-direction: column; gap: .5rem; }

.inc-item {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 1rem;
    align-items: center;
    padding: 1rem 1.25rem;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    cursor: pointer;
    transition: box-shadow .2s;
}
.inc-item:hover { box-shadow: 0 2px 8px rgba(0,0,0,.06); }

.inc-prioridad {
    width: 4px;
    height: 40px;
    border-radius: 2px;
}
.inc-prioridad.urgente { background: var(--danger); }
.inc-prioridad.alta { background: var(--warning); }
.inc-prioridad.media { background: var(--primary); }
.inc-prioridad.baja { background: var(--gray-300); }

.inc-info h3 {
    font-size: .95rem;
    font-weight: 600;
    margin-bottom: .15rem;
}
.inc-info .meta {
    font-size: .8rem;
    color: var(--gray-500);
}

/* Badges */
.badge {
    display: inline-block;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    text-transform: capitalize;
}
.badge.abierta { background: #dbeafe; color: #1e40af; }
.badge.en_progreso { background: #fef3c7; color: #92400e; }
.badge.resuelta { background: #d1fae5; color: #065f46; }
.badge.cerrada { background: var(--gray-100); color: var(--gray-500); }

.badge.urgente { background: #fee2e2; color: #991b1b; }
.badge.alta { background: #fef3c7; color: #92400e; }
.badge.media { background: #dbeafe; color: #1e40af; }
.badge.baja { background: var(--gray-100); color: var(--gray-500); }

.inc-badges { display: flex; gap: .4rem; flex-shrink: 0; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .6rem 1.2rem;
    border: none;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .2s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-sm { padding: .4rem .8rem; font-size: .8rem; }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: #fff;
    border-radius: var(--radius);
    width: 95%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 2rem;
}
.modal h2 {
    font-size: 1.25rem;
    margin-bottom: 1.25rem;
}
.modal .form-group {
    margin-bottom: 1rem;
}
.modal label {
    display: block;
    font-size: .85rem;
    font-weight: 500;
    margin-bottom: .3rem;
    color: var(--gray-700);
}
.modal input,
.modal select,
.modal textarea {
    width: 100%;
    padding: .6rem .75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: .9rem;
    font-family: inherit;
}
.modal textarea { min-height: 100px; resize: vertical; }
.modal .actions {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    margin-top: 1.5rem;
}

/* Detail view */
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}
.detail-header h2 { font-size: 1.25rem; }
.detail-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.detail-meta .field-label {
    font-size: .75rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: .05em;
}
.detail-meta .field-value {
    font-size: .95rem;
    font-weight: 500;
}

.comentarios-list {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: .75rem;
}
.comentario {
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: .75rem 1rem;
}
.comentario .autor {
    font-weight: 600;
    font-size: .85rem;
}
.comentario .fecha {
    font-size: .75rem;
    color: var(--gray-500);
}
.comentario .texto {
    margin-top: .3rem;
    font-size: .9rem;
}

.add-comment {
    display: flex;
    gap: .5rem;
    margin-top: 1rem;
}
.add-comment textarea {
    flex: 1;
    padding: .6rem .75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: .9rem;
    font-family: inherit;
    min-height: 60px;
    resize: vertical;
}

/* Store selector */
.store-search {
    position: relative;
}
.store-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    z-index: 10;
    display: none;
}
.store-dropdown.active { display: block; }
.store-option {
    padding: .5rem .75rem;
    cursor: pointer;
    font-size: .85rem;
}
.store-option:hover { background: var(--gray-100); }
.store-option .cod { font-weight: 600; }
.store-option .city { color: var(--gray-500); font-size: .8rem; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--gray-500);
}
.empty-state p { font-size: 1rem; margin-bottom: 1rem; }

/* Responsive */
@media (max-width: 768px) {
    .header { padding: .75rem 1rem; }
    .container { padding: 1rem; }
    .inc-item { grid-template-columns: auto 1fr; gap: .5rem; }
    .inc-badges { grid-column: 2; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .detail-meta { grid-template-columns: 1fr 1fr; }
}
