/* ═══════════════════════════════════════════════════════════════════
   ProcuraDesk Responsive CSS
   Mobile (<768px) | Tablet (768-1024px) | Desktop (>1024px)
   Mobile Survival Mode — Dark UI for procuradores en juzgados
   ═══════════════════════════════════════════════════════════════════ */

/* ── Mobile Variables ────────────────────────────────────────────── */
:root {
  --mobile-bg: #0f172a;
  --mobile-bg-card: #1e293b;
  --mobile-bg-subtle: #111827;
  --mobile-orange: #f97316;
  --mobile-blue: #3b82f6;
  --mobile-red: #ef4444;
  --mobile-green: #22c55e;
  --mobile-header-h: 56px;
  --mobile-bottomnav-h: 64px;
}

/* ── Mobile hamburger & bottom nav (injected by mobile.js) ─────── */

.mobile-hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--fg);
  cursor: pointer;
  padding: 6px;
  margin-right: 4px;
  flex-shrink: 0;
  z-index: 50;
}

/* Legacy bottom nav — hidden, replaced by msm-bottomnav */
.mobile-bottom-nav {
  display: none !important;
}

/* Sidebar overlay mode */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 89;
  -webkit-tap-highlight-color: transparent;
}

.sidebar-overlay.visible { display: block; }

/* Mobile back button for drawer */
.mobile-back-btn {
  display: none;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 0;
  align-items: center;
  gap: 4px;
}


/* ═══════════════════════════════════════════════════════════════════
   MSM active — hide desktop UI (works at ANY viewport width)
   Applied by mobile.js via body.msm-active class
   ═══════════════════════════════════════════════════════════════════ */

body.msm-active .header,
body.msm-active .sidebar,
body.msm-active .main,
body.msm-active .layout {
  display: none !important;
}

body.msm-active .msm-shell {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--mobile-bg, #0f172a);
  color: #e2e8f0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
  z-index: 999;
}


/* ═══════════════════════════════════════════════════════════════════
   MOBILE SURVIVAL MODE: < 768px
   ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {

  /* ── Layout ────────────────────────────────────────────────────── */
  .layout {
    grid-template-columns: 1fr !important;
    grid-template-rows: var(--header-h) 1fr !important;
  }

  /* ── MSM Shell ────────────────────────────────────────────────── */
  .msm-shell {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: var(--mobile-bg);
    color: #e2e8f0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
    z-index: 999;
  }

  /* ── MSM Header ───────────────────────────────────────────────── */
  .msm-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--mobile-header-h);
    padding-top: env(safe-area-inset-top, 0px);
    background: var(--mobile-bg);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: 16px;
    padding-right: 16px;
    z-index: 1000;
    box-sizing: border-box;
  }

  .msm-header-logo {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .msm-header-logo svg {
    width: 24px;
    height: 24px;
    color: var(--mobile-orange);
  }

  .msm-header-logo-text {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
  }

  .msm-header-logo-text .logo-procura {
    color: #ffffff;
  }

  .msm-header-logo-text .logo-desk {
    color: var(--mobile-orange);
  }

  .msm-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .msm-header-updated {
    font-size: 10px;
    color: rgba(255,255,255,0.4);
    white-space: nowrap;
  }

  .msm-header-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--mobile-orange);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
  }

  /* ── MSM Scroll Area ──────────────────────────────────────────── */
  .msm-scroll {
    flex: 1;
    margin-top: calc(var(--mobile-header-h) + env(safe-area-inset-top, 0px));
    margin-bottom: calc(var(--mobile-bottomnav-h) + env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    overflow-x: hidden;
    max-width: 100vw;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }

  .msm-section {
    display: none;
    padding: 16px;
    min-height: calc(100vh - var(--mobile-header-h) - var(--mobile-bottomnav-h) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }

  .msm-section.active {
    display: block;
  }

  /* ── MSM Bottom Nav ───────────────────────────────────────────── */
  .msm-bottomnav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--mobile-bottomnav-h);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(15,23,42,0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 1000;
  }

  .msm-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 64px;
    min-height: 48px;
    padding: 6px 12px;
    color: rgba(255,255,255,0.5);
    font-size: 10px;
    font-weight: 500;
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s;
  }

  .msm-nav-item:active {
    transform: scale(0.97);
  }

  .msm-nav-item svg {
    width: 24px;
    height: 24px;
  }

  .msm-nav-item.active {
    color: var(--mobile-orange);
  }

  .msm-nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 3px;
    background: var(--mobile-orange);
    border-radius: 0 0 3px 3px;
  }

  .msm-nav-badge {
    position: absolute;
    top: 2px;
    right: 8px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: var(--mobile-red);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
  }

  /* ── RISK CARDS (Bloque 1) ────────────────────────────────────── */
  .msm-risk-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
  }

  .msm-risk-card {
    border-radius: 16px;
    padding: 16px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.1s;
  }

  .msm-risk-card:active {
    transform: scale(0.97);
  }

  .msm-risk-card--danger {
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.3);
  }

  .msm-risk-card--info {
    background: rgba(59,130,246,0.1);
    border: 1px solid rgba(59,130,246,0.3);
  }

  .msm-risk-number {
    font-size: 40px;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 4px;
  }

  .msm-risk-number--red { color: var(--mobile-red); }
  .msm-risk-number--blue { color: var(--mobile-blue); }

  @keyframes msmPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
  }

  .msm-risk-number.pulse {
    animation: msmPulse 1.5s ease-in-out infinite;
  }

  .msm-risk-label {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255,255,255,0.8);
    margin-bottom: 2px;
  }

  .msm-risk-sub {
    font-size: 11px;
    color: rgba(255,255,255,0.4);
  }

  .msm-risk-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--mobile-blue);
    color: #fff;
    margin-top: 4px;
    animation: msmPulse 1.5s ease-in-out infinite;
  }

  /* ── AGENDA DEL DIA (Bloque 2) ────────────────────────────────── */
  .msm-agenda-title {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 12px;
  }

  .msm-agenda-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
  }

  .msm-agenda-item {
    background: var(--mobile-bg-card);
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .msm-agenda-hora {
    font-size: 18px;
    font-weight: 700;
    color: var(--mobile-orange);
    font-family: 'SF Mono', 'Fira Code', monospace;
    min-width: 52px;
    flex-shrink: 0;
  }

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

  .msm-agenda-sala {
    font-size: 12px;
    color: rgba(255,255,255,0.4);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .msm-agenda-proc {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .msm-agenda-cliente {
    font-size: 12px;
    color: rgba(255,255,255,0.4);
  }

  .msm-agenda-call {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--mobile-orange);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
  }

  .msm-agenda-call:active {
    transform: scale(0.97);
  }

  .msm-agenda-empty {
    background: rgba(34,197,94,0.1);
    border: 1px solid rgba(34,197,94,0.2);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    color: var(--mobile-green);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 20px;
  }

  /* ── BUSCADOR TACTICO (Bloque 3) ──────────────────────────────── */
  .msm-search-wrap {
    position: relative;
    margin-bottom: 12px;
  }

  .msm-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: rgba(255,255,255,0.3);
    pointer-events: none;
  }

  .msm-search-input {
    width: 100%;
    height: 48px;
    padding: 0 16px 0 42px;
    background: var(--mobile-bg-card);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    color: #fff;
    font-size: 15px;
    outline: none;
    box-sizing: border-box;
    -webkit-appearance: none;
  }

  .msm-search-input::placeholder {
    color: rgba(255,255,255,0.3);
  }

  .msm-search-input:focus {
    border-color: var(--mobile-orange);
    box-shadow: 0 0 0 2px rgba(249,115,22,0.2);
  }

  .msm-search-chips {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .msm-search-chips::-webkit-scrollbar { display: none; }

  .msm-search-chip {
    padding: 6px 14px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    color: rgba(255,255,255,0.6);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s, color 0.15s;
  }

  .msm-search-chip:active,
  .msm-search-chip.active {
    background: rgba(249,115,22,0.15);
    border-color: var(--mobile-orange);
    color: var(--mobile-orange);
  }

  /* ── EXPEDIENTES STACK (Bloque 4) ─────────────────────────────── */
  .msm-exp-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 16px;
  }

  /* Skeleton Loader */
  @keyframes msmShimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
  }

  .msm-skeleton {
    background: var(--mobile-bg-card);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 8px;
  }

  .msm-skeleton-line {
    height: 14px;
    border-radius: 6px;
    background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
    background-size: 200% 100%;
    animation: msmShimmer 1.5s infinite;
    margin-bottom: 8px;
  }

  .msm-skeleton-line:last-child { margin-bottom: 0; }
  .msm-skeleton-line.short { width: 60%; }
  .msm-skeleton-line.medium { width: 80%; }

  /* Expediente Card */
  .msm-exp-card {
    background: var(--mobile-bg-card);
    border-radius: 16px;
    padding: 16px;
    border-left: 3px solid transparent;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.1s;
    position: relative;
    overflow: hidden;
  }

  .msm-exp-card:active {
    transform: scale(0.98);
  }

  .msm-exp-card.plazo-critico { border-left-color: var(--mobile-red); }
  .msm-exp-card.plazo-proximo { border-left-color: var(--mobile-orange); }
  .msm-exp-card.plazo-ok { border-left-color: var(--mobile-green); }

  .msm-exp-badges {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
    flex-wrap: wrap;
  }

  .msm-exp-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.5);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 180px;
  }

  .msm-exp-badge--tipo {
    background: rgba(249,115,22,0.15);
    color: var(--mobile-orange);
  }

  .msm-exp-cliente {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .msm-exp-autos {
    font-size: 13px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    margin-bottom: 4px;
    display: flex;
    gap: 8px;
    align-items: center;
  }

  .msm-exp-autos-num {
    color: var(--mobile-orange);
  }

  .msm-exp-autos-nig {
    color: rgba(255,255,255,0.35);
    font-size: 12px;
  }

  .msm-exp-plazo-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 6px;
    margin-top: 4px;
  }

  .msm-exp-plazo-badge.critico {
    background: rgba(239,68,68,0.15);
    color: var(--mobile-red);
  }

  .msm-exp-plazo-badge.proximo {
    background: rgba(249,115,22,0.15);
    color: var(--mobile-orange);
  }

  .msm-exp-plazo-badge.ok {
    background: rgba(34,197,94,0.15);
    color: var(--mobile-green);
  }

  .msm-exp-hito {
    font-size: 12px;
    color: rgba(255,255,255,0.35);
    font-style: italic;
    margin-top: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* ── BOTTOM SHEET ─────────────────────────────────────────────── */
  .msm-sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
  }

  .msm-sheet-overlay.visible {
    opacity: 1;
    pointer-events: auto;
  }

  .msm-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 95vh;
    background: var(--mobile-bg);
    border-radius: 16px 16px 0 0;
    z-index: 1101;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .msm-sheet.open {
    transform: translateY(0);
  }

  .msm-sheet-handle {
    display: flex;
    justify-content: center;
    padding: 12px 0 8px;
    flex-shrink: 0;
  }

  .msm-sheet-handle::after {
    content: '';
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255,255,255,0.2);
  }

  .msm-sheet-tabs {
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
    padding: 0 16px;
  }

  .msm-sheet-tabs::-webkit-scrollbar { display: none; }

  .msm-sheet-tab {
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    color: rgba(255,255,255,0.4);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    cursor: pointer;
    flex-shrink: 0;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
  }

  .msm-sheet-tab.active {
    color: var(--mobile-orange);
    border-bottom-color: var(--mobile-orange);
  }

  .msm-sheet-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
  }

  .msm-sheet-actions {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
  }

  .msm-sheet-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    text-align: center;
  }

  .msm-sheet-btn:active {
    transform: scale(0.97);
  }

  .msm-sheet-btn--primary {
    background: var(--mobile-orange);
    color: #fff;
  }

  .msm-sheet-btn--secondary {
    background: rgba(255,255,255,0.08);
    color: #fff;
  }

  /* ── AGENDA SECTION (tab) ─────────────────────────────────────── */
  .msm-cal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
  }

  .msm-cal-title {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
  }

  .msm-cal-nav {
    display: flex;
    gap: 8px;
  }

  .msm-cal-btn {
    background: rgba(255,255,255,0.06);
    border: none;
    border-radius: 8px;
    color: #fff;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .msm-cal-btn:active { transform: scale(0.97); }
  .msm-cal-btn--today { background: var(--mobile-orange); }

  .msm-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 16px;
  }

  .msm-cal-dow {
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: rgba(255,255,255,0.35);
    padding: 8px 0;
    text-transform: uppercase;
  }

  .msm-cal-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    min-width: 44px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 15px;
    color: rgba(255,255,255,0.7);
    position: relative;
    -webkit-tap-highlight-color: transparent;
  }

  .msm-cal-day:active { transform: scale(0.95); }
  .msm-cal-day.other-month { color: rgba(255,255,255,0.2); }
  .msm-cal-day.today { background: var(--mobile-orange); color: #fff; font-weight: 700; }
  .msm-cal-day.selected { background: rgba(249,115,22,0.2); border: 1px solid var(--mobile-orange); }

  .msm-cal-dots {
    display: flex;
    gap: 3px;
    margin-top: 2px;
  }

  .msm-cal-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
  }

  .msm-cal-dot--red { background: var(--mobile-red); }
  .msm-cal-dot--orange { background: var(--mobile-orange); }
  .msm-cal-dot--blue { background: var(--mobile-blue); }

  .msm-cal-events {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .msm-cal-event {
    background: var(--mobile-bg-card);
    border-radius: 10px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .msm-cal-event-time {
    font-size: 14px;
    font-weight: 600;
    color: var(--mobile-orange);
    font-family: 'SF Mono', 'Fira Code', monospace;
    min-width: 48px;
  }

  .msm-cal-event-badge {
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(249,115,22,0.15);
    color: var(--mobile-orange);
    flex-shrink: 0;
  }

  .msm-cal-event-desc {
    font-size: 13px;
    color: rgba(255,255,255,0.7);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* ── NOTIFICACIONES SECTION ───────────────────────────────────── */
  .msm-notif-group-title {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
    margin-top: 16px;
  }

  .msm-notif-group-title:first-child { margin-top: 0; }

  .msm-notif-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .msm-notif-item {
    background: var(--mobile-bg-card);
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    overflow: hidden;
  }

  .msm-notif-item:active { transform: scale(0.98); }
  .msm-notif-item.unread { border-left: 3px solid var(--mobile-blue); }

  .msm-notif-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(59,130,246,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
  }

  .msm-notif-body {
    flex: 1;
    min-width: 0;
  }

  .msm-notif-text {
    font-size: 13px;
    color: rgba(255,255,255,0.8);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .msm-notif-date {
    font-size: 11px;
    color: rgba(255,255,255,0.3);
  }

  /* ── BUSCADOR SECTION ─────────────────────────────────────────── */
  .msm-buscar-recientes-title {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
    margin-top: 16px;
  }

  .msm-buscar-reciente {
    padding: 10px 14px;
    color: rgba(255,255,255,0.6);
    font-size: 14px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    display: flex;
    align-items: center;
    gap: 8px;
    -webkit-tap-highlight-color: transparent;
  }

  .msm-buscar-reciente:active { background: rgba(255,255,255,0.04); }

  .msm-buscar-reciente svg {
    width: 14px;
    height: 14px;
    color: rgba(255,255,255,0.2);
    flex-shrink: 0;
  }

  .msm-buscar-results {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
  }

  /* ── PULL TO REFRESH ──────────────────────────────────────────── */
  .msm-pull-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 0;
    overflow: hidden;
    transition: height 0.2s;
    color: var(--mobile-orange);
    font-size: 13px;
  }

  .msm-pull-indicator.pulling {
    height: 48px;
  }

  .msm-pull-indicator.refreshing {
    height: 48px;
  }

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

  .msm-pull-indicator.refreshing svg {
    animation: msmSpin 0.8s linear infinite;
  }

  /* ── Context menu (long press) ────────────────────────────────── */
  .msm-context-menu {
    position: fixed;
    z-index: 1200;
    background: var(--mobile-bg-card);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 6px 0;
    min-width: 180px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  }

  .msm-context-item {
    padding: 12px 16px;
    font-size: 14px;
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .msm-context-item:active {
    background: rgba(255,255,255,0.06);
  }

  /* ── Swipe actions on exp cards ───────────────────────────────── */
  .msm-exp-card-inner {
    position: relative;
    z-index: 1;
    background: var(--mobile-bg-card);
    border-radius: 16px;
    transition: transform 0.15s;
  }

  .msm-swipe-actions {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: stretch;
    border-radius: 0 16px 16px 0;
    overflow: hidden;
  }

  .msm-swipe-action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    flex-direction: column;
    gap: 4px;
  }

  .msm-swipe-action--call { background: var(--mobile-green); }
  .msm-swipe-action--view { background: var(--mobile-blue); }

  /* ── General mobile active feedback ───────────────────────────── */
  .msm-shell button:active,
  .msm-shell [role="button"]:active {
    transform: scale(0.97);
    transition: transform 0.05s;
  }

  /* ── HIDE original desktop elements ───────────────────────────── */
  .mobile-hamburger { display: none !important; }
  .mobile-bottom-nav { display: none !important; }
  .mobile-card-list { display: none !important; }
  .mobile-back-btn { display: none !important; }

  /* ── No hover on touch ────────────────────────────────────────── */
  * { -webkit-tap-highlight-color: transparent; }

  /* ── Loading indicator ────────────────────────────────────────── */
  .msm-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    color: rgba(255,255,255,0.3);
    font-size: 13px;
    gap: 8px;
  }

  .msm-loading svg {
    animation: msmSpin 0.8s linear infinite;
    width: 18px;
    height: 18px;
  }

  /* ── Empty state ──────────────────────────────────────────────── */
  .msm-empty {
    text-align: center;
    padding: 32px 16px;
    color: rgba(255,255,255,0.3);
    font-size: 14px;
  }
}


/* ═══════════════════════════════════════════════════════════════════
   TABLET: 768px - 1024px
   ═══════════════════════════════════════════════════════════════════ */

@media (min-width: 768px) and (max-width: 1024px) {

  /* ── Layout ────────────────────────────────────────────────────── */
  :root {
    --sidebar-w: 56px;
  }

  /* ── Sidebar: icon-only, expand on hover ───────────────────────── */
  .sidebar {
    width: var(--sidebar-w) !important;
    transition: width .2s ease;
    overflow: visible !important;
    z-index: 30;
  }

  .sidebar:hover {
    width: 220px !important;
    box-shadow: var(--shadow);
  }

  .sidebar-section-label,
  .sidebar-section-toggle span:first-child {
    display: none;
  }

  .sidebar:hover .sidebar-section-label,
  .sidebar:hover .sidebar-section-toggle span:first-child {
    display: inline;
  }

  .sidebar-item {
    padding: 8px 16px !important;
    justify-content: center;
    overflow: hidden;
    white-space: nowrap;
  }

  .sidebar:hover .sidebar-item {
    justify-content: flex-start;
  }

  .sidebar-item span:not(.sidebar-count),
  .sidebar-count {
    display: none;
  }

  .sidebar:hover .sidebar-item span:not(.sidebar-count),
  .sidebar:hover .sidebar-count {
    display: inline;
  }

  .sidebar-section-toggle {
    padding: 6px 16px !important;
    justify-content: center;
    overflow: hidden;
  }

  .sidebar:hover .sidebar-section-toggle {
    justify-content: flex-start;
  }

  /* ── Header ────────────────────────────────────────────────────── */
  .header {
    padding: 0 14px !important;
  }

  .header-title { display: none !important; }

  /* ── Table: hide less important columns ────────────────────────── */
  .col-cuantia,
  .col-obs,
  .col-nig,
  .col-ref,
  .col-lexnet,
  .col-usuario,
  .col-situacion {
    display: none !important;
  }

  /* ── Drawer ────────────────────────────────────────────────────── */
  .main-split.drawer-open .main-content {
    flex: 0 0 40% !important;
  }

  .main-split.drawer-open .panel {
    width: 60% !important;
  }

  /* ── KPIs ──────────────────────────────────────────────────────── */
  .kpi-bar {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 8px !important;
    padding: 12px 14px 0 !important;
  }

  /* ── Filters ───────────────────────────────────────────────────── */
  .filter-bar {
    padding: 12px 14px !important;
  }

  .search-wrap {
    max-width: 280px !important;
  }

  /* ── Email ─────────────────────────────────────────────────────── */
  .email-list-pane.has-detail {
    width: 280px !important;
  }
}


/* ═══════════════════════════════════════════════════════════════════
   Mobile Card List (legacy — kept for fallback)
   ═══════════════════════════════════════════════════════════════════ */

.mobile-card-list {
  display: none;
  padding: 0 12px 12px;
  gap: 10px;
}

.mobile-card {
  background: var(--bg-default);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}

.mobile-card:active {
  background: var(--bg-subtle);
  border-color: var(--border);
}

.mobile-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 6px;
  gap: 8px;
}

.mobile-card-proc {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
  font-family: var(--font-mono);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-card-plazo {
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  padding: 2px 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

.mobile-card-plazo.critico { background: var(--red-dim); color: var(--red); }
.mobile-card-plazo.proximo { background: var(--yellow-dim); color: var(--yellow); }
.mobile-card-plazo.ok { background: var(--green-dim); color: var(--green); }

.mobile-card-cliente {
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-card-juzgado {
  font-size: 12px;
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.mobile-card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mobile-card-interno {
  font-size: 11px;
  color: var(--fg-subtle);
  font-family: var(--font-mono);
}

.mobile-card-fecha {
  font-size: 11px;
  color: var(--fg-muted);
  white-space: nowrap;
}


/* ═══════════════════════════════════════════════════════════════════
   Email attachment chips - clickeable
   ═══════════════════════════════════════════════════════════════════ */

.email-attach-chip[data-attach-enhanced] {
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.email-attach-chip[data-attach-enhanced]:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}


/* ═══════════════════════════════════════════════════════════════════
   PWA standalone mode adjustments
   ═══════════════════════════════════════════════════════════════════ */

@media (display-mode: standalone) {
  .header {
    padding-top: env(safe-area-inset-top, 0px);
  }

  .msm-header {
    padding-top: env(safe-area-inset-top, 0px);
    height: calc(var(--mobile-header-h) + env(safe-area-inset-top, 0px));
  }
}


/* ═══════════════════════════════════════════════════════════════════
   Touch & accessibility improvements
   ═══════════════════════════════════════════════════════════════════ */

@media (hover: none) and (pointer: coarse) {
  .sidebar-item,
  .email-row,
  .doc-card,
  .interv-card,
  .mobile-card,
  .action-btn,
  .quick-filter-tag,
  .page-btn {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .exp-table td {
    padding: 12px !important;
  }

  /* Disable hover effects on touch devices */
  .sidebar-item:hover,
  .kpi-card:hover,
  .kpi-card-v2:hover {
    background: inherit;
    border-color: inherit;
  }
}

/* Ocultar logo original React y mostrar el nuevo */
.sidebar-logo, .sidebar-brand, .sidebar > img, .sidebar > a > img {
  display: none !important;
}
.pd-logo-wrap {
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.pd-logo-wrap img {
  height: 36px !important;
  width: auto !important;
  max-width: 190px !important;
}

/* Ocultar logo antiguo del header React */
.header-logo { display: none !important; }

.pd-logo-wrap img {
  height: 52px !important;
  width: auto !important;
  max-width: 210px !important;
  padding: 4px 8px !important;
}

/* Ocultar UI desktop en móvil cuando MSM está activo */
@media (max-width: 767px) {
  body.msm-active .layout {
    display: none !important;
  }
}
