:root {
    --brand-navy: #0f294a;
    --brand-blue: #1a54a6;
    --brand-blue-light: #eff6ff;
    --bg-app: #f1f5f9;
    --bg-card: #ffffff;
    --bg-subtle: #f8fafc;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 12px;
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 10px 28px rgba(15, 23, 42, 0.08);
    --sidebar-w: 252px;
}

body.dark-mode {
    --bg-app: #0b1120;
    --bg-card: #131c31;
    --bg-subtle: #19243d;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #26334d;
    --brand-blue-light: #1e3a5f;
}

* { box-sizing: border-box; }
html, body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-app);
    color: var(--text-main);
    font-size: 14px;
    line-height: 1.45;
    -webkit-tap-highlight-color: transparent;
}

a { color: var(--brand-blue); text-decoration: none; }
body.dark-mode a { color: #60a5fa; }

/* Layout Principal */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--brand-navy);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform .22s ease;
}

.sidebar-brand {
    padding: 18px 18px 14px;
    border-bottom: 1px solid rgba(255,255,255,.09);
    display: flex;
    align-items: center;
    gap: 11px;
}
.sidebar-brand img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    background: #fff;
    border-radius: 8px;
    padding: 3px;
}
.sidebar-brand .brand-title {
    font-weight: 800;
    font-size: 15px;
    color: #fff;
    letter-spacing: .2px;
}
.sidebar-brand .brand-sub {
    font-size: 11px;
    color: #93c5fd;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    overflow-y: auto;
}
.nav-section-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: #94a3b8;
    padding: 10px 10px 5px;
    font-weight: 700;
}
.nav-item-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9.5px 12px;
    border-radius: 9px;
    color: #cbd5e1 !important;
    font-weight: 500;
    margin-bottom: 3px;
    transition: all .14s ease;
}
.nav-item-link i {
    width: 18px;
    text-align: center;
    font-size: 14.5px;
}
.nav-item-link:hover {
    background: rgba(255,255,255,.08);
    color: #fff !important;
}
.nav-item-link.active {
    background: var(--brand-blue);
    color: #fff !important;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(26, 84, 166, 0.45);
}
.nav-badge {
    margin-left: auto;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 999px;
}

.sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid rgba(255,255,255,.09);
    font-size: 12px;
}

.main-area {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: 60px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 80;
}

.page-content {
    padding: 20px 22px 84px;
    max-width: 1460px;
    width: 100%;
    margin: 0 auto;
}

/* Tarjetas, Grids y Controles */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    font-weight: 700;
}
.card-body { padding: 16px 18px; }

.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 15px 16px;
    display: flex;
    align-items: center;
    gap: 13px;
    box-shadow: var(--shadow-sm);
}
.kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.kpi-val { font-size: 22px; font-weight: 800; line-height: 1.1; }
.kpi-lbl { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Botones */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8.5px 14px;
    border-radius: 9px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all .14s ease;
    white-space: nowrap;
}
.btn-sm { padding: 5.5px 10px; font-size: 12px; border-radius: 7px; }
.btn-primary { background: var(--brand-blue); color: #fff !important; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-success { background: #16a34a; color: #fff !important; }
.btn-danger { background: #dc2626; color: #fff !important; }
.btn-warning { background: #d97706; color: #fff !important; }
.btn-secondary {
    background: var(--bg-subtle);
    color: var(--text-main) !important;
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--border); }

/* Formularios */
.form-group { margin-bottom: 12px; }
.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 5px;
}
.form-control {
    width: 100%;
    padding: 8.5px 11px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-main);
    font-size: 13.5px;
    font-family: inherit;
}
.form-control:focus {
    outline: none;
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 3px rgba(26, 84, 166, 0.16);
}

/* Tablas */
.table-wrap { width: 100%; overflow-x: auto; }
table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table.data-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--text-muted);
    background: var(--bg-subtle);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
table.data-table td {
    padding: 10.5px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table.data-table tr:hover td { background: var(--bg-subtle); }

/* Badges de Estado y Prioridad */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
}
.badge-triaje     { background: #fae8ff; color: #86198f; }
.badge-backlog    { background: #e2e8f0; color: #334155; }
.badge-programado { background: #e0f2fe; color: #0369a1; }
.badge-progreso   { background: #dbeafe; color: #1d4ed8; }
.badge-espera     { background: #fef3c7; color: #b45309; }
.badge-qa         { background: #ede9fe; color: #6d28d9; }
.badge-resuelto   { background: #dcfce7; color: #15803d; }
.badge-cerrado    { background: #d1fae5; color: #065f46; }

.prio-baja    { background: #f1f5f9; color: #475569; }
.prio-media   { background: #e0f2fe; color: #0369a1; }
.prio-alta    { background: #ffedd5; color: #c2410c; }
.prio-critica { background: #fee2e2; color: #b91c1c; }

.code-pill {
    font-family: 'JetBrains Mono', Consolas, monospace;
    font-size: 12px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 6px;
    background: var(--brand-blue-light);
    color: var(--brand-blue);
}
body.dark-mode .code-pill { color: #93c5fd; }

.progress-track {
    height: 7px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #1a54a6, #16a34a);
    border-radius: 999px;
    transition: width .25s ease;
}

/* Tablero Kanban Estilo Jira */
.kanban-board {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    padding-bottom: 14px;
    align-items: flex-start;
}
.kanban-col {
    min-width: 282px;
    max-width: 282px;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 190px);
}
.kanban-col-header {
    padding: 11px 13px;
    font-weight: 700;
    font-size: 12.5px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.kanban-list {
    padding: 10px;
    overflow-y: auto;
    min-height: 110px;
    display: flex;
    flex-direction: column;
    gap: 9px;
}
.kanban-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 11px 12px;
    box-shadow: var(--shadow-sm);
    cursor: grab;
    transition: transform .12s ease, box-shadow .12s ease;
}
.kanban-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Modal Universal */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.58);
    backdrop-filter: blur(2px);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 14px;
}
.modal-backdrop.open { display: flex; }
.modal-dialog {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    width: 100%;
    max-width: 660px;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: 0 24px 60px rgba(0,0,0,.3);
}
.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 800;
    font-size: 16px;
}
.modal-body { padding: 18px 20px; }

/* Toast */
#toast-box {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast-msg {
    background: #0f172a;
    color: #fff;
    padding: 11px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: var(--shadow-md);
    border-left: 4px solid #22c55e;
    max-width: 360px;
}
.toast-msg.err { border-left-color: #ef4444; }

/* Barra Inferior PWA Movil + Boton Flotante + Rapido */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 62px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    z-index: 120;
    justify-content: space-around;
    align-items: center;
    padding: 0 6px;
}
.mob-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    font-size: 10.5px;
    font-weight: 600;
    color: var(--text-muted) !important;
    padding: 6px 8px;
}
.mob-nav-btn i { font-size: 17px; }
.mob-nav-btn.active { color: var(--brand-blue) !important; }

.fab-quick {
    display: none;
    position: fixed;
    right: 16px;
    bottom: 74px;
    z-index: 130;
    background: var(--brand-blue);
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 12px 18px;
    font-weight: 700;
    font-size: 13.5px;
    box-shadow: 0 8px 22px rgba(26, 84, 166, 0.4);
    cursor: pointer;
    align-items: center;
    gap: 7px;
}

/* Pestañas Limpias (Tabs) para evitar exceso de información en pantalla */
.tabs-nav {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    padding: 0 14px;
    background: var(--bg-subtle);
    border-radius: var(--radius) var(--radius) 0 0;
    overflow-x: auto;
}
.tab-link {
    appearance: none;
    background: transparent;
    border: none;
    border-bottom: 2.5px solid transparent;
    padding: 12px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
    font-family: inherit;
}
.tab-link:hover { color: var(--text-main); }
.tab-link.active {
    color: var(--brand-blue);
    border-bottom-color: var(--brand-blue);
    font-weight: 700;
}
body.dark-mode .tab-link.active {
    color: #60a5fa;
    border-bottom-color: #60a5fa;
}
.tab-pane { display: none; padding: 18px; }
.tab-pane.active { display: block; }

/* Filas compactas estilo Jira / Linear para barra derecha */
.compact-prop {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 7px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.compact-prop:last-child { border-bottom: none; }
.compact-prop-label {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 12.5px;
    min-width: 92px;
}
.compact-prop .form-control {
    padding: 5px 8px;
    font-size: 12.5px;
    border-color: transparent;
    background: var(--bg-subtle);
    text-align: right;
    font-weight: 600;
}
.compact-prop .form-control:hover,
.compact-prop .form-control:focus {
    border-color: var(--border);
    background: var(--bg-card);
    text-align: left;
}

details.clean-collapse > summary {
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--brand-blue);
    padding: 6px 0;
    user-select: none;
}

/* Campanita de Alertas en Tiempo Real */
.bell-wrap {
    position: relative;
}
.bell-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: #fff;
    font-size: 10.5px;
    font-weight: 800;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.5);
}
.bell-dropdown {
    display: none;
    position: absolute;
    top: 42px;
    right: 0;
    width: 340px;
    max-width: calc(100vw - 24px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    z-index: 250;
    overflow: hidden;
}
.bell-dropdown.open { display: block; }
.notif-item {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 12.5px;
    cursor: pointer;
    transition: background .12s ease;
}
.notif-item:hover { background: var(--bg-subtle); }
.notif-item.unread {
    background: var(--brand-blue-light);
    border-left: 3px solid var(--brand-blue);
}

.text-muted { color: var(--text-muted); }

@media (max-width: 960px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.mobile-open { transform: translateX(0); }
    .main-area { margin-left: 0; }
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3, .grid-2 { grid-template-columns: 1fr; }
    .page-content { padding: 14px 12px 92px; }
    .topbar { padding: 0 12px; }
    .mobile-bottom-nav { display: flex; }
    .fab-quick { display: flex; }
    .hide-mobile { display: none !important; }
}
