/* ── Reset & Variables ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:        #0f1117;
    --bg2:       #1a1d27;
    --bg3:       #252836;
    --border:    #2e3347;
    --text:      #e2e8f0;
    --muted:     #8892a4;
    --primary:   #4f7ef8;
    --primary-h: #3a64d8;
    --success:   #22c55e;
    --danger:    #ef4444;
    --warning:   #f59e0b;
    --purple:    #a855f7;
    --orange:    #f97316;
    --radius:    10px;
    --shadow:    0 4px 24px rgba(0,0,0,.4);
    --sidebar-w: 240px;
    --top-h:     56px;
}

html { font-size: 15px; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); }
body.app { display: flex; min-height: 100vh; overflow: hidden; }
a { text-decoration: none; color: inherit; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w); min-width: var(--sidebar-w);
    background: var(--bg2); border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    height: 100vh; position: fixed; left: 0; top: 0; z-index: 200;
    transition: transform .25s;
}
.sidebar.collapsed { transform: translateX(calc(-1 * var(--sidebar-w))); }
.sidebar-brand {
    display: flex; align-items: center; gap: .65rem;
    padding: 1.1rem 1.2rem; border-bottom: 1px solid var(--border);
    font-weight: 700; font-size: 1.05rem; color: var(--primary);
    flex-shrink: 0;
}
.sidebar-brand i { font-size: 1.3rem; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: .7rem .6rem; }
.nav-section {
    font-size: .7rem; font-weight: 700; color: var(--muted);
    text-transform: uppercase; letter-spacing: .08em;
    padding: .9rem .6rem .3rem;
}
.nav-item {
    display: flex; align-items: center; gap: .7rem;
    padding: .6rem .8rem; border-radius: 8px;
    font-size: .87rem; color: var(--muted);
    transition: background .15s, color .15s; margin-bottom: .1rem;
    cursor: pointer;
}
.nav-item i { width: 16px; text-align: center; font-size: .9rem; }
.nav-item:hover  { background: var(--bg3); color: var(--text); }
.nav-item.active { background: rgba(79,126,248,.15); color: var(--primary); font-weight: 600; }

.sidebar-footer {
    display: flex; align-items: center; gap: .5rem;
    padding: .9rem 1rem; border-top: 1px solid var(--border); flex-shrink: 0;
}
.user-chip { display: flex; align-items: center; gap: .55rem; flex: 1; min-width: 0; }
.user-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .8rem; flex-shrink: 0;
}
.user-info { min-width: 0; }
.user-nombre { font-size: .83rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-rol    { font-size: .72rem; color: var(--muted); }
.btn-logout  { color: var(--muted); padding: .4rem .5rem; border-radius: 7px; transition: color .15s, background .15s; }
.btn-logout:hover { color: var(--danger); background: rgba(239,68,68,.1); }

/* ── Main Wrap ───────────────────────────────────────────── */
.main-wrap {
    margin-left: var(--sidebar-w);
    flex: 1; display: flex; flex-direction: column;
    height: 100vh; overflow: hidden;
    transition: margin-left .25s;
}
.main-wrap.expanded { margin-left: 0; }

/* ── Topbar ──────────────────────────────────────────────── */
.topbar {
    height: var(--top-h); min-height: var(--top-h);
    background: var(--bg2); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: .8rem;
    padding: 0 1.4rem; position: sticky; top: 0; z-index: 100;
}
.sidebar-toggle {
    background: none; border: none; color: var(--muted);
    cursor: pointer; font-size: 1.1rem; padding: .3rem .5rem;
    border-radius: 7px; transition: color .15s;
}
.sidebar-toggle:hover { color: var(--text); background: var(--bg3); }
.topbar-title { font-weight: 700; font-size: 1rem; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: .6rem; }
.lang-btn {
    font-size: .78rem; font-weight: 700; letter-spacing: .05em;
    min-width: 36px; padding: .4rem .55rem;
}
.icon-btn {
    background: var(--bg3); border: 1px solid var(--border);
    color: var(--muted); cursor: pointer; padding: .45rem .65rem;
    border-radius: 8px; font-size: .9rem; position: relative;
    transition: color .15s, border-color .15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--primary); }
.notif-badge {
    position: absolute; top: -5px; right: -5px;
    background: var(--danger); color: #fff;
    border-radius: 999px; font-size: .65rem; font-weight: 700;
    padding: .1rem .35rem; min-width: 16px; text-align: center;
}

/* ── Panel Notificaciones ────────────────────────────────── */
.notif-panel {
    position: fixed; right: 1rem; top: calc(var(--top-h) + .5rem);
    width: 340px; background: var(--bg2); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    z-index: 300; display: none; max-height: 480px;
    flex-direction: column; overflow: hidden;
}
.notif-panel.open { display: flex; }
.notif-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: .8rem 1rem; border-bottom: 1px solid var(--border);
}
.notif-header button { background: none; border: none; color: var(--primary); cursor: pointer; font-size: .8rem; }
.notif-list { overflow-y: auto; flex: 1; }
.notif-item {
    padding: .75rem 1rem; border-bottom: 1px solid var(--border);
    cursor: pointer; transition: background .15s;
}
.notif-item:hover { background: var(--bg3); }
.notif-item.unread { border-left: 3px solid var(--primary); }
.notif-item strong { font-size: .85rem; display: block; margin-bottom: .15rem; }
.notif-item small  { color: var(--muted); font-size: .75rem; }
.notif-empty { padding: 1.5rem; text-align: center; color: var(--muted); font-size: .85rem; }

/* ── Page Content ────────────────────────────────────────── */
.page-content { flex: 1; overflow-y: auto; padding: 1.4rem 1.6rem; }

/* ── Dashboard ───────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem; margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.2rem 1rem;
    display: flex; flex-direction: column; gap: .4rem;
}
.stat-card .stat-icon { font-size: 1.5rem; margin-bottom: .2rem; }
.stat-card .stat-val  { font-size: 1.8rem; font-weight: 800; }
.stat-card .stat-lbl  { color: var(--muted); font-size: .8rem; }
.stat-card.blue    .stat-icon { color: var(--primary); }
.stat-card.green   .stat-icon { color: var(--success); }
.stat-card.red     .stat-icon { color: var(--danger); }
.stat-card.yellow  .stat-icon { color: var(--warning); }
.stat-card.purple  .stat-icon { color: var(--purple); }
.stat-card.orange  .stat-icon { color: var(--orange); }
.stat-card.is-clickable { cursor: pointer; transition: transform .15s, border-color .15s, box-shadow .15s; }
.stat-card.is-clickable:hover { transform: translateY(-1px); border-color: var(--primary); box-shadow: var(--shadow); }
.stat-card.is-clickable:focus { outline: 2px solid rgba(79,126,248,.45); outline-offset: 2px; }

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width:900px) { .dash-grid { grid-template-columns: 1fr; } }

.dash-panel {
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1rem;
}
.dash-panel h3 { font-size: .9rem; margin-bottom: .9rem; color: var(--muted); text-transform: uppercase; font-size: .75rem; letter-spacing: .06em; }
.dash-row {
    display: flex; align-items: center; gap: .7rem;
    padding: .55rem 0; border-bottom: 1px solid var(--border); font-size: .84rem;
}
.dash-row:last-child { border-bottom: none; }
.dash-row .dr-name { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-row .dr-meta { color: var(--muted); font-size: .76rem; }

/* ── Seguimiento ─────────────────────────────────────────── */
.seguimiento-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.seguimiento-col {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: .75rem .85rem;
    position: relative;
    overflow: hidden;
}
.seguimiento-col::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--border);
}
.seguimiento-col-tickets::before { background: var(--orange); }
.seguimiento-col-tareas::before { background: var(--primary); }
.seguimiento-col-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .45rem;
    font-size: .75rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 700;
}
.seguimiento-col .dash-row {
    border-bottom-color: rgba(255,255,255,.08);
}
@media (max-width: 900px) {
    .seguimiento-split { grid-template-columns: 1fr; }
}

/* ── Dashboard Charts ─────────────────────────────────────── */
.dash-charts-section {
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1rem; margin-top: 1rem;
}
.dash-charts-header {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: .6rem; margin-bottom: 1rem;
}
.dash-charts-header h3 {
    font-size: .75rem; color: var(--muted); text-transform: uppercase;
    letter-spacing: .06em; margin: 0;
}
.dash-charts-filters { display: flex; gap: .5rem; flex-wrap: wrap; }
.dash-charts-filters select {
    font-size: .82rem; padding: .3rem .6rem;
    border: 1px solid var(--border); border-radius: 6px;
    background: var(--bg); color: var(--text); cursor: pointer;
}
.dash-charts-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem;
}
@media (max-width: 680px) { .dash-charts-grid { grid-template-columns: 1fr; } }
.dash-chart-wrap { display: flex; flex-direction: column; align-items: center; }
.dash-chart-label {
    font-size: .78rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: .05em; color: var(--muted); margin-bottom: .5rem; align-self: flex-start;
}
.dash-chart-nodata {
    color: var(--muted); font-size: .84rem; padding: 2rem 0; text-align: center; width: 100%;
}


/* ── Kanban Board ────────────────────────────────────────── */
.kanban-wrapper {
    display: flex; gap: 1rem; padding-bottom: 1rem;
    overflow-x: auto; min-height: calc(100vh - 160px); align-items: flex-start;
}
.kanban-col {
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: var(--radius); min-width: 280px; max-width: 280px;
    display: flex; flex-direction: column; flex-shrink: 0;
    max-height: calc(100vh - 180px);
}
.col-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: .75rem 1rem; border-bottom: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    background: var(--bg2); position: sticky; top: 0; z-index: 1;
}
.col-title { display: flex; align-items: center; gap: .5rem; font-weight: 600; font-size: .88rem; }
.col-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.col-count { background: var(--bg3); color: var(--muted); font-size: .73rem; padding: .12rem .5rem; border-radius: 999px; font-weight: 600; }
.col-body { padding: .6rem; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: .55rem; }
.col-body.drag-over { background: rgba(79,126,248,.06); border-radius: 0 0 var(--radius) var(--radius); }
.col-empty { text-align: center; color: var(--muted); font-size: .78rem; padding: 1.2rem .4rem; }
.col-empty i { display: block; font-size: 1.6rem; margin-bottom: .4rem; opacity: .3; }

/* ── Tarjeta ─────────────────────────────────────────────── */
.k-card {
    background: var(--bg3); border: 1px solid var(--border);
    border-radius: 8px; padding: .8rem; cursor: grab;
    transition: box-shadow .2s, transform .15s, opacity .15s;
    position: relative;
}
.k-card:hover { box-shadow: var(--shadow); border-color: var(--primary); transform: translateY(-1px); }
.k-card.dragging { opacity: .4; cursor: grabbing; }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: .4rem; margin-bottom: .35rem; }
.card-titulo { font-weight: 600; font-size: .88rem; line-height: 1.3; flex: 1; }
.card-folio  { font-size: .72rem; color: var(--muted); margin-bottom: .3rem; }
.card-actions { display: flex; gap: .25rem; opacity: 0; transition: opacity .15s; }
.k-card:hover .card-actions { opacity: 1; }
.card-actions button { background: none; border: none; color: var(--muted); cursor: pointer; padding: .18rem .28rem; border-radius: 5px; font-size: .78rem; transition: color .15s, background .15s; }
.card-actions .edit:hover { color: var(--primary); background: rgba(79,126,248,.12); }
.card-actions .del:hover  { color: var(--danger);  background: rgba(239,68,68,.12); }
.card-actions .view:hover { color: var(--success); background: rgba(34,197,94,.1); }
.card-sub { font-size: .77rem; color: var(--muted); margin-bottom: .45rem; display: flex; align-items: center; gap: .3rem; }
.card-meta { display: flex; flex-wrap: wrap; gap: .35rem; }
.card-footer { margin-top: .55rem; display: flex; justify-content: space-between; align-items: center; }
.card-date { font-size: .74rem; color: var(--muted); }
.card-date.vence-pronto { color: var(--warning); }
.card-date.vencido      { color: var(--danger); }
.card-progress { margin-top: .5rem; }
.progress-bar { background: var(--bg); border-radius: 999px; height: 5px; overflow: hidden; }
.progress-fill { background: var(--primary); height: 100%; border-radius: 999px; transition: width .3s; }
.progress-lbl  { font-size: .72rem; color: var(--muted); text-align: right; margin-top: .15rem; }

/* ── Badges ──────────────────────────────────────────────── */
.badge { padding: .15rem .5rem; border-radius: 999px; font-weight: 600; font-size: .7rem; }
.badge-baja    { background: rgba(100,116,139,.2); color: #94a3b8; }
.badge-media   { background: rgba(245,158,11,.15);  color: var(--warning); }
.badge-alta    { background: rgba(239,68,68,.15);   color: var(--danger); }
.badge-urgente { background: rgba(239,68,68,.3);    color: #ff6b6b; }

/* ── Tabla (lista) ───────────────────────────────────────── */
.vista-tabla { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .65rem .9rem; text-align: left; border-bottom: 1px solid var(--border); font-size: .84rem; }
th { background: var(--bg3); color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
tr:hover td { background: rgba(255,255,255,.02); }
.tbl-actions { display: flex; gap: .3rem; }
.tbl-actions button { background: none; border: none; color: var(--muted); cursor: pointer; padding: .2rem .35rem; border-radius: 5px; font-size: .82rem; transition: color .15s; }
.tbl-actions button:hover { color: var(--primary); }

/* ── Barra de herramientas ───────────────────────────────── */
.toolbar {
    display: flex; flex-wrap: wrap; gap: .7rem; align-items: center;
    margin-bottom: 1.2rem;
}
.toolbar .toolbar-right { margin-left: auto; display: flex; gap: .5rem; }
.view-toggle button {
    background: var(--bg3); border: 1px solid var(--border);
    color: var(--muted); padding: .4rem .65rem; border-radius: 7px;
    cursor: pointer; font-size: .85rem; transition: all .15s;
}
.view-toggle button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.search-input {
    background: var(--bg3); border: 1px solid var(--border);
    color: var(--text); padding: .45rem .8rem; border-radius: 8px;
    font-size: .85rem; width: 220px; outline: none;
}
.search-input:focus { border-color: var(--primary); }

/* ── Botones ─────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem 1.1rem; border-radius: 8px; border: none; cursor: pointer; font-size: .88rem; font-weight: 600; transition: background .15s, transform .1s; }
.btn:active { transform: scale(.97); }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); }
.btn-secondary { background: var(--bg3); color: var(--muted); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); color: var(--text); }
.btn-danger    { background: rgba(239,68,68,.15); color: var(--danger); border: 1px solid rgba(239,68,68,.3); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.65); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 500; opacity: 0; pointer-events: none; transition: opacity .2s; }
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal { background: var(--bg2); border: 1px solid var(--border); border-radius: 14px; width: 95%; max-width: 640px; max-height: 92vh; overflow-y: auto; box-shadow: var(--shadow); transform: translateY(20px); transition: transform .25s; }
.modal-overlay.active .modal { transform: translateY(0); }
.modal.modal-lg { max-width: 860px; }
.modal.modal-fullscreen {
    width: 100vw;
    max-width: none;
    height: 100vh;
    max-height: none;
    border-radius: 0;
    border: none;
    display: flex;
    flex-direction: column;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg2); z-index: 1; border-radius: 14px 14px 0 0; }
.modal.modal-fullscreen .modal-header { border-radius: 0; }
.modal-header h2 { font-size: 1.05rem; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 1.2rem; cursor: pointer; padding: .2rem .5rem; border-radius: 6px; }
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 1.2rem 1.4rem; }
.modal.modal-fullscreen .modal-body {
    flex: 1;
    overflow: auto;
    padding: 1rem 1.2rem 1.2rem;
}
.modal-footer { display: flex; justify-content: flex-end; gap: .7rem; padding: 1rem 1.4rem; border-top: 1px solid var(--border); }

.project-kanban-fullscreen {
    min-height: 100%;
    display: flex;
    flex-direction: column;
}
.project-kanban-topbar {
    display: flex;
    justify-content: flex-start;
    margin-bottom: .65rem;
}
.project-kanban-fullscreen .tab-content.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}
#proyKanbanTareasBoard,
#proyKanbanTicketsBoard {
    flex: 1;
    min-height: 0;
}
.project-kanban-fullscreen .kanban-wrapper {
    min-height: calc(100vh - 250px);
    max-height: none;
}

/* ── Detalle (view panel) ────────────────────────────────── */
.detail-panel { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.4rem; margin-bottom: 1rem; }
.detail-panel h3 { font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .8rem; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem 1.2rem; }
.detail-item label { display: block; font-size: .75rem; color: var(--muted); margin-bottom: .15rem; }
.detail-item span  { font-size: .88rem; font-weight: 500; }
.detail-tabs { display: flex; gap: .3rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.tab-btn { background: none; border: none; color: var(--muted); cursor: pointer; padding: .6rem 1rem; font-size: .85rem; border-bottom: 2px solid transparent; transition: color .15s; }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Formulario ──────────────────────────────────────────── */
.form-row { display: flex; gap: .9rem; margin-bottom: .9rem; }
.form-group { display: flex; flex-direction: column; gap: .3rem; flex: 1; }
.form-group.full { flex: 1 0 100%; }
label { font-size: .8rem; color: var(--muted); font-weight: 600; }
.req  { color: var(--danger); }
input, select, textarea {
    background: var(--bg3); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text); padding: .52rem .8rem;
    font-size: .87rem; outline: none; transition: border-color .15s;
    width: 100%; font-family: inherit;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,126,248,.12); }
select option { background: var(--bg3); }
textarea { resize: vertical; }
input[type=range] { padding: 0; background: none; border: none; }

/* ── Checklist usuarios ──────────────────────────────────── */
.user-checklist { display: flex; flex-wrap: wrap; gap: .5rem; max-height: 140px; overflow-y: auto; }
.user-check-item { display: flex; align-items: center; gap: .4rem; background: var(--bg3); border: 1px solid var(--border); border-radius: 7px; padding: .35rem .65rem; cursor: pointer; font-size: .82rem; }
.user-check-item input { width: auto; margin: 0; }

/* ── Comentarios ─────────────────────────────────────────── */
.comment-list { display: flex; flex-direction: column; gap: .8rem; }
.comment-item { background: var(--bg3); border-radius: 8px; padding: .8rem; font-size: .85rem; }
.comment-header { display: flex; justify-content: space-between; margin-bottom: .35rem; }
.comment-autor  { font-weight: 600; font-size: .82rem; }
.comment-date   { color: var(--muted); font-size: .75rem; }
.comment-form   { display: flex; gap: .6rem; margin-top: .8rem; }
.comment-form textarea { flex: 1; min-height: 60px; }

/* ── Toast ───────────────────────────────────────────────── */
.toast { position: fixed; bottom: 1.5rem; right: 1.5rem; background: var(--bg3); border: 1px solid var(--border); color: var(--text); padding: .75rem 1.2rem; border-radius: 10px; font-size: .88rem; box-shadow: var(--shadow); z-index: 999; opacity: 0; transform: translateY(10px); transition: opacity .25s, transform .25s; pointer-events: none; max-width: 320px; }
.toast.show    { opacity: 1; transform: translateY(0); }
.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }

/* ── Loading ─────────────────────────────────────────────── */
.loading-state { display: flex; align-items: center; justify-content: center; padding: 4rem; color: var(--muted); gap: .7rem; font-size: .95rem; }
.empty-state   { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4rem; color: var(--muted); gap: .5rem; }
.empty-state i { font-size: 2.5rem; opacity: .3; }

/* ── Privilegios grid ────────────────────────────────────── */
.priv-grid table { font-size: .82rem; }
.priv-grid th, .priv-grid td { padding: .5rem .7rem; }
.priv-grid input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }

/* ── Detail panel & tabs ─────────────────────────────────── */
.detail-panel { margin-bottom: 1rem; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .5rem .8rem; margin-bottom: .5rem; }
.detail-item label { display: block; font-size: .72rem; color: var(--muted); margin-bottom: .15rem; text-transform: uppercase; letter-spacing: .04em; }
.detail-item span  { font-size: .84rem; font-weight: 500; }
.detail-tabs { display: flex; gap: .4rem; border-bottom: 1px solid var(--border); margin: .8rem 0 .6rem; }
.tab-btn { background: none; border: none; padding: .5rem .9rem; color: var(--muted); cursor: pointer; font-size: .83rem; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .15s, border-color .15s; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Folio badge ─────────────────────────────────────────── */
.folio-badge { background: rgba(249,115,22,.15); color: var(--orange, #f97316); border: 1px solid rgba(249,115,22,.3); border-radius: 5px; padding: .15rem .5rem; font-size: .75rem; font-weight: 700; font-family: monospace; letter-spacing: .04em; }

/* ── Comentarios ─────────────────────────────────────────── */
.comment-item { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: .6rem .8rem; }
.comment-author { font-size: .75rem; color: var(--muted); margin-bottom: .25rem; }
.comment-author span { margin-left: .5rem; }
.comment-body { font-size: .84rem; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.comment-composer { background: var(--bg3); border: 1px solid var(--border); border-radius: 10px; padding: .8rem; }
.comment-composer-actions { display: flex; gap: .7rem; align-items: center; flex-wrap: wrap; margin-top: .2rem; }
.comment-hint { color: var(--muted); font-size: .75rem; }
.comment-upload-list { display: flex; flex-direction: column; gap: .35rem; margin-top: .6rem; }
.comment-upload-item {
    display: flex; align-items: center; justify-content: space-between;
    gap: .6rem; background: rgba(255,255,255,.03); border: 1px solid var(--border);
    border-radius: 8px; padding: .45rem .6rem; font-size: .8rem;
}
.comment-upload-item small { display: block; color: var(--muted); margin-top: .15rem; }
.comment-upload-item button {
    background: none; border: none; color: var(--muted); cursor: pointer;
    width: 26px; height: 26px; border-radius: 6px;
}
.comment-upload-item button:hover { color: var(--danger); background: rgba(239,68,68,.12); }
.comment-upload-total { color: var(--muted); font-size: .75rem; margin-top: .15rem; }
.comment-attachments { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .55rem; }
.comment-attachment {
    display: inline-flex; align-items: center; gap: .5rem; text-decoration: none;
    background: rgba(255,255,255,.03); border: 1px solid var(--border); border-radius: 8px;
    padding: .45rem .55rem; max-width: 220px;
}
.comment-attachment.file i { color: var(--primary); }
.comment-attachment.file span, .comment-attachment.image span {
    font-size: .78rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.comment-attachment small { color: var(--muted); font-size: .7rem; }
.comment-attachment.image { flex-direction: column; align-items: flex-start; max-width: 170px; }
.comment-attachment.image img {
    width: 100%; max-width: 150px; height: 96px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border);
}
.comment-tools { display: flex; justify-content: flex-end; margin-top: .45rem; }

.image-preview-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.82); z-index: 1200;
    display: none; align-items: center; justify-content: center; padding: 1.25rem;
}
.image-preview-overlay.active { display: flex; }
.image-preview-box { position: relative; max-width: min(96vw, 1100px); max-height: 92vh; display: flex; flex-direction: column; align-items: center; gap: .75rem; }
.image-preview-box img { max-width: 100%; max-height: calc(92vh - 48px); object-fit: contain; border-radius: 10px; box-shadow: var(--shadow); }
.image-preview-caption { color: #fff; font-size: .86rem; text-align: center; max-width: 80ch; }
.image-preview-close {
    position: absolute; top: -12px; right: -12px; width: 38px; height: 38px; border-radius: 999px;
    border: 1px solid rgba(255,255,255,.2); background: rgba(15,17,23,.9); color: #fff; cursor: pointer;
}
.image-preview-close:hover { background: rgba(239,68,68,.9); border-color: rgba(239,68,68,.9); }

/* ── Resolución box ──────────────────────────────────────── */
.resolucion-box { background: rgba(16,185,129,.08); border: 1px solid rgba(16,185,129,.25); border-radius: 8px; padding: .6rem .8rem; color: var(--success, #10b981); font-size: .84rem; margin-top: .5rem; }

/* ── Escalation tree ────────────────────────────────────── */
.esc-tree-wrap { background: var(--bg3); border: 1px solid var(--border); border-radius: 10px; padding: .9rem; }
.esc-tree-root, .esc-tree-children { list-style: none; margin: 0; padding-left: 0; }
.esc-tree-children { margin-left: 1.35rem; padding-left: .9rem; border-left: 1px dashed var(--border); }
.esc-tree-item { margin: .45rem 0; }
.esc-tree-node {
    background: rgba(255,255,255,.02);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: .65rem .8rem;
    transition: border-color .15s, background .15s, transform .15s;
}
.esc-tree-item.current > .esc-tree-node {
    border-color: var(--primary);
    background: rgba(79,126,248,.12);
}
.esc-tree-item:not(.current) > .esc-tree-node { cursor: pointer; }
.esc-tree-item:not(.current) > .esc-tree-node:hover {
    border-color: var(--primary);
    background: rgba(79,126,248,.08);
    transform: translateY(-1px);
}
.esc-tree-main { display: flex; align-items: flex-start; gap: .65rem; }
.esc-tree-icon {
    width: 28px; height: 28px; min-width: 28px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 999px; background: rgba(79,126,248,.15); color: var(--primary);
}
.esc-tree-text { min-width: 0; flex: 1; }
.esc-tree-title { font-size: .84rem; font-weight: 700; line-height: 1.35; word-break: break-word; }
.esc-tree-meta { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .35rem; }

/* ── Acuerdos box ────────────────────────────────────────── */
.acuerdos-box { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: .8rem; font-size: .84rem; line-height: 1.6; white-space: pre-wrap; }

/* ── Asistentes ──────────────────────────────────────────── */
.asistentes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .4rem; max-height: 200px; overflow-y: auto; padding: .5rem; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; }
.asistente-check { display: flex; align-items: center; gap: .4rem; font-size: .84rem; cursor: pointer; padding: .3rem .5rem; border-radius: 6px; transition: background .15s; }
.asistente-check:hover { background: var(--bg2); }
.asistentes-list { display: flex; flex-wrap: wrap; gap: .4rem; }
.avatar-chip { display: flex; align-items: center; gap: .4rem; background: var(--bg3); border: 1px solid var(--border); border-radius: 20px; padding: .25rem .7rem .25rem .3rem; font-size: .82rem; }

/* ── Avatar sm ───────────────────────────────────────────── */
.avatar-sm { width: 30px; height: 30px; min-width: 30px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .78rem; }

/* ── Privilegios tabla ───────────────────────────────────── */
.privilegios-tabla { overflow-x: auto; }
.privilegios-tabla table { font-size: .82rem; }
.privilegios-tabla th, .privilegios-tabla td { padding: .45rem .7rem; text-align: center; }
.privilegios-tabla td:first-child { text-align: left; font-weight: 500; }
.privilegios-tabla input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }

/* ── Filter select ───────────────────────────────────────── */
.filter-select { background: var(--bg3); border: 1px solid var(--border); color: var(--text); padding: .45rem .7rem; border-radius: 8px; font-size: .84rem; cursor: pointer; }
.filter-select:focus { outline: none; border-color: var(--primary); }

/* ── Table row actions ───────────────────────────────────── */
.tbl-actions { display: flex; gap: .3rem; }
.tbl-actions button { background: none; border: 1px solid var(--border); color: var(--muted); width: 30px; height: 30px; border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: .8rem; transition: color .15s, border-color .15s, background .15s; }
.tbl-actions button:hover { border-color: var(--primary); color: var(--primary); background: rgba(99,102,241,.08); }

/* ── Form full-width group within row ────────────────────── */
.form-group.full { width: 100%; }

/* ── required mark ───────────────────────────────────────── */
.req { color: var(--danger); }

/* ── Notif panel ─────────────────────────────────────────── */
.notif-panel { position: fixed; top: 60px; right: 1rem; width: 320px; background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); max-height: 420px; overflow-y: auto; z-index: 500; display: none; }
.notif-panel.open { display: block; }
.notif-panel-header { padding: .7rem 1rem; border-bottom: 1px solid var(--border); font-size: .83rem; font-weight: 600; color: var(--muted); }
.notif-item { padding: .7rem 1rem; border-bottom: 1px solid var(--border); }
.notif-item.new { background: rgba(99,102,241,.05); }
.notif-item.is-link { cursor: pointer; }
.notif-title { font-size: .84rem; font-weight: 600; margin-bottom: .2rem; }
.notif-msg { font-size: .8rem; color: var(--muted); margin-bottom: .2rem; }
.notif-time { font-size: .72rem; color: var(--muted); }
.multi-select { min-height: 120px; background: var(--bg3); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: .35rem; }
.multi-select:focus { outline: none; border-color: var(--primary); }
.field-help { display: block; margin-top: .35rem; color: var(--muted); font-size: .75rem; }
.muted-inline { color: var(--muted); font-size: .84rem; }
.followers-list { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .2rem; }
.follower-chip { display: inline-flex; align-items: center; gap: .35rem; border: 1px solid var(--border); background: var(--bg3); border-radius: 999px; padding: .28rem .65rem; font-size: .8rem; }

/* ── btn-sm ──────────────────────────────────────────────── */
.btn-sm { padding: .3rem .75rem !important; font-size: .8rem !important; }

/* ── Section heading ─────────────────────────────────────── */
.section-head { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 1rem 0 .4rem; padding: 0; }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(calc(-1 * var(--sidebar-w))); }
    .sidebar.open { transform: translateX(0); }
    .main-wrap { margin-left: 0; }
    .form-row { flex-direction: column; }
    .dash-grid { grid-template-columns: 1fr; }
}

/* ── Topbar user chip (solo tablet/móvil) ─────────────────── */
.topbar-user {
    display: none;
    align-items: center;
    gap: .45rem;
}
.topbar-user-nombre {
    font-size: .8rem;
    font-weight: 600;
    white-space: nowrap;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}
@media (max-width: 768px) {
    .topbar-user { display: flex; }
}
