:root {
  --primary: #1a1a1a;
  --primary-dark: #000000;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --bg: #f1f5f9;
  --sidebar-bg: #2d2d2d;
  --sidebar-text: #c8c8c8;
  --sidebar-active: #565656;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --text: #2d2d2d;
  --text-muted: #64748b;
  --radius: 10px;
  --shadow: 0 1px 4px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); }

/* SCREENS */
.screen { display: none; }
.screen.active { display: flex; }

/* LOGIN */
#login-screen {
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #2d2d2d 0%, #4a4a4a 100%);
}
.login-box {
  background: white;
  border-radius: 16px;
  padding: 48px 40px;
  width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.logo { text-align: center; margin-bottom: 32px; }
.logo-icon { font-size: 48px; }
.logo h1 { font-size: 24px; font-weight: 700; color: var(--text); margin-top: 8px; }
.logo p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.field input {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 14px; transition: border-color .2s;
}
.field input:focus { outline: none; border-color: var(--primary); }
.error-msg { background: #fef2f2; color: var(--danger); border-radius: 8px; padding: 10px 14px; font-size: 13px; margin-bottom: 12px; }

/* APP LAYOUT */
#app-screen { min-height: 100vh; }
.sidebar {
  width: 220px; min-height: 100vh; background: var(--sidebar-bg);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.sidebar-header {
  padding: 20px 18px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.logo-icon-sm { font-size: 24px; }
.app-title { color: white; font-weight: 700; font-size: 16px; }
.nav-links { list-style: none; padding: 12px 0; flex: 1; }
.nav-links li { }
.nav-link {
  display: block; padding: 11px 18px; color: var(--sidebar-text);
  text-decoration: none; font-size: 14px; transition: background .15s, color .15s;
  border-radius: 0;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: white; }
.nav-link.active { background: var(--sidebar-active); color: white; font-weight: 600; }
.sidebar-footer {
  padding: 16px 18px; border-top: 1px solid rgba(255,255,255,.07);
  display: flex; flex-direction: column; gap: 8px;
}
.sidebar-footer span { color: var(--sidebar-text); font-size: 13px; }
.main-content { flex: 1; overflow-y: auto; }

/* VIEWS */
.view { display: none; padding: 32px; }
.view.active { display: block; }
.view-header {
  margin-bottom: 28px; display: flex; align-items: flex-start;
  justify-content: space-between; gap: 16px;
}
.view-header-text { flex: 1; }
.view-header h2 { font-size: 22px; font-weight: 700; }
.view-header p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

/* BUTTONS */
.btn-primary {
  background: var(--primary); color: white; border: none; border-radius: 8px;
  padding: 10px 20px; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background .15s; width: 100%;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 12px; border: 1px solid #dadce0; border-radius: 8px;
  background: white; color: #3c4043; font-size: 15px; font-weight: 500;
  text-decoration: none; cursor: pointer; transition: background .15s;
}
.btn-google:hover { background: #f8f9fa; }
.btn-secondary {
  background: white; color: var(--primary); border: 1.5px solid var(--primary);
  border-radius: 8px; padding: 8px 16px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.btn-secondary:hover { background: #eff6ff; }
.btn-ghost {
  background: transparent; color: var(--sidebar-text); border: 1px solid rgba(255,255,255,.15);
  border-radius: 6px; padding: 6px 12px; font-size: 13px; cursor: pointer;
  transition: background .15s;
}
.btn-ghost:hover { background: rgba(255,255,255,.08); }
.btn-danger {
  background: transparent; color: var(--danger); border: 1px solid var(--danger);
  border-radius: 6px; padding: 4px 10px; font-size: 12px; cursor: pointer;
}

/* UPLOAD ZONE */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  background: white; padding: 40px; text-align: center;
  cursor: pointer; transition: border-color .2s; margin-bottom: 24px;
}
.upload-zone:hover { border-color: var(--primary); }
.upload-zone.small { padding: 16px; margin-top: 16px; }
.upload-icon { font-size: 40px; margin-bottom: 12px; }
.upload-zone p { color: var(--text-muted); font-size: 14px; margin-bottom: 8px; }
.upload-hint { font-size: 12px; color: #94a3b8; margin-bottom: 16px; }
.upload-zone .btn-primary { width: auto; }
.upload-zone .btn-secondary { width: auto; }

/* SPINNER */
#statement-upload-status {
  display: flex; align-items: center; gap: 12px;
  background: white; border-radius: var(--radius); padding: 20px 24px;
  margin-bottom: 20px; border: 1px solid var(--border);
}
.spinner {
  width: 24px; height: 24px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* RESULT CARD */
#statement-result {
  background: white; border-radius: var(--radius); padding: 24px;
  border: 1px solid var(--border); margin-bottom: 24px;
}
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.result-stat { text-align: center; padding: 16px; border-radius: 8px; }
.result-stat.ok { background: #f0fdf4; }
.result-stat.warn { background: #fefce8; }
.result-stat.err { background: #fef2f2; }
.result-stat.partial { background: #fff7ed; }
.stat-num { font-size: 32px; font-weight: 700; }
.stat-num.ok { color: var(--success); }
.stat-num.warn { color: var(--warning); }
.stat-num.err { color: var(--danger); }
.stat-num.partial { color: #c2410c; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.ai-summary {
  background: #f8fafc; border-radius: 8px; padding: 16px;
  font-size: 14px; line-height: 1.6; white-space: pre-wrap;
  border-left: 3px solid var(--primary);
}

/* RECONCILIATION TABLE */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.section-header h3 { font-size: 18px; font-weight: 700; }
.legend { display: flex; gap: 12px; }
.badge {
  font-size: 12px; padding: 4px 10px; border-radius: 20px; font-weight: 600;
}
.badge.matched { background: #dcfce7; color: var(--success); }
.badge.unmatched { background: #fef2f2; color: var(--danger); }
.badge.invoice-only { background: #fefce8; color: var(--warning); }
.badge.duplicate { background: #fdf4ff; color: #7e22ce; }

table { width: 100%; border-collapse: collapse; background: white; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
th { background: #f8fafc; font-size: 12px; font-weight: 600; text-transform: uppercase; color: var(--text-muted); padding: 12px 16px; text-align: left; }
td { padding: 12px 16px; font-size: 14px; border-top: 1px solid var(--border); }
tr.row-matched { }
tr.row-unmatched { background: #fff5f5; }
tr.row-invoice { background: #fffbeb; }
.status-pill {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 8px;
  border-radius: 20px; white-space: nowrap;
}
.status-matched { background: #dcfce7; color: var(--success); }
.status-unmatched { background: #fef2f2; color: var(--danger); }
.status-invoice { background: #fefce8; color: var(--warning); }
.status-duplicate { background: #fdf4ff; color: #7e22ce; }
.status-partial { background: #fff7ed; color: #c2410c; }
tr.row-duplicate { background: #faf5ff; }
tr.row-partial { background: #fffbf5; }
.status-desconocido { background: #f1f5f9; color: #475569; }
tr.row-desconocido { background: #f8fafc; }
.chat-link { font-size: 12px; color: var(--primary); cursor: pointer; text-decoration: underline; }
.icon-download {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; color: var(--primary); opacity: 0.85; flex-shrink: 0;
}
.icon-download:hover { opacity: 1; }
.icon-download svg { width: 100%; height: 100%; }
.btn-validate {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  color: var(--warning); background: #fff7ed; border: 1px solid #fed7aa; border-radius: 6px;
  padding: 6px 10px; cursor: pointer; white-space: nowrap;
}
.btn-validate:hover { background: #ffedd5; }
.btn-reject-link {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  color: var(--danger); background: #fef2f2; border: 1px solid #fecaca; border-radius: 6px;
  padding: 6px 10px; cursor: pointer; white-space: nowrap;
}
.btn-reject-link:hover { background: #fee2e2; }
.btn-reject {
  background: var(--danger); color: white; border: none; border-radius: 8px;
  padding: 8px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-reject:hover { background: #b91c1c; }

/* DOCUMENT TYPE TAGS (Factura / Resumen / Falta resumen / Sin clasificar) */
.doc-tag {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 9px;
  border-radius: 20px; white-space: nowrap; text-decoration: none; margin-right: 4px;
  vertical-align: middle;
}
a.doc-tag { cursor: pointer; }
a.doc-tag:hover { filter: brightness(0.96); }
.tag-factura { background: #E6F1FB; color: #0C447C; }
.tag-resumen { background: #EEEDFE; color: #3C3489; }
.tag-falta-resumen { background: #FCEBEB; color: #791F1F; }
.tag-sin-clasificar { background: #f1f5f9; color: var(--text-muted); }

/* "+ Agregar factura" — reemplaza el link "Buscar factura" en filas Sin factura del dashboard */
.btn-add-invoice {
  display: inline-block; background: transparent; color: #DC2626; border: 1.5px solid #DC2626;
  border-radius: 20px; padding: 10px 20px; font-size: 14px; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: background .15s;
}
.btn-add-invoice:hover { background: #fef2f2; }

/* "🔍 Elegir factura" — buscador manual entre facturas ya cargadas */
.btn-manual-match {
  display: inline-block; background: transparent; color: var(--text-muted); border: 1.5px solid var(--border);
  border-radius: 20px; padding: 10px 20px; font-size: 14px; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: background .15s;
}
.btn-manual-match:hover { background: #f8fafc; }

/* INVOICES LIST */
.table-wrap { overflow-x: auto; }

.upload-options { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.upload-opt { margin-bottom: 0; }
.upload-opt p { margin-bottom: 6px; }
.upload-opt .btn-primary, .upload-opt .btn-secondary { width: auto; margin-top: 8px; }
.drag-folder-zone.drag-over { border-color: var(--primary); background: #eff6ff; transform: scale(1.01); }
.drag-folder-zone { transition: transform .15s, background .15s; }

.progress-bar-wrap {
  background: var(--border); border-radius: 999px; height: 8px;
  overflow: hidden; margin-bottom: 8px;
}
.progress-bar {
  height: 100%; background: var(--primary); border-radius: 999px;
  width: 0%; transition: width .2s;
}
#invoice-progress { background: white; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 20px; }

.consolidate-banner {
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
  color: white; border-radius: var(--radius); padding: 20px 24px;
  margin-bottom: 24px; gap: 16px;
}
.consolidate-info { display: flex; align-items: center; gap: 14px; }
.consolidate-icon { font-size: 32px; }
.consolidate-info strong { font-size: 15px; display: block; margin-bottom: 2px; }
.consolidate-info p { font-size: 13px; opacity: .85; margin: 0; }
.btn-consolidate {
  background: white; color: var(--primary); border: none; border-radius: 8px;
  padding: 12px 24px; font-size: 14px; font-weight: 700; cursor: pointer;
  white-space: nowrap; transition: opacity .15s; flex-shrink: 0;
}
.btn-consolidate:hover { opacity: .9; }
.btn-consolidate-dash {
  background: var(--primary); color: white; border: none; border-radius: 8px;
  padding: 10px 22px; font-size: 14px; font-weight: 700; cursor: pointer;
  white-space: nowrap; transition: background .15s; flex-shrink: 0; align-self: flex-start;
}
.btn-consolidate-dash:hover { background: var(--primary-dark); }
.btn-consolidate-dash:disabled { opacity: .6; cursor: wait; }

/* PORTALES DE PEAJES */
.portales-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.portal-card { background: white; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); padding: 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.portal-card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.portal-card-header h3 { font-size: 16px; font-weight: 700; margin: 0; }
.btn-portal { font-size: 13px; font-weight: 600; color: var(--primary); text-decoration: none; background: #f0f0f0; border-radius: 6px; padding: 6px 12px; white-space: nowrap; transition: background .15s; }
.btn-portal:hover { background: #e2e2e2; }
.portal-peajes { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.portal-peajes li { font-size: 13px; color: var(--text-muted); }
.portal-nota { font-size: 12px; color: #94a3b8; margin: 0; font-style: italic; border-top: 1px solid var(--border); padding-top: 10px; }

/* CARD GRID */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.stmt-card {
  background: white; border-radius: var(--radius); padding: 20px;
  border: 1px solid var(--border); box-shadow: var(--shadow); cursor: pointer;
  transition: box-shadow .15s;
}
.stmt-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.12); }
.stmt-card.selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.stmt-card h4 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.stmt-card p { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.stmt-mini-stats { display: flex; gap: 8px; flex-wrap: wrap; }
.mini-stat { font-size: 12px; padding: 3px 8px; border-radius: 20px; font-weight: 600; }
.mini-stat.ok { background: #dcfce7; color: var(--success); }
.mini-stat.warn { background: #fef2f2; color: var(--danger); }
.mini-stat.dup { background: #fdf4ff; color: #7e22ce; }
.mini-stat.sinpago { background: #fff7ed; color: #c2410c; }
.mini-stat.partial { background: #fff7ed; color: #c2410c; }

/* Facturas sin pago */
.sinpago-banner { background: #fff7ed; border: 1px solid #fed7aa; color: #c2410c; border-radius: 8px; padding: 10px 16px; margin-bottom: 16px; font-size: 14px; font-weight: 600; }
.row-sinpago { background: #fff9f5; }
.row-sinpago:hover { background: #ffedd5 !important; }
.badge-sinpago { display: inline-block; font-size: 10px; font-weight: 700; background: #c2410c; color: white; border-radius: 4px; padding: 1px 5px; vertical-align: middle; margin-right: 4px; }
.badge-resumen { display: inline-block; font-size: 11px; font-weight: 600; background: #eff6ff; color: #1d4ed8; border-radius: 4px; padding: 2px 7px; white-space: nowrap; }
.filter-row th { background: #f8fafc; padding: 8px 12px; border-bottom: 1px solid #e2e8f0; }
.th-filter { font-size: 12px; padding: 5px 10px; border: 1px solid #e2e8f0; border-radius: 6px; background: white; color: var(--text); cursor: pointer; font-weight: 400; }

/* CHAT */
.chat-container { display: flex; flex-direction: column; height: calc(100vh - 180px); }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px 0; display: flex; flex-direction: column; gap: 12px; }
.chat-bubble {
  max-width: 72%; padding: 12px 16px; border-radius: 16px;
  font-size: 14px; line-height: 1.6; white-space: pre-wrap;
}
.chat-bubble.user { background: var(--primary); color: white; align-self: flex-end; border-bottom-right-radius: 4px; }
.chat-bubble.assistant { background: white; color: var(--text); align-self: flex-start; border-bottom-left-radius: 4px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.chat-bubble.loading { background: #f1f5f9; color: var(--text-muted); }
.chat-input-row { display: flex; gap: 10px; padding: 16px 0 0; }
.chat-input-row input {
  flex: 1; padding: 12px 16px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 14px;
}
.chat-input-row input:focus { outline: none; border-color: var(--primary); }
.chat-input-row .btn-primary { width: auto; }

/* ── BUZON DE MEJORAS ──────────────────────────────────────────────────────── */

/* View override: beige background, full height */
#view-buzon.view {
  background: #eceae4;
  padding: 0;
  min-height: 100%;
}

/* Centered content wrapper */
.buzon-wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: 48px 32px 120px;
}

/* Large title override */
#view-buzon .view-header { margin-bottom: 32px; }
#view-buzon .view-header-text h2 {
  font-size: 34px;
  font-weight: 800;
  color: #1a1a1a;
  letter-spacing: -.5px;
}
#view-buzon .view-header-text p {
  font-size: 15px;
  color: #8b8782;
  margin-top: 6px;
}

/* Form card */
div.buzon-form-card {
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid #dedad3;
  overflow: hidden;
  margin-bottom: 36px;
}
div.buzon-form-card textarea.buzon-textarea {
  display: block;
  width: 100%;
  min-height: 120px;
  padding: 22px 22px 14px;
  border: none;
  border-bottom: 1px solid #e8e4dd;
  border-radius: 0;
  font-size: 17px;
  font-family: inherit;
  line-height: 1.65;
  resize: none;
  overflow: hidden;
  color: #1a1a1a;
  background: transparent;
  outline: none;
}
div.buzon-form-card textarea.buzon-textarea::placeholder { color: #b0aca6; }

/* Error */
div.buzon-error {
  margin: 0 22px 10px;
  font-size: 13px;
  color: #dc2626;
  background: #fef2f2;
  border-radius: 8px;
  padding: 8px 12px;
}

/* Action bar (bottom of form card) */
div.buzon-action-bar {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: #faf9f7;
}

/* Pill buttons (Adjuntar, Audio/Mic) */
label.buzon-adjunto-label,
button.buzon-mic-btn {
  display: -webkit-inline-box;
  display: -ms-inline-flexbox;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 500;
  color: #5c5854;
  cursor: pointer;
  padding: 7px 14px 7px 10px;
  border: none;
  border-radius: 999px;
  background: #e8e4dd;
  transition: background .15s;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1;
}
label.buzon-adjunto-label:hover,
button.buzon-mic-btn:hover { background: #dedad3; }
.buzon-pill-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #c9c5be;
  font-size: 11px;
  flex-shrink: 0;
}
button.buzon-mic-btn.activo { background: #e8e8e8; color: #1a1a1a; }
button.buzon-mic-btn.activo .buzon-pill-icon { background: #d4d4d4; }
@keyframes pulso { from { transform: scale(1); } to { transform: scale(1.12); } }

/* Adjunto chips */
div.buzon-adjuntos-preview {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
}
span.buzon-adjunto-chip {
  font-size: 12px;
  background: #e8e4dd;
  border-radius: 999px;
  padding: 4px 10px;
  display: -webkit-inline-box;
  display: -ms-inline-flexbox;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #5c5854;
}
span.buzon-adjunto-chip button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  color: #8b8782;
  padding: 0;
  line-height: 1;
}

/* Send / Guardar button */
button.btn-buzon-guardar {
  background: #1a1a1a;
  color: #ffffff;
  border: none;
  border-radius: 999px;
  padding: 10px 24px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  margin-left: auto;
  transition: background .15s;
  flex-shrink: 0;
}
button.btn-buzon-guardar:hover { background: #333333; }
button.btn-buzon-guardar:disabled { opacity: .5; cursor: wait; }

/* Section label */
p.buzon-section-label {
  font-size: 11px;
  font-weight: 700;
  color: #8b8782;
  text-transform: uppercase;
  letter-spacing: .8px;
  margin: 0 0 12px;
}

/* Notes list (flat with dividers) */
div.buzon-historial { display: block; }
p.buzon-historial-vacio {
  font-size: 14px;
  color: #8b8782;
  padding: 12px 0;
}

/* Note row */
div.buzon-nota-row {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px 0;
  border-bottom: 1px solid #dedad3;
}
div.buzon-nota-row:last-child { border-bottom: none; }

/* Avatar circle */
div.buzon-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #9ab5d4;
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: .5px;
}

/* Note content */
div.buzon-nota-info { flex: 1; min-width: 0; }
div.buzon-nota-header {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 3px;
}
span.buzon-nota-name {
  font-size: 15px;
  font-weight: 700;
  color: #1a1a1a;
}
span.buzon-nota-fecha {
  font-size: 13px;
  color: #8b8782;
  white-space: nowrap;
  flex-shrink: 0;
}
p.buzon-nota-preview {
  font-size: 14px;
  color: #5c5854;
  line-height: 1.5;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
span.buzon-enviada-badge {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #15803d;
  background: #dcfce7;
  border-radius: 999px;
  padding: 2px 10px;
}

/* Adjunto links in rows */
div.buzon-nota-adjuntos {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
img.buzon-adjunto-thumb {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid #dedad3;
  cursor: pointer;
}
a.buzon-adjunto-pdf {
  display: -webkit-inline-box;
  display: -ms-inline-flexbox;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #5c5854;
  text-decoration: none;
  background: #e8e4dd;
  border-radius: 6px;
  padding: 4px 10px;
}

/* Skeleton */
div.buzon-skeleton {
  background: -webkit-linear-gradient(left, #e5e2db 25%, #dedad3 50%, #e5e2db 75%);
  background: linear-gradient(90deg, #e5e2db 25%, #dedad3 50%, #e5e2db 75%);
  background-size: 200% 100%;
  -webkit-animation: bz-shimmer 1.4s infinite;
  animation: bz-shimmer 1.4s infinite;
  border-radius: 8px;
  height: 60px;
  margin-bottom: 12px;
}
@-webkit-keyframes bz-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes bz-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ── CHAT MODO ACTIVO ── */
div.buzon-chat-wrap {
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid #dedad3;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  flex-direction: column;
  max-height: 540px;
  overflow: hidden;
  margin-bottom: 32px;
}
div.buzon-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 24px 12px;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
div.buzon-burbuja {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.65;
  white-space: pre-wrap;
}
div.buzon-burbuja.user {
  background: #e8e4dd;
  color: #1a1a1a;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
div.buzon-burbuja.assistant {
  background: none;
  color: #1a1a1a;
  align-self: flex-start;
  padding-left: 0;
}
div.buzon-typing {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 4px 0;
  align-self: flex-start;
}
div.buzon-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8b8782;
  -webkit-animation: bz-bounce .9s infinite ease-in-out;
  animation: bz-bounce .9s infinite ease-in-out;
}
div.buzon-typing span:nth-child(2) { -webkit-animation-delay: .15s; animation-delay: .15s; }
div.buzon-typing span:nth-child(3) { -webkit-animation-delay: .3s; animation-delay: .3s; }
@-webkit-keyframes bz-bounce { 0%,60%,100% { -webkit-transform: translateY(0); transform: translateY(0); } 30% { -webkit-transform: translateY(-6px); transform: translateY(-6px); } }
@keyframes bz-bounce { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-6px); } }

div.buzon-chat-footer {
  border-top: 1px solid #e8e4dd;
  background: #faf9f7;
}
div.buzon-chat-input-row {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 16px;
}
div.buzon-chat-input-row textarea.buzon-textarea {
  -webkit-box-flex: 1;
  -ms-flex: 1;
  flex: 1;
  display: block;
  min-height: 44px;
  max-height: 160px;
  padding: 11px 14px;
  border: 1.5px solid #dedad3;
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  line-height: 1.5;
  resize: none;
  overflow: hidden;
  outline: none;
  background: #ffffff;
  transition: border-color .2s;
}
div.buzon-chat-input-row textarea.buzon-textarea:focus { border-color: #1a1a1a; }
button.btn-buzon-send {
  background: #1a1a1a;
  color: #ffffff;
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background .15s;
}
button.btn-buzon-send:hover { background: #333; }
button.btn-buzon-send:disabled { opacity: .5; cursor: wait; }
div.buzon-completada {
  text-align: center;
  padding: 14px 20px;
  font-size: 14px;
  color: #8b8782;
  background: #faf9f7;
  border-top: 1px solid #e8e4dd;
}

/* Chat historial ref label */
p.buzon-ref-label {
  font-size: 11px;
  font-weight: 700;
  color: #8b8782;
  text-transform: uppercase;
  letter-spacing: .8px;
  margin: 32px 0 12px;
}

/* ── ADMIN ── */
div.buzon-admin-card {
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid #dedad3;
  padding: 18px 20px;
  margin-bottom: 12px;
}
div.buzon-toggle-row {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
label.buzon-toggle {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
  cursor: pointer;
}
label.buzon-toggle input[type="checkbox"] {
  opacity: 0; width: 0; height: 0; position: absolute;
}
span.buzon-toggle-track {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #c9c5be;
  border-radius: 26px;
  transition: background .2s;
}
span.buzon-toggle-track:before {
  content: '';
  position: absolute;
  width: 20px; height: 20px;
  left: 3px; top: 3px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
label.buzon-toggle input[type="checkbox"]:checked + span.buzon-toggle-track { background: #16a34a; }
label.buzon-toggle input[type="checkbox"]:checked + span.buzon-toggle-track:before { transform: translateX(22px); }

div.buzon-sesion-row {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #f0ede8;
}
div.buzon-sesion-row:last-child { border-bottom: none; }
p.buzon-sesion-email { font-size: 14px; font-weight: 500; color: #1a1a1a; }
p.buzon-sesion-fecha { font-size: 12px; color: #8b8782; margin-top: 2px; }

/* ── MODAL ── */
div.buzon-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
div.buzon-modal-box {
  background: #ffffff;
  border-radius: 14px;
  max-width: 700px;
  width: 100%;
  max-height: 80vh;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
div.buzon-modal-header {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e8e4dd;
  font-size: 15px;
  font-weight: 600;
}
button.buzon-modal-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #8b8782;
  padding: 4px;
}
pre.buzon-informe-pre {
  padding: 20px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-y: auto;
  flex: 1;
  color: #1a1a1a;
}

/* ── DUPLICATE CONFIRM MODAL ── */
div.dup-modal {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.5); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
div.dup-modal-box {
  background: var(--card-bg); border-radius: 14px; max-width: 440px; width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.25); padding: 24px;
}
div.dup-modal-header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
div.dup-modal-header svg { flex-shrink: 0; }
h3.dup-modal-title { font-size: 16px; font-weight: 700; color: var(--text); }
p.dup-modal-body { font-size: 14px; color: var(--text); line-height: 1.5; margin-bottom: 8px; word-break: break-word; }
p.dup-modal-hint { font-size: 13px; color: var(--text-muted); margin-bottom: 22px; line-height: 1.5; }
div.dup-modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
div.dup-modal-actions .btn-primary, div.dup-modal-actions .btn-secondary, div.dup-modal-actions .btn-danger { width: auto; }
div.dup-modal-actions .btn-danger {
  background: var(--danger); color: white; border-color: var(--danger);
  border-radius: 8px; padding: 10px 20px; font-size: 14px; font-weight: 600;
}

@media (max-width: 480px) {
  div.dup-modal-box { max-width: 100%; }
  div.dup-modal-actions { flex-direction: column-reverse; }
  div.dup-modal-actions .btn-primary, div.dup-modal-actions .btn-secondary, div.dup-modal-actions .btn-danger { width: 100%; }
}

/* ── PENDING BACKUP (bloqueo por ventana de 6 meses) ── */
div.pending-backup-list { display: flex; flex-direction: column; gap: 10px; margin: 16px 0 22px; }
div.pending-backup-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg);
}
div.pending-backup-row .pending-backup-label { font-size: 14px; font-weight: 600; color: var(--text); }
div.pending-backup-row .pending-backup-check { display: none; color: var(--success); font-size: 18px; font-weight: 700; }
div.pending-backup-row.done { border-color: var(--success); background: #f0fdf4; }
div.pending-backup-row.done .pending-backup-check { display: inline; }
div.pending-backup-row.done button { display: none; }
div.pending-backup-row button.btn-primary { width: auto; padding: 8px 14px; font-size: 13px; }

@media (max-width: 480px) {
  div.pending-backup-row { flex-direction: column; align-items: stretch; }
  div.pending-backup-row button.btn-primary { width: 100%; }
}

/* UTILITIES */
.hidden { display: none !important; }
.mt-8 { margin-top: 8px; }
.text-muted { color: var(--text-muted); font-size: 13px; }
