/* ========= Plenario Tickets — estilos globales ========= */
:root {
    --bg: #f5f7fa;
    --surface: #ffffff;
    --surface-2: #f9fafc;
    --border: #e4e8ee;
    --text: #1e2430;
    --text-muted: #6a7280;
    --primary: #1f4e79;
    --primary-2: #2a6aa8;
    --success: #2e7d32;
    --warning: #c27a00;
    --danger: #c0392b;
    --info: #2a6aa8;
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
    --radius: 8px;
    --panel: var(--surface);
    --panel-2: var(--surface-2);
    --primary-hover: var(--primary-2);
    --accent: #6f42c1;
    --sidebar-w: 240px;
    --topbar-h: 54px;
}
[data-theme="dark"] {
    --bg: #0f1419;
    --surface: #1a212b;
    --surface-2: #141a23;
    --border: #2a3341;
    --text: #e6eaf0;
    --text-muted: #8b95a5;
    --primary: #4a90d9;
    --primary-2: #5fa3eb;
    --shadow: 0 1px 3px rgba(0,0,0,.35), 0 2px 12px rgba(0,0,0,.3);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; color: var(--text); }
h1 { font-size: 22px; font-weight: 600; }
h2 { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
h3 { font-size: 15px; font-weight: 600; }

/* ========== LAYOUT ========== */
.app, .app-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 0; display: flex; flex-direction: column; }
.sidebar-brand { padding: 18px 20px; border-bottom: 1px solid var(--border); }
.sidebar-brand .logo { font-weight: 700; font-size: 15px; color: var(--primary); display: flex; align-items: center; gap: 8px; }
.sidebar-brand .logo::before { content: "T"; display: inline-flex; width: 26px; height: 26px; align-items: center; justify-content: center; background: var(--primary); color: white; border-radius: 6px; font-weight: 800; }
.sidebar-brand .sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; padding-left: 34px; }
.nav { padding: 8px 0; flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.nav-section { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); padding: 14px 20px 6px; font-weight: 700; }
.nav-item, .sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 8px 20px; color: var(--text); cursor: pointer; border-left: 3px solid transparent; font-size: 13px; user-select: none; text-decoration: none; }
.nav-item:hover, .sidebar nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav-item.active, .sidebar nav a.active { background: var(--surface-2); border-left-color: var(--primary); color: var(--primary); font-weight: 600; }
.nav-item .icon { width: 16px; display: inline-flex; justify-content: center; opacity: .75; }
.sidebar-footer { padding: 12px 20px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text-muted); display: flex; justify-content: space-between; align-items: center; }

.main { display: flex; flex-direction: column; min-height: 100vh; }
.topbar { height: 54px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; }
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 12px; }
.breadcrumb { font-size: 13px; color: var(--text-muted); }
.breadcrumb strong { color: var(--text); }
.user-chip { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: white; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; }
.user-name { font-weight: 600; line-height: 1.2; }
.user-rol { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; line-height: 1.2; }

.content { padding: 24px; flex: 1; }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; gap: 16px; flex-wrap: wrap; }
.page-header h1 { margin: 0; font-size: 22px; font-weight: 600; }
.page-header .subtitle { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* ========== CARDS & KPIS ========== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card-title { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 4px; font-weight: 700; }
.card-subtle { color: var(--text-muted); font-size: 12px; }
.kpi { font-size: 28px; font-weight: 700; margin-top: 4px; line-height: 1.1; }
.kpi-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
@media (max-width: 960px) {
    .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
}

/* ========== METRIC ========== */
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.metric { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow); }
.metric-label { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; }
.metric-value { font-size: 22px; font-weight: 700; }
.metric-value.success { color: var(--success); }
.metric-value.danger { color: var(--danger); }
.metric-value.warning { color: var(--warning); }

/* ========== BUTTONS ========== */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 6px; cursor: pointer; font-size: 13px; font-family: inherit; transition: all .15s; text-decoration: none; }
.btn:hover { background: var(--surface-2); border-color: var(--primary); text-decoration: none; }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-2); border-color: var(--primary-2); color: white; }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #e54d3c; border-color: #e54d3c; color: white; }
.btn-success { background: var(--success); color: white; border-color: var(--success); }
.btn-warning { background: var(--warning); color: white; border-color: var(--warning); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-group { display: inline-flex; gap: 6px; }
.btn-ghost { background: transparent; border: 1px solid transparent; color: var(--text); padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.btn-ghost:hover { background: var(--surface-2); }

/* ========== FORM ========== */
.input, select, textarea, input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], input[type=time], input[type=search] { width: 100%; padding: 7px 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 6px; font-size: 13px; font-family: inherit; }
.input:focus, select:focus, textarea:focus, input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(31,78,121,.15); }
textarea { min-height: 80px; resize: vertical; }
label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; font-weight: 600; }
.filter-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; align-items: end; margin-bottom: 16px; }
.row-filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.row-filters > * { min-width: 160px; }
.form-row { display: block; margin-bottom: 12px; }
.form-row > label { display: block; margin-bottom: 4px; }
.form-row > input, .form-row > select, .form-row > textarea { width: 100%; }
.form-row > .help { margin-top: 4px; }
.form-row-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 12px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 12px; }
.form-row-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 12px; }
.flag { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; font-weight: normal; color: var(--text); }
.field-error { color: var(--danger); font-size: 12px; }
.req { color: var(--danger); }
.help { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.form-row.inline-toggle { display: flex; align-items: center; justify-content: flex-start; gap: 12px; }
.form-row.inline-toggle > label:first-child { margin-bottom: 0; flex: 0 0 auto; min-width: 140px; }
.inline-toggle { display: flex; align-items: center; gap: 12px; }
.cbx-list { border: 1px solid var(--border); border-radius: 6px; max-height: 180px; overflow-y: auto; padding: 6px 8px; background: var(--surface); }
.cbx-list label { display: flex; align-items: center; gap: 8px; padding: 4px 2px; font-size: 13px; color: var(--text); font-weight: normal; cursor: pointer; margin: 0; }
.cbx-list label:hover { background: var(--surface-2); }
.cbx-list input[type=checkbox] { width: auto; margin: 0; }

/* ========== TABLE ========== */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--surface); }
.tbl th { text-align: left; padding: 10px 12px; background: var(--surface-2); color: var(--text-muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; border-bottom: 2px solid var(--border); }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:hover td { background: var(--surface-2); }
.tbl tr:last-child td { border-bottom: none; }
.tbl .mono { font-family: 'JetBrains Mono', 'Consolas', monospace; font-size: 12px; }
.tbl tr.unread td { font-weight: 600; }
.tbl tr.unread td:first-child { border-left: 3px solid var(--primary); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mono { font-family: 'JetBrains Mono', 'Consolas', monospace; font-size: 12px; }

/* ========== PILLS ========== */
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--border); color: var(--text); }
.pill-success { background: rgba(46,125,50,.15); color: var(--success); }
.pill-warning { background: rgba(194,122,0,.15); color: var(--warning); }
.pill-danger { background: rgba(192,57,43,.15); color: var(--danger); }
.pill-info { background: rgba(42,106,168,.15); color: var(--info); }
.pill-muted { background: var(--border); color: var(--text-muted); }
.pill-accent { background: rgba(111,66,193,.15); color: var(--accent); }

/* ========== TOAST ========== */
.toast-stack, #toasts { position: fixed; top: 20px; right: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 10px 16px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: 6px; box-shadow: var(--shadow); min-width: 260px; font-size: 13px; animation: slideIn .25s ease; }
.toast.success { border-left-color: var(--success); }
.toast.danger, .toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.info { border-left-color: var(--info); }
@keyframes slideIn { from { transform: translateX(120%); } to { transform: translateX(0); } }

/* ========== MODAL ========== */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 500; display: flex; align-items: center; justify-content: center; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); width: 640px; max-width: 92vw; max-height: 88vh; display: flex; flex-direction: column; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); }

/* ========== SWITCH ========== */
.switch { position: relative; display: inline-block; width: 48px; height: 26px; }
.switch input { display: none; }
.slider { position: absolute; cursor: pointer; inset: 0; background: #cfd5dd; border-radius: 26px; transition: .2s; }
.slider::before { content: ""; position: absolute; height: 20px; width: 20px; left: 3px; top: 3px; background: white; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--success); }
.switch input:checked + .slider::before { transform: translateX(22px); }

/* ========== WIZARD ========== */
.wizard-steps { display: flex; gap: 0; margin-bottom: 20px; border-bottom: 1px solid var(--border); padding: 0; }
.wizard-step { flex: 1; padding: 12px 16px; cursor: pointer; text-align: center; font-size: 13px; color: var(--text-muted); border-bottom: 3px solid transparent; }
.wizard-step.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.wizard-step.done { color: var(--success); }
.wizard-step .step-num { display: inline-flex; width: 22px; height: 22px; border-radius: 50%; background: var(--border); color: var(--text-muted); align-items: center; justify-content: center; font-size: 11px; font-weight: 700; margin-right: 6px; }
.wizard-step.active .step-num { background: var(--primary); color: white; }
.wizard-step.done .step-num { background: var(--success); color: white; }
.wizard-actions { display: flex; justify-content: space-between; margin-top: 20px; gap: 8px; }

/* ========== TIMELINE ========== */
.timeline { position: relative; padding: 0 0 0 24px; list-style: none; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.timeline-item { position: relative; padding: 0 0 20px; }
.timeline-item::before { content: ""; position: absolute; left: -21px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--primary); border: 2px solid var(--surface); }
.timeline-item.success::before { background: var(--success); }
.timeline-item.warning::before { background: var(--warning); }
.timeline-item.danger::before { background: var(--danger); }
.timeline-item.muted::before { background: var(--text-muted); }
.timeline-item .ti-head { font-weight: 600; margin-bottom: 2px; font-size: 13px; }
.timeline-item .ti-meta { color: var(--text-muted); font-size: 11px; margin-bottom: 6px; }
.timeline-item .ti-body { font-size: 13px; background: var(--surface-2); padding: 10px 14px; border-radius: 6px; border: 1px solid var(--border); line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.timeline-item .ti-actions { margin-top: 8px; display: flex; gap: 6px; }

/* ========== MISC ========== */
.separator { height: 1px; background: var(--border); margin: 16px 0; }
.login-wrap, .login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1f4e79, #2a6aa8); padding: 20px; }
.login-card, .login-box { background: var(--surface); width: 420px; max-width: 100%; border-radius: 12px; padding: 32px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-logo { text-align: center; font-size: 24px; font-weight: 700; color: var(--primary); margin-bottom: 6px; }
.login-sub { text-align: center; color: var(--text-muted); margin-bottom: 24px; font-size: 13px; }
.login-box h1 { margin: 0 0 6px; font-size: 20px; font-weight: 600; text-align: center; color: var(--primary); }
.login-box .field { margin-bottom: 14px; }
.login-box label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.login-box button { width: 100%; padding: 10px; justify-content: center; }
.login-tabs { display: flex; margin-bottom: 24px; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.login-tab { flex: 1; padding: 8px; text-align: center; font-size: 13px; cursor: pointer; background: var(--surface-2); color: var(--text-muted); border: none; font-family: inherit; }
.login-tab.active { background: var(--primary); color: white; font-weight: 600; }
.hidden { display: none !important; }
.badge-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.badge-dot.on { background: var(--success); box-shadow: 0 0 0 3px rgba(46,125,50,.18); }
.badge-dot.off { background: #c0c4ca; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }
.drag-handle { cursor: grab; color: var(--text-muted); padding-right: 8px; }
.pager { display: flex; gap: 4px; padding: 12px; justify-content: center; flex-wrap: wrap; }
.demo-banner { background: #fff8e1; border-bottom: 1px solid #f5d87a; padding: 6px 24px; font-size: 12px; color: #8a6400; text-align: center; }
[data-theme="dark"] .demo-banner { background: #2d2410; color: #e3b94f; border-color: #4a3a10; }

/* ========== Overlay "Procesando" ========== */
.busy-overlay { position: fixed; inset: 0; background: rgba(15,20,25,.55); z-index: 9999; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff; font-size: 18px; gap: 24px; backdrop-filter: blur(2px); animation: fadeIn .15s ease; }
.busy-overlay .spinner { width: 64px; height: 64px; border: 6px solid rgba(255,255,255,.2); border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; }
.busy-overlay .busy-msg { font-weight: 600; text-shadow: 0 2px 8px rgba(0,0,0,.5); }
.busy-overlay .busy-sub { font-size: 13px; color: rgba(255,255,255,.85); max-width: 400px; text-align: center; line-height: 1.4; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ========== Botones-icono ========== */
.btn-icon { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 6px; cursor: pointer; font-size: 14px; line-height: 1; transition: all .15s; text-decoration: none; }
.btn-icon:hover { background: var(--surface-2); border-color: var(--primary); color: var(--primary); text-decoration: none; }
.btn-icon-danger:hover { border-color: var(--danger); color: var(--danger); }

/* ========== Icono info con tooltip ========== */
.info-tip { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; border-radius: 50%; background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); font-size: 10px; font-style: normal; cursor: help; margin-left: 4px; vertical-align: middle; font-weight: 700; }
.info-tip:hover { background: var(--primary); color: white; border-color: var(--primary); }
.info-tip[data-tip]:hover::after { content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%); background: #1e2430; color: #fff; padding: 8px 12px; border-radius: 6px; font-size: 12px; font-weight: normal; line-height: 1.4; white-space: pre-wrap; width: max-content; max-width: 360px; z-index: 1000; box-shadow: 0 4px 16px rgba(0,0,0,.25); pointer-events: none; }
.info-tip[data-tip]:hover::before { content: ""; position: absolute; left: 50%; bottom: calc(100% + 2px); transform: translateX(-50%); border: 6px solid transparent; border-top-color: #1e2430; z-index: 1001; }

/* ========== Ticket-specific ========== */
/* ========== Switch Vista Lista/Kanban ========== */
.view-switch {
    display: inline-flex; gap: 0; margin: 6px 0 12px;
    border: 1px solid var(--border); border-radius: 8px;
    background: var(--surface); overflow: hidden;
}
.view-switch-btn {
    padding: 6px 14px; font-size: 13px; color: var(--text-muted); text-decoration: none;
    border-right: 1px solid var(--border); cursor: pointer; transition: all .15s;
    user-select: none;
}
.view-switch-btn:last-child { border-right: none; }
.view-switch-btn:hover { background: var(--surface-2); color: var(--text); }
.view-switch-btn.active { background: var(--primary); color: white; font-weight: 600; }

/* ========== Kanban board ========== */
.kanban-board {
    display: flex; gap: 12px; overflow-x: auto; padding: 4px 2px 12px;
    align-items: flex-start; min-height: 200px;
}
.kanban-col {
    flex: 0 0 280px; min-width: 280px; max-width: 320px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    display: flex; flex-direction: column; max-height: calc(100vh - 320px);
}
.kanban-col-header {
    padding: 8px 10px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    background: var(--surface-2); border-radius: 8px 8px 0 0;
}
.kanban-col-count { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.kanban-col-body {
    padding: 8px; display: flex; flex-direction: column; gap: 6px;
    overflow-y: auto; flex: 1; min-height: 80px;
}
.kanban-col-body.drag-over { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.kanban-col-empty {
    text-align: center; color: var(--text-muted); font-size: 11px;
    padding: 16px 8px; font-style: italic; opacity: .6;
}

.kanban-card {
    background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
    padding: 8px 10px; cursor: grab; font-size: 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
    transition: transform .1s, box-shadow .15s;
    user-select: none;
}
.kanban-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.10); border-color: var(--primary); }
.kanban-card.dragging { opacity: .4; cursor: grabbing; }
.kanban-card.ticket-pendiente { background: #fde2e7; }
.kanban-card.ticket-vencido { border-left: 3px solid var(--danger); }
.kanban-card.ticket-tomado { border-left: 3px solid var(--success); }
.kanban-card.unread { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
[data-theme="dark"] .kanban-card.ticket-pendiente { background: #4a2730; }

.kanban-card-head { display: flex; gap: 6px; align-items: center; margin-bottom: 4px; flex-wrap: wrap; }
.kanban-card-head .mono { font-size: 12px; font-weight: 700; color: var(--primary); text-decoration: none; }
.kanban-card-ref { font-size: 10px; color: var(--text-muted); font-family: monospace; }
.kanban-card-oe { font-size: 9px; color: var(--text-muted); background: var(--surface-2); padding: 1px 5px; border-radius: 8px; font-weight: 600; }
.kanban-card-asunto {
    font-size: 12px; line-height: 1.35; margin: 3px 0;
    color: var(--text); font-weight: 500;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; text-overflow: ellipsis;
}
.kanban-card-meta { font-size: 10.5px; color: var(--text-muted); display: flex; gap: 3px; flex-wrap: wrap; }
.kanban-card-foot { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 5px; }
.kanban-card-badge { font-size: 10px; padding: 1px 5px; background: var(--surface-2); border-radius: 8px; }

.ticket-vencido td { color: var(--danger); }
.ticket-tomado td:first-child { border-left: 3px solid var(--success); }

/* Tickets pendientes: fila entera rosa pastel (idem grilla del Plenario Winform).
   El left-border + el fondo se mantienen también en hover, por encima del hover default. */
.ticket-pendiente td:first-child { border-left: 3px solid var(--warning); }
.ticket-pendiente td { background: #fde2e7; }
.tbl tr.ticket-pendiente:hover td { background: #fbcfd8; }
[data-theme="dark"] .ticket-pendiente td { background: #4a2730; }
[data-theme="dark"] .tbl tr.ticket-pendiente:hover td { background: #5a323d; }
.nota-cliente .ti-body { border-left: 3px solid var(--accent); }
.nota-auditoria .ti-body { background: var(--surface); border-style: dashed; font-size: 11px; color: var(--text-muted); }
.workflow-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; padding: 12px 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); }
.avance-bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.avance-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width .3s; }

/* ========== Grouped ticket view ========== */
.group-header-asignado td { background: var(--surface); border-top: 2px solid var(--border); padding: 10px 16px; font-size: 13px; color: var(--text); letter-spacing: .02em; }
.group-header-estado td { background: color-mix(in srgb, var(--primary) 8%, var(--bg)); padding: 6px 16px 6px 32px; font-size: 12px; color: var(--primary); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }

/* ========== Compact ticket table ========== */
.tbl-compact td, .tbl-compact th { padding: 4px 6px; }
.tbl-compact th { font-size: 11px; white-space: nowrap; }
.drag-handle { user-select: none; }
.drag-handle:hover { background: var(--surface-2); color: var(--text); }
tr[draggable=true]:hover .drag-handle { color: var(--primary); }
tr[draggable=true].dragging { box-shadow: 0 2px 12px rgba(0,0,0,.15); }
/* Drop hover dentro del mismo subgrupo — feedback verde */
tr[draggable=true].drop-blocked { background: rgba(192, 57, 43, .08); cursor: not-allowed; }
tr[draggable=true].drop-blocked td { border-top: 1px dashed var(--danger); }
/* Animación flash al rechazar un drop entre subgrupos distintos */
tr[draggable=true].drop-rejected { animation: dropReject .4s ease-out; }
@keyframes dropReject {
    0%   { background: rgba(192, 57, 43, .25); }
    100% { background: transparent; }
}

/* ========== Módulo Mensajería WhatsApp ========== */
.wa-inbox { display: grid; grid-template-columns: 320px 1fr 280px; gap: 0; height: calc(100vh - 180px); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.wa-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; background: var(--surface); }
.wa-filters { padding: 8px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.wa-filters input, .wa-filters select { width: 100%; font-size: 12px; }
.wa-conv-list { flex: 1; overflow-y: auto; }
.wa-conv-item { display: flex; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; text-decoration: none; color: var(--text); }
.wa-conv-item:hover { background: var(--surface-2); }
.wa-conv-item.active { background: color-mix(in srgb, var(--primary) 12%, transparent); border-left: 3px solid var(--primary); }
.wa-avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, #25D366, #128C7E); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; flex-shrink: 0; }
.wa-conv-body { flex: 1; min-width: 0; }
.wa-conv-head { display: flex; justify-content: space-between; gap: 6px; }
.wa-conv-preview { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-conv-meta { display: flex; gap: 4px; margin-top: 4px; align-items: center; }

.wa-thread { display: flex; flex-direction: column; background: var(--bg); }
.wa-thread-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--text-muted); }
.wa-thread-head { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
.wa-messages { flex: 1; overflow-y: auto; padding: 16px; background: linear-gradient(180deg, var(--bg), var(--surface-2)); }
.wa-msg { display: flex; margin: 6px 0; }
.wa-msg-in { justify-content: flex-start; }
.wa-msg-out { justify-content: flex-end; }
.wa-msg-body { max-width: 70%; padding: 8px 12px; border-radius: 12px; font-size: 13px; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.wa-msg-in .wa-msg-body { background: var(--surface); }
.wa-msg-out .wa-msg-body { background: #dcf8c6; color: #1f2c2f; }
[data-theme="dark"] .wa-msg-out .wa-msg-body { background: #056162; color: #fff; }
.wa-msg-time { font-size: 10px; color: var(--text-muted); margin-top: 4px; text-align: right; }
.wa-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); background: var(--surface); }
.wa-input textarea { flex: 1; resize: none; padding: 8px; border: 1px solid var(--border); border-radius: 8px; font-family: inherit; font-size: 13px; }
.wa-input button { padding: 8px 16px; }

.wa-details { border-left: 1px solid var(--border); padding: 16px; overflow-y: auto; background: var(--surface); }
.wa-details h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }

/* ========== Multi-select dropdown ========== */
.ms-drop { position: relative; display: inline-block; width: 100%; }
.ms-drop-btn { width: 100%; text-align: left; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 7px 10px; font-size: 13px; cursor: pointer; color: var(--text); display: flex; justify-content: space-between; align-items: center; gap: 8px; font-family: inherit; }
.ms-drop-btn:hover { border-color: var(--primary); }
.ms-drop-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-drop-caret { font-size: 10px; color: var(--text-muted); flex-shrink: 0; }
.ms-drop-menu { display: none; position: absolute; left: 0; top: 100%; z-index: 200; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); min-width: 100%; max-height: 280px; overflow-y: auto; box-shadow: 0 4px 16px rgba(0,0,0,.18); padding: 4px 0; margin-top: 2px; }
.ms-drop.open .ms-drop-menu { display: block; }
.ms-drop-actions { display: flex; gap: 4px; padding: 4px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.ms-drop-action { flex: 1; background: var(--surface-2); border: 1px solid var(--border); border-radius: 3px; padding: 3px 6px; font-size: 11px; cursor: pointer; color: var(--text); }
.ms-drop-action:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.ms-drop-item { display: flex; align-items: center; gap: 6px; padding: 5px 12px; cursor: pointer; font-size: 12px; color: var(--text); white-space: nowrap; }
.ms-drop-item:hover { background: var(--surface-2); }
.ms-drop-item input[type=checkbox] { margin: 0; cursor: pointer; }

/* ========== Quick-action bar ========== */
.qa-bar { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; }
.qa-btn { background: none; border: 1px solid transparent; border-radius: 4px; padding: 2px 5px; font-size: 13px; cursor: pointer; color: var(--text-muted); line-height: 1.4; text-decoration: none; display: inline-flex; align-items: center; transition: background .1s, border-color .1s; }
.qa-btn:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.qa-btn-active { color: var(--success); border-color: color-mix(in srgb, var(--success) 40%, transparent); }
.qa-btn-warn { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 40%, transparent); }
.qa-btn-entregar:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); border-color: var(--accent); color: var(--accent); }

/* Chips de @-mención: distinguir staff vs cliente, resaltar solicitante */
.mention-chip { font-size: 11px; padding: 2px 8px; border-radius: 12px; border: 1px solid var(--border); cursor: pointer; user-select: none; line-height: 1.5; display: inline-block; }
.mention-staff { background: color-mix(in srgb, var(--info, var(--accent)) 10%, transparent); color: var(--text); }
.mention-staff:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); border-color: var(--accent); }
.mention-cliente { background: color-mix(in srgb, var(--success) 10%, transparent); color: var(--text); }
.mention-cliente:hover { background: color-mix(in srgb, var(--success) 22%, transparent); border-color: var(--success); }
.mention-solicitante { background: color-mix(in srgb, var(--warning) 22%, transparent) !important; border-color: var(--warning) !important; font-weight: 700; }
.mention-solicitante::after { content: " ★"; color: var(--warning); }

/* dropdown */
.qa-drop { position: relative; display: inline-block; }
.qa-menu { display: none; position: absolute; right: 0; top: 100%; z-index: 200; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); min-width: 160px; box-shadow: 0 4px 16px rgba(0,0,0,.18); padding: 4px 0; }
.qa-drop.open .qa-menu { display: block; }
.qa-menu-item, button.qa-menu-item { display: block; width: 100%; text-align: left; background: none; border: none; padding: 7px 12px; font-size: 12px; cursor: pointer; color: var(--text); white-space: nowrap; font-family: inherit; }
.qa-menu-item:hover, button.qa-menu-item:hover { background: var(--surface-2); }
.qa-menu-current { background: color-mix(in srgb, var(--primary, var(--accent)) 12%, transparent); font-weight: 600; }
.qa-menu-current::before { content: "● "; color: var(--primary, var(--accent)); }
/* Hacer que los qa-menu sean más altos cuando tienen muchos ítems */
.qa-menu { max-height: 320px; overflow-y: auto; }
/* Variante: menú anclado al borde izquierdo (cuando el dropdown está en una columna angosta) */
.qa-menu-left { right: auto; left: 0; }

/* ---------- Pills clickeables (inline dropdowns) ---------- */
.pill-drop { display: inline-block; max-width: 100%; }
.pill-clickable {
    cursor: pointer; font-family: inherit; border-width: 1px; border-style: solid;
    padding: 2px 6px; line-height: 1.3;
    display: inline-flex; align-items: center; gap: 4px;
    max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    transition: filter .1s, box-shadow .1s;
}
.pill-clickable:hover { filter: brightness(1.08); box-shadow: 0 0 0 1px var(--accent); }
.pill-caret { font-size: 8px; opacity: .6; }

/* ---------- Input editable para OE ---------- */
.oe-input {
    width: 48px; height: 22px; padding: 0 4px; margin-top: 2px;
    font-size: 11px; font-weight: 600; font-family: inherit; text-align: center;
    border: 1px solid transparent; border-radius: 3px;
    background: transparent; color: var(--text-muted);
    -moz-appearance: textfield;  /* Firefox: ocultar spinners */
    box-sizing: border-box;
}
.oe-input::-webkit-outer-spin-button, .oe-input::-webkit-inner-spin-button {
    -webkit-appearance: none; margin: 0;  /* Chrome/Safari: ocultar spinners */
}
.oe-input:hover { background: var(--surface-2); cursor: text; }
.oe-input:focus { outline: none; border-color: var(--accent); background: var(--surface); color: var(--text); cursor: text; }
.oe-input.oe-saving { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.oe-input.oe-saved { background: color-mix(in srgb, var(--success) 25%, transparent); }
.oe-input.oe-error { background: color-mix(in srgb, var(--danger) 25%, transparent); }

/* REF# input — mismo patrón visual que OE, ancho un poco mayor para 6 dígitos */
.ref-input {
    width: 64px; height: 18px; padding: 0 4px;
    font-size: 10px; font-family: inherit; text-align: center;
    border: 1px solid transparent; border-radius: 3px;
    background: transparent; color: var(--text-muted);
    -moz-appearance: textfield; box-sizing: border-box;
}
.ref-input::-webkit-outer-spin-button, .ref-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ref-input:hover { background: var(--surface-2); cursor: text; }
.ref-input:focus { outline: none; border-color: var(--accent); background: var(--surface); color: var(--text); cursor: text; }
.ref-input.oe-saving { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.ref-input.oe-saved { background: color-mix(in srgb, var(--success) 25%, transparent); }
.ref-input.oe-error { background: color-mix(in srgb, var(--danger) 25%, transparent); }

/* ---------- Cliente NO ABONADO (Categoria_2 = NA) ----------
   Inspirado en Plenario Winform: italic + color gris claro para distinguir
   clientes que no tienen abono activo. */
.cli-no-abonado .cli-nombre {
    font-style: italic;
    color: var(--text-muted);
    font-weight: 500;
}
[data-theme="dark"] .cli-no-abonado .cli-nombre { color: #9aa3b0; }
.grv-cri { color: var(--danger) !important; }
.grv-imp { color: var(--warning) !important; }
.grv-nor { color: var(--success) !important; }

/* ========== Group collapse toggle ========== */
.grp-toggle { display: inline-block; width: 14px; transition: transform .15s; font-size: 11px; }
.group-header-asignado:hover td, .group-header-estado:hover td { filter: brightness(0.96); }

/* ========== Quill editor ========== */
.ql-toolbar.ql-snow { border-color: var(--border); background: var(--surface); border-radius: var(--radius) var(--radius) 0 0; }
.ql-container.ql-snow { border-color: var(--border); border-radius: 0 0 var(--radius) var(--radius); min-height: 160px; font-family: inherit; font-size: 13px; }
.ql-editor { min-height: 160px; color: var(--text); background: var(--bg); }
.ql-editor.ql-blank::before { color: var(--text-muted); font-style: normal; }
[data-theme="dark"] .ql-toolbar.ql-snow .ql-stroke { stroke: var(--text); }
[data-theme="dark"] .ql-toolbar.ql-snow .ql-fill { fill: var(--text); }
[data-theme="dark"] .ql-toolbar.ql-snow .ql-picker-label { color: var(--text); }

/* ========== RTF rendering ========== */
.rtf-content { font-size: 13px; line-height: 1.6; color: var(--text); word-wrap: break-word; }
.rtf-content p { margin: 0 0 8px; }
.rtf-content p:last-child { margin-bottom: 0; }
.rtf-content ul, .rtf-content ol { margin: 4px 0 8px 24px; }
.rtf-content table { border-collapse: collapse; margin: 8px 0; }
.rtf-content table td, .rtf-content table th { border: 1px solid var(--border); padding: 4px 8px; font-size: 12px; }
.rtf-content img { max-width: 100%; height: auto; }
.rtf-content a { color: var(--primary); }
.rtf-content pre, .rtf-content code { background: var(--surface-2); border-radius: 3px; padding: 1px 4px; font-family: monospace; font-size: 12px; }
.rtf-preview { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; margin-bottom: 4px; max-height: 200px; overflow-y: auto; font-size: 12px; line-height: 1.5; }

/* ========== Loading overlay ========== */
.loading-overlay { position: fixed; inset: 0; z-index: 9999; backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); background: rgba(0,0,0,.12); display: flex; align-items: center; justify-content: center; }
.loading-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 28px; display: flex; align-items: center; gap: 12px; box-shadow: 0 8px 32px rgba(0,0,0,.18); font-size: 14px; font-weight: 500; }
@keyframes tkt-spin { to { transform: rotate(360deg); } }
.loading-spinner { width: 20px; height: 20px; border: 2.5px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: tkt-spin .7s linear infinite; flex-shrink: 0; }
