/* ============================================================
   PILAY LEGAL — Design System
   ============================================================ */
:root {
  --primary-dark: #001E61;
  --primary-blue: #004BEE;
  --primary-green: #93D38B;
  --secondary-light: #D7E3F9;
  --secondary-lighter: #F5F9FF;
  --secondary-dark-green: #00843E;
  --secondary-mid-green: #7FB86D;
  --secondary-pale-green: #DBF2DB;
  --grey-white: #FFFFFF;
  --grey-f2: #F2F2F2;
  --grey-d2: #D2D2D2;
  --grey-8b: #8B8B8B;
  --grey-41: #414141;
  --grey-dark: #222222;
  --alert-success: #06AB70;
  --alert-error: #F11212;
  --alert-warning: #FFAB00;

  --sidebar-width: 240px;
  --sidebar-collapsed: 64px;
  --topbar-height: 60px;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 2px 12px rgba(0,30,97,.08);
  --shadow-md: 0 4px 24px rgba(0,30,97,.12);
  --transition: .2s cubic-bezier(.4,0,.2,1);
}

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

html { font-size: 14px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--grey-f2);
  color: var(--grey-dark);
  height: 100vh;
  overflow: hidden;
}
#appRoot {
  display: flex;
  height: 100vh;
}
#appRoot.hidden { display: none !important; }

/* ─── SCROLLBAR ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--grey-d2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--grey-8b); }

/* ─── SIDEBAR ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--primary-dark);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  transition: width var(--transition);
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .sidebar-version { opacity: 0; pointer-events: none; }
.sidebar.collapsed .sidebar-footer { display: none; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  min-height: 64px;
}

.logo { display: flex; align-items: center; gap: 10px; overflow: hidden; }
.logo-icon {
  width: 34px; height: 34px;
  background: var(--primary-blue);
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  font-weight: 800; color: white; font-size: 16px;
  flex-shrink: 0;
}
.logo-text { display: flex; flex-direction: column; transition: opacity var(--transition); }
.logo-name { color: white; font-weight: 700; font-size: 15px; line-height: 1.1; }
.logo-sub { color: rgba(255,255,255,.5); font-size: 11px; }

.sidebar-toggle {
  background: none; border: none; color: rgba(255,255,255,.6);
  cursor: pointer; padding: 4px 6px; border-radius: 4px;
  transition: all var(--transition); flex-shrink: 0;
}
.sidebar-toggle:hover { background: rgba(255,255,255,.1); color: white; }

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

.nav-section-label {
  color: rgba(255,255,255,.3);
  font-size: 10px; font-weight: 700;
  letter-spacing: .08em;
  padding: 10px 12px 4px;
  white-space: nowrap;
  transition: opacity var(--transition);
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.7);
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
  position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: white; }
.nav-item.active { background: var(--primary-blue); color: white; }
.nav-item.active .nav-icon { color: white; }
.nav-icon { width: 18px; text-align: center; flex-shrink: 0; font-size: 15px; }
.nav-label { font-size: 13px; font-weight: 500; flex: 1; transition: opacity var(--transition); }
.nav-badge {
  background: var(--alert-error);
  color: white; font-size: 10px; font-weight: 700;
  padding: 2px 5px; border-radius: 10px;
  min-width: 18px; text-align: center;
  transition: opacity var(--transition);
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.1);
}
.sidebar-version { color: rgba(255,255,255,.3); font-size: 11px; }

/* ─── MAIN CONTENT ─────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  transition: margin-left var(--transition);
  max-width: calc(100vw - var(--sidebar-width));
}
.main-content.expanded {
  margin-left: var(--sidebar-collapsed);
  max-width: calc(100vw - var(--sidebar-collapsed));
}

/* ─── TOPBAR ───────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: white;
  border-bottom: 1px solid var(--grey-d2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow);
}

.breadcrumb {
  font-size: 16px; font-weight: 600;
  color: var(--grey-dark);
}

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

.search-box {
  position: relative;
  display: flex; align-items: center;
}
.search-icon {
  position: absolute; left: 10px;
  color: var(--grey-8b); font-size: 13px;
  pointer-events: none;
}
.search-box input {
  width: 240px;
  padding: 7px 12px 7px 32px;
  border: 1px solid var(--grey-d2);
  border-radius: 20px;
  font-size: 13px;
  background: var(--grey-f2);
  transition: all var(--transition);
  outline: none;
}
.search-box input:focus {
  width: 300px;
  border-color: var(--primary-blue);
  background: white;
  box-shadow: 0 0 0 3px rgba(0,75,238,.1);
}

.search-results {
  position: absolute; top: calc(100% + 6px); left: 0;
  width: 360px;
  background: white;
  border: 1px solid var(--grey-d2);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 200;
  overflow: hidden;
}
.search-result-item {
  padding: 10px 14px;
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid var(--grey-f2);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--secondary-lighter); }
.search-result-type {
  font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 10px;
  background: var(--secondary-light);
  color: var(--primary-blue);
  text-transform: uppercase;
}
.search-result-title { font-size: 13px; font-weight: 500; flex: 1; }
.search-result-sub { font-size: 11px; color: var(--grey-8b); }

.alert-btn {
  position: relative;
  background: none; border: none;
  color: var(--grey-8b); font-size: 18px;
  cursor: pointer; padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.alert-btn:hover { background: var(--grey-f2); color: var(--primary-dark); }
.alert-count {
  position: absolute; top: 2px; right: 2px;
  background: var(--alert-error);
  color: white; font-size: 9px; font-weight: 700;
  width: 16px; height: 16px;
  border-radius: 50%;
  display: grid; place-items: center;
}

.user-info { display: flex; align-items: center; gap: 8px; }
.user-avatar {
  width: 34px; height: 34px;
  background: var(--secondary-light);
  color: var(--primary-blue);
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
}
.user-name { font-size: 13px; font-weight: 500; color: var(--grey-41); }

/* ─── ALERTS PANEL ─────────────────────────────────────────── */
.alerts-panel {
  position: fixed; top: var(--topbar-height); right: 0;
  width: 380px; height: calc(100vh - var(--topbar-height));
  background: white;
  border-left: 1px solid var(--grey-d2);
  box-shadow: -4px 0 20px rgba(0,0,0,.1);
  z-index: 90;
  display: flex; flex-direction: column;
  transform: translateX(0);
  animation: slideInRight .25s ease;
}
.alerts-panel.hidden { display: none; }

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.alerts-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--grey-d2);
}
.alerts-panel-header h3 { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.btn-close-panel {
  background: none; border: none; cursor: pointer;
  color: var(--grey-8b); font-size: 16px; padding: 4px;
  border-radius: 4px; transition: all var(--transition);
}
.btn-close-panel:hover { background: var(--grey-f2); color: var(--grey-dark); }
.alerts-panel-content { flex: 1; overflow-y: auto; padding: 12px; }

.alert-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px; border-radius: var(--radius);
  margin-bottom: 8px;
  border-left: 3px solid var(--grey-d2);
  background: var(--grey-f2);
  transition: all var(--transition);
  cursor: pointer;
}
.alert-item:hover { background: var(--secondary-lighter); }
.alert-item.vencido { border-color: var(--alert-error); background: #FFF5F5; }
.alert-item.urgente { border-color: var(--alert-warning); background: #FFFBF0; }
.alert-item.proximo { border-color: var(--primary-blue); background: var(--secondary-lighter); }
.alert-item-icon { font-size: 18px; flex-shrink: 0; margin-top: 2px; }
.alert-item-body { flex: 1; }
.alert-item-title { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.alert-item-sub { font-size: 11px; color: var(--grey-8b); }
.alert-item-days { font-size: 11px; font-weight: 700; }
.alert-item-days.vencido { color: var(--alert-error); }
.alert-item-days.urgente { color: var(--alert-warning); }
.alert-item-days.proximo { color: var(--primary-blue); }

/* ─── VIEW CONTAINER ───────────────────────────────────────── */
.view-container {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;       /* clave para que flex hijo pueda scrollear */
  animation: fadeInView .3s ease;
}

@keyframes fadeInView {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── CARDS & STATS ────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  border-top: 3px solid var(--primary-blue);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card.green { border-top-color: var(--secondary-dark-green); }
.stat-card.orange { border-top-color: var(--alert-warning); }
.stat-card.red { border-top-color: var(--alert-error); }
.stat-card.navy { border-top-color: var(--primary-dark); }
.stat-card.teal { border-top-color: var(--alert-success); }

.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius);
  display: grid; place-items: center;
  font-size: 20px;
  margin-bottom: 14px;
  background: var(--secondary-light);
  color: var(--primary-blue);
}
.stat-card.green .stat-icon { background: var(--secondary-pale-green); color: var(--secondary-dark-green); }
.stat-card.orange .stat-icon { background: #FFF8E6; color: var(--alert-warning); }
.stat-card.red .stat-icon { background: #FFF0F0; color: var(--alert-error); }
.stat-card.navy .stat-icon { background: var(--secondary-light); color: var(--primary-dark); }
.stat-card.teal .stat-icon { background: #E6F9F3; color: var(--alert-success); }

.stat-number {
  font-size: 32px; font-weight: 700;
  color: var(--grey-dark); line-height: 1;
  margin-bottom: 4px;
}
.stat-label { font-size: 12px; color: var(--grey-8b); font-weight: 500; }

/* ─── GRID LAYOUTS ─────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.grid-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: 20px; margin-bottom: 24px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 24px; }

@media (max-width: 1200px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-1-2, .grid-2-1 { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ─── CARD ─────────────────────────────────────────────────── */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--grey-f2);
}
.card-title {
  font-size: 14px; font-weight: 600;
  color: var(--grey-dark);
  display: flex; align-items: center; gap: 8px;
}
.card-title i { color: var(--primary-blue); }
.card-body { padding: 16px 20px; }

/* ─── TOOLBAR ──────────────────────────────────────────────── */
.toolbar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar-left { display: flex; align-items: center; gap: 10px; flex: 1; flex-wrap: wrap; }
.toolbar-right { display: flex; align-items: center; gap: 8px; }

/* ─── TABS ─────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--grey-f2);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.tab {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--grey-8b);
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.tab:hover { background: rgba(0,0,0,.05); color: var(--grey-dark); }
.tab.active {
  background: white;
  color: var(--primary-blue);
  box-shadow: 0 1px 4px rgba(0,0,0,.1);
}
.tab .tab-count {
  background: var(--secondary-light);
  color: var(--primary-blue);
  font-size: 10px; font-weight: 700;
  padding: 1px 5px; border-radius: 8px;
  margin-left: 4px;
}
.tab.active .tab-count { background: var(--primary-blue); color: white; }

/* ─── INPUTS & SELECTS ─────────────────────────────────────── */
.input, .select, textarea.input {
  padding: 8px 12px;
  border: 1.5px solid var(--grey-d2);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--grey-dark);
  background: white;
  transition: all var(--transition);
  outline: none;
  font-family: inherit;
}
.input:focus, .select:focus, textarea.input:focus {
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(0,75,238,.1);
}
.select { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238B8B8B' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px;
}
.input-sm { padding: 6px 10px; font-size: 12px; }
textarea.input { resize: vertical; min-height: 80px; }

.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--grey-41); margin-bottom: 5px; }
.form-label span.required { color: var(--alert-error); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.input-full { width: 100%; }

/* ─── BUTTONS ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn i { font-size: 12px; }
.btn:active { transform: scale(.97); }

.btn-primary { background: var(--primary-blue); color: white; }
.btn-primary:hover { background: #0039CC; box-shadow: 0 4px 12px rgba(0,75,238,.3); }

.btn-secondary { background: var(--grey-f2); color: var(--grey-41); }
.btn-secondary:hover { background: var(--grey-d2); }

.btn-success { background: var(--alert-success); color: white; }
.btn-success:hover { background: #058B5C; }

.btn-danger { background: var(--alert-error); color: white; }
.btn-danger:hover { background: #CC0000; }

.btn-warning { background: var(--alert-warning); color: white; }
.btn-warning:hover { background: #E09900; }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--grey-d2);
  color: var(--grey-41);
}
.btn-outline:hover { border-color: var(--primary-blue); color: var(--primary-blue); background: var(--secondary-lighter); }

.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-icon { padding: 7px; width: 32px; height: 32px; justify-content: center; }

/* ─── TABLE ────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: white;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  padding: 11px 14px;
  text-align: left;
  font-size: 11px; font-weight: 700;
  color: var(--grey-8b);
  text-transform: uppercase; letter-spacing: .05em;
  background: var(--grey-f2);
  border-bottom: 1px solid var(--grey-d2);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.data-table th:hover { color: var(--primary-blue); }
.data-table th .sort-icon { margin-left: 4px; opacity: .4; }
.data-table th.sorted .sort-icon { opacity: 1; color: var(--primary-blue); }

.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--grey-f2);
  vertical-align: middle;
  color: var(--grey-dark);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--secondary-lighter); }
.data-table tr { transition: background var(--transition); }

.td-truncate { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-nowrap { white-space: nowrap; }
.td-actions { display: flex; align-items: center; gap: 4px; }

/* ─── BADGES ───────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px; font-weight: 700;
  white-space: nowrap;
}
.badge-blue { background: var(--secondary-light); color: var(--primary-blue); }
.badge-green { background: var(--secondary-pale-green); color: var(--secondary-dark-green); }
.badge-orange { background: #FFF8E6; color: #CC7A00; }
.badge-red { background: #FFF0F0; color: var(--alert-error); }
.badge-grey { background: var(--grey-f2); color: var(--grey-8b); }
.badge-navy { background: var(--secondary-light); color: var(--primary-dark); }
.badge-teal { background: #E6F9F3; color: var(--alert-success); }

.priority-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; }
.priority-urgente { color: var(--alert-error); }
.priority-alta { color: var(--alert-warning); }
.priority-normal { color: var(--grey-8b); }
.priority-baja { color: var(--secondary-mid-green); }

.deadline-badge {
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 20px;
}
.deadline-vencido { background: #FFF0F0; color: var(--alert-error); }
.deadline-hoy { background: #FFF8E6; color: #CC7A00; animation: pulse 2s infinite; }
.deadline-pronto { background: var(--secondary-light); color: var(--primary-blue); }
.deadline-ok { background: var(--grey-f2); color: var(--grey-8b); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .6; }
}

/* ─── TIPO CD LABELS ───────────────────────────────────────── */
.tipo-badge { padding: 3px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; }

/* ─── MODAL ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,30,97,.35);
  backdrop-filter: blur(3px);
  z-index: 500;
  display: grid; place-items: center;
  padding: 20px;
  animation: fadeIn .2s ease;
}
.modal-overlay.hidden { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: white;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  width: 100%; max-width: 680px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  animation: slideUp .25s ease;
}
.modal-box.modal-wide { max-width: 900px; }
.modal-box.modal-detail { max-width: 820px; }

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--grey-f2);
}
.modal-header h2 { font-size: 16px; font-weight: 700; color: var(--grey-dark); }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--grey-8b); font-size: 18px; padding: 4px;
  border-radius: 4px; transition: all var(--transition);
}
.modal-close:hover { background: var(--grey-f2); color: var(--grey-dark); }

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

.modal-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--grey-f2);
}
.modal-footer.hidden { display: none; }

/* ─── TOAST ────────────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 20px; right: 20px;
  z-index: 1000;
  display: flex; flex-direction: column-reverse; gap: 8px;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  background: white;
  border-left: 4px solid var(--primary-blue);
  min-width: 280px; max-width: 360px;
  animation: toastIn .3s ease;
  font-size: 13px;
}
.toast.success { border-color: var(--alert-success); }
.toast.error { border-color: var(--alert-error); }
.toast.warning { border-color: var(--alert-warning); }
.toast-icon { font-size: 16px; flex-shrink: 0; }
.toast.success .toast-icon { color: var(--alert-success); }
.toast.error .toast-icon { color: var(--alert-error); }
.toast.warning .toast-icon { color: var(--alert-warning); }
.toast-msg { flex: 1; font-weight: 500; }
.toast-close { background: none; border: none; cursor: pointer; color: var(--grey-8b); font-size: 14px; padding: 2px; }

@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes toastOut {
  from { transform: translateX(0); opacity: 1; max-height: 100px; }
  to { transform: translateX(100%); opacity: 0; max-height: 0; padding: 0; margin: 0; }
}

/* ─── EMPTY STATE ──────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  padding: 60px 20px;
  text-align: center;
}
.empty-state-icon { font-size: 48px; color: var(--grey-d2); margin-bottom: 16px; }
.empty-state-title { font-size: 16px; font-weight: 600; color: var(--grey-8b); margin-bottom: 6px; }
.empty-state-sub { font-size: 13px; color: var(--grey-d2); margin-bottom: 20px; }

/* ─── LOADING ──────────────────────────────────────────────── */
.loading {
  display: flex; flex-direction: column; align-items: center;
  padding: 60px;
}
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--grey-d2);
  border-top-color: var(--primary-blue);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── PAGINATION ───────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--grey-f2);
  font-size: 12px; color: var(--grey-8b);
}
.pagination-btns { display: flex; gap: 4px; }
.page-btn {
  padding: 4px 10px;
  border: 1px solid var(--grey-d2);
  border-radius: 4px;
  background: white;
  font-size: 12px; cursor: pointer;
  transition: all var(--transition);
}
.page-btn:hover { border-color: var(--primary-blue); color: var(--primary-blue); }
.page-btn.active { background: var(--primary-blue); color: white; border-color: var(--primary-blue); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ─── ACTIVITY FEED ────────────────────────────────────────── */
.activity-list { display: flex; flex-direction: column; gap: 0; }
.activity-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--grey-f2);
  position: relative;
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 8px; height: 8px;
  border-radius: 50%; flex-shrink: 0;
  margin-top: 5px;
}
.activity-dot.carta { background: var(--primary-blue); }
.activity-dot.juicio { background: var(--primary-dark); }
.activity-dot.mediacion { background: var(--alert-success); }
.activity-dot.oficio { background: var(--alert-warning); }
.activity-dot.reclamo { background: var(--alert-error); }
.activity-body { flex: 1; }
.activity-title { font-size: 12px; font-weight: 600; color: var(--grey-dark); }
.activity-sub { font-size: 11px; color: var(--grey-8b); margin-top: 2px; }
.activity-time { font-size: 11px; color: var(--grey-d2); white-space: nowrap; }

/* ─── CHART CARD ───────────────────────────────────────────── */
.chart-container { position: relative; height: 240px; }
.chart-container-tall { position: relative; height: 320px; }

/* ─── DETAIL VIEW ──────────────────────────────────────────── */
.detail-header {
  display: flex; align-items: flex-start; gap: 16px;
  margin-bottom: 20px;
  padding: 20px;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.detail-icon {
  width: 56px; height: 56px;
  border-radius: var(--radius);
  display: grid; place-items: center;
  font-size: 24px;
  background: var(--secondary-light);
  color: var(--primary-blue);
  flex-shrink: 0;
}
.detail-title-block { flex: 1; }
.detail-title { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.detail-sub { font-size: 13px; color: var(--grey-8b); }
.detail-badges { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.detail-field { display: flex; flex-direction: column; gap: 3px; }
.detail-field-label { font-size: 11px; font-weight: 700; color: var(--grey-8b); text-transform: uppercase; }
.detail-field-value { font-size: 13px; font-weight: 500; color: var(--grey-dark); }

/* ─── COMMENTS ─────────────────────────────────────────────── */
.comment-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.comment-item {
  background: var(--grey-f2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.comment-header { display: flex; justify-content: space-between; margin-bottom: 5px; }
.comment-user { font-size: 11px; font-weight: 700; color: var(--primary-blue); }
.comment-date { font-size: 11px; color: var(--grey-8b); }
.comment-text { font-size: 13px; color: var(--grey-dark); line-height: 1.5; }
.comment-input-row { display: flex; gap: 8px; }
.comment-input-row .input { flex: 1; }

/* ─── TIMELINE ──────────────────────────────────────────────── */
.timeline { display: flex; flex-direction: column; gap: 0; margin-bottom: 16px; position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 10px; top: 0; bottom: 0; width: 2px; background: var(--grey-f2); }
.timeline-item { display: flex; gap: 12px; position: relative; padding: 6px 0; }
.timeline-dot {
  width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; position: absolute; left: -24px; top: 6px;
  font-size: 9px; color: #fff;
}
.timeline-body { flex: 1; padding-bottom: 4px; }
.timeline-action { font-size: 12px; font-weight: 600; color: var(--grey-dark); line-height: 1.4; }
.timeline-action .text-muted { font-weight: 400; }
.timeline-meta { font-size: 11px; color: var(--grey-8b); margin-top: 2px; }

/* ─── CONFIG TABLE ─────────────────────────────────────────── */
.config-section { margin-bottom: 32px; }
.config-section-title {
  font-size: 14px; font-weight: 700;
  color: var(--grey-dark); margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.config-section-title i { color: var(--primary-blue); }

/* ─── INFO BOX ─────────────────────────────────────────────── */
.info-box {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
}
.info-box.blue { background: var(--secondary-lighter); border-left: 3px solid var(--primary-blue); }
.info-box.green { background: var(--secondary-pale-green); border-left: 3px solid var(--secondary-dark-green); }
.info-box.warning { background: #FFF8E6; border-left: 3px solid var(--alert-warning); }

/* ─── FAB ──────────────────────────────────────────────────── */
.fab {
  position: fixed; bottom: 24px; right: 24px;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--primary-blue);
  color: white;
  border: none;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,75,238,.4);
  transition: all var(--transition);
  z-index: 40;
  display: grid; place-items: center;
}
.fab:hover { transform: scale(1.08) rotate(90deg); box-shadow: 0 6px 20px rgba(0,75,238,.5); }

/* ─── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: var(--sidebar-collapsed); }
  .sidebar .logo-text, .sidebar .nav-label, .sidebar .nav-badge,
  .sidebar .nav-section-label, .sidebar .sidebar-footer { opacity: 0; pointer-events: none; }
  .main-content { margin-left: var(--sidebar-collapsed); max-width: calc(100vw - var(--sidebar-collapsed)); }
  .view-container { padding: 14px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .data-table td, .data-table th { padding: 8px 10px; }
  .topbar { padding: 0 12px; }
  .search-box input { width: 160px; }
  .user-name { display: none; }
}

/* ─── MISC ─────────────────────────────────────────────────── */
.text-muted { color: var(--grey-8b); }
.text-sm { font-size: 12px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.flex-row { display: flex; align-items: center; gap: 8px; }
.divider { height: 1px; background: var(--grey-f2); margin: 16px 0; }

.page-title {
  font-size: 20px; font-weight: 700;
  color: var(--grey-dark);
  margin-bottom: 20px;
  display: flex; align-items: center; gap: 10px;
}
.page-title i { color: var(--primary-blue); }

.section-title {
  font-size: 15px; font-weight: 700;
  color: var(--grey-dark);
  margin-bottom: 14px;
}

/* ─── LOGIN SCREEN ─────────────────────────────────────────── */
.login-screen {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--secondary-lighter);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: var(--grey-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 40px 36px;
  width: 100%; max-width: 360px;
  display: flex; flex-direction: column; align-items: center; gap: 20px;
}
.login-logo { display: flex; align-items: center; gap: 14px; }
.login-error {
  color: var(--alert-error); font-size: 13px;
  background: #fff0f0; border-radius: var(--radius-sm);
  padding: 8px 12px; width: 100%; text-align: center;
}
.btn-ms {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 11px 16px;
  border: 1.5px solid var(--grey-d2); border-radius: var(--radius-sm);
  background: var(--grey-white); color: var(--grey-dark);
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
  justify-content: center;
}
.btn-ms:hover { border-color: var(--primary-blue); box-shadow: 0 0 0 3px rgba(0,75,238,.1); }
.btn-ms:disabled { opacity: .6; cursor: not-allowed; }
.login-hint { font-size: 12px; color: var(--grey-8b); text-align: center; }

/* ─── WELCOME SCREEN ───────────────────────────────────────── */
.welcome-screen {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--secondary-lighter);
  display: flex; align-items: center; justify-content: center;
}
.welcome-card {
  background: var(--grey-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 44px 40px;
  width: 100%; max-width: 480px;
  display: flex; flex-direction: column; align-items: center; gap: 24px;
}
.welcome-body { width: 100%; display: flex; flex-direction: column; gap: 16px; }
.welcome-title { font-size: 20px; font-weight: 700; color: var(--grey-dark); text-align: center; }
.welcome-desc { font-size: 14px; color: var(--grey-8b); text-align: center; line-height: 1.6; }
.welcome-alert {
  display: flex; align-items: flex-start; gap: 14px;
  background: var(--secondary-lighter);
  border: 1.5px solid var(--secondary-light);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.welcome-user {
  text-align: center; font-size: 13px; color: var(--grey-8b);
  background: var(--grey-f2); border-radius: var(--radius-sm);
  padding: 8px 12px;
}

/* ─── ADMIN USERS PANEL ────────────────────────────────────── */
.user-row {
  padding: 14px 0; border-bottom: 1px solid var(--grey-f2);
  display: flex; flex-direction: column; gap: 10px;
}
.user-row:last-child { border-bottom: none; }
.user-row-info {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.user-avatar-sm {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary-blue); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.user-row-modules { display: flex; flex-wrap: wrap; gap: 6px; padding-left: 44px; }
.mod-toggle {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; cursor: pointer;
  border: 1.5px solid var(--grey-d2); background: var(--grey-f2); color: var(--grey-8b);
  transition: all var(--transition);
}
.mod-toggle.on {
  border-color: var(--primary-blue); background: var(--secondary-light); color: var(--primary-blue);
}
.mod-toggle:hover:not(:disabled) { border-color: var(--primary-blue); color: var(--primary-blue); }
.mod-toggle:disabled { opacity: .5; cursor: not-allowed; }

.toggle-switch { display: flex; align-items: center; cursor: pointer; margin-left: auto; }
.toggle-switch input { display: none; }
.toggle-track {
  width: 36px; height: 20px; background: var(--grey-d2); border-radius: 10px;
  position: relative; transition: background var(--transition);
}
.toggle-track::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 14px; height: 14px; background: white; border-radius: 50%;
  transition: transform var(--transition);
}
.toggle-switch input:checked + .toggle-track { background: var(--alert-success); }
.toggle-switch input:checked + .toggle-track::after { transform: translateX(16px); }

/* ─── LOGOUT BUTTON ────────────────────────────────────────── */
.btn-logout {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 10px;
  border: 1.5px solid var(--grey-d2); border-radius: var(--radius-sm);
  background: transparent; color: var(--grey-8b);
  font-size: 12px; font-weight: 500; cursor: pointer;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
  white-space: nowrap;
}
.btn-logout:hover {
  border-color: var(--alert-error);
  color: var(--alert-error);
  background: #fff5f5;
}

.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; }

.color-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
