/* ═══════════════════════════════════════════════════════
   Firmia — Design System v2
   Sidebar layout · Gradient · Transitions · Curved
═══════════════════════════════════════════════════════ */

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

:root {
  --sidebar-w:        240px;
  --topbar-h:         60px;
  --editor-topbar-h:  52px;

  /* Sidebar gradient */
  --grad-start:   #1e1b4b;
  --grad-end:     #4338ca;
  --sidebar-bg:   linear-gradient(180deg, var(--grad-start) 0%, var(--grad-end) 100%);

  /* Content */
  --bg:           #f5f5f7;
  --surface:      #ffffff;
  --border:       #e5e5ea;
  --text:         #1c1c1e;
  --muted:        #8e8e93;

  /* Accents */
  --accent:       #4f46e5;
  --accent-2:     #7c3aed;
  --danger:       #ef4444;
  --success:      #22c55e;

  /* Radii */
  --r-sm:   8px;
  --r:      12px;
  --r-lg:   16px;
  --r-xl:   20px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.07);
  --shadow:    0 4px 20px rgba(0,0,0,.09);
  --shadow-lg: 0 8px 40px rgba(0,0,0,.14);

  /* Transitions */
  --ease: cubic-bezier(.4,0,.2,1);
  --t150: 150ms var(--ease);
  --t250: 250ms var(--ease);
  --t350: 350ms var(--ease);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: .9375rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ══════════════════════════════════════════
   LAYOUT
══════════════════════════════════════════ */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ──────────────── SIDEBAR ──────────────── */

.app-sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  z-index: 200;
  transition: transform var(--t350), width var(--t350);
  overflow: hidden;
}

/* Logo */
.sidebar-header {
  padding: 1.375rem 1.125rem 1.125rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .625rem;
  color: #fff;
  text-decoration: none;
  flex: 1;
  min-width: 0;
}

.sidebar-brand-icon {
  width: 36px; height: 36px;
  background: rgba(255,255,255,.18);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  transition: background var(--t150), transform var(--t250);
}
.sidebar-brand:hover .sidebar-brand-icon {
  background: rgba(255,255,255,.28);
  transform: rotate(-6deg) scale(1.05);
}

.sidebar-brand-name {
  font-weight: 700;
  font-size: 1.0625rem;
  letter-spacing: -.3px;
  color: #fff;
  white-space: nowrap;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 1rem .75rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.sidebar-nav::-webkit-scrollbar { width: 0; }

.sidebar-section-title {
  font-size: .625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(255,255,255,.35);
  padding: .75rem .5rem .375rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .625rem .875rem;
  border-radius: var(--r-sm);
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  transition: background var(--t150), color var(--t150), transform var(--t150);
  position: relative;
  white-space: nowrap;
}
.sidebar-link i {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  transition: transform var(--t250);
}
.sidebar-link:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
  transform: translateX(4px);
}
.sidebar-link:hover i { transform: scale(1.15); }

.sidebar-link.is-active {
  background: rgba(255,255,255,.18);
  color: #fff;
  font-weight: 600;
}
.sidebar-link.is-active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: #fff;
  border-radius: 0 3px 3px 0;
}

/* Sidebar bottom: user */
.sidebar-bottom {
  padding: .75rem;
  border-top: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .5rem .5rem;
  border-radius: var(--r-sm);
  transition: background var(--t150);
}
.sidebar-user:hover { background: rgba(255,255,255,.07); }

.user-avatar {
  width: 34px; height: 34px;
  background: rgba(255,255,255,.2);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: .8125rem; font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name  { font-size: .8125rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role  { font-size: .6875rem; color: rgba(255,255,255,.45); }

.logout-btn {
  background: none; border: none;
  color: rgba(255,255,255,.45);
  cursor: pointer; padding: 6px;
  border-radius: var(--r-sm);
  transition: all var(--t150);
  display: flex; align-items: center;
  flex-shrink: 0;
}
.logout-btn:hover { color: #fff; background: rgba(255,255,255,.12); transform: scale(1.1); }

/* ──────────────── MAIN ──────────────── */

.app-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--t350);
}

/* ──────────────── TOPBAR ──────────────── */

.app-topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.75rem;
  gap: .875rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-xs);
}

.topbar-toggle {
  display: none;
  background: none; border: none;
  color: var(--muted); font-size: 1.25rem;
  cursor: pointer; padding: 4px; border-radius: var(--r-sm);
  transition: color var(--t150);
}
.topbar-toggle:hover { color: var(--text); }

.topbar-title {
  font-weight: 700;
  font-size: .9375rem;
  color: var(--text);
  letter-spacing: -.2px;
}

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .5rem; }

.topbar-user-btn {
  display: flex; align-items: center; gap: .5rem;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r); padding: .35rem .75rem .35rem .5rem;
  cursor: pointer; color: var(--text);
  text-decoration: none;
  font-size: .8125rem; font-weight: 500;
  transition: all var(--t150);
}
.topbar-user-btn:hover { background: var(--border); color: var(--text); }

.topbar-avatar {
  width: 26px; height: 26px;
  background: var(--accent);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: .6875rem; font-weight: 700; color: #fff;
}

/* ──────────────── CONTENT ──────────────── */

.app-content {
  flex: 1;
  padding: 1.75rem 2rem;
}
.app-content.is-full {
  padding: 0;
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
}

/* ──────────────── FOOTER ──────────────── */

.app-footer {
  padding: 1rem 2rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .5rem;
  color: var(--muted);
  font-size: .75rem;
  background: var(--surface);
}

/* ══════════════════════════════════════════
   COMPONENTES
══════════════════════════════════════════ */

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border) !important;
  border-radius: var(--r-lg) !important;
  box-shadow: var(--shadow-sm) !important;
  transition: transform var(--t250), box-shadow var(--t250);
  overflow: hidden;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow) !important;
}
.card-body  { padding: 1.375rem 1.375rem; }
.card-footer {
  padding: .75rem 1.375rem;
  background: transparent;
  border-top: 1px solid var(--border) !important;
}

/* Botones */
.btn {
  font-size: .875rem;
  font-weight: 500;
  border-radius: var(--r-sm) !important;
  padding: .5rem 1rem;
  transition: all var(--t150);
  border: 1px solid transparent;
  display: inline-flex; align-items: center; gap: .375rem;
}
.btn:active { transform: scale(.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%) !important;
  border-color: transparent !important;
  color: #fff !important;
  box-shadow: 0 2px 8px rgba(79,70,229,.35);
}
.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 16px rgba(79,70,229,.45);
  transform: translateY(-1px);
}

.btn-light {
  background: var(--surface) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}
.btn-light:hover { background: var(--bg) !important; border-color: #d1d1d6 !important; }

.btn-success {
  background: var(--success) !important;
  border-color: var(--success) !important;
  color: #fff !important;
}
.btn-danger {
  background: var(--danger) !important;
  border-color: var(--danger) !important;
  color: #fff !important;
}
.btn-sm { padding: .3125rem .7rem !important; font-size: .8125rem !important; }
.btn-lg { padding: .6875rem 1.5rem !important; font-size: 1rem !important; }

/* Forms */
.form-control, .form-select {
  border: 1px solid var(--border);
  border-radius: var(--r-sm) !important;
  background: var(--surface);
  color: var(--text);
  font-size: .875rem;
  padding: .5625rem .875rem;
  transition: border-color var(--t150), box-shadow var(--t150);
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,70,229,.15);
  outline: none;
}
.form-label {
  font-size: .8125rem; font-weight: 600;
  color: #3a3a3c; margin-bottom: .375rem;
}
.input-group-text {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r-sm) !important; color: var(--muted);
}
.form-control-color { height: 40px; padding: .25rem .4rem; }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }

/* Alerts */
.alert { border-radius: var(--r) !important; border: none !important; font-size: .875rem; }
.alert-danger  { background: #fef2f2; color: #991b1b; border-left: 3px solid var(--danger) !important; }
.alert-success { background: #f0fdf4; color: #166534; border-left: 3px solid var(--success) !important; }
.alert-warning { background: #fffbeb; color: #92400e; border-left: 3px solid #f59e0b !important; }
.alert-info    { background: #eff6ff; color: #1e40af; border-left: 3px solid var(--accent) !important; }

/* Badges */
.badge { border-radius: 20px !important; font-weight: 500; font-size: .6875rem; padding: .25em .6em; }

/* Dropdown */
.dropdown-menu {
  border: 1px solid var(--border) !important;
  border-radius: var(--r) !important;
  box-shadow: var(--shadow) !important;
  padding: .375rem;
  min-width: 170px;
  animation: dropIn var(--t250) both;
}
@keyframes dropIn {
  from { opacity: 0; transform: translateY(-6px) scale(.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}
.dropdown-item { border-radius: var(--r-sm); font-size: .875rem; padding: .45rem .75rem; color: var(--text); transition: background var(--t150); }
.dropdown-item:hover { background: var(--bg); }
.dropdown-divider { border-color: var(--border); margin: .3rem 0; }

/* Modal */
.modal-content { border-radius: var(--r-xl) !important; border: none !important; box-shadow: var(--shadow-lg) !important; }
.modal-header  { padding: 1.375rem 1.5rem .75rem; border-bottom: 1px solid var(--border); }
.modal-body    { padding: 1rem 1.5rem; }
.modal-footer  { padding: .75rem 1.5rem 1.375rem; border-top: none; }

/* Page header */
.page-header { margin-bottom: 1.75rem; }
.page-header h1 { font-size: 1.375rem; font-weight: 700; letter-spacing: -.4px; margin-bottom: .25rem; }
.page-header p  { color: var(--muted); font-size: .875rem; }

/* ══════════════════════════════════════════
   LOGIN
══════════════════════════════════════════ */

.login-page {
  min-height: 100vh;
  display: flex;
  background: var(--sidebar-bg);
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 20% 50%, rgba(99,102,241,.3) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 20%, rgba(167,139,250,.25) 0%, transparent 50%);
}
.login-left {
  flex: 1;
  display: flex; flex-direction: column;
  justify-content: center; align-items: flex-start;
  padding: 3rem 4rem;
  position: relative; z-index: 1;
  color: #fff;
}
.login-left-brand {
  display: flex; align-items: center; gap: .75rem;
  font-weight: 800; font-size: 1.5rem; color: #fff;
  margin-bottom: 3rem;
}
.login-left-brand-icon {
  width: 44px; height: 44px;
  background: rgba(255,255,255,.2);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
}
.login-headline {
  font-size: 2.25rem; font-weight: 800;
  line-height: 1.15; letter-spacing: -.5px;
  margin-bottom: 1rem; color: #fff;
}
.login-headline span { color: rgba(255,255,255,.55); }
.login-sub { font-size: 1rem; color: rgba(255,255,255,.6); max-width: 340px; }

.login-right {
  width: 460px;
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  padding: 3rem 2.5rem;
}
.login-form-wrap { width: 100%; max-width: 360px; }
.login-form-title {
  font-size: 1.375rem; font-weight: 700;
  letter-spacing: -.3px; margin-bottom: .375rem;
}
.login-form-sub { color: var(--muted); font-size: .875rem; margin-bottom: 1.75rem; }

/* ══════════════════════════════════════════
   UPLOAD ZONE
══════════════════════════════════════════ */

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--r-lg);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  background: var(--surface);
  transition: border-color var(--t250), background var(--t250), transform var(--t250);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: #eef2ff;
  transform: scale(1.01);
}

/* ══════════════════════════════════════════
   EDITOR DE PLANTILLAS
══════════════════════════════════════════ */

.editor-wrap {
  display: flex;
  overflow: hidden;
  height: calc(100vh - var(--topbar-h) - var(--editor-topbar-h));
  /* compensa el panel izquierdo fijo (ya no ocupa espacio en el flujo flex) */
  padding-left: 252px;
}

/* Panel izquierdo FIJO — siempre visible sin importar el scroll */
.editor-sidebar-left {
  position: fixed;
  top: calc(var(--topbar-h) + var(--editor-topbar-h));
  left: var(--sidebar-w);
  width: 252px;
  height: calc(100vh - var(--topbar-h) - var(--editor-topbar-h));
  z-index: 80;
  background: #18181b;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  border-right: 1px solid rgba(255,255,255,.06);
}
/* Sidebar colapsado: reposicionar panel izquierdo */
body.sidebar-collapsed .editor-sidebar-left {
  left: var(--sidebar-w-collapsed);
}
.editor-sidebar-left::-webkit-scrollbar { width: 3px; }
.editor-sidebar-left::-webkit-scrollbar-thumb { background: #3f3f46; border-radius: 4px; }

.editor-section { padding: 1rem; }
.editor-section + .editor-section { border-top: 1px solid rgba(255,255,255,.06); }
.editor-section-title {
  font-size: .6rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em;
  color: #52525b; margin-bottom: .75rem;
}

/* Visor PDF */
.editor-pdf-area {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
  background: #27272a;
  min-height: 0;
}
.editor-toolbar {
  background: #1c1c1e;
  border-bottom: 1px solid rgba(255,255,255,.06);
  padding: .5rem .875rem;
  display: flex; align-items: center; gap: .5rem;
  flex-shrink: 0;
}
.editor-toolbar .btn {
  background: rgba(255,255,255,.07) !important;
  border-color: rgba(255,255,255,.1) !important;
  color: #d4d4d8 !important;
  padding: .3rem .6rem !important;
}
.editor-toolbar .btn:hover { background: rgba(255,255,255,.14) !important; }
.editor-toolbar span, #zoomLevel { color: #71717a; font-size: .8125rem; }
#zoomLevel { min-width: 40px; text-align: center; }
#currentPage, #totalPages { color: #d4d4d8; }

#pdfContainer { flex: 1; overflow: auto; padding: 1rem; min-height: 0; }
#pdfContainer::-webkit-scrollbar { width: 6px; height: 6px; }
#pdfContainer::-webkit-scrollbar-thumb { background: #3f3f46; border-radius: 4px; }
#pdfPages { display: flex; flex-direction: column; align-items: center; }

/* Panel props */
.editor-sidebar-right {
  width: 228px; flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto; display: flex; flex-direction: column;
  min-height: 0;
}
.editor-sidebar-right::-webkit-scrollbar { width: 3px; }
.editor-sidebar-right::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.props-panel { padding: 1rem; }
.props-title { font-size: .6rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: .875rem; }
.prop-row { margin-bottom: .625rem; }
.prop-row label { font-size: .75rem; font-weight: 600; color: var(--muted); display: block; margin-bottom: 3px; }

/* Topbar del editor */
.editor-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .625rem 1.125rem;
  display: flex; align-items: center; gap: .75rem;
  flex-shrink: 0; height: 52px;
}
.editor-topbar h5 { font-size: .9rem; font-weight: 700; margin: 0; }

/* Roles en sidebar */
.rol-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 9px; border-radius: 8px;
  cursor: pointer; margin-bottom: 3px;
  transition: background var(--t150);
}
.rol-item:hover { background: rgba(255,255,255,.07); }
.rol-item.active { background: rgba(255,255,255,.1); }
.rol-item .rol-name { flex: 1; font-size: .8rem; font-weight: 500; color: #d4d4d8; }
.rol-item .btn-link { color: #52525b !important; }
.rol-item .btn-link:hover { color: #e4e4e7 !important; }
.rol-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* Campos arrastrables */
.campo-draggable {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 8px;
  cursor: grab; user-select: none;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.07);
  transition: background var(--t150), transform var(--t150), border-color var(--t150);
  margin-bottom: 5px;
  color: #a1a1aa; font-size: .8125rem; font-weight: 500;
}
.campo-draggable i:first-child { font-size: .875rem; }
.campo-draggable .bi-grip-vertical { margin-left: auto; font-size: .75rem; color: #3f3f46; }
.campo-draggable:hover { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.15); color: #e4e4e7; transform: translateX(3px); }
.campo-draggable.dragging { opacity: .4; cursor: grabbing; }

/* Campos en el PDF */
.pdf-campo {
  position: absolute; box-sizing: border-box;
  border: 2px solid; border-radius: 5px;
  cursor: move; display: flex; align-items: center;
  font-size: 10px; font-weight: 700; gap: 4px;
  padding: 2px 8px; white-space: nowrap; overflow: hidden;
  z-index: 10; transition: box-shadow var(--t150);
}
.pdf-campo:hover { box-shadow: 0 0 0 3px rgba(255,255,255,.35); }
.pdf-campo.selected { box-shadow: 0 0 0 2px #fff, 0 0 0 5px rgba(255,255,255,.2); }

.pdf-campo .campo-delete {
  position: absolute; top: -7px; right: -7px;
  width: 16px; height: 16px;
  background: #ef4444; color: #fff; border: none;
  border-radius: 50%; font-size: 9px; font-weight: 900;
  line-height: 16px; text-align: center; cursor: pointer;
  display: none; padding: 0;
}
.pdf-campo.selected .campo-delete,
.pdf-campo:hover .campo-delete { display: block; }

.pdf-campo .resize-handle {
  position: absolute; bottom: 0; right: 0;
  width: 9px; height: 9px; cursor: se-resize;
  background: rgba(255,255,255,.5); display: none; border-radius: 2px 0 3px 0;
}
.pdf-campo.selected .resize-handle,
.pdf-campo:hover .resize-handle { display: block; }

.pdf-page-wrap {
  position: relative; margin: 0 auto 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,.5);
  background: #fff;
}
.pdf-page-wrap canvas { display: block; }

/* ══════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════ */

@media (max-width: 768px) {
  .app-sidebar {
    transform: translateX(-100%);
    box-shadow: none;
  }
  .app-sidebar.is-open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .app-main { margin-left: 0; }
  .topbar-toggle { display: flex; }
  .login-left { display: none; }
  .login-right { width: 100%; }
}

/* Overlay for mobile sidebar */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 150;
  opacity: 0;
  transition: opacity var(--t250);
}
.sidebar-overlay.is-visible { display: block; }
.sidebar-overlay.is-active   { opacity: 1; }

/* Misc */
.text-muted { color: var(--muted) !important; }
hr { border-color: var(--border); }
.spinner-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center; z-index: 9999;
}

/* ══════════════════════════════════════════
   SIDEBAR DOCKABLE (COLLAPSE)
══════════════════════════════════════════ */

:root { --sidebar-w-collapsed: 64px; }

.sidebar-dock-btn {
  background: none; border: none;
  color: rgba(255,255,255,.4);
  cursor: pointer; padding: 5px 6px;
  border-radius: var(--r-sm);
  transition: all var(--t150);
  font-size: .9rem; flex-shrink: 0;
  display: flex; align-items: center;
}
.sidebar-dock-btn:hover { color: #fff; background: rgba(255,255,255,.12); }

@media (min-width: 769px) {
  body.sidebar-collapsed .app-sidebar { width: var(--sidebar-w-collapsed); }
  body.sidebar-collapsed .app-main   { margin-left: var(--sidebar-w-collapsed); }

  body.sidebar-collapsed .sidebar-brand-name,
  body.sidebar-collapsed .sidebar-section-title,
  body.sidebar-collapsed .sidebar-link span,
  body.sidebar-collapsed .user-info,
  body.sidebar-collapsed .logout-btn { display: none; }

  body.sidebar-collapsed .sidebar-header {
    flex-direction: column; gap: .5rem; padding: .875rem .5rem;
  }
  body.sidebar-collapsed .sidebar-brand { flex: none; justify-content: center; }
  body.sidebar-collapsed .sidebar-nav   { align-items: center; padding: .75rem .375rem; }
  body.sidebar-collapsed .sidebar-link  { justify-content: center; padding: .625rem; }
  body.sidebar-collapsed .sidebar-link i { width: auto; }
  body.sidebar-collapsed .sidebar-link:hover { transform: none; }
  body.sidebar-collapsed .sidebar-link.is-active::before { display: none; }
  body.sidebar-collapsed .sidebar-user   { justify-content: center; padding: .375rem; }
  body.sidebar-collapsed .sidebar-bottom { padding: .5rem .375rem; }
}

@media (max-width: 768px) { .sidebar-dock-btn { display: none; } }

/* ══════════════════════════════════════════
   MÓDULO DOCUMENTOS
══════════════════════════════════════════ */

/* Stat cards */
.doc-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.125rem 1.375rem;
  display: flex; align-items: center; gap: .875rem;
  transition: transform var(--t250), box-shadow var(--t250);
}
.doc-stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.doc-stat-icon {
  width: 44px; height: 44px; border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; flex-shrink: 0;
}
.doc-stat-num { font-size: 1.5rem; font-weight: 700; letter-spacing: -.5px; line-height: 1; }
.doc-stat-lbl { font-size: .75rem; color: var(--muted); margin-top: .2rem; }

/* Estado badges */
.doc-badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .22em .65em; font-size: .6875rem; font-weight: 600;
  border-radius: 20px; white-space: nowrap;
}
.doc-badge-pendiente  { background: #fffbeb; color: #92400e; }
.doc-badge-en_proceso { background: #eff6ff; color: #1e40af; }
.doc-badge-completado { background: #f0fdf4; color: #166534; }
.doc-badge-cancelado  { background: #fef2f2; color: #991b1b; }

/* Progress mini */
.progress-mini {
  height: 5px; border-radius: 10px; background: var(--border);
  overflow: hidden; min-width: 80px;
}
.progress-mini-bar {
  height: 100%; border-radius: 10px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .4s var(--ease);
}
.progress-mini-bar.done      { background: var(--success); }
.progress-mini-bar.cancelled { background: var(--muted); }

/* Timeline */
.doc-timeline { position: relative; padding-left: 1.875rem; }
.doc-timeline::before {
  content: ''; position: absolute;
  left: 9px; top: 10px; bottom: 10px;
  width: 2px; background: var(--border); border-radius: 2px;
}
.doc-tl-item {
  position: relative; margin-bottom: .875rem;
}
.doc-tl-dot {
  position: absolute; left: -1.875rem;
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--border); background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  font-size: .6rem; color: var(--muted);
}
.doc-tl-dot.done   { border-color: var(--success); color: var(--success); background: #f0fdf4; }
.doc-tl-dot.accent { border-color: var(--accent);  color: var(--accent);  background: #eef2ff; }
.doc-tl-dot.warn   { border-color: #f59e0b; color: #f59e0b; background: #fffbeb; }
.doc-tl-label { font-size: .875rem; font-weight: 600; color: var(--text); }
.doc-tl-date  { font-size: .75rem; color: var(--muted); }
