/* ============================================================
   BARG Design System — barg.css
   Design tokens + componentes globales
   Stack: html-tailwind-like (vanilla CSS custom properties)
   Fuente: Inter | Primary: #16a085 | Data-Dense Dashboard
   ============================================================ */

/* ── Google Fonts ─────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Design Tokens ────────────────────────────────────────── */
:root {
  /* Colors */
  --color-primary:        #16a085;
  --color-primary-dark:   #117a65;
  --color-primary-light:  #1abc9c;
  --color-primary-subtle: #e8f8f5;

  --color-danger:         #e74c3c;
  --color-danger-dark:    #c0392b;
  --color-danger-subtle:  #fdf3f2;

  --color-warning:        #f39c12;
  --color-warning-subtle: #fef9e7;

  --color-success:        #27ae60;
  --color-success-subtle: #eafaf1;

  --color-info:           #2980b9;
  --color-info-subtle:    #ebf5fb;

  /* Neutrals */
  --color-bg:             #f4f6f8;
  --color-surface:        #ffffff;
  --color-surface-2:      #f8fafc;
  --color-border:         #e2e8f0;
  --color-border-strong:  #cbd5e0;

  --color-text:           #1a202c;
  --color-text-secondary: #4a5568;
  --color-text-muted:     #718096;
  --color-text-disabled:  #a0aec0;

  /* Sidebar */
  --color-sidebar-bg:     #1a2332;
  --color-sidebar-hover:  #243447;
  --color-sidebar-active: #16a085;
  --color-sidebar-text:   #a0aec0;
  --color-sidebar-text-active: #ffffff;

  /* Typography */
  --font-body:   'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:   'Fira Code', ui-monospace, monospace;

  --text-xs:    0.75rem;   /* 12px */
  --text-sm:    0.875rem;  /* 14px */
  --text-base:  1rem;      /* 16px */
  --text-lg:    1.125rem;  /* 18px */
  --text-xl:    1.25rem;   /* 20px */
  --text-2xl:   1.5rem;    /* 24px */
  --text-3xl:   1.875rem;  /* 30px */

  --weight-normal:   400;
  --weight-medium:   500;
  --weight-semibold: 600;
  --weight-bold:     700;

  --leading-tight:  1.25;
  --leading-normal: 1.5;
  --leading-relaxed:1.625;

  /* Spacing */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Radii */
  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  12px;
  --radius-xl:  16px;
  --radius-full:9999px;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:  0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
  --shadow-lg:  0 10px 15px rgba(0,0,0,.07), 0 4px 6px rgba(0,0,0,.05);
  --shadow-xl:  0 20px 25px rgba(0,0,0,.1),  0 10px 10px rgba(0,0,0,.04);

  /* Z-index scale */
  --z-base:    10;
  --z-dropdown:20;
  --z-modal:   30;
  --z-toast:   50;
  --z-navbar:  40;

  /* Transitions */
  --transition-fast:   150ms ease;
  --transition-normal: 200ms ease;
  --transition-slow:   300ms ease;

  /* Layout */
  --sidebar-width:       240px;
  --sidebar-collapsed:   64px;
  --topbar-height:       56px;
  --content-max-width:   1400px;

  /* Compatibility aliases */
  --color-text-primary: var(--color-text);
  --font-sans: var(--font-body);
  --sp-1:   0.25rem;
  --sp-1-5: 0.375rem;
  --sp-2:   0.5rem;
  --sp-3:   0.75rem;
  --sp-3-5: 0.875rem;
  --sp-4:   1rem;
  --sp-5:   1.25rem;
  --sp-6:   1.5rem;
  --sp-8:   2rem;
  --sp-10:  2.5rem;
  --sp-12:  3rem;
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--color-primary-dark); }

button, [role="button"] {
  cursor: pointer;
  font-family: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

img, svg { display: block; max-width: 100%; }

/* ── Layout Shell ─────────────────────────────────────────── */
.barg-shell {
  display: flex;
  min-height: 100vh;
}

.barg-sidebar {
  width: var(--sidebar-width);
  background: var(--color-sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: var(--z-navbar);
  transition: width var(--transition-slow);
  overflow: hidden;
}

.barg-main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-top: var(--topbar-height);
  overflow-x: hidden;
  transition: margin-left var(--transition-slow);
}

.barg-topbar {
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  gap: var(--space-4);
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  z-index: var(--z-navbar);
  box-shadow: var(--shadow-sm);
}

.barg-content {
  flex: 1;
  padding: var(--space-6);
  max-width: var(--content-max-width);
  width: 100%;
}

/* ── Sidebar Components ───────────────────────────────────── */
.sidebar-logo {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 var(--space-5);
  border-bottom: 1px solid rgba(255,255,255,.06);
  gap: var(--space-3);
  flex-shrink: 0;
}

.sidebar-logo-mark {
  width: 32px;
  height: 32px;
  background: var(--color-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  color: #fff;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.sidebar-logo-sub {
  font-size: var(--text-xs);
  color: var(--color-sidebar-text);
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-3) 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.28) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 8px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.22);
  border-radius: 6px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.4); }

.sidebar-section-label {
  padding: var(--space-4) var(--space-5) var(--space-2);
  font-size: 0.625rem;
  font-weight: var(--weight-semibold);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--color-sidebar-text);
  opacity: .5;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  color: var(--color-sidebar-text);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  border-radius: 0;
  transition: background var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  position: relative;
}

.sidebar-link:hover {
  background: var(--color-sidebar-hover);
  color: #fff;
}

.sidebar-link.active {
  background: rgba(22,160,133,.15);
  color: var(--color-primary-light);
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--color-primary);
  border-radius: 0 2px 2px 0;
}

.sidebar-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: .7;
  transition: opacity var(--transition-fast);
}

.sidebar-link:hover svg,
.sidebar-link.active svg { opacity: 1; }

.sidebar-badge {
  margin-left: auto;
  background: var(--color-danger);
  color: #fff;
  font-size: 0.625rem;
  font-weight: var(--weight-bold);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  min-width: 18px;
  text-align: center;
  line-height: 16px;
}

.sidebar-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid rgba(255,255,255,.06);
}

/* ── Topbar Components ────────────────────────────────────── */
.topbar-title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
  flex-shrink: 0;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.topbar-user:hover { background: var(--color-surface-2); }

.topbar-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  flex-shrink: 0;
}

.topbar-user-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text);
}

.topbar-user-role {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

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

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

.card-title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}

.card-body {
  padding: var(--space-6);
}

.card-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* KPI stat card */
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-normal), transform var(--transition-normal);
  cursor: default;
}

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

.stat-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.stat-value {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--color-text);
  line-height: var(--leading-tight);
}

.stat-sub {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast),
              border-color var(--transition-fast), box-shadow var(--transition-fast),
              opacity var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.5;
  font-family: inherit;
}

.btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* Primary */
.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.btn-primary:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
  box-shadow: 0 0 0 3px rgba(22,160,133,.2);
}

/* Secondary / outline */
.btn-secondary {
  background: #fff;
  color: var(--color-text-secondary);
  border-color: var(--color-border-strong);
}
.btn-secondary:hover {
  background: var(--color-surface-2);
  border-color: var(--color-text-muted);
}

/* Danger */
.btn-danger {
  background: var(--color-danger);
  color: #fff;
  border-color: var(--color-danger);
}
.btn-danger:hover {
  background: var(--color-danger-dark);
  border-color: var(--color-danger-dark);
  box-shadow: 0 0 0 3px rgba(231,76,60,.2);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--color-surface-2); }

/* Icon button */
.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--radius-md);
}

/* Sizes */
.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
}
.btn-lg {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-base);
}

/* ── Forms ────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
}

.form-label.required::after {
  content: ' *';
  color: var(--color-danger);
}

.form-control {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  line-height: var(--leading-normal);
}

.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(22,160,133,.15);
}

.form-control::placeholder { color: var(--color-text-disabled); }

.form-control:disabled {
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  cursor: not-allowed;
}

select.form-control { cursor: pointer; }

.form-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--color-danger);
}

.form-control.is-error { border-color: var(--color-danger); }
.form-control.is-error:focus { box-shadow: 0 0 0 3px rgba(231,76,60,.15); }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

thead th {
  background: var(--color-surface-2);
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--color-border);
  transition: background var(--transition-fast);
}

tbody tr:last-child { border-bottom: none; }

tbody tr:hover { background: var(--color-surface-2); }

tbody td {
  padding: var(--space-3) var(--space-4);
  color: var(--color-text);
  vertical-align: middle;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* ── Badges / Pills ───────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: 18px;
  white-space: nowrap;
}

.badge-primary   { background: var(--color-primary-subtle);  color: var(--color-primary-dark); }
.badge-success   { background: var(--color-success-subtle);  color: var(--color-success); }
.badge-danger    { background: var(--color-danger-subtle);   color: var(--color-danger); }
.badge-warning   { background: var(--color-warning-subtle);  color: var(--color-warning); }
.badge-info      { background: var(--color-info-subtle);     color: var(--color-info); }
.badge-neutral   { background: var(--color-surface-2);       color: var(--color-text-muted); }

.badge-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

/* ── Modals ───────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(2px);
  z-index: var(--z-modal);
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: fadeIn var(--transition-normal) both;
}

.modal-overlay.is-open { display: flex; }

.modal-box {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideUp var(--transition-slow) both;
}

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

.modal-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-2);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  flex-shrink: 0;
}

/* Close button */
.btn-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--color-surface-2);
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
}
.btn-close:hover {
  background: var(--color-danger);
  color: #fff;
}
.btn-close svg { width: 16px; height: 16px; }

/* ── Toast Notifications ──────────────────────────────────── */
#barg-toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.barg-toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: #ffffff;
  color: var(--color-text-primary);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 20px rgba(0,0,0,.14), 0 1px 6px rgba(0,0,0,.08);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  min-width: 260px;
  max-width: 420px;
  pointer-events: auto;
  animation: slideInRight var(--transition-slow) both;
  border-left: 4px solid var(--color-primary);
}

.barg-toast.is-success { border-left-color: var(--color-success); }
.barg-toast.is-success svg { color: var(--color-success); }
.barg-toast.is-error   { border-left-color: var(--color-danger); }
.barg-toast.is-error svg   { color: var(--color-danger); }
.barg-toast.is-warning { border-left-color: var(--color-warning); }
.barg-toast.is-warning svg { color: var(--color-warning); }

.barg-toast svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--color-primary); }

.barg-toast.is-hiding {
  animation: slideOutRight var(--transition-slow) both;
}

/* ── Tabs ─────────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--color-border);
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-muted);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  white-space: nowrap;
}

.tab-btn:hover { color: var(--color-text); }

.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.tab-btn svg { width: 16px; height: 16px; }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Alerts / Inline messages ─────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  border: 1px solid;
}

.alert-success { background: var(--color-success-subtle); color: var(--color-success); border-color: rgba(39,174,96,.2); }
.alert-danger   { background: var(--color-danger-subtle);  color: var(--color-danger);  border-color: rgba(231,76,60,.2); }
.alert-warning  { background: var(--color-warning-subtle); color: var(--color-warning); border-color: rgba(243,156,18,.2); }
.alert-info     { background: var(--color-info-subtle);    color: var(--color-info);    border-color: rgba(41,128,185,.2); }

/* ── Skeleton / Loading ───────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--color-border) 25%, var(--color-surface-2) 50%, var(--color-border) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-pulse {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

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

/* ── Panic badge flotante ─────────────────────────────────── */
#barg-panic-fab {
  position: fixed;
  bottom: var(--space-8);
  right: var(--space-8);
  z-index: var(--z-toast);
  width: 56px;
  height: 56px;
  background: var(--color-danger);
  border-radius: var(--radius-full);
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(231,76,60,.5);
  cursor: pointer;
  border: none;
  animation: pulse-ring 2s ease-out infinite;
}

#barg-panic-fab.has-alerts { display: flex; }
#barg-panic-fab svg { width: 24px; height: 24px; color: #fff; }

#barg-panic-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #fff;
  color: var(--color-danger);
  border-radius: var(--radius-full);
  font-size: 0.6rem;
  font-weight: var(--weight-bold);
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}

@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(231,76,60,.5); }
  70%  { box-shadow: 0 0 0 12px rgba(231,76,60,0); }
  100% { box-shadow: 0 0 0 0 rgba(231,76,60,0); }
}

/* ── Lightbox ─────────────────────────────────────────────── */
#barg-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.92);
  z-index: 10100;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  cursor: default;
}
#barg-lightbox.is-open { display: flex; }
#barg-lb-toolbar button:hover,
#barg-lb-toolbar a:hover { background: rgba(255,255,255,.3) !important; }

/* ── Confirm modal singleton ──────────────────────────────── */
#barg-confirm-modal .modal-box { max-width: 400px; }

/* ── Utility classes ──────────────────────────────────────── */
.flex     { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); }

.text-muted    { color: var(--color-text-muted); }
.text-sm       { font-size: var(--text-sm); }
.text-xs       { font-size: var(--text-xs); }
.font-semibold { font-weight: var(--weight-semibold); }
.font-bold     { font-weight: var(--weight-bold); }

.mt-4  { margin-top: var(--space-4); }
.mb-4  { margin-bottom: var(--space-4); }
.mb-6  { margin-bottom: var(--space-6); }

.w-full { width: 100%; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Animations ───────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

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

@keyframes slideOutRight {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(24px); }
}

/* ── Reduced motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1024px) {
  .barg-sidebar { width: var(--sidebar-collapsed); }
  .barg-main    { margin-left: var(--sidebar-collapsed); }
  .barg-topbar  { left: var(--sidebar-collapsed); }
  .sidebar-logo-text, .sidebar-logo-sub,
  .sidebar-section-label, .sidebar-link span,
  .sidebar-badge { display: none; }
  .sidebar-link { justify-content: center; padding: var(--space-4); }
  .sidebar-link svg { opacity: .85; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .topbar-user-role { display: none; }
}

@media (max-width: 768px) {
  .barg-sidebar { transform: translateX(-100%); width: var(--sidebar-width); }
  .barg-sidebar.is-open { transform: translateX(0); }
  /* El sidebar móvil se abre a ancho completo → restaurar labels y alineación
     (override del colapso a íconos de la query de 1024px) */
  .sidebar-logo-text, .sidebar-logo-sub, .sidebar-section-label { display: block; }
  .sidebar-link span { display: inline; }
  .sidebar-badge { display: inline-flex; }
  .sidebar-link { justify-content: flex-start; padding: var(--space-3) var(--space-5); }
  .barg-main { margin-left: 0; }
  .barg-topbar { left: 0; }
  .barg-content { padding: var(--space-4); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal-box { border-radius: var(--radius-xl) var(--radius-xl) 0 0; max-height: 95vh; }
  .tabs { gap: 0; }
  #barg-menu-toggle { display: flex !important; }
  .topbar-user-name, .topbar-user-role { display: none; }
  .topbar-title { font-size: var(--text-sm); }
}

@media (max-width: 480px) {
  :root { --text-sm: 0.8125rem; }
  .btn { padding: var(--space-2) var(--space-3); }
}

/* ── Extra button variants ────────────────────────────────── */
.btn-warning {
  background: #e67e22; color: #fff; border-color: #e67e22;
}
.btn-warning:hover {
  background: #d35400; border-color: #d35400;
  box-shadow: 0 0 0 3px rgba(230,126,34,.2);
}
.btn-info {
  background: #2980b9; color: #fff; border-color: #2980b9;
}
.btn-info:hover {
  background: #2471a3; border-color: #2471a3;
  box-shadow: 0 0 0 3px rgba(41,128,185,.2);
}
.btn-violet {
  background: #8e44ad; color: #fff; border-color: #8e44ad;
}
.btn-violet:hover {
  background: #7d3c98; border-color: #7d3c98;
  box-shadow: 0 0 0 3px rgba(142,68,173,.2);
}

/* ── Planilla detail modal footer layout ─────────────────── */
#pd-footer {
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  gap: 0;
}

.pd-footer-band {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border-bottom: 1px solid transparent;
  flex-wrap: wrap;
}
.pd-footer-band--assign  { background: #f0fdf4; border-color: #bbf7d0; }
.pd-footer-band--reassign { background: #fffbeb; border-color: #fde68a; }

.pd-footer-band-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}

.pd-footer-select {
  flex: 1;
  min-width: 150px;
  min-height: 40px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  background: #fff;
  cursor: pointer;
}

.pd-footer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
  flex-wrap: wrap;
}
.pd-footer-start,
.pd-footer-end {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.pd-footer-end { margin-left: auto; }

.btn-pd { min-height: 40px; }

@media (max-width: 560px) {
  .pd-footer-band { flex-direction: column; align-items: stretch; }
  .pd-footer-band-label { display: none; }
  .pd-footer-select { min-width: 100%; }
  .pd-footer-actions { flex-direction: column; align-items: stretch; }
  .pd-footer-start,
  .pd-footer-end { width: 100%; margin-left: 0; }
  .pd-footer-start .btn,
  .pd-footer-end .btn { flex: 1; justify-content: center; }
}
