*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, sans-serif; transition: background .3s, color .3s; }

/* Layout */
body { display: flex; min-height: 100vh; }
.sidebar { width: 240px; min-height: 100vh; display: flex; flex-direction: column; transition: width .25s ease; flex-shrink: 0; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100; }
.sidebar.collapsed { width: 64px; }
.main-wrap { flex: 1; display: flex; flex-direction: column; margin-left: 240px; transition: margin-left .25s ease; min-height: 100vh; }
.sidebar.collapsed ~ .main-wrap { margin-left: 64px; }
.topbar { height: 56px; display: flex; align-items: center; gap: 14px; padding: 0 20px; flex-shrink: 0; }
.content { flex: 1; padding: 24px; overflow-y: auto; }

/* Sidebar items */
.sb-logo { padding: 16px 20px; font-weight: 700; font-size: 1rem; display: flex; align-items: center; gap: 10px; white-space: nowrap; overflow: hidden; }
.sb-logo-text { transition: opacity .2s; }
.sidebar.collapsed .sb-logo-text { opacity: 0; width: 0; overflow: hidden; }
.sb-toggle-btn { background: none; border: none; cursor: pointer; padding: 6px; display: flex; flex-direction: column; gap: 5px; }
.sb-toggle-btn span { display: block; width: 22px; height: 2px; background: currentColor; border-radius: 2px; }
.sb-nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.sb-item { display: flex; align-items: center; gap: 12px; padding: 10px 16px; cursor: pointer; border-radius: 10px; margin: 2px 8px; transition: background .15s; white-space: nowrap; overflow: hidden; font-size: .9rem; user-select: none; }
.sb-icon { font-size: 1.15rem; flex-shrink: 0; width: 24px; text-align: center; }
.sb-label { transition: opacity .2s; flex: 1; }
.sb-arrow { font-size: .75rem; transition: transform .2s; }
.sb-item.open .sb-arrow { transform: rotate(90deg); }
.sidebar.collapsed .sb-label,
.sidebar.collapsed .sb-arrow { opacity: 0; width: 0; overflow: hidden; }
.sb-sub { overflow: hidden; max-height: 0; transition: max-height .25s ease; }
.sb-sub.open { max-height: 400px; }
.sb-subitem { padding: 8px 16px 8px 52px; cursor: pointer; font-size: .85rem; border-radius: 8px; margin: 1px 8px; transition: background .15s; }
.sidebar.collapsed .sb-sub { display: none; }
.sb-footer { padding: 14px; border-top: 1px solid var(--border, #e5e7eb); }
.sb-user { display: flex; align-items: center; gap: 10px; overflow: hidden; }
.sb-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary, #6C63FF); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .9rem; flex-shrink: 0; }
.sb-user-info { display: flex; flex-direction: column; overflow: hidden; }
.sb-user-name { font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-logout { background: none; border: none; cursor: pointer; font-size: .75rem; opacity: .6; text-align: left; padding: 0; }
.sb-logout:hover { opacity: 1; }
.page-title { font-weight: 600; font-size: 1rem; }
.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 99; }

/* Cards & Tables */
.card { border-radius: 14px; padding: 20px; margin-bottom: 20px; }
.card-title { font-size: 1.05rem; font-weight: 600; margin-bottom: 16px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border, #e5e7eb); }
th { font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .4px; }
tr:hover td { background: var(--row-hover, rgba(0,0,0,.03)); }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
label { font-size: .82rem; font-weight: 600; }
input, select, textarea { border-radius: 8px; font-size: .9rem; outline: none; width: 100%; }
textarea { resize: vertical; min-height: 80px; }
.btn { border: none; border-radius: 8px; padding: 8px 18px; font-size: .875rem; font-weight: 600; cursor: pointer; transition: all .15s; }
.btn-primary { background: #6C63FF; color: #fff; }
.btn-primary:hover { background: #5a52d5; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: .78rem; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: .75rem; font-weight: 600; }
.badge-green { background: #d1fae5; color: #065f46; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-yellow { background: #fef3c7; color: #92400e; }

/* Filters row */
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; align-items: flex-end; }
.filters input, .filters select { max-width: 180px; }
.search-box { padding: 8px 12px; border-radius: 8px; font-size: .875rem; width: 200px; }

/* Pagination */
.pagination { display: flex; gap: 6px; align-items: center; margin-top: 12px; }
.page-btn { border: none; border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: .8rem; }

/* Stat cards */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { border-radius: 12px; padding: 16px; }
.stat-label { font-size: .78rem; margin-bottom: 6px; opacity: .7; }
.stat-val { font-size: 1.4rem; font-weight: 700; }

/* Semaforo cuadre */
.semaforo { width: 20px; height: 20px; border-radius: 50%; display: inline-block; }
.sem-verde { background: #22c55e; }
.sem-rojo { background: #ef4444; }
.sem-amarillo { background: #f59e0b; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; width: 240px !important; }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0 !important; }
  .overlay.show { display: block; }
}

/* Badge extra */
.badge-blue { background: #dbeafe; color: #1e40af; }

/* Modal */
.modal-bg { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 200; align-items: center; justify-content: center; }
.modal-bg.show { display: flex; }
.modal { border-radius: 16px; padding: 28px; width: 90%; max-width: 520px; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-close { background: none; border: none; font-size: 1.4rem; cursor: pointer; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
