/* ===================== SoportePlus - Estilos ===================== */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #172033;
  --muted: #64748b;
  --border: #e5e9f2;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef2ff;
  --sidebar: #111827;
  --sidebar-soft: #1f2937;
  --shadow: 0 4px 20px rgba(15, 23, 42, .06);
  --radius: 14px;
  --status-abierto: #3b82f6;
  --status-progreso: #f59e0b;
  --status-resuelto: #10b981;
  --status-cerrado: #64748b;
  --priority-baja: #64748b;
  --priority-media: #3b82f6;
  --priority-alta: #f59e0b;
  --priority-critica: #ef4444;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Segoe UI", Inter, system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
svg { width: 20px; height: 20px; display: block; }

/* ===================== Autenticación ===================== */
.auth-view { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
.auth-brand {
  position: relative;
  overflow: hidden;
  background: linear-gradient(145deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-lighter) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 60px;
}
.auth-brand-inner { position: relative; z-index: 2; max-width: 460px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: rgba(255,255,255,.16); color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-logo-lg { width: 56px; height: 56px; border-radius: 15px; background: rgba(255,255,255,.2); }
.brand-logo-lg svg { width: 30px; height: 30px; }
.auth-brand h1 { font-size: 42px; margin: 24px 0 12px; letter-spacing: -.5px; }
.auth-brand-sub { font-size: 17px; line-height: 1.6; color: rgba(255,255,255,.82); margin: 0 0 36px; }
.auth-features { display: grid; gap: 16px; }
.auth-feature { display: flex; align-items: center; gap: 12px; font-size: 15px; color: rgba(255,255,255,.92); }
.feature-dot {
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: grid; place-items: center; flex-shrink: 0;
}
.feature-dot::after { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #a5f3fc; }
.auth-orb { position: absolute; border-radius: 50%; background: rgba(255,255,255,.07); }
.auth-orb-1 { width: 420px; height: 420px; top: -120px; right: -140px; }
.auth-orb-2 { width: 300px; height: 300px; bottom: -110px; left: -90px; }
.auth-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-mobile-logo { display: none; align-items: center; gap: 10px; margin-bottom: 28px; font-size: 20px; }
.auth-mobile-logo .brand-logo { background: var(--primary); }
.auth-tabs { display: flex; gap: 6px; background: var(--surface-2); padding: 5px; border-radius: 11px; margin-bottom: 26px; }
.auth-tab {
  flex: 1; border: 0; background: transparent; padding: 10px;
  border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 600;
}
.auth-tab.active { background: var(--surface); color: var(--primary); box-shadow: 0 1px 4px rgba(15,23,42,.08); }
.auth-form { display: grid; gap: 18px; }
.field { display: grid; gap: 7px; }
.field-label { font-weight: 600; font-size: 13px; color: #334155; }
input, select, textarea {
  width: 100%; padding: 11px 13px; border: 1px solid var(--border);
  border-radius: 9px; background: var(--surface); color: var(--text);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
textarea { resize: vertical; min-height: 110px; }
.auth-hint {
  background: var(--primary-light); border-radius: 10px; padding: 14px;
  font-size: 12.5px; color: #4338ca; line-height: 1.9;
}
.auth-hint code { background: rgba(79,70,229,.12); padding: 2px 6px; border-radius: 5px; font-weight: 700; }
.auth-footer { margin-top: 28px; color: var(--muted); font-size: 12px; }
.auth-register-link { margin: 2px 0 0; text-align: center; font-size: 12.5px; color: var(--muted); }
.link-button {
  border: 0; background: transparent; padding: 0; cursor: pointer;
  color: var(--primary); font-weight: 700; font-size: inherit;
}
.link-button:hover { text-decoration: underline; }

/* ===================== Botones ===================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 9px; padding: 10px 16px;
  font-weight: 600; cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); border-color: #cbd5e1; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: #fff1f2; color: #e11d48; }
.btn-danger:hover { background: #ffe4e6; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  padding: 8px; border-radius: 8px; display: grid; place-items: center;
}
.icon-btn:hover { background: rgba(148,163,184,.15); color: var(--text); }

/* ===================== Layout app ===================== */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 252px; background: var(--sidebar); color: #cbd5e1;
  display: flex; flex-direction: column; position: fixed;
  top: 0; bottom: 0; left: 0; z-index: 40;
}
.sidebar-brand {
  height: 72px; display: flex; align-items: center; gap: 12px;
  padding: 0 22px; font-size: 18px; font-weight: 700; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-nav { padding: 20px 12px; flex: 1; overflow-y: auto; }
.nav-section { font-size: 10.5px; letter-spacing: 1.3px; color: #64748b; font-weight: 700; padding: 0 12px 10px; }
.nav-section-gap { padding-top: 24px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px;
  border-radius: 9px; color: #cbd5e1; font-weight: 500; margin-bottom: 3px;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--sidebar-soft); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.nav-icon { display: grid; place-items: center; }
.nav-icon svg { width: 19px; height: 19px; }
.sidebar-bottom { padding: 14px; border-top: 1px solid rgba(255,255,255,.07); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 6px; }
.avatar {
  width: 36px; height: 36px; border-radius: 10px; background: var(--primary-dark); color: #fff;
  display: grid; place-items: center; font-weight: 700; flex-shrink: 0; font-size: 13px;
}
.sidebar-user-info { display: grid; min-width: 0; flex: 1; }
.sidebar-user-info strong { font-size: 13px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-info span { font-size: 11px; color: #94a3b8; }
.sidebar-user .icon-btn { color: #94a3b8; }
.sidebar-user .icon-btn:hover { background: var(--sidebar-soft); color: #fff; }
.app-main { flex: 1; margin-left: 252px; min-width: 0; display: flex; flex-direction: column; }
/* La barra de título de cada página se oculta por completo. */
.topbar {
  height: 0; min-height: 0; padding: 0; border: 0;
  background: transparent; position: static;
  display: flex; align-items: center; gap: 0;
}
.topbar-title, .topbar-new { display: none !important; }
.mobile-menu { display: none; }
.sidebar-overlay { display: none; }
.content { padding: 28px 30px 50px; flex: 1; }

/* ===================== Componentes ===================== */
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-heading h3 { margin: 0 0 5px; font-size: 20px; }
.page-heading p { margin: 0; color: var(--muted); font-size: 13px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); display: flex; gap: 14px; align-items: flex-start;
}
.stat-icon { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0; }
.stat-icon svg { width: 21px; height: 21px; }
.stat-body strong { display: block; font-size: 26px; line-height: 1.1; letter-spacing: -.5px; }
.stat-body span { color: var(--muted); font-size: 12.5px; }
.tint-indigo { background: var(--primary-light); color: var(--primary); }
.tint-blue { background: #eff6ff; color: #2563eb; }
.tint-amber { background: #fffbeb; color: #d97706; }
.tint-green { background: #ecfdf5; color: #059669; }
.tint-red { background: #fff1f2; color: #e11d48; }
.tint-slate { background: #f1f5f9; color: #475569; }

/* Cuenta regresiva de atención en el dashboard. */
.countdown-card { margin-bottom: 22px; }
.sla-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.sla-chip {
  font-size: 11.5px; font-weight: 700; color: #475569;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 5px 10px; border-radius: 20px;
}
.countdown-groups { display: grid; gap: 14px; }
.countdown-group { border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.countdown-group-late { background: #fff7f8; border-color: #fecdd3; }
.countdown-group-ontime { background: var(--surface-2); }
.countdown-group-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.countdown-group-head h5 { margin: 0; font-size: 13px; color: #475569; }
.countdown-group-late .countdown-group-head h5 { color: #e11d48; }
.countdown-count {
  min-width: 26px; text-align: center; padding: 3px 8px; border-radius: 20px;
  font-size: 12px; font-weight: 700; background: var(--surface); color: var(--muted);
}
.countdown-group-late .countdown-count { background: #e11d48; color: #fff; }
.countdown-list { display: grid; gap: 8px; }
.countdown-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 14px; align-items: center;
  padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface-2);
}
.countdown-main { min-width: 0; }
.countdown-meta { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.countdown-limit { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.countdown-value {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 14px;
  white-space: nowrap; color: #059669;
}
.countdown-value.warn { color: #d97706; }
.countdown-value.late { color: #e11d48; }
@media (max-width: 800px) {
  .countdown-row { grid-template-columns: 1fr; gap: 6px; }
  .countdown-limit { white-space: normal; }
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { padding: 17px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-header h4 { margin: 0; font-size: 15px; }
.card-header small { color: var(--muted); }
.card-body { padding: 20px; }

.bar-row { display: grid; grid-template-columns: 110px 1fr 34px; align-items: center; gap: 12px; margin-bottom: 14px; font-size: 12.5px; }
.bar-row:last-child { margin-bottom: 0; }
.bar-row > span:first-child { color: #475569; }
.bar-row > span:last-child { text-align: right; font-weight: 700; }
.bar-track { height: 9px; background: #eef2f7; border-radius: 20px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 20px; transition: width .4s; }

.filters {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 15px 18px; margin-bottom: 18px; box-shadow: var(--shadow);
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
}
.filter-group { display: grid; gap: 5px; min-width: 150px; flex: 1; }
.filter-group label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.filter-group input, .filter-group select { padding: 8px 11px; font-size: 13px; }
.filter-search { flex: 2; min-width: 220px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); padding: 13px 18px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); white-space: nowrap;
}
td { padding: 14px 18px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
tbody tr:hover { background: #fafbff; }
tbody tr:last-child td { border-bottom: 0; }
.ticket-code { font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; color: var(--muted); }
.ticket-title { font-weight: 600; color: var(--text); }
.ticket-title:hover { color: var(--primary); }
.ticket-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px;
  border-radius: 20px; font-size: 11.5px; font-weight: 700; white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-abierto { color: var(--status-abierto); background: #eff6ff; }
.badge-en_progreso { color: var(--status-progreso); background: #fffbeb; }
.badge-resuelto { color: var(--status-resuelto); background: #ecfdf5; }
.badge-cerrado { color: var(--status-cerrado); background: #f1f5f9; }
.priority { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-size: 12.5px; }
.priority-dot { width: 8px; height: 8px; border-radius: 50%; }
.priority-baja { color: var(--priority-baja); }
.priority-media { color: var(--priority-media); }
.priority-alta { color: var(--priority-alta); }
.priority-critica { color: var(--priority-critica); }
.priority-baja .priority-dot { background: var(--priority-baja); }
.priority-media .priority-dot { background: var(--priority-media); }
.priority-alta .priority-dot { background: var(--priority-alta); }
.priority-critica .priority-dot { background: var(--priority-critica); }
.assignee { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.assignee .avatar { width: 26px; height: 26px; border-radius: 8px; font-size: 10px; }
.unassigned { color: var(--muted); font-style: italic; font-size: 12px; }
.table-footer { padding: 13px 18px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.row-actions { display: flex; justify-content: flex-end; gap: 4px; }
.row-actions .icon-btn svg { width: 17px; height: 17px; }
.icon-btn.danger:hover { background: #fff1f2; color: #e11d48; }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.icon-btn:disabled:hover { background: transparent; color: var(--muted); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state svg { width: 46px; height: 46px; margin: 0 auto 14px; color: #cbd5e1; }
.empty-state h4 { margin: 0 0 6px; color: var(--text); }
.empty-state p { margin: 0; }

/* ===================== Formularios ===================== */
.form-card { max-width: 760px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.required::after { content: ' *'; color: #ef4444; }
.form-hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; }

/* Vista "Nuevo ticket": formulario compacto para verlo completo sin scroll. */
.content-compact { padding: 16px 24px 20px; }
.content-compact .form-card { max-width: 1140px; }
.content-compact .card-header { padding: 10px 16px; }
.content-compact .card-body { padding: 12px 16px; }
.content-compact #new-ticket-form { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 12px; }
.content-compact .field { gap: 4px; }
.content-compact .field-label { font-size: 12px; line-height: 1.2; }
.content-compact input,
.content-compact select,
.content-compact textarea { padding: 7px 10px; font-size: 13px; }
.content-compact textarea { min-height: 72px; }
.content-compact .form-hint { margin-top: 3px; }
.content-compact .attachment-drop { padding: 8px; gap: 4px; border-radius: 8px; }
.content-compact .attachment-drop .form-hint { font-size: 10.5px; }
.content-compact .form-tail {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: end;
}
.content-compact .form-tail .form-actions { margin: 0; padding: 0; border: 0; }

@media (max-width: 1100px) {
  .content-compact #new-ticket-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content-compact .wide-on-medium { grid-column: 1 / -1; }
  .content-compact .form-tail { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .content-compact #new-ticket-form { grid-template-columns: 1fr; }
}
.catalog-new { display: flex; gap: 8px; align-items: center; }
.catalog-new input { flex: 1; min-width: 0; }
.color-row { display: flex; gap: 8px; align-items: center; }
.color-row input[type="color"] {
  width: 48px; height: 41px; padding: 3px; cursor: pointer; flex-shrink: 0;
  border-radius: 9px; background: var(--surface);
}
.color-row input[type="text"] { flex: 1; min-width: 0; font-family: ui-monospace, Consolas, monospace; }
.logo-preview {
  min-height: 120px; width: 100%; border: 1px dashed var(--border); border-radius: 12px;
  background: var(--surface-2); display: grid; place-items: center; padding: 14px;
}
.logo-preview img { max-height: 92px; max-width: 100%; object-fit: contain; }

/* ===================== Configuración ===================== */
.config-section-title h4 { margin: 0; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .7px; }
.config-section-title p { margin: 5px 0 0; font-size: 12.5px; color: var(--muted); }
.config-section-gap { margin-top: 30px; padding-top: 22px; border-top: 1px solid var(--border); }
.switch-label, .inline-check {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  font-size: 12.5px; color: var(--text); font-weight: 500;
}
.switch-label input, .inline-check input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.smtp-options { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; }
.smtp-options-title {
  width: 100%; margin: 0 0 2px; font-size: 11.5px; font-weight: 700;
  color: var(--muted); text-transform: uppercase; letter-spacing: .6px;
}
.smtp-options-title:not(:first-child) { margin-top: 8px; }
.card-footer-actions {
  padding: 16px 20px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap;
}
.card-footer-actions .btn svg { width: 15px; height: 15px; vertical-align: -2px; margin-right: 3px; }

/* ===================== Plantilla de correo ===================== */
.email-template-block { display: grid; gap: 12px; padding-top: 18px; border-top: 1px solid var(--border); }
.email-template-block .form-grid { gap: 12px; }
.email-template-block textarea {
  min-height: 220px; font-family: ui-monospace, Consolas, monospace;
  font-size: 12px; line-height: 1.55; resize: vertical;
}
.template-vars { display: grid; gap: 6px; }
.template-var-list { display: flex; flex-wrap: wrap; gap: 6px; }
.template-var-list code {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px;
  padding: 2px 6px; font-size: 11px; color: var(--primary);
}
.mail-preview { display: grid; gap: 8px; }
.mail-preview-subject {
  padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; font-weight: 600;
}
.mail-preview-text {
  margin: 0; padding: 12px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; white-space: pre-wrap; word-break: break-word;
  font-size: 12px; line-height: 1.6; max-height: 320px; overflow: auto;
}
.email-assets { display: grid; gap: 16px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.email-asset-block { display: grid; gap: 10px; justify-items: start; }
.email-asset-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.email-template-block textarea#sm-image-urls,
.email-template-block textarea#sm-template-html { min-height: 72px; }
.email-logo-preview {
  min-height: 60px; max-width: 260px; display: flex; align-items: center; justify-content: center;
  padding: 8px; background: var(--surface); border: 1px dashed var(--border); border-radius: 8px;
}
.email-logo-preview img { max-width: 220px; max-height: 80px; height: auto; }
.email-asset-thumbs { display: flex; gap: 10px; flex-wrap: wrap; }
.email-asset-thumb { position: relative; display: inline-block; }
.email-asset-thumb img {
  width: 96px; height: 72px; object-fit: cover; border: 1px solid var(--border); border-radius: 8px;
}
.email-thumb-remove {
  position: absolute; top: -7px; right: -7px; width: 22px; height: 22px; border: 0;
  border-radius: 50%; background: var(--danger); color: #fff; font-size: 15px; line-height: 1; cursor: pointer;
}
.email-asset-empty { color: var(--muted); font-size: 12px; }
.mail-preview-frame {
  width: 100%; min-height: 320px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff;
}
.email-edit { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 300px; }
.email-edit input { min-width: 230px; flex: 1 1 230px; }
.email-edit .btn svg { width: 14px; height: 14px; vertical-align: -2px; margin-right: 3px; }

/* ===================== Catálogos (vista minimalista) ===================== */
.catalog-heading { margin-bottom: 24px; }
.catalog-heading h3 { font-size: 19px; font-weight: 600; }
.catalog-heading p { font-size: 12.5px; }
.catalog-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; max-width: 900px; }
.catalog-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 10px; border-bottom: 1px solid var(--border); margin-bottom: 2px;
}
.catalog-panel-head h4 { margin: 0; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .7px; }
.link-add {
  border: 0; background: none; color: var(--primary); cursor: pointer;
  font-size: 12.5px; font-weight: 600; padding: 4px 2px;
}
.link-add:hover { text-decoration: underline; }
.catalog-list { list-style: none; margin: 0; padding: 0; }
.catalog-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 2px; border-bottom: 1px solid var(--border);
}
.catalog-name { flex: 1; font-size: 13.5px; color: var(--text); }
.catalog-count { font-size: 11.5px; color: var(--muted); min-width: 18px; text-align: right; }
.catalog-action {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  display: grid; place-items: center; padding: 5px; border-radius: 6px;
  opacity: .45; transition: opacity .15s, background .15s, color .15s;
}
.catalog-item:hover .catalog-action, .catalog-action:focus-visible { opacity: 1; }
.catalog-action svg { width: 15px; height: 15px; }
.catalog-action:hover { background: var(--surface-2); color: var(--text); }
.catalog-action.danger:hover { background: #fff1f2; color: #e11d48; }
.catalog-empty { color: var(--muted); font-size: 12.5px; padding: 14px 2px; margin: 0; }

/* ===================== Detalle ticket ===================== */
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; margin-bottom: 18px; font-size: 13px; }
.back-link:hover { color: var(--primary); }
.back-link svg { width: 16px; height: 16px; }
.detail-header {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.detail-header-top { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.detail-header h3 { margin: 6px 0 10px; font-size: 22px; }
.detail-header .ticket-code { font-size: 12px; }
.detail-badges { display: flex; gap: 8px; flex-wrap: wrap; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.detail-meta {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
  margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border);
}
.meta-item span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700; margin-bottom: 5px; }
.meta-item strong { font-size: 13px; font-weight: 600; }
.detail-layout { display: grid; grid-template-columns: 1fr 320px; gap: 18px; align-items: start; }
.timeline { display: grid; gap: 18px; }
.comment { display: flex; gap: 12px; }
.comment .avatar { background: #e0e7ff; color: var(--primary); }
.comment-main { flex: 1; min-width: 0; }
.comment-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.comment-head strong { font-size: 13px; }
.comment-head time { font-size: 11px; color: var(--muted); }
.comment-role { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--primary); font-weight: 700; }
.comment-body {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
}
.activity { display: grid; gap: 0; }
.activity-item { display: flex; gap: 12px; position: relative; padding-bottom: 18px; }
.activity-item:not(:last-child)::before {
  content: ''; position: absolute; left: 5px; top: 14px; bottom: 0; width: 2px; background: var(--border);
}
.activity-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--primary); margin-top: 4px; flex-shrink: 0; z-index: 1; box-shadow: 0 0 0 3px var(--primary-light); }
.activity-item p { margin: 0; font-size: 12.5px; }
.activity-item time { font-size: 11px; color: var(--muted); }
.activity-item small { display: block; color: var(--muted); margin-top: 2px; }

/* ===================== Modal / Toast ===================== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: var(--surface); border-radius: 16px; width: 100%; max-width: 520px;
  box-shadow: 0 24px 60px rgba(15,23,42,.25); overflow: hidden;
}
.modal-header { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-header h4 { margin: 0; font-size: 16px; }
.modal-body { padding: 22px; display: grid; gap: 16px; max-height: 65vh; overflow-y: auto; }
.modal-footer { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.toast-root { position: fixed; bottom: 24px; right: 24px; z-index: 200; display: grid; gap: 10px; }
.toast {
  background: #1e293b; color: #fff; padding: 13px 17px; border-radius: 10px;
  box-shadow: 0 12px 30px rgba(15,23,42,.25); font-weight: 500; display: flex;
  align-items: center; gap: 10px; animation: slideIn .25s ease;
}
.toast.success { background: #065f46; }
.toast.error { background: #9f1239; }
.toast svg { width: 18px; height: 18px; }
@keyframes slideIn { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ===================== Imágenes adjuntas ===================== */
.attachment-drop {
  border: 1.5px dashed var(--border); border-radius: 12px; background: var(--surface-2);
  padding: 16px; display: flex; flex-direction: column; align-items: center;
  gap: 8px; text-align: center; transition: border-color .15s, background .15s;
}
.attachment-drop.dragging { border-color: var(--primary); background: var(--primary-light); }
.attachment-drop .btn svg { width: 16px; height: 16px; vertical-align: -3px; margin-right: 4px; }
.attachment-drop .form-hint { margin: 0; }
.attachment-preview { display: flex; flex-wrap: wrap; gap: 10px; }
.attachment-preview:empty { display: none; }
.attachment-thumb {
  position: relative; width: 118px; border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; background: var(--surface); padding: 6px;
}
.attachment-thumb img {
  width: 100%; height: 74px; object-fit: cover; border-radius: 6px; display: block; background: var(--surface-2);
}
.attachment-thumb span, .attachment-thumb small {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.attachment-thumb span { font-size: 11.5px; margin-top: 6px; }
.attachment-thumb small { font-size: 10px; color: var(--muted); }
.attachment-remove {
  position: absolute; top: 10px; right: 10px; width: 24px; height: 24px;
  border: 0; border-radius: 50%; background: rgba(15, 23, 42, .75); color: #fff;
  display: grid; place-items: center; cursor: pointer; padding: 0;
}
.attachment-remove:hover { background: #e11d48; }
.attachment-remove svg { width: 13px; height: 13px; }
.attachment-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.attachment-card {
  width: 132px; padding: 0; text-align: left; cursor: pointer; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden; color: var(--text);
  transition: border-color .15s, transform .15s;
}
.attachment-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.attachment-card img { width: 100%; height: 96px; object-fit: cover; display: block; background: var(--surface-2); }
.attachment-card span {
  display: block; padding: 7px 9px; font-size: 11px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.image-modal { max-width: 880px; }
.image-viewer { display: grid; place-items: center; min-height: 180px; }
.image-viewer img { max-width: 100%; max-height: 68vh; object-fit: contain; border-radius: 8px; }

/* ===================== Tema oscuro ===================== */
[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #162033;
  --surface-2: #1e293b;
  --text: #e6edf7;
  --muted: #94a3b8;
  --border: #2d3a50;
  --shadow: 0 4px 22px rgba(0, 0, 0, .35);
}
[data-theme="dark"] tbody tr:hover { background: rgba(255, 255, 255, .035); }
[data-theme="dark"] .bar-track { background: #2d3a50; }
[data-theme="dark"] .empty-state svg { color: #475569; }
[data-theme="dark"] .auth-hint { color: var(--primary); background: var(--primary-light); }
[data-theme="dark"] .auth-hint code { background: rgba(255, 255, 255, .1); }
[data-theme="dark"] .badge-abierto { background: rgba(59, 130, 246, .18); color: #93c5fd; }
[data-theme="dark"] .badge-en_progreso { background: rgba(245, 158, 11, .18); color: #fcd34d; }
[data-theme="dark"] .badge-resuelto { background: rgba(16, 185, 129, .18); color: #6ee7b7; }
[data-theme="dark"] .badge-cerrado { background: rgba(148, 163, 184, .18); color: #cbd5e1; }
[data-theme="dark"] .priority-baja { color: #cbd5e1; }
[data-theme="dark"] .priority-media { color: #93c5fd; }
[data-theme="dark"] .priority-alta { color: #fcd34d; }
[data-theme="dark"] .priority-critica { color: #fca5a5; }
[data-theme="dark"] .btn-secondary:hover { border-color: #475569; }
[data-theme="dark"] .comment-body { background: var(--surface-2); }
[data-theme="dark"] .activity-dot { box-shadow: 0 0 0 3px var(--primary-light); }
[data-theme="dark"] .catalog-action.danger:hover { background: rgba(225, 29, 72, .18); color: #fda4af; }

/* ===================== Responsive ===================== */
@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-layout { grid-template-columns: 1fr; }
  .detail-meta { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .auth-view { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-mobile-logo { display: flex; }
  .sidebar { transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: none; }
  .sidebar-overlay.show { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 30; }
  .app-main { margin-left: 0; }
  .mobile-menu {
    display: grid;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 25;
    background: var(--surface);
    box-shadow: 0 4px 14px rgba(15,23,42,.18);
  }
  .grid-2, .form-grid, .catalog-layout { grid-template-columns: 1fr; gap: 32px; }
  .content { padding: 20px; }
}
@media (max-width: 560px) {
  .stat-grid { grid-template-columns: 1fr; }
  .topbar-new { display: none; }
  .detail-meta { grid-template-columns: 1fr; }
  .page-heading { flex-direction: column; align-items: flex-start; }
}

/* ===================== Impresión de ticket ===================== */
.print-area { display: none; }
@media print {
  @page { size: A4; margin: 15mm; }
  html, body { background: #fff !important; height: auto !important; }
  #auth-view, #app-view, #sidebar-overlay, #modal-root, #toast-root { display: none !important; }
  .print-area {
    display: block !important; color: #111; font-family: Arial, Helvetica, sans-serif;
    font-size: 12px; line-height: 1.45;
  }
  .print-header {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 20px;
    padding-bottom: 10px; border-bottom: 2px solid #1e293b;
  }
  .print-header h2 { margin: 4px 0 0; font-size: 15px; }
  .print-logo { max-width: 140px; max-height: 45px; height: auto; display: block; }
  .print-header-right { text-align: right; display: grid; gap: 2px; }
  .print-header-right strong { font-size: 14px; }
  .print-header-right span { color: #666; font-size: 10px; }
  .print-title { margin: 16px 0 6px; }
  .print-title h1 { margin: 0; font-size: 20px; }
  .print-title p { margin: 4px 0 0; color: #555; }
  .print-section { margin-top: 16px; break-inside: avoid; }
  .print-section h3 {
    margin: 0 0 8px; font-size: 12px; text-transform: uppercase;
    letter-spacing: .05em; border-bottom: 1px solid #ddd; padding-bottom: 4px;
  }
  .print-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px 14px; }
  .print-meta-item { border: 1px solid #e2e8f0; border-radius: 4px; padding: 6px 8px; }
  .print-meta-item span { display: block; color: #64748b; font-size: 9px; text-transform: uppercase; }
  .print-desc { white-space: pre-wrap; border: 1px solid #e2e8f0; border-radius: 4px; padding: 10px; }
  .print-item { padding: 6px 0; border-bottom: 1px solid #f1f5f9; break-inside: avoid; }
  .print-item small { display: block; color: #64748b; font-size: 10px; }
  .print-item p { margin: 4px 0 0; white-space: pre-wrap; }
  .print-empty { color: #64748b; font-style: italic; }
  .print-images { display: flex; flex-wrap: wrap; gap: 8px; }
  .print-images img {
    max-width: 32%; max-height: 190px; object-fit: contain;
    border: 1px solid #e2e8f0; border-radius: 4px;
  }
  .print-footer {
    margin-top: 22px; padding-top: 8px; border-top: 1px solid #ddd;
    color: #666; font-size: 10px; text-align: center;
  }
}
