/* ================================================================
   AURORIA — Global Styles
   ================================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --sidebar-w: 240px;
  --color-bg: #f1f5f9;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #0f172a;
  --color-text-muted: #64748b;
  --color-primary: #0d9488;
  --color-primary-hover: #0f766e;
  --color-primary-light: #ccfbf1;
  --color-success: #059669;
  --color-warning: #d97706;
  --color-danger: #dc2626;
  --color-purple: #7c3aed;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, .07), 0 2px 4px rgba(0, 0, 0, .05);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, .1), 0 4px 6px rgba(0, 0, 0, .05);
  --font: 'Roboto', 'Google Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Google Sans', 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
}

html,
body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Layout ─────────────────────────────────────────────── */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  background: #0f172a;
  color: #94a3b8;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  transition: width .22s cubic-bezier(.4,0,.2,1), min-width .22s cubic-bezier(.4,0,.2,1);
}

.sidebar.collapsed {
  width: 52px;
  min-width: 52px;
}

/* Logo area */
.sidebar-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 8px 8px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  overflow: hidden;
  flex-shrink: 0;
  gap: 8px;
}
.sidebar:not(.collapsed) .sidebar-logo {
  flex-direction: row;
  padding: 14px 16px;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f0fdfa;
  flex-shrink: 0;
}

.logo-text {
  overflow: hidden;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
  transition: opacity .18s;
}
.sidebar.collapsed .logo-text {
  display: none;
}

.logo-title {
  display: block;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: #fff;
  letter-spacing: .01em;
  line-height: 1.1;
}

.logo-subtitle {
  display: block;
  font-size: 10.5px;
  font-weight: 400;
  color: #5eead4;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-top: 1px;
}

/* Toggle button — beside logo when expanded, below logo when collapsed */
.sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: #64748b;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.sidebar-toggle:hover {
  background: rgba(255,255,255,.1);
  color: #f0fdfa;
}

.sidebar-nav {
  flex: 1;
  padding: 4px 6px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #94a3b8;
  opacity: .45;
  padding: 10px 10px 4px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity .15s, max-height .2s, padding .2s;
  max-height: 40px;
}
.sidebar.collapsed .nav-section-label {
  opacity: 0;
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  pointer-events: none;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: #94a3b8;
  font-size: 13.5px;
  font-weight: 400;
  transition: background .15s, color .15s, padding .2s;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 10px 6px;
}

.nav-item:hover {
  background: rgba(255,255,255,.07);
  color: #f0fdfa;
}
.nav-item.active {
  background: rgba(13,148,136,.22);
  color: #f0fdfa;
  font-weight: 600;
}
.nav-item svg { flex-shrink: 0; }

/* Hide labels when collapsed */
.nav-item > span:not(.nav-badge) {
  transition: opacity .15s, width .15s;
  overflow: hidden;
}
.sidebar.collapsed .nav-item > span:not(.nav-badge) {
  opacity: 0;
  width: 0;
  pointer-events: none;
}

/* Tooltip on hover when collapsed */
.sidebar.collapsed .nav-item {
  overflow: visible;
}
.sidebar.collapsed .nav-item:hover::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: #1e293b;
  color: #f0fdfa;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 1000;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
}

.nav-badge {
  margin-left: auto;
  background: #ef4444;
  color: white;
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
  flex-shrink: 0;
  transition: all .15s;
}
.sidebar.collapsed .nav-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  min-width: 8px;
  width: 8px;
  height: 8px;
  padding: 0;
  font-size: 0;
  border-radius: 50%;
  margin-left: 0;
}

.sidebar-bottom {
  padding: 8px 6px 12px;
  border-top: 1px solid rgba(255,255,255,.07);
  overflow: hidden;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 6px;
  margin-top: 6px;
  overflow: hidden;
}
.sidebar.collapsed .sidebar-user {
  justify-content: center;
  padding: 8px 0;
  flex-direction: column;
  gap: 6px;
}
.sidebar.collapsed .user-info {
  display: none;
}
.sidebar.collapsed .logout-btn {
  padding: 4px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #0d9488;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: #f0fdfa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  display: block;
  font-size: 11px;
  color: #5eead4;
}

.logout-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  padding: 4px;
  border-radius: 4px;
  display: flex;
}

.logout-btn:hover {
  color: #ef4444;
}

/* ── Main content ────────────────────────────────────────── */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
}

/* ── Page header ─────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -.01em;
}

.page-subtitle {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
}

.card-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
}

.card-body {
  padding: 20px;
}

.card-body.p-0 {
  padding: 0;
}

/* ── Dashboard ───────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: box-shadow .15s, transform .1s;
  box-shadow: var(--shadow);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.stat-icon-wrap {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-blue .stat-icon-wrap {
  background: #ccfbf1;
  color: #0d9488;
}

.stat-purple .stat-icon-wrap {
  background: #ccfbf1;
  color: #0f766e;
}

.stat-yellow .stat-icon-wrap {
  background: #fef3c7;
  color: #ca8a04;
}

.stat-green .stat-icon-wrap {
  background: #dcfce7;
  color: #16a34a;
}

.stat-gray .stat-icon-wrap {
  background: #f1f5f9;
  color: #64748b;
}

.stat-blue .stat-icon-wrap svg,
.stat-purple .stat-icon-wrap svg,
.stat-yellow .stat-icon-wrap svg,
.stat-green .stat-icon-wrap svg,
.stat-gray .stat-icon-wrap svg {
  width: 20px;
  height: 20px;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--color-text);
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

@media (max-width: 900px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

.activity-feed {
  padding: 8px 0;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 20px;
  cursor: pointer;
  transition: background .1s;
}

.activity-item:hover {
  background: #f8fafc;
}

.activity-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  background: #f1f5f9;
}

.activity-desc {
  font-size: 13px;
  color: var(--color-text);
  margin-bottom: 2px;
}

.activity-meta {
  font-size: 11px;
  color: var(--color-text-muted);
}

/* ── Tables ──────────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  text-align: left;
  padding: 12px 18px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--color-text-muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--color-border);
}

.table td {
  padding: 18px 18px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 14px;
}

.table tr:last-child td {
  border-bottom: none;
}

.table-row-link {
  cursor: pointer;
  transition: background .1s;
}

.table-row-link:hover {
  background: #f8fafc;
}

.case-title {
  font-weight: 500;
}

.case-number-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--color-primary);
  background: var(--color-primary-light);
  border: 1px solid #c7d2fe;
  border-radius: 4px;
  padding: 2px 7px;
  letter-spacing: .03em;
  white-space: nowrap;
}

.case-number-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 2px;
}

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

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-xs {
  padding: 1px 6px;
  font-size: 10px;
}

.badge-blue {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge-green {
  background: #d1fae5;
  color: #065f46;
}

.badge-yellow {
  background: #fef3c7;
  color: #92400e;
}

.badge-purple {
  background: #ede9fe;
  color: #5b21b6;
}

.badge-gray {
  background: #f1f5f9;
  color: #475569;
}

.badge-red {
  background: #fee2e2;
  color: #991b1b;
}

.badge-pink {
  background: #fce7f3;
  color: #9d174d;
}

.badge-plain {
  background: transparent;
  color: var(--color-text);
  font-weight: 500;
  padding: 0;
}

.doc-progress {
  font-size: 12px;
  font-weight: 600;
}

.doc-complete {
  color: var(--color-success);
}

.doc-missing {
  color: var(--color-warning);
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.btn-primary:hover {
  background: var(--color-primary-hover);
}

.btn-primary:disabled {
  opacity: .6;
  cursor: not-allowed;
}

.btn-secondary {
  background: white;
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn-secondary:hover {
  background: #f8fafc;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12.5px;
}

.btn-full {
  width: 100%;
  justify-content: center;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
}

.btn-icon:hover {
  background: #f1f5f9;
  color: var(--color-text);
}

/* ── Forms ───────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 13.5px;
  color: var(--color-text);
  background: white;
  transition: border-color .15s, box-shadow .15s;
  font-family: var(--font);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, .12);
}

.input-warning {
  border-color: #f59e0b !important;
  background-color: #fffbeb;
}
.input-warning:focus {
  border-color: #d97706 !important;
  box-shadow: 0 0 0 3px rgba(245,158,11,.15) !important;
}

.form-select-sm {
  padding: 5px 8px;
  font-size: 12.5px;
}

.form-textarea {
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  background: white;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.modal-box--wide {
  max-width: 92vw;
  width: 92vw;
  max-height: 95vh;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--color-border);
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--color-text-muted);
  padding: 2px;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 16px 20px;
  border-top: 1px solid var(--color-border);
}

/* ── Toasts ──────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateX(20px);
  transition: all .25s;
  min-width: 260px;
}

.toast.toast-show {
  opacity: 1;
  transform: translateX(0);
}

.toast-success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #6ee7b7;
}

.toast-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.toast-info {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #93c5fd;
}

.toast-icon {
  font-weight: 700;
}

/* ── Filters / Search ────────────────────────────────────── */
.filters-row {
  gap: 12px;
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 7px 12px;
  flex: 1;
  min-width: 200px;
}

.search-input {
  border: none;
  background: none;
  outline: none;
  font-size: 13.5px;
  flex: 1;
}

.filter-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-group .form-select {
  width: auto;
  min-width: 150px;
}

/* ── Empty State ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--color-text-muted);
}

.empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.empty-state p {
  margin-bottom: 16px;
}

/* ── Case View (3-panel) ─────────────────────────────────── */
.case-view {
  display: grid;
  grid-template-columns: 280px 6px 1fr 6px 360px;
  gap: 0;
  height: calc(100vh - 56px);
  margin: -28px -32px;
}

.case-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--color-border);
  background: white;
  min-width: 0;
}

.case-panel:last-child {
  border-right: none;
}

/* ── Left panel: icon rail (collapsed state) ─────────── */
.left-icon-rail {
  display: none; /* shown via JS when collapsed */
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  gap: 2px;
  height: 100%;
  overflow: hidden;
  background: var(--color-surface, #f8fafc);
  border-right: 1px solid var(--color-border);
}

.rail-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  transition: background 0.15s, color 0.15s;
}
.rail-btn:hover {
  background: var(--color-border);
  color: var(--color-text);
}
.rail-divider {
  width: 24px;
  height: 1px;
  background: var(--color-border);
  margin: 6px 0;
}
.rail-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--color-danger, #ef4444);
  color: white;
  font-size: 9px;
  font-weight: 700;
  border-radius: 99px;
  min-width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

/* Left panel full content */
.left-panel-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-width: 0;
}

/* Panel resizer handle */
.panel-resizer {
  width: 6px;
  background: var(--color-border);
  cursor: col-resize;
  position: relative;
  flex-shrink: 0;
  transition: background 0.15s;
  z-index: 10;
}
.panel-resizer:hover,
.panel-resizer:active {
  background: var(--color-primary);
}
.panel-resizer::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 32px;
  border-radius: 2px;
  background: rgba(0,0,0,0.15);
}
.panel-resizer:hover::after {
  background: rgba(255,255,255,0.6);
}

/* Collapse button */
.panel-expand-btn {
  flex-shrink: 0;
}

/* Prevent text selection while dragging */
.case-view.resizing * {
  user-select: none;
  pointer-events: none;
}
.case-view.resizing .panel-resizer {
  pointer-events: all;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  background: white;
}

.panel-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text);
}

.panel-subtitle {
  font-size: 11px;
  color: var(--color-text-muted);
}

.panel-badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.panel-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.doc-version {
  font-size: 11px;
  color: var(--color-text-muted);
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 999px;
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.detail-section {
  margin-bottom: 20px;
}

.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--color-text-muted);
  margin-bottom: 10px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 6px 0;
  border-bottom: 1px solid #f8fafc;
  gap: 8px;
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  font-size: 12px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.detail-value {
  font-size: 13px;
  font-weight: 500;
  text-align: right;
}

.doc-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.doc-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px;
  border-radius: var(--radius);
  background: #f8fafc;
}

.doc-item.missing {
  background: #fff7ed;
}

.doc-status-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.doc-name {
  font-size: 12.5px;
  font-weight: 500;
  display: block;
}

.doc-date {
  font-size: 11px;
  color: var(--color-text-muted);
}

.doc-date.missing {
  color: #d97706;
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── AI Chat Panel ───────────────────────────────────────── */
.ai-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-avatar {
  width: 36px;
  height: 36px;
  background: var(--color-primary-light);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
  flex-shrink: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-msg {
  display: flex;
}

.chat-msg.user {
  justify-content: flex-end;
}

.chat-msg.assistant {
  justify-content: flex-start;
}

.chat-bubble {
  display: flex;
  gap: 8px;
  max-width: 92%;
}

.chat-msg.user .chat-bubble {
  flex-direction: row-reverse;
}

.chat-avatar-sm {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  flex-shrink: 0;
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-avatar-sm.user-av {
  background: #f1f5f9;
  color: var(--color-text-muted);
}

.chat-content {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.chat-msg.user .chat-content {
  align-items: flex-end;
}

.chat-text {
  padding: 8px 12px;
  border-radius: var(--radius-lg);
  font-size: 13px;
  line-height: 1.5;
}

.chat-msg.assistant .chat-text {
  background: #f1f5f9;
  color: var(--color-text);
  border-bottom-left-radius: 4px;
}

.chat-msg.user .chat-text {
  background: var(--color-primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-text h1,
.chat-text h2,
.chat-text h3 {
  font-size: 13px;
  margin-bottom: 4px;
}

.chat-text ul {
  margin: 4px 0 4px 16px;
}

.chat-text li {
  margin-bottom: 2px;
}

.chat-text p {
  margin-bottom: 4px;
}

.chat-text p:last-child {
  margin-bottom: 0;
}

.chat-text hr {
  border: none;
  border-top: 1px solid rgba(0, 0, 0, .1);
  margin: 8px 0;
}

.chat-text blockquote {
  border-left: 3px solid var(--color-primary);
  padding-left: 8px;
  color: var(--color-text-muted);
  font-style: italic;
}

.chat-time {
  font-size: 10px;
  color: var(--color-text-muted);
}

.chat-typing {
  display: flex;
  gap: 4px;
  padding: 10px 12px;
  background: #f1f5f9;
  border-radius: var(--radius-lg);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}

.chat-typing.hidden {
  display: none;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--color-text-muted);
  border-radius: 50%;
  animation: typing 1.2s infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: .2s;
}

.typing-dot:nth-child(3) {
  animation-delay: .4s;
}

@keyframes typing {

  0%,
  80%,
  100% {
    transform: scale(0.6);
    opacity: .5;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.spinner-xs {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255, 255, 255, .4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: middle;
  margin-right: 4px;
}

.chat-input-area {
  padding: 10px;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

.chat-quick-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.quick-btn {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: white;
  font-size: 11.5px;
  cursor: pointer;
  transition: all .1s;
  white-space: nowrap;
}

.quick-btn:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.chat-textarea {
  flex: 1;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 13px;
  resize: none;
  font-family: var(--font);
}

.chat-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .1);
}

.btn-send {
  padding: 8px 12px;
}

/* ── Document Preview Panel ──────────────────────────────── */
.doc-preview {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #e8eaf0;
}

.doc-paper-wrap {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 20px 16px;
}

.doc-paper {
  background: #ffffff;
  box-shadow: 0 2px 12px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.06);
  border-radius: 2px;
  padding: 48px 52px;
  width: 100%;
  max-width: 780px;
  min-height: 600px;
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 12px;
  line-height: 1.75;
  color: #1a1a1a;
}

.doc-paper--editing {
  outline: 2px solid var(--color-primary);
  outline-offset: 4px;
  cursor: text;
  caret-color: var(--color-primary);
}

/* doc-content stays for backward compat but paper overrides */
.doc-paper h1 {
  font-size: 15px;
  font-weight: 800;
  text-align: center;
  margin: 0 0 6px;
  letter-spacing: .3px;
  text-transform: uppercase;
}
.doc-paper h2 {
  font-size: 12px;
  font-weight: 700;
  margin: 18px 0 6px;
  text-transform: uppercase;
  letter-spacing: .4px;
  border-bottom: 1.5px solid #1a1a1a;
  padding-bottom: 3px;
}
.doc-paper h3 {
  font-size: 11.5px;
  font-weight: 700;
  margin: 12px 0 4px;
}
.doc-paper p {
  margin: 0 0 10px;
  text-align: justify;
}
.doc-paper ul, .doc-paper ol {
  margin: 4px 0 10px 24px;
}
.doc-paper li { margin-bottom: 3px; }
.doc-paper hr {
  border: none;
  border-top: 1px solid #ccc;
  margin: 14px 0;
}
.doc-paper strong { font-weight: 700; }
.doc-paper table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 11px;
}
.doc-paper th {
  background: #f0f4ff;
  font-weight: 700;
  padding: 5px 8px;
  border: 1px solid #ccc;
  text-align: left;
}
.doc-paper td {
  padding: 4px 8px;
  border: 1px solid #ddd;
  vertical-align: top;
}
.doc-paper blockquote {
  border-left: 3px solid #aaa;
  padding: 6px 12px;
  margin: 8px 0;
  color: #444;
  font-style: italic;
}

.doc-content {
  font-size: 13px;
  line-height: 1.7;
}

.doc-content h1 {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--color-text);
}

.doc-content h2 {
  font-size: 14px;
  font-weight: 700;
  margin: 16px 0 8px;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 4px;
}

.doc-content h3 {
  font-size: 13px;
  font-weight: 600;
  margin: 12px 0 6px;
}

.doc-content p {
  margin-bottom: 10px;
}

.doc-content ul {
  margin: 6px 0 10px 20px;
}

.doc-content li {
  margin-bottom: 3px;
}

.doc-content hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 16px 0;
}

.doc-content strong {
  font-weight: 700;
}

.doc-content blockquote {
  border-left: 3px solid var(--color-warning);
  background: #fffbeb;
  padding: 8px 12px;
  margin: 10px 0;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.doc-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0 0;
  border-top: 1px solid var(--color-border);
  margin-top: 16px;
}

.doc-meta {
  font-size: 11px;
  color: var(--color-text-muted);
}

/* ── Emails ──────────────────────────────────────────────── */
.email-outer {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.emails-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 0;
  flex: 1;
  min-height: 580px;
}

.email-list-panel {
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
}

.email-list-header {
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  font-size: 12px;
  color: var(--color-text-muted);
}

.email-unread {
  color: var(--color-primary);
  font-weight: 600;
}

.email-list {
  flex: 1;
  overflow-y: auto;
}

.email-item {
  padding: 12px 16px;
  border-bottom: 1px solid #f8fafc;
  cursor: pointer;
  transition: background .1s;
}

.email-item:hover {
  background: #f8fafc;
}

.email-item.selected {
  background: var(--color-primary-light);
}

.email-item.unread .email-from {
  font-weight: 700;
}

.email-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3px;
}

.email-from {
  font-size: 13px;
  font-weight: 500;
}

.email-time {
  font-size: 11px;
  color: var(--color-text-muted);
}

.email-subject {
  font-size: 12.5px;
  color: var(--color-text);
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-item-bottom {
  display: flex;
  align-items: center;
  gap: 6px;
}

.attach-count {
  font-size: 11px;
  color: var(--color-text-muted);
}

.email-detail-panel {
  display: flex;
  flex-direction: column;
}

.email-detail {
  padding: 20px;
}

.email-detail-subject {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
}

.email-detail-meta {
  font-size: 12px;
  color: var(--color-text-muted);
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 10px;
}

.email-detail-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.email-detail-body {
  background: #f8fafc;
  border-radius: var(--radius);
  padding: 14px;
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 16px;
  white-space: normal;
}

.email-attachments {
  margin-bottom: 16px;
}

.email-attachments h4 {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 8px;
}

.attachment-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.attachment-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #f1f5f9;
  border-radius: var(--radius);
  font-size: 13px;
}

.attach-size {
  margin-left: auto;
  color: var(--color-text-muted);
  font-size: 11px;
}

.ai-summary {
  background: var(--color-primary-light);
  border: 1px solid #c7d2fe;
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
}

.ai-summary-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 6px;
}

.ai-summary p {
  font-size: 13px;
  color: var(--color-text);
}

.missing-docs {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #c7d2fe;
}

.missing-docs strong {
  font-size: 12px;
  color: var(--color-danger);
}

.missing-docs ul {
  margin: 4px 0 0 16px;
  font-size: 12.5px;
}

.email-case-link {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 16px;
}

.email-case-link-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-success);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.email-case-link-content {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.email-case-link-content:hover .case-title {
  text-decoration: underline;
}

.email-process-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  margin-bottom: 12px;
}

.email-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Companies ───────────────────────────────────────────── */
.companies-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.company-card {
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: box-shadow .15s, transform .1s;
  box-shadow: var(--shadow);
}

.company-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.company-card-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 14px;
}

.company-name {
  font-size: 17px;
  font-weight: 800;
  color: var(--color-text);
  line-height: 1.2;
  letter-spacing: -0.3px;
}

.company-details {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}

.company-detail-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--color-text-muted);
}

.company-card-footer {
  display: flex;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
  font-size: 12px;
  color: var(--color-text-muted);
}

.company-cases {
  font-weight: 600;
  color: var(--color-text);
}

.company-detail-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.company-detail-top {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  align-items: stretch;
}

.company-info-card .detail-row {
  padding: 9px 0;
  border-bottom: 1px solid var(--color-border);
}

.company-info-card .detail-row:last-child {
  border-bottom: none;
}

/* Plantillas: altura fija ~6 items, scroll interno */
#company-files-list {
  max-height: 360px;
  overflow-y: auto;
}

#company-files-list>div {
  padding: 4px 8px !important;
}

/* Casos: altura fija ~5 filas, scroll interno */
.company-cases-card .card-body {
  max-height: 280px;
  overflow-y: auto;
}

.company-cases-card .table {
  margin: 0;
}

.company-cases-card .table thead th {
  background: var(--color-bg);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-text-muted);
  position: sticky;
  top: 0;
  z-index: 1;
  box-shadow: 0 1px 0 var(--color-border);
}

.company-cases-card .table tbody tr:hover {
  background: var(--color-primary-light);
  cursor: pointer;
}

@media (max-width: 768px) {
  .company-detail-top {
    grid-template-columns: 1fr;
  }
}

/* ── AI Page ─────────────────────────────────────────────── */
.ai-page-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 20px;
  height: calc(100vh - 160px);
}

.ai-chat-area {
  display: flex;
  flex-direction: column;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.ai-global-chat {
  background: #fafafa;
}

.ai-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.quick-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.quick-link {
  display: block;
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--color-text);
  cursor: pointer;
  transition: background .1s;
}

.quick-link:hover {
  background: #f1f5f9;
}

.system-status {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.green {
  background: #10b981;
}

.status-dot.yellow {
  background: #f59e0b;
}

.status-dot.blue {
  background: #3b82f6;
}

/* ── Settings ────────────────────────────────────────────── */
.settings-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 700px;
}

.profile-section {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.profile-avatar-lg {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  background: var(--color-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
}

.profile-info h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 2px;
}

.profile-info p {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

.mt-4 {
  margin-top: 16px;
}

.mt-2 {
  margin-top: 8px;
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--color-border);
  gap: 16px;
}

.setting-item:last-child {
  border-bottom: none;
}

.setting-info strong {
  display: block;
  font-size: 13.5px;
  margin-bottom: 2px;
}

.setting-info p {
  font-size: 12px;
  color: var(--color-text-muted);
}

.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #cbd5e1;
  border-radius: 999px;
  transition: .2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: .2s;
}

.toggle input:checked+.toggle-slider {
  background: var(--color-primary);
}

.toggle input:checked+.toggle-slider::before {
  transform: translateX(20px);
}

.req-docs-section {
  margin-bottom: 16px;
}

.req-docs-title {
  font-size: 13.5px;
  font-weight: 700;
  margin-bottom: 8px;
}

.req-docs-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.req-docs-list li {
  font-size: 13px;
  color: var(--color-text-muted);
  padding: 4px 0;
}

/* ── Login ───────────────────────────────────────────────── */
.login-bg {
  display: flex;
  height: 100vh;
}

.login-card {
  width: 440px;
  padding: 52px 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: white;
  border-right: 1px solid var(--color-border);
}

.login-art {
  flex: 1;
  background: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px;
  position: relative;
  overflow: hidden;
}

.login-art::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 30% 50%, rgba(13, 148, 136, .18) 0%, transparent 65%),
    radial-gradient(ellipse at 75% 20%, rgba(13, 148, 136, .1) 0%, transparent 50%);
}

.login-art-content {
  color: white;
  max-width: 400px;
  position: relative;
  z-index: 1;
}

.art-icon {
  width: 56px;
  height: 56px;
  margin-bottom: 28px;
  color: #5eead4;
  display: block;
}

.login-art-content h2 {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  margin-bottom: 16px;
  line-height: 1.2;
  letter-spacing: -.01em;
}

.login-art-content p {
  font-size: 15px;
  color: #94a3b8;
  margin-bottom: 32px;
  line-height: 1.65;
}

.art-features {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.art-feature {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: #cbd5e1;
}

.art-feature span {
  width: 22px;
  height: 22px;
  background: rgba(13, 148, 136, .25);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #5eead4;
  flex-shrink: 0;
}

.login-logo {
  text-align: center;
  margin-bottom: 40px;
}

.login-logo-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  background: #ccfbf1;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0d9488;
}

.login-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -.01em;
}

.login-subtitle {
  font-size: 13.5px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.login-hint {
  font-size: 11.5px;
  color: var(--color-text-muted);
  text-align: center;
  margin-top: 12px;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 12px;
  color: var(--color-text-muted);
  font-size: 13px;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

.google-btn-wrapper {
  display: flex;
  justify-content: center;
}

.google-signin-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 300px;
  padding: 10px 16px;
  background: #fff;
  border: 1px solid #dadce0;
  border-radius: 4px;
  font-family: 'Google Sans', Roboto, Arial, sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: #3c4043;
  cursor: pointer;
  transition: box-shadow 0.15s;
  margin: 0 auto;
}
.google-signin-btn:hover {
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  background: #f8f9fa;
}
.google-signin-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ── Email toolbar (búsqueda + barra de acciones) ───────────── */
.email-toolbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 6px 0 10px;
}

.email-search-wrap {
  width: 100%;
}

.email-search-input {
  height: 34px;
  font-size: 13px;
  width: 100%;
}

.email-action-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
}

.checked-count {
  font-weight: 600;
  margin-right: 4px;
}

/* ── Email list con checkboxes ──────────────────────────────── */
.email-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.email-item-checkbox {
  padding-top: 14px;
  flex-shrink: 0;
}

.email-item-body {
  flex: 1;
  min-width: 0;
}

.email-item.pinned {
  background: #fffbeb;
  border-left: 3px solid #f59e0b;
}

/* ── Previews de archivos ───────────────────────────────────── */
.text-preview {
  width: 100%;
  height: 78vh;
  overflow: auto;
  background: #1e1b4b;
  color: #c7d2fe;
  padding: 16px;
  border-radius: 6px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.word-preview {
  width: 100%;
  height: 78vh;
  overflow: auto;
  background: #fff;
  color: #1e293b;
  padding: 32px 40px;
  border-radius: 6px;
  font-family: 'Georgia', serif;
  font-size: 14px;
  line-height: 1.7;
}

.word-preview h1,
.word-preview h2,
.word-preview h3 {
  margin: 16px 0 8px;
}

.word-preview p {
  margin-bottom: 8px;
}

.word-preview table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: 12px;
}

.word-preview td,
.word-preview th {
  border: 1px solid #ccc;
  padding: 4px 8px;
}

.excel-tabs {
  display: flex;
  gap: 4px;
  padding: 0 0 6px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.excel-tab {
  padding: 4px 12px;
  font-size: 12px;
  border-radius: 4px 4px 0 0;
  border: 1px solid var(--color-border);
  background: #f1f5f9;
  cursor: pointer;
}

.excel-tab.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.excel-content {
  flex: 1;
  overflow: auto;
  border-radius: 0 0 6px 6px;
  border: 1px solid var(--color-border);
  background: #fff;
}

.excel-content table {
  border-collapse: collapse;
  font-size: 12px;
}

.excel-content td,
.excel-content th {
  border: 1px solid #d1d5db;
  padding: 3px 8px;
  min-width: 60px;
  white-space: nowrap;
}

.excel-content tr:first-child td,
.excel-content tr:first-child th {
  background: #f0f4ff;
  font-weight: 600;
  position: sticky;
  top: 0;
}

/* ── Archivos de plantilla por empresa ──────────────────────── */
.company-file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
}

.company-file-item:last-child {
  border-bottom: none;
}

.company-file-icon {
  font-size: 22px;
  flex-shrink: 0;
}

.company-file-info {
  flex: 1;
  min-width: 0;
}

.company-file-name {
  display: block;
  font-weight: 500;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.company-file-meta {
  display: block;
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 1px;
}

.company-file-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* ── Cuentas de correo IMAP ─────────────────────────────────── */
.btn-xs {
  padding: 3px 8px;
  font-size: 11.5px;
}

.btn-danger {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fca5a5;
}

.btn-danger:hover {
  background: #fecaca;
}

.btn-warning {
  background: #fef3c7;
  color: #d97706;
  border: 1px solid #fcd34d;
}

.btn-warning:hover {
  background: #fde68a;
}

.email-account-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
}

.email-account-item:last-child {
  border-bottom: none;
}

.email-account-info {
  flex: 1;
  min-width: 0;
}

.email-account-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.email-account-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  align-items: center;
}

.empty-state-sm {
  padding: 16px 0;
}

@media (max-width: 768px) {
  .login-bg {
    flex-direction: column;
  }

  .login-art {
    display: none;
  }

  .login-card {
    width: 100%;
    border-right: none;
    padding: 32px 24px;
  }

  .case-view {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    height: auto;
  }

  .ai-page-layout {
    grid-template-columns: 1fr;
  }
}

/* ── Tipos de Solicitud ─────────────────────────────────────── */
.rt-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
  align-items: start;
}

.rt-list-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rt-type-card {
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: box-shadow .12s, border-color .12s;
}

.rt-type-card:hover {
  box-shadow: var(--shadow);
  border-color: #c7d2fe;
}

.rt-type-card--active {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .1);
}

.rt-type-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.rt-req-count {
  font-size: 11.5px;
  color: var(--color-text-muted);
}

.rt-type-desc {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 6px;
}

.rt-detail-col {
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  min-height: 400px;
}

.rt-empty-detail {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
}

.rt-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--color-border);
}


.rt-template-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 16px;
}

.rt-template-preview {
  margin-top: 10px;
  padding: 10px 14px;
  background: var(--color-surface-2, #f8fafc);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-family: monospace;
  font-size: 12px;
  color: var(--color-text-muted);
  white-space: pre-wrap;
  max-height: 80px;
  overflow: hidden;
}

.rt-reqs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.rt-req-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 8px;
}

.rt-req-order {
  width: 22px;
  height: 22px;
  background: var(--color-primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.rt-req-info {
  flex: 1;
  min-width: 0;
}

.rt-req-label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--color-text);
}

.rt-req-type {
  display: block;
  font-size: 11.5px;
  color: var(--color-text-muted);
  font-family: monospace;
  margin-top: 1px;
}

.rt-req-required {
  flex-shrink: 0;
}

.rt-req-actions {
  flex-shrink: 0;
}

/* ── Reply composer ─────────────────────────────────────────── */
.email-reply-composer {
  margin-top: 20px;
  border-top: 2px solid var(--color-border);
  padding-top: 16px;
}

.email-reply-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 10px;
}

.email-reply-header strong {
  color: var(--color-text);
}

.reply-textarea {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 13.5px;
  font-family: inherit;
  resize: vertical;
  outline: none;
  transition: border-color .15s;
}

.reply-textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .1);
}

.reply-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

/* ── Reply composer rediseñado ──────────────────────────────── */
.email-reply-composer {
  margin-top: 24px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

/* Cabecera */
.email-reply-composer-header {
  background: var(--color-primary);
  color: white;
  padding: 9px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.reply-composer-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 13.5px;
}

.btn-ghost {
  background: rgba(255, 255, 255, .15);
  border: 1px solid rgba(255, 255, 255, .3);
  color: white;
  border-radius: var(--radius);
  padding: 3px 9px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background .15s;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, .28);
}

/* Fila Para / CC */
.reply-recipients-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--color-border);
  background: #fafbff;
}

.reply-cc-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--color-border);
  background: #fafbff;
  flex-wrap: wrap;
}

.reply-recipients-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  white-space: nowrap;
  min-width: 28px;
}

.reply-to-chip-main {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.reply-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  color: #3730a3;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 12px;
}

.reply-chip--cc {
  padding: 3px 6px 3px 10px;
}

.reply-chip-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: #6366f1;
  font-size: 14px;
  line-height: 1;
  padding: 0 1px;
  opacity: .7;
}

.reply-chip-remove:hover {
  opacity: 1;
  color: var(--color-danger);
}

.reply-cc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.reply-cc-input {
  border: none;
  outline: none;
  font-size: 13px;
  color: var(--color-text);
  background: transparent;
  flex: 1;
  min-width: 180px;
}

/* Barra de formato */
.reply-format-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px 10px;
  border-bottom: 1px solid var(--color-border);
  background: #f8f9ff;
  flex-wrap: wrap;
}

.fmt-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 7px;
  border-radius: 5px;
  font-size: 13px;
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s;
  line-height: 1;
}

.fmt-btn:hover {
  background: #e0e7ff;
  color: var(--color-primary);
}

.fmt-btn b {
  font-size: 14px;
}

.fmt-btn.fmt-italic i {
  font-style: italic;
}

.fmt-btn.fmt-underline u {
  text-decoration: underline;
}

.fmt-btn.fmt-danger:hover {
  background: #fee2e2;
  color: var(--color-danger);
}

.fmt-select {
  border: 1px solid var(--color-border);
  border-radius: 5px;
  padding: 3px 6px;
  font-size: 12px;
  color: var(--color-text);
  background: white;
  cursor: pointer;
  outline: none;
}

.fmt-divider {
  width: 1px;
  height: 18px;
  background: var(--color-border);
  margin: 0 4px;
  flex-shrink: 0;
}

/* Editor rico */
.reply-dropzone {
  position: relative;
}

.reply-editor {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--color-border);
  padding: 14px 16px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  min-height: 120px;
  line-height: 1.6;
}

.reply-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--color-text-muted);
  pointer-events: none;
}

.reply-editor:focus {
  background: #fafbff;
}

.reply-editor ul,
.reply-editor ol {
  padding-left: 20px;
}

.reply-drop-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(79, 70, 229, .08);
  border: 2px dashed var(--color-primary);
  border-radius: var(--radius);
  z-index: 10;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--color-primary);
  pointer-events: none;
}

.reply-drop-overlay.active {
  display: flex;
}

/* Archivos adjuntos */
.reply-files-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px;
}

.reply-files-preview:not(:empty) {
  padding: 8px 16px;
  border-bottom: 1px solid var(--color-border);
}

.reply-file-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  background: #f0f1ff;
  border: 1px solid #c7d2fe;
  border-radius: 20px;
  padding: 3px 8px 3px 10px;
  font-size: 12px;
  color: #4338ca;
}

.reply-file-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: #6366f1;
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
  opacity: .7;
}

.reply-file-remove:hover {
  opacity: 1;
  color: var(--color-danger);
}

/* Pie */
.reply-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: #f8f9ff;
}

/* ── Banner reconexión Gmail ─────────────────────────────────── */
.gmail-reconnect-banner {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: var(--radius);
  margin-bottom: 16px;
  padding: 12px 16px;
}

.gmail-reconnect-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.gmail-reconnect-content span {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  color: #92400e;
  flex: 1;
}

.btn-ghost-dark {
  background: none;
  border: 1px solid #d97706;
  color: #92400e;
  border-radius: var(--radius);
  padding: 4px 10px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.btn-ghost-dark:hover {
  background: #fde68a;
}

.detail-key {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-right: 4px;
}

.doc-status-icon {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

.doc-ok {
  background: #dcfce7;
  color: #16a34a;
}

/* ── Tag Input ───────────────────────────────────────────────── */
.tag-input-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-height: 40px;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: #fff;
  cursor: text;
}
.tag-input-wrap:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(13,148,136,.1);
}
.tag-input-field {
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  font-family: var(--font);
  min-width: 120px;
  flex: 1;
  padding: 0;
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.tag-chip button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-primary);
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  opacity: .7;
}
.tag-chip button:hover { opacity: 1; }

/* ── Base Legal Page ─────────────────────────────────────────── */
.ld-filters {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  align-items: center;
}
.ld-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  align-items: start;
}
.ld-list-col {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
}
.ld-detail-col {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  min-height: 320px;
  overflow: hidden;
}
.ld-empty-detail {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
}
.ld-doc-card {
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background .15s;
}
.ld-doc-card:last-child { border-bottom: none; }
.ld-doc-card:hover { background: var(--color-bg); }
.ld-doc-card--active { background: var(--color-primary-light) !important; }
.ld-doc-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.ld-ref {
  font-size: 11px;
  color: var(--color-text-muted);
  font-family: monospace;
}
.ld-doc-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  margin: 0 0 6px;
  line-height: 1.4;
}
.ld-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.ld-tag {
  font-size: 11px;
  padding: 2px 7px;
  background: #f1f5f9;
  color: var(--color-text-muted);
  border-radius: 10px;
  border: 1px solid var(--color-border);
}
.ld-detail-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--color-border);
}
.ld-detail-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
  margin: 6px 0 0;
  line-height: 1.4;
}
.ld-content-box {
  padding: 20px 24px;
  max-height: calc(100vh - 340px);
  overflow-y: auto;
}
.ld-content-pre {
  white-space: pre-wrap;
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--color-text);
  margin: 0;
}
.ld-preview-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ld-preview-iframe {
  width: 100%;
  height: calc(100vh - 280px);
  min-height: 400px;
  border: none;
  display: block;
}
.ld-docx-preview {
  padding: 24px;
  overflow-y: auto;
  max-height: calc(100vh - 280px);
}
.ld-docx-content {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.7;
  color: var(--color-text);
}
.ld-docx-content h1, .ld-docx-content h2, .ld-docx-content h3 {
  font-family: var(--font-display);
  margin: 16px 0 8px;
}
.ld-docx-content p { margin: 0 0 10px; }
.ld-docx-content table { border-collapse: collapse; width: 100%; margin-bottom: 16px; }
.ld-docx-content td, .ld-docx-content th { border: 1px solid var(--color-border); padding: 6px 10px; }
/* Upload drop zone */
.ld-upload-drop {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.ld-upload-drop:hover, .ld-drop-zone--over {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}
.ld-file-info-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--color-bg);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  font-size: 13px;
  margin-top: 8px;
}
.ld-file-info-row span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ld-file-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  background: #f1f5f9;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 1px 5px;
}
.ld-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0 12px;
}
.ld-search-input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  font-family: var(--font);
  padding: 9px 0;
  flex: 1;
}

.doc-missing-icon {
  background: #fee2e2;
  color: #dc2626;
}

/* ── Email HTML iframe ───────────────────────────────────────── */
.email-html-frame {
  width: 100%;
  min-height: 200px;
  border: none;
  border-radius: var(--radius);
  display: block;
  background: #fff;
}

/* ── Asistente IA — pantalla de bienvenida ───────────────────── */
.ai-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 32px;
  gap: 12px;
}
.ai-welcome-icon {
  width: 56px;
  height: 56px;
  background: var(--color-primary-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
}
.ai-welcome-icon svg { width: 28px; height: 28px; }
.ai-welcome-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
}
.ai-welcome-desc {
  font-size: 14px;
  color: var(--color-text-muted);
  max-width: 420px;
  line-height: 1.6;
  margin: 0;
}
.ai-welcome-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 8px;
}
.ai-welcome-suggestions span {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.ai-welcome-suggestions span:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  color: var(--color-primary);
}

/* ── Email Category Tabs (top bar, outside the list panel) ────── */
.email-tabs-bar {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  padding: 0 8px;
  flex-shrink: 0;
  min-height: 44px;
}

.email-cat-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, border-color .15s, background .15s;
  position: relative;
}
.email-cat-tab:hover {
  color: var(--color-text);
  background: #f8fafc;
}
.email-cat-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}
.email-cat-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: #f1f5f9;
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}
.email-cat-tab.active .email-cat-count {
  background: var(--color-primary-light);
  color: var(--color-primary);
}
.email-cat-tab.has-unread .email-cat-count {
  background: var(--color-primary);
  color: #fff;
}

/* ── Email legal request indicators ─────────────────────────── */
.email-item.legal-request {
  border-left: 3px solid var(--color-primary);
}

/* Tab Solicitudes — color ámbar para que destaque */
.email-cat-tab[onclick*="solicitudes"] .email-cat-count {
  background: #fef3c7;
  color: #92400e;
}
.email-cat-tab[onclick*="solicitudes"].active {
  color: #d97706;
  border-bottom-color: #d97706;
}
.email-cat-tab[onclick*="solicitudes"].active .email-cat-count {
  background: #fef3c7;
  color: #92400e;
}

.email-quick-action {
  margin-top: 6px;
}

.btn-quick-case {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--color-primary);
  background: var(--color-primary-light);
  border: 1px solid var(--color-primary);
  border-radius: 20px;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn-quick-case:hover {
  background: var(--color-primary);
  color: #fff;
}
.btn-quick-case:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* AI preview banner in email detail */
.ai-preview-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin: 0 16px 16px;
  border: 1px solid;
}
.ai-preview-maternity  { background: #fdf2f8; border-color: #f0abdb; }
.ai-preview-paternity  { background: #eff6ff; border-color: #93c5fd; }
.ai-preview-death      { background: #f8fafc; border-color: #cbd5e1; }
.ai-preview-other      { background: #f5f3ff; border-color: #c4b5fd; }

.ai-preview-banner-icon {
  font-size: 20px;
  flex-shrink: 0;
}
.ai-preview-banner-content {
  flex: 1;
  min-width: 0;
}
.ai-preview-banner-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
}
.ai-preview-banner-desc {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* ── Equipo y límites de tokens ──────────────────────────────── */
.team-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
}
.team-user-row:last-child { border-bottom: none; }

.team-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.token-usage-bar-wrap {
  width: 100%;
}

.token-usage-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-bottom: 3px;
}

.token-usage-bar-bg {
  height: 6px;
  background: var(--color-border);
  border-radius: 3px;
  overflow: hidden;
}

.token-usage-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.token-limit-presets {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.form-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.info-banner {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.82rem;
  color: #1d4ed8;
}

.modal-att-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #f8fafc;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 10px 12px;
}
.modal-att-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.modal-att-icon { font-size: 15px; flex-shrink: 0; }
.modal-att-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-text);
}
.modal-att-size { color: var(--color-text-muted); font-size: 11px; flex-shrink: 0; }
/* ── Cases List — card rows ───────────────────────────────────── */
.cases-list {
  display: flex;
  flex-direction: column;
}

.case-row {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background .15s;
}
.case-row:last-child { border-bottom: none; }
.case-row:hover { background: #f8fafc; }

.case-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.case-row-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.case-row-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 0.80rem;
  color: var(--color-text-muted);
}

.case-meta-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.case-meta-label {
  font-weight: 600;
  color: var(--color-text);
  font-size: 0.78rem;
}

.case-meta-item .text-success { color: var(--color-success); }
.case-meta-item .text-warning { color: var(--color-warning); }

.case-row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.case-status-select {
  font-size: 0.82rem;
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  outline: none;
  font-weight: 500;
  transition: border-color .15s;
  min-width: 130px;
}
.case-status-select:hover,
.case-status-select:focus { border-color: var(--color-primary); }

.btn-icon-sm {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.btn-icon-sm svg { width: 16px; height: 16px; }
.btn-icon-sm:hover { background: var(--color-bg); color: var(--color-text); }
.btn-icon-sm.btn-icon-danger {
  color: var(--color-danger);
  background: #fee2e2;
}
.btn-icon-sm.btn-icon-danger:hover {
  background: #fca5a5;
  color: #991b1b;
}

/* ── Cases v2 ─────────────────────────────────────────────────── */
.cv2-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 20px;
}

.cv2-card {
  display: flex;
  align-items: center;
  gap: 0;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow .18s, transform .12s;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.cv2-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.10);
  transform: translateY(-1px);
}

.cv2-accent {
  width: 5px;
  align-self: stretch;
  flex-shrink: 0;
}

.cv2-body {
  flex: 1;
  min-width: 0;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cv2-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cv2-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.cv2-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #f1f5f9;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 0.80rem;
  color: #475569;
  font-weight: 500;
  white-space: nowrap;
}
.cv2-chip-icon { font-size: 0.78rem; }
.cv2-chip--ok  { background: #dcfce7; color: #166534; }
.cv2-chip--warn { background: #fef9c3; color: #854d0e; }

.cv2-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  flex-shrink: 0;
}

.cv2-status-select {
  font-size: 0.83rem;
  font-weight: 600;
  padding: 6px 14px;
  border: 1.5px solid;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  outline: none;
  min-width: 138px;
  transition: opacity .15s;
}
.cv2-status-select:hover { opacity: .8; }

.cv2-del-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: #fee2e2;
  color: #dc2626;
  cursor: pointer;
  transition: background .15s;
  flex-shrink: 0;
}
.cv2-del-btn svg { width: 15px; height: 15px; }
.cv2-del-btn:hover { background: #fca5a5; }

/* ── Cases v3 ─────────────────────────────────────────────────── */
.cv3-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
}

.cv3-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 20px 24px;
  cursor: pointer;
  transition: box-shadow .18s, transform .12s;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.cv3-card:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,.09);
  transform: translateY(-1px);
}

.cv3-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cv3-title {
  font-size: 1.10rem;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cv3-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.84rem;
  color: #64748b;
}

.cv3-meta-item { font-weight: 500; }
.cv3-sep { color: #cbd5e1; }
.cv3-docs-ok   { color: #059669; font-weight: 600; }
.cv3-docs-warn { color: #d97706; font-weight: 600; }

.cv3-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.cv3-select {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 7px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  color: #0f172a;
  cursor: pointer;
  outline: none;
  min-width: 140px;
  transition: border-color .15s;
}
.cv3-select:hover,
.cv3-select:focus { border-color: #0d9488; }

.cv3-del {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: #fee2e2;
  color: #dc2626;
  cursor: pointer;
  transition: background .15s;
  flex-shrink: 0;
}
.cv3-del svg { width: 15px; height: 15px; }
.cv3-del:hover { background: #fca5a5; }

/* ── Document editor panel ───────────────────────────────────── */
.doc-mode-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--color-border);
  padding: 0 16px;
  background: #f8fafc;
}

.doc-mode-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border: none;
  background: transparent;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.doc-mode-tab svg { width: 14px; height: 14px; }
.doc-mode-tab:hover { color: var(--color-text); }
.doc-mode-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.doc-editor-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.doc-footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Adjuntos del correo origen en el caso ─────────────────────────── */
.att-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.att-item {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.att-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  background: #f8fafc;
  font-size: 12.5px;
}

.att-icon {
  flex-shrink: 0;
  color: var(--color-text-muted);
  display: flex;
}

.att-name {
  flex: 1;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.att-size {
  font-size: 11px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.att-toggle {
  background: none;
  border: none;
  padding: 2px 6px;
  font-size: 11px;
  color: var(--color-primary);
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 3px;
}

.att-toggle:hover {
  background: var(--color-primary-light, #eff6ff);
}

.att-no-text {
  font-size: 11px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.att-extracted-text {
  margin: 0;
  padding: 10px;
  font-size: 11.5px;
  line-height: 1.6;
  font-family: inherit;
  white-space: pre-wrap;
  word-break: break-word;
  background: #fff;
  border-top: 1px solid var(--color-border);
  max-height: 200px;
  overflow-y: auto;
  color: var(--color-text);
}

/* ── Selector de tipo de documento ───────────────────────────────────── */
.doc-type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  max-width: 340px;
}

.doc-type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 12px;
  background: var(--color-bg);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg, 10px);
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, background .15s;
  font-family: inherit;
}

.doc-type-card:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-light, #eff6ff);
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}

.doc-type-icon {
  display: flex;
  color: var(--color-primary);
}

.doc-type-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text);
  text-align: center;
  line-height: 1.3;
}

/* ── Dropdown de regenerar ───────────────────────────────────────────── */
.doc-type-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  z-index: 100;
  min-width: 200px;
  overflow: hidden;
}

.doc-type-dropdown button {
  display: block;
  width: 100%;
  padding: 9px 14px;
  background: none;
  border: none;
  text-align: left;
  font-size: 13px;
  font-family: inherit;
  color: var(--color-text);
  cursor: pointer;
  transition: background .1s;
}

.doc-type-dropdown button:hover {
  background: var(--color-surface, #f8fafc);
}

/* ── Toolbar del editor de documentos ───────────────────────────────── */
.doc-toolbar {
  display: none;
  align-items: center;
  gap: 2px;
  padding: 6px 10px;
  background: var(--color-surface, #f8fafc);
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}

.toolbar-btn {
  padding: 4px 8px;
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
  color: var(--color-text);
  cursor: pointer;
  transition: background .12s, border-color .12s;
  line-height: 1.4;
}

.toolbar-btn:hover {
  background: var(--color-bg);
  border-color: var(--color-border);
}

.toolbar-sep {
  width: 1px;
  height: 18px;
  background: var(--color-border);
  margin: 0 4px;
}

/* Editor como textarea en lugar de contenteditable */
.doc-editor {
  flex: 1;
  width: 100%;
  padding: 24px 28px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  line-height: 1.8;
  border: none;
  outline: none;
  resize: none;
  background: #fafbfc;
  color: var(--color-text);
  box-sizing: border-box;
  overflow-y: auto;
}
